:root {
  color-scheme: dark;
  --bg: #070908;
  --surface: #101411;
  --surface-2: #161b17;
  --surface-3: #1d231e;
  --gold: #d8ad54;
  --gold-bright: #f5d581;
  --gold-dim: #8f6d2e;
  --green: #20c97a;
  --red: #ff5b64;
  --text: #f4f1e8;
  --muted: #969d96;
  --line: rgba(216,173,84,.18);
  --shadow: 0 24px 80px rgba(0,0,0,.42);
  --radius: 20px;
  font-family: Inter, "Hiragino Sans", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; min-width: 320px; color: var(--text); background:
  radial-gradient(circle at 12% 0%, rgba(45,91,63,.18), transparent 28rem),
  radial-gradient(circle at 100% 15%, rgba(216,173,84,.08), transparent 24rem),
  var(--bg); }
button,input,select,textarea { font: inherit; }
button { color: inherit; }
button:focus-visible,input:focus-visible,select:focus-visible,textarea:focus-visible { outline: 2px solid var(--gold-bright); outline-offset: 2px; }
.app-shell { min-height: 100vh; padding-bottom: 96px; }
.topbar { position: sticky; top: 0; z-index: 20; height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 0 clamp(16px,4vw,46px); border-bottom: 1px solid var(--line); background: rgba(7,9,8,.86); backdrop-filter: blur(18px); }
.brand { display:flex; align-items:center; gap:12px; border:0; background:none; cursor:pointer; text-align:left; padding:0; }
.brand-mark { width:40px; height:40px; display:grid; place-items:center; border-radius:50%; color:#12120f; font-size:23px; background:linear-gradient(145deg,var(--gold-bright),var(--gold-dim)); box-shadow:0 0 26px rgba(216,173,84,.18); }
.brand strong { display:block; letter-spacing:.12em; font-family: Georgia, serif; font-size:15px; }
.brand small { display:block; margin-top:2px; color:var(--gold); letter-spacing:.32em; font-size:9px; }
.desktop-nav { display:flex; align-items:center; gap:4px; margin-left:auto; margin-right:18px; }
.desktop-nav-item { border:0; border-radius:10px; padding:9px 12px; color:var(--muted); background:transparent; cursor:pointer; font-size:12px; }
.desktop-nav-item:hover { color:var(--text); background:rgba(255,255,255,.04); }
.desktop-nav-item.active { color:var(--gold-bright); background:rgba(216,173,84,.08); }
.topbar-actions { display:flex; gap:12px; align-items:center; }
.status-badge { display:inline-flex; align-items:center; gap:7px; color:var(--muted); font-size:12px; padding:7px 10px; border:1px solid rgba(255,255,255,.08); border-radius:999px; background:rgba(255,255,255,.03); }
.status-dot { width:7px; height:7px; border-radius:50%; background:#777; }
.status-badge.cloud .status-dot { background:var(--green); box-shadow:0 0 8px var(--green); }
.status-badge.local .status-dot { background:var(--gold); }
main { width:min(1440px,100%); margin:auto; padding:32px clamp(16px,4vw,46px) 20px; }
.view { display:none; animation:fade .2s ease; }
.view.active { display:block; }
@keyframes fade { from {opacity:0; transform:translateY(4px)} }
.hero-panel { overflow:hidden; position:relative; min-height:190px; display:flex; align-items:flex-end; justify-content:space-between; gap:30px; padding:38px; border:1px solid rgba(216,173,84,.26); border-radius:26px; background:
  linear-gradient(110deg,rgba(22,54,37,.92),rgba(12,18,14,.95) 55%,rgba(45,34,15,.92)),
  repeating-linear-gradient(45deg,transparent,transparent 16px,rgba(255,255,255,.015) 16px,rgba(255,255,255,.015) 17px); box-shadow:var(--shadow); }
.hero-panel::after { content:"♠"; position:absolute; right:2%; top:-42px; color:rgba(216,173,84,.06); font-size:280px; font-family:Georgia,serif; transform:rotate(-8deg); }
.eyebrow { margin:0 0 7px; color:var(--gold); font-size:10px; font-weight:800; letter-spacing:.25em; }
h1,h2,p { margin-top:0; }
h1 { margin-bottom:8px; font-family:Georgia,"Yu Mincho",serif; font-size:clamp(28px,4vw,46px); line-height:1.15; }
h2 { margin-bottom:0; font-size:20px; }
.hero-subtitle { margin:0; color:#b6bdb7; }
.hero-result { position:relative; z-index:1; text-align:right; }
.hero-result span { display:block; color:#b2b9b2; font-size:13px; }
.hero-result strong { display:block; margin-top:7px; font-size:clamp(35px,5.5vw,68px); font-family:Georgia,serif; letter-spacing:-.04em; }
.metric-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-top:18px; }
.metric-card,.panel { border:1px solid rgba(255,255,255,.075); background:linear-gradient(145deg,rgba(22,27,23,.96),rgba(12,15,13,.98)); border-radius:var(--radius); box-shadow:0 16px 48px rgba(0,0,0,.20); }
.metric-card { padding:20px; min-height:128px; display:flex; flex-direction:column; justify-content:center; }
.metric-card.primary { border-color:rgba(216,173,84,.34); }
.metric-label { color:var(--muted); font-size:12px; }
.metric-card strong { margin:8px 0 5px; font-size:28px; font-family:Georgia,serif; }
.metric-card small { color:var(--muted); }
.positive { color:var(--green)!important; }
.negative { color:var(--red)!important; }
.dashboard-grid { display:grid; grid-template-columns:minmax(0,2fr) minmax(300px,.8fr); gap:18px; margin-top:18px; }
.panel { padding:24px; }
.panel-head { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom:18px; }
.segmented { display:flex; padding:3px; border-radius:10px; background:#090c0a; border:1px solid rgba(255,255,255,.07); }
.segment { border:0; border-radius:7px; padding:7px 11px; color:var(--muted); background:transparent; cursor:pointer; font-size:12px; }
.segment.active { color:#111; background:var(--gold); font-weight:800; }
.chart { min-height:285px; width:100%; position:relative; }
.chart.tall { min-height:350px; }
.chart svg { display:block; width:100%; height:100%; overflow:visible; }
.chart-empty,.empty-state { min-height:180px; display:grid; place-items:center; text-align:center; color:var(--muted); border:1px dashed rgba(255,255,255,.10); border-radius:14px; padding:24px; }
.chart-tooltip { position:absolute; pointer-events:none; z-index:3; padding:8px 10px; border-radius:9px; color:var(--text); background:#050706; border:1px solid var(--line); font-size:12px; box-shadow:0 10px 30px #000; transform:translate(-50%,-115%); white-space:nowrap; }
.goal-panel { min-height:390px; }
.text-button { border:0; padding:5px; color:var(--gold); background:none; cursor:pointer; }
.goal-ring-wrap { display:grid; place-items:center; margin:10px 0 22px; }
.goal-ring { width:170px; aspect-ratio:1; display:grid; place-items:center; border-radius:50%; background:conic-gradient(var(--gold) var(--progress),rgba(255,255,255,.08) 0); position:relative; box-shadow:0 0 40px rgba(216,173,84,.09); }
.goal-ring::before { content:""; position:absolute; inset:10px; border-radius:50%; background:#101411; border:1px solid rgba(255,255,255,.06); }
.goal-ring>div { position:relative; text-align:center; }
.goal-ring strong { display:block; font-family:Georgia,serif; font-size:35px; }
.goal-ring span { color:var(--muted); font-size:11px; }
.goal-summary { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.goal-summary div { padding:12px; border-radius:12px; background:rgba(255,255,255,.03); }
.goal-summary span { display:block; color:var(--muted); font-size:11px; }
.goal-summary strong { display:block; margin-top:4px; }
.goal-warnings { margin-top:12px; color:#e4c888; font-size:12px; line-height:1.7; }
.recent-panel { margin-top:18px; }
.entry-list { display:grid; gap:10px; }
.entry-row { display:grid; grid-template-columns:110px minmax(170px,1.2fr) minmax(120px,.8fr) 100px 130px 78px; align-items:center; gap:14px; padding:14px 16px; border:1px solid rgba(255,255,255,.065); border-radius:14px; background:rgba(255,255,255,.025); transition:.15s; }
.entry-row:hover { border-color:rgba(216,173,84,.25); transform:translateY(-1px); }
.entry-date { color:var(--muted); font-size:12px; }
.entry-main strong { display:block; }
.entry-main span,.entry-meta { color:var(--muted); font-size:12px; }
.entry-result { text-align:right; font-family:Georgia,serif; font-size:18px; font-weight:800; }
.entry-actions { display:flex; justify-content:flex-end; gap:4px; }
.mini-button { border:0; width:32px; height:32px; border-radius:9px; color:var(--muted); background:rgba(255,255,255,.05); cursor:pointer; }
.mini-button:hover { color:var(--text); background:rgba(255,255,255,.10); }
.page-heading { display:flex; align-items:flex-end; justify-content:space-between; gap:20px; margin-bottom:22px; }
.page-heading h1 { margin-bottom:0; }
.gold-button,.outline-button,.danger-button { min-height:44px; border-radius:12px; padding:10px 17px; cursor:pointer; font-weight:800; transition:.15s; }
.gold-button { border:1px solid #e8c570; color:#16130d; background:linear-gradient(#f2d581,#bd8b34); box-shadow:0 8px 25px rgba(216,173,84,.13); }
.gold-button:hover { filter:brightness(1.07); transform:translateY(-1px); }
.gold-button.compact { min-height:38px; padding:7px 13px; font-size:13px; }
.outline-button { border:1px solid rgba(216,173,84,.28); color:var(--gold-bright); background:rgba(216,173,84,.04); }
.danger-button { border:1px solid rgba(255,91,100,.4); color:#ff9da3; background:rgba(255,91,100,.08); }
button:disabled { opacity:.55; cursor:not-allowed; transform:none!important; }
.toolbar-panel { display:grid; grid-template-columns:minmax(220px,1fr) 170px 140px; gap:12px; margin-bottom:16px; padding:15px; }
.search-box { position:relative; }
.search-box span { position:absolute; left:13px; top:50%; transform:translateY(-50%); color:var(--muted); }
.search-box input { padding-left:37px; }
input,select,textarea { width:100%; color:var(--text); border:1px solid rgba(255,255,255,.11); border-radius:11px; background:#0a0d0b; padding:11px 12px; }
textarea { resize:vertical; }
.analysis-grid { display:grid; grid-template-columns:1.4fr 1fr; gap:18px; }
.analysis-grid .wide { grid-column:1/-1; }
.ranking-list { display:grid; gap:9px; }
.rank-row { display:grid; grid-template-columns:34px 1fr auto; align-items:center; gap:10px; padding:11px; background:rgba(255,255,255,.025); border-radius:12px; }
.rank-number { width:28px; height:28px; display:grid; place-items:center; color:#10100d; background:var(--gold); border-radius:50%; font-weight:900; font-size:12px; }
.rank-row small { display:block; color:var(--muted); margin-top:3px; }
.insight-list { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.insight { padding:15px; border-radius:13px; background:rgba(255,255,255,.03); border-left:3px solid var(--gold); }
.insight strong { display:block; margin-bottom:7px; }
.insight p { margin:0; color:var(--muted); line-height:1.65; font-size:13px; }
.goal-detail-grid,.settings-grid { display:grid; grid-template-columns:repeat(2,1fr); gap:18px; }
.goal-detail-card { padding:28px; min-height:200px; }
.goal-detail-card strong.big { display:block; margin:13px 0; font-size:34px; font-family:Georgia,serif; }
.goal-progress { height:9px; overflow:hidden; border-radius:999px; background:rgba(255,255,255,.08); }
.goal-progress i { display:block; height:100%; border-radius:inherit; background:linear-gradient(90deg,var(--gold-dim),var(--gold-bright)); }
.settings-card p { color:var(--muted); line-height:1.7; }
.button-stack { display:grid; gap:9px; }
.file-button { display:grid; place-items:center; }
.file-button input { display:none; }
.danger-zone { border-color:rgba(255,91,100,.18); }
.muted { color:var(--muted); }
.bottom-nav { display:none; }
.app-dialog { width:min(720px,calc(100% - 24px)); max-height:calc(100vh - 30px); overflow:auto; color:var(--text); border:1px solid rgba(216,173,84,.25); border-radius:22px; background:#101411; box-shadow:0 30px 100px #000; padding:0; }
.app-dialog.small { width:min(520px,calc(100% - 24px)); }
.app-dialog::backdrop { background:rgba(0,0,0,.72); backdrop-filter:blur(5px); }
.app-dialog form { padding:24px; }
.dialog-head { display:flex; justify-content:space-between; gap:15px; margin-bottom:22px; }
.dialog-head h2 { font-size:25px; }
.icon-button { width:38px; height:38px; border:1px solid rgba(255,255,255,.09); border-radius:50%; background:rgba(255,255,255,.04); cursor:pointer; font-size:21px; }
.form-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-grid.single { grid-template-columns:1fr; }
.field { display:block; position:relative; }
.field.wide,.result-preview.wide { grid-column:1/-1; }
.field>span { display:block; margin:0 0 7px; color:#b8bdb8; font-size:12px; font-weight:700; }
.field.money b { position:absolute; right:12px; bottom:12px; color:var(--muted); font-size:12px; }
.field.money input { padding-right:35px; }
.result-preview { display:flex; justify-content:space-between; align-items:center; padding:15px 17px; border-radius:13px; background:linear-gradient(100deg,rgba(216,173,84,.08),rgba(32,201,122,.04)); border:1px solid rgba(216,173,84,.16); }
.result-preview span { color:var(--muted); font-size:12px; }
.result-preview strong { font-family:Georgia,serif; font-size:26px; }
.form-error { min-height:20px; margin:12px 0 0; color:#ff8c93; font-size:12px; }
.dialog-actions { display:flex; justify-content:flex-end; gap:10px; margin-top:14px; }
.toast-region { position:fixed; z-index:100; right:20px; bottom:20px; display:grid; gap:10px; }
.toast { min-width:260px; max-width:380px; padding:13px 15px; border:1px solid var(--line); border-radius:12px; color:var(--text); background:#111613; box-shadow:0 14px 50px #000; animation:toast-in .2s ease; }
.toast.error { border-color:rgba(255,91,100,.4); }
@keyframes toast-in { from{opacity:0; transform:translateY(8px)} }
.sr-only { position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0,0,0,0); }

@media (max-width: 920px) {
  .metric-grid { grid-template-columns:repeat(2,1fr); }
  .dashboard-grid,.analysis-grid,.goal-detail-grid,.settings-grid { grid-template-columns:1fr; }
  .analysis-grid .wide { grid-column:auto; }
  .entry-row { grid-template-columns:90px 1fr 120px 70px; }
  .entry-row .entry-meta:nth-of-type(2),.entry-row .entry-meta:nth-of-type(3) { display:none; }
  .insight-list { grid-template-columns:1fr; }
}
@media (max-width: 640px) {
  .app-shell { padding-bottom:88px; }
  .topbar { height:62px; padding:0 13px; }
  .brand-mark { width:34px; height:34px; font-size:19px; }
  .brand strong { font-size:12px; }
  .status-badge { display:none; }
  .desktop-nav { display:none; }
  .topbar .gold-button { display:none; }
  main { padding:17px 12px 12px; }
  .hero-panel { min-height:210px; display:block; padding:25px 21px; }
  .hero-result { margin-top:28px; text-align:left; }
  .hero-result strong { font-size:43px; }
  .metric-grid { gap:9px; margin-top:10px; }
  .metric-card { min-height:106px; padding:14px; }
  .metric-card strong { font-size:21px; }
  .panel { padding:17px; }
  .dashboard-grid,.recent-panel { margin-top:10px; gap:10px; }
  .panel-head { margin-bottom:14px; }
  .chart { min-height:235px; }
  .entry-row { grid-template-columns:1fr auto; gap:8px; padding:13px; }
  .entry-date { grid-column:1/-1; }
  .entry-meta { display:none!important; }
  .entry-result { grid-row:2; grid-column:2; }
  .entry-actions { grid-column:1/-1; justify-content:flex-end; }
  .toolbar-panel { grid-template-columns:1fr 1fr; }
  .toolbar-panel .search-box { grid-column:1/-1; }
  .page-heading { align-items:center; }
  .page-heading .gold-button { padding:9px 11px; font-size:12px; }
  .bottom-nav { position:fixed; z-index:30; left:0; right:0; bottom:0; height:74px; display:grid; grid-template-columns:repeat(5,1fr); align-items:center; padding:6px 8px max(6px,env(safe-area-inset-bottom)); border-top:1px solid var(--line); background:rgba(7,9,8,.94); backdrop-filter:blur(18px); }
  .nav-item { height:52px; border:0; background:none; display:grid; place-items:center; gap:2px; color:var(--muted); cursor:pointer; }
  .nav-item span { font-size:20px; line-height:1; }
  .nav-item small { font-size:9px; }
  .nav-item.active { color:var(--gold-bright); }
  .nav-fab { width:52px; height:52px; justify-self:center; margin-top:-25px; border:2px solid #f5d581; border-radius:50%; color:#111; background:linear-gradient(#f1d27c,#b8842f); box-shadow:0 8px 26px rgba(216,173,84,.27); font-size:28px; cursor:pointer; }
  .form-grid { grid-template-columns:1fr; }
  .field.wide,.result-preview.wide { grid-column:auto; }
  .app-dialog { width:100%; max-width:none; max-height:92vh; margin:auto 0 0; border-radius:22px 22px 0 0; }
  .app-dialog form { padding:20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .toast-region { left:12px; right:12px; bottom:90px; }
  .toast { min-width:0; max-width:none; }
}
