:root {
  --ground: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #efeee8;
  --line: #e2e0d6;
  --ink: #1d2124;
  --ink-2: #5c6469;
  --ink-3: #949ba1;
  --accent: #4d9626;
  --accent-soft: rgba(108, 191, 52, 0.13);
  --blue: #3f7cae;
  --danger: #c93f39;
  --round: ui-rounded, "Hiragino Maru Gothic ProN", -apple-system, sans-serif;
  --body: -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #14171a; --surface: #1c2023; --surface-2: #24282c; --line: #32383d;
    --ink: #eef1f2; --ink-2: #a8b0b5; --ink-3: #737b81;
    --accent: #8ed35c; --accent-soft: rgba(142, 211, 92, 0.14);
    --blue: #9cc2e6; --danger: #ef6f68;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--ground); color: var(--ink);
  font-family: var(--body); line-height: 1.6; -webkit-font-smoothing: antialiased;
}
h1, h2 { font-family: var(--round); letter-spacing: -0.01em; }
h2 { font-size: 1rem; margin: 0 0 10px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--surface);
}
.brand { font-family: var(--round); font-weight: 700; font-size: 1.05rem; }
.brand .for { color: var(--ink-2); font-weight: 600; font-size: 0.85rem; }
.beta {
  font-size: 0.62rem; font-weight: 700; color: var(--accent);
  border: 1px solid var(--accent); border-radius: 999px; padding: 1px 8px; vertical-align: middle;
}
.privacy-chip { font-size: 0.75rem; color: var(--ink-2); }

.page { max-width: 1020px; margin: 0 auto; padding: 28px 20px 60px; }

/* 読み込み前 */
.empty { max-width: 620px; margin: 40px auto; text-align: center; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.empty h1 { font-size: clamp(1.5rem, 4vw, 2rem); margin: 0; line-height: 1.35; text-wrap: balance; }
.empty p { color: var(--ink-2); font-size: 0.92rem; margin: 0; }
.dropzone {
  width: 100%; padding: 44px 20px; border: 2px dashed var(--line); border-radius: 16px;
  background: var(--surface); color: var(--ink-2); font-size: 0.9rem; cursor: pointer;
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover, .dropzone:focus-visible, .dropzone.over {
  border-color: var(--accent); background: var(--accent-soft); outline: none;
}
.dz-icon { font-size: 1.6rem; }
.ghost-btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-family: var(--body); font-size: 0.82rem; font-weight: 600;
  padding: 8px 18px; border-radius: 999px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.error { color: var(--danger); font-size: 0.85rem; font-weight: 600; }
.note { color: var(--ink-3); font-size: 0.75rem; margin: 6px 0 0; }

/* 読み込み後 */
.file-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.file-name { font-weight: 700; font-family: var(--round); }
.file-meta { color: var(--ink-3); font-size: 0.78rem; margin-left: 10px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px;
}
.stat .k { font-size: 0.72rem; color: var(--ink-2); }
.stat .v { font-family: var(--round); font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.stat .v.minus { color: var(--danger); }
.stat .sub { font-size: 0.72rem; color: var(--ink-3); }

.chart-card, .card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  padding: 18px 20px; margin-bottom: 16px;
}
.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.range-chips { display: flex; gap: 6px; }
.range-chips button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  font-family: var(--body); font-size: 0.76rem; font-weight: 600;
  padding: 4px 13px; border-radius: 999px; cursor: pointer;
}
.range-chips button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
.chart-wrap { position: relative; margin-top: 8px; }
#chart { width: 100%; height: 320px; display: block; touch-action: pan-y; }
.tooltip {
  position: absolute; pointer-events: none; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  font-size: 0.75rem; box-shadow: 0 6px 20px rgba(0,0,0,0.12); max-width: 240px; z-index: 2;
}
.tooltip .tt-date { color: var(--ink-2); }
.tooltip .tt-balance { font-family: var(--round); font-weight: 700; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.tooltip .tt-balance.minus { color: var(--danger); }
.tooltip ul { margin: 4px 0 0; padding: 0; list-style: none; color: var(--ink-2); }
.tooltip li { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }

.legend { display: flex; gap: 18px; margin-top: 10px; font-size: 0.72rem; color: var(--ink-2); flex-wrap: wrap; }
.legend .sw { display: inline-block; width: 22px; height: 0; border-top: 2.5px solid var(--accent); vertical-align: middle; margin-right: 6px; }
.legend .sw.dashed { border-top-style: dashed; border-top-color: var(--blue); }
.legend .sw.today { border-top: 2px dotted var(--ink-3); }

.grid-2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; }
@media (max-width: 760px) { .grid-2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.82rem; }
th, td { text-align: right; padding: 7px 10px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--ink-2); font-weight: 600; font-size: 0.72rem; }
td.minus { color: var(--danger); }
tr.year-now td { background: var(--accent-soft); }

.wallet-list { margin: 0; padding: 0; list-style: none; }
.wallet-list li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 0.85rem; }
.wallet-list li:last-child { border-bottom: none; }
.wallet-list .w-meta { color: var(--ink-3); font-size: 0.72rem; }
.wallet-list .w-balance { font-family: var(--round); font-weight: 700; font-variant-numeric: tabular-nums; }

.foot { max-width: 1020px; margin: 0 auto; padding: 0 20px 40px; color: var(--ink-3); font-size: 0.72rem; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
