:root {
  color-scheme: light;
  --ink: #10131a;
  --muted: #626a78;
  --paper: #eef0f4;
  --card: #ffffff;
  --line: #cfd4dd;
  --accent: #2558e5;
  --accent-strong: #163fba;
  --expense: #ef4f32;
  --danger: #c6352b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input, select { font: inherit; }
button, label[for] { -webkit-tap-highlight-color: transparent; }

.topbar {
  max-width: 1320px;
  margin: auto;
  min-height: 78px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--ink); text-decoration: none; font-size: 1.2rem; font-weight: 700; letter-spacing: -.04em; }
.brand span { color: var(--accent); }
.privacy { color: var(--muted); font-size: .875rem; display: flex; align-items: center; gap: 9px; }
.privacy span { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px rgba(37, 88, 229, .17); }
main { max-width: 1320px; margin: auto; padding: 0 32px; }

.welcome {
  min-height: calc(100vh - 150px);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(350px, .75fr);
  align-items: center;
  gap: clamp(60px, 10vw, 150px);
  padding: 74px 4vw 90px;
}

.eyebrow { text-transform: uppercase; letter-spacing: .15em; font-size: .75rem; font-weight: 700; color: var(--accent); margin: 0 0 16px; }
h1, h2, p { margin-top: 0; }
h1 { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: clamp(3.7rem, 7vw, 6.6rem); line-height: .92; letter-spacing: -.045em; font-weight: 400; margin-bottom: 28px; }
h1 em { color: var(--accent); font-weight: 400; }
.lede { max-width: 620px; color: var(--muted); font-size: 1.15rem; line-height: 1.65; }
.actions, .setup-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 34px; }
#file-input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.button { border: 1px solid transparent; border-radius: 7px; padding: 13px 19px; cursor: pointer; font-weight: 650; font-size: .92rem; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:focus-visible, select:focus-visible { outline: 3px solid rgba(37, 88, 229, .45); outline-offset: 2px; }
.primary { background: var(--accent); color: white; }
.primary:hover { background: var(--accent-strong); }
.secondary { border-color: var(--line); background: transparent; color: var(--ink); }
.secondary:hover { background: #e1e4ea; }
.compact { padding: 9px 13px; font-size: .82rem; }
.error { color: var(--danger); min-height: 1.4em; margin-top: 14px; }
.notice { color: var(--ink); background: var(--card); border: 1px solid #cc7a00; border-left-width: 4px; border-radius: 7px; padding: 13px 15px; margin: 18px 0 0; line-height: 1.5; font-size: .86rem; }

.how-card { background: var(--ink); color: #ffffff; border-radius: 14px; padding: 34px; box-shadow: 24px 24px 0 #c7ccd5; }
.how-card .eyebrow { color: #6f94ff; }
.how-card ol { list-style: none; margin: 0; padding: 0; counter-reset: steps; }
.how-card li { position: relative; padding: 0 0 25px 45px; color: #aeb7c7; line-height: 1.5; counter-increment: steps; }
.how-card li::before { content: counter(steps); position: absolute; left: 0; width: 26px; height: 26px; display: grid; place-items: center; border: 1px solid #485162; border-radius: 50%; color: #6f94ff; font-size: .75rem; }
.how-card li span { display: block; color: white; font-weight: 650; }
.local-note { border-top: 1px solid #343b49; padding-top: 24px; }
.local-note p { color: #aeb7c7; line-height: 1.5; font-size: .88rem; margin: 7px 0 0; }

.setup { max-width: 880px; margin: 72px auto; }
.setup h2, .panel h2 { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 2.5rem; font-weight: 400; letter-spacing: -.025em; margin-bottom: 12px; }
.setup > div > p:last-child { color: var(--muted); line-height: 1.6; max-width: 720px; }
.account-list { margin-top: 32px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); overflow: hidden; }
.account-list label { padding: 15px 18px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.account-list label:last-child { border: 0; }
.account-list strong { overflow-wrap: anywhere; }
select { min-width: 245px; border: 1px solid var(--line); background: var(--paper); border-radius: 6px; padding: 9px 34px 9px 11px; color: var(--ink); }

.dashboard { padding: 55px 0 80px; }
.dashboard-head { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin-bottom: 30px; }
.dashboard-head h1 { font-size: clamp(3rem, 5vw, 5rem); margin: 0; }
.dashboard-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: .82rem; }
.metrics { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); background: var(--card); border-radius: 11px; margin-bottom: 20px; overflow: hidden; }
.metrics article { padding: 22px 25px; border-right: 1px solid var(--line); }
.metrics article:last-child { border: 0; }
.metrics p { color: var(--muted); font-size: .82rem; margin-bottom: 8px; }
.metrics strong { display: block; font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 2.2rem; font-weight: 400; }
.metrics small { display: block; color: var(--muted); font-size: .75rem; margin-top: 5px; }
.metrics .net { background: var(--ink); color: white; }
.metrics .net p, .metrics .net small { color: #aeb7c7; }
.negative { color: var(--danger); }
.grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(310px, .55fr); gap: 20px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 11px; padding: 25px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel h2 { font-size: 2rem; margin: 0; }
.cashflow-panel { min-height: 430px; }
.category-panel, .explorer-panel, .annual-panel { grid-column: 1 / -1; }
.segmented { display: flex; border: 1px solid var(--line); padding: 3px; border-radius: 7px; }
.segmented button { border: 0; padding: 7px 10px; background: transparent; color: var(--muted); font-size: .75rem; cursor: pointer; border-radius: 4px; }
.segmented button.active { background: var(--ink); color: white; }
.chart-controls { display: flex; align-items: end; flex-wrap: wrap; justify-content: end; gap: 10px; }
.range-control { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.range-control select { display: block; min-width: 170px; margin-top: 5px; padding-top: 7px; padding-bottom: 7px; background-color: var(--card); font-size: .78rem; text-transform: none; letter-spacing: normal; }
.legend { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: .75rem; margin: 24px 0 0 59px; }
.legend span { width: 9px; height: 9px; border-radius: 2px; margin-left: 12px; }
.legend span:first-child { margin-left: 0; }
.legend small { margin-left: auto; font-size: .7rem; }
.income-dot { background: var(--accent); }
.expense-dot { background: var(--expense); }
.chart { overflow-x: auto; min-height: 390px; scrollbar-width: thin; }
.chart svg { display: block; width: 100%; min-width: 680px; height: auto; }
.gridline { stroke: #dfe3ea; stroke-width: 1; }
.axis-label { fill: #687180; font: 11px Inter, ui-sans-serif, system-ui, sans-serif; }
.bar-income { fill: var(--accent); }
.bar-expense { fill: var(--expense); }
.month-hit { fill: transparent; cursor: pointer; }
.month-hit:hover, .month-hit:focus { fill: rgba(37, 88, 229, .07); outline: none; }
.month-hit.selected { fill: rgba(37, 88, 229, .11); }
.explain { color: var(--muted); font-size: .82rem; line-height: 1.5; margin: 20px 0; }
.lumpy-list > div { display: flex; justify-content: space-between; gap: 15px; padding: 13px 0; border-top: 1px solid var(--line); }
.lumpy-list strong, .lumpy-list small { display: block; }
.lumpy-list strong { font-size: .86rem; }
.lumpy-list small { color: var(--muted); font-size: .72rem; margin-top: 4px; }
.lumpy-list b { font-size: .86rem; white-space: nowrap; }
.empty { color: var(--muted); font-size: .85rem; border-top: 1px solid var(--line); padding-top: 16px; }
.category-list { display: grid; grid-template-columns: 1fr 1fr; gap: 20px 38px; margin-top: 26px; }
.category-list > div > div:first-child { display: flex; justify-content: space-between; gap: 20px; font-size: .82rem; margin-bottom: 8px; }
.category-list > div > div:last-child { height: 7px; background: #e2e5eb; border-radius: 5px; overflow: hidden; }
.category-list i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.explorer-help { color: var(--muted); font-size: .8rem; line-height: 1.5; max-width: 260px; text-align: right; }
.month-strip { display: flex; gap: 8px; overflow-x: auto; margin: 26px -25px 0; padding: 0 25px 16px; scrollbar-width: thin; }
.month-strip button { flex: 0 0 126px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); padding: 11px 12px; text-align: left; cursor: pointer; }
.month-strip button span, .month-strip button strong { display: block; }
.month-strip button span { color: var(--muted); font-size: .72rem; margin-bottom: 4px; }
.month-strip button strong { font-size: .9rem; }
.month-strip button.active { color: white; background: var(--ink); border-color: var(--ink); }
.month-strip button.active span { color: #b9c3bd; }
.drill-head { min-height: 66px; display: flex; justify-content: space-between; align-items: center; gap: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.drill-head > strong { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 1.55rem; font-weight: 400; white-space: nowrap; }
.breadcrumbs { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.breadcrumbs span { color: #a2aaa5; }
.breadcrumbs button { border: 0; background: transparent; color: var(--accent); padding: 4px 0; cursor: pointer; font-weight: 650; }
.breadcrumbs button:last-child { color: var(--ink); cursor: default; }
.category-trend { margin: 22px 0 2px; padding: 20px; border-radius: 9px; background: #f3f5f8; border: 1px solid var(--line); }
.trend-summary { display: flex; justify-content: space-between; align-items: end; gap: 28px; }
.trend-summary h3 { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 1.7rem; font-weight: 400; margin: 0; }
.trend-summary dl { display: flex; gap: 25px; margin: 0; }
.trend-summary dl div { min-width: 105px; }
.trend-summary dt { color: var(--muted); font-size: .68rem; margin-bottom: 4px; }
.trend-summary dd { margin: 0; font-size: .84rem; font-weight: 700; }
.trend-chart { overflow-x: auto; min-height: 220px; margin-top: 14px; scrollbar-width: thin; }
.trend-chart svg { display: block; width: 100%; height: auto; }
.trend-area { fill: rgba(239, 79, 50, .12); }
.trend-line { fill: none; stroke: var(--expense); stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.trend-average-line { stroke: #9da7a1; stroke-width: 1; stroke-dasharray: 5 5; }
.trend-dot { fill: var(--card); stroke: var(--expense); stroke-width: 2.5; cursor: pointer; }
.trend-dot:hover, .trend-dot:focus { fill: var(--expense); stroke: var(--ink); outline: none; }
.trend-dot.selected { fill: var(--expense); stroke: var(--ink); }
.drill-children { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 20px; }
.drill-children button { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); padding: 15px; text-align: left; cursor: pointer; overflow: hidden; }
.drill-children button:hover { border-color: #8d98aa; background: #f3f5f8; }
.drill-children strong, .drill-children small { display: block; }
.drill-children strong { font-size: .9rem; }
.drill-children small { color: var(--muted); font-size: .7rem; margin-top: 4px; }
.drill-children b { font-size: .86rem; white-space: nowrap; }
.drill-children i { grid-column: 1 / -1; display: block; height: 4px; border-radius: 3px; background: #e2e5eb; margin-top: 7px; overflow: hidden; }
.drill-children i span { display: block; height: 100%; border-radius: inherit; background: var(--accent); }
.drill-transactions { padding-top: 8px; }
.transaction-label { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .09em; margin: 15px 2px 2px; }
.drill-transactions > div { display: flex; justify-content: space-between; gap: 24px; padding: 13px 2px; border-bottom: 1px solid var(--line); }
.drill-transactions span, .drill-transactions strong, .drill-transactions small { display: block; }
.drill-transactions strong { font-size: .86rem; }
.drill-transactions small { color: var(--muted); font-size: .72rem; margin-top: 4px; }
.drill-transactions b { white-space: nowrap; font-size: .86rem; }
.year-strip { display: flex; gap: 8px; overflow-x: auto; margin: 26px 0 18px; padding-bottom: 6px; scrollbar-width: thin; }
.year-strip button { min-width: 120px; border: 1px solid var(--line); border-radius: 7px; background: var(--paper); color: var(--ink); padding: 11px 14px; text-align: left; cursor: pointer; }
.year-strip button strong, .year-strip button span { display: block; }
.year-strip button strong { font-size: 1rem; }
.year-strip button span { color: var(--muted); font-size: .72rem; margin-top: 3px; }
.year-strip button.active { background: var(--ink); border-color: var(--ink); color: white; }
.year-strip button.active span { color: #b9c3bd; }
.annual-metrics { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
.annual-metrics > div { min-height: 100px; padding: 17px 19px; border-right: 1px solid var(--line); }
.annual-metrics > div:last-child { border: 0; }
.annual-metrics span, .annual-metrics small { display: block; color: var(--muted); font-size: .72rem; }
.annual-metrics strong { display: block; font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 1.75rem; font-weight: 400; margin: 6px 0 2px; }
.annual-metrics .annual-net { background: var(--ink); color: white; }
.annual-metrics .annual-net span { color: #aeb7c7; }
.annual-breakdown-head { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 24px; min-height: 55px; border-bottom: 1px solid var(--line); }
.annual-breakdown-head > strong { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 1.5rem; font-weight: 400; }
.annual-children { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding-top: 18px; }
.annual-children > * { display: grid; grid-template-columns: 1fr auto; gap: 4px 18px; border: 1px solid var(--line); border-radius: 8px; background: white; color: var(--ink); padding: 14px; text-align: left; }
.annual-children button { font: inherit; cursor: pointer; }
.annual-children button:hover { border-color: #8d98aa; background: #f3f5f8; }
.annual-children strong, .annual-children small, .annual-children b { display: block; }
.annual-children strong { font-size: .86rem; }
.annual-children small { color: var(--muted); font-size: .7rem; margin-top: 4px; }
.annual-children > * > span:nth-child(2) { text-align: right; }
.annual-children b { font-size: .86rem; white-space: nowrap; }
.annual-children i { grid-column: 1 / -1; display: block; height: 4px; border-radius: 3px; background: #e2e5eb; margin-top: 7px; overflow: hidden; }
.annual-children i span { display: block; height: 100%; background: var(--expense); border-radius: inherit; }
.annual-comparison { margin-top: 30px; padding-top: 24px; border-top: 1px solid var(--line); }
.annual-comparison h3 { font-family: Iowan Old Style, Baskerville, Georgia, serif; font-size: 1.55rem; font-weight: 400; margin: 0 0 14px; }
.table-scroll { overflow-x: auto; }
.annual-comparison table { width: 100%; min-width: 650px; border-collapse: collapse; font-size: .78rem; }
.annual-comparison th, .annual-comparison td { padding: 11px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.annual-comparison thead th { color: var(--muted); font-size: .68rem; text-transform: uppercase; letter-spacing: .07em; }
.annual-comparison th:first-child, .annual-comparison td:first-child { text-align: left; }
footer { text-align: center; color: var(--muted); font-size: .75rem; padding: 24px; border-top: 1px solid var(--line); }
.hidden { display: none !important; }

@media (max-width: 860px) {
  .welcome { grid-template-columns: 1fr; padding: 60px 0 90px; gap: 55px; }
  .how-card { max-width: 560px; }
  .grid { grid-template-columns: 1fr; }
  .category-panel, .explorer-panel, .annual-panel { grid-column: auto; }
  .metrics { grid-template-columns: 1fr; }
  .annual-metrics { grid-template-columns: 1fr 1fr; }
  .annual-metrics > div:nth-child(2) { border-right: 0; }
  .annual-metrics > div { border-bottom: 1px solid var(--line); }
  .annual-metrics > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .metrics article { border-right: 0; border-bottom: 1px solid var(--line); }
  .dashboard-head { align-items: start; flex-direction: column; }
}

@media (max-width: 560px) {
  .topbar, main { padding-left: 18px; padding-right: 18px; }
  .privacy { font-size: .72rem; }
  h1 { font-size: 3.7rem; }
  .actions .button { width: 100%; text-align: center; }
  .how-card { padding: 27px 23px; box-shadow: 10px 10px 0 #c7ccd5; }
  .account-list label { align-items: stretch; flex-direction: column; }
  select { min-width: 0; width: 100%; }
  .dashboard-actions { align-items: start; flex-direction: column; }
  .panel { padding: 20px 16px; }
  .panel-head { flex-direction: column; }
  .chart-controls { align-items: stretch; justify-content: start; width: 100%; }
  .range-control { flex: 1; }
  .range-control select { min-width: 0; width: 100%; }
  .legend small { display: none; }
  .category-list { grid-template-columns: 1fr; }
  .explorer-help { text-align: left; }
  .trend-summary { align-items: start; flex-direction: column; }
  .trend-summary dl { display: grid; grid-template-columns: 1fr 1fr; width: 100%; gap: 14px; }
  .drill-children { grid-template-columns: 1fr; }
  .annual-children { grid-template-columns: 1fr; }
  .month-strip { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; }
}

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