:root {
  color-scheme: light;
  --bg: #f4f5f8; --card: #ffffff; --line: #e6e8ee; --ink: #0d0f14; --ink2: #4b5160; --ink3: #8a90a0; --field: #f1f2f6;
  --accent: #3b5bfd; --accent-soft: #e9edff; --accent-ink: #fff;
  --hero-a: #1b2250; --hero-b: #3b5bfd;
  --good: #128a4a; --bad: #cf3340; --warn: #9a5b00; --warn-bg: #fff4d9; --good-bg: #e3f6ea;
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100; --series-5: #e87ba4; --series-other: #b4b8c4;
  --shadow: 0 1px 2px rgba(16,20,40,.04), 0 6px 24px -8px rgba(16,20,40,.10);
  --radius: 18px; --ease: cubic-bezier(.2,.8,.2,1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e0f13; --card: #17181e; --line: #272932; --ink: #f1f2f6; --ink2: #b9bdca; --ink3: #7e8394; --field: #1f2129;
    --accent: #7c93ff; --accent-soft: #232a4d; --accent-ink: #0b0d18;
    --hero-a: #161b3d; --hero-b: #3447b8;
    --good: #4fd08a; --bad: #ff7a85; --warn: #f0b64a; --warn-bg: #352a10; --good-bg: #123222;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-other: #5b6070;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px -10px rgba(0,0,0,.6);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.45 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.025em; font-weight: 700; }
h2 { font-size: 15px; margin: 0 0 10px; letter-spacing: -.01em; font-weight: 650; }
h3 { font-size: 11px; margin: 16px 0 4px; color: var(--ink3); text-transform: uppercase; letter-spacing: .07em; font-weight: 650; }
a { color: var(--accent); }
.muted { color: var(--ink2); } .small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pos { color: var(--good); } .neg { color: var(--bad); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* motion */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes sheet { from { opacity: 0; transform: translateY(28px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }
#main.enter > * { animation: rise .42s var(--ease) both; }
#main.enter > *:nth-child(2) { animation-delay: .04s; } #main.enter > *:nth-child(3) { animation-delay: .08s; } #main.enter > *:nth-child(n+4) { animation-delay: .12s; }
#main.enter .grid > * { animation: rise .45s var(--ease) both; }
#main.enter .grid > *:nth-child(2) { animation-delay: .05s; } #main.enter .grid > *:nth-child(3) { animation-delay: .1s; } #main.enter .grid > *:nth-child(n+4) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* layout: bottom tabs on phones, sidebar on desktop */
#main { padding: 18px 16px 150px; max-width: 1240px; margin: 0 auto; }
#nav { position: fixed; z-index: 5; bottom: 0; left: 0; right: 0; display: flex; background: color-mix(in srgb, var(--card) 86%, transparent); backdrop-filter: saturate(1.6) blur(18px); -webkit-backdrop-filter: saturate(1.6) blur(18px); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
#nav .brand { display: none; }
#nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 7px 0 5px; font-size: 10.5px; font-weight: 550; color: var(--ink3); text-decoration: none; border-radius: 12px; transition: color .2s, background .2s, transform .15s var(--ease); }
#nav a svg { width: 22px; height: 22px; transition: transform .25s var(--ease); }
#nav a:active { transform: scale(.94); }
#nav a.on { color: var(--accent); } #nav a.on svg { transform: translateY(-1px) scale(1.08); }
#fab { position: fixed; z-index: 6; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom)); width: 58px; height: 58px; border-radius: 20px; border: 0; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 10px 26px -6px color-mix(in srgb, var(--accent) 65%, transparent); cursor: pointer; transition: transform .2s var(--ease), box-shadow .2s; }
#fab svg { width: 26px; height: 26px; stroke-width: 2.4; }
#fab:hover { transform: translateY(-2px) scale(1.04); } #fab:active { transform: scale(.94); }
@media (min-width: 900px) {
  #nav { top: 0; right: auto; width: 212px; flex-direction: column; border-top: 0; border-right: 1px solid var(--line); padding: 20px 12px; gap: 3px; background: var(--card); backdrop-filter: none; }
  #nav .brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 19px; padding: 2px 10px 20px; letter-spacing: -.03em; }
  #nav .brand .logo { width: 30px; height: 30px; border-radius: 10px; background: linear-gradient(135deg, var(--hero-a), var(--hero-b)); color: #fff; display: grid; place-items: center; font-size: 17px; }
  #nav a { flex: none; flex-direction: row; gap: 11px; padding: 10px 12px; font-size: 14px; color: var(--ink2); }
  #nav a svg { width: 19px; height: 19px; }
  #nav a:hover { background: var(--field); color: var(--ink); }
  #nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 650; } #nav a.on svg { transform: none; }
  #main { margin-left: 212px; padding: 30px 36px 70px; max-width: none; }
  #fab { bottom: 30px; right: 32px; }
}

.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.grid { display: grid; gap: 14px; }
@media (min-width: 900px) { .grid.two { grid-template-columns: 1fr 1fr; align-items: start; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; min-width: 0; box-shadow: var(--shadow); }
.ch { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px; } .ch h2 { margin: 0; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); transition: transform .25s var(--ease); }
.tile:hover { transform: translateY(-2px); }
.card .tile { box-shadow: none; background: var(--field); border-color: transparent; }
.tile .lbl { font-size: 12px; color: var(--ink2); font-weight: 550; }
.tile .val { font-size: 21px; font-weight: 700; letter-spacing: -.02em; margin-top: 2px; }
.tile .sub { font-size: 12px; color: var(--ink3); }
.hero { border: 0; color: #fff; background: radial-gradient(120% 140% at 100% 0%, var(--hero-b), var(--hero-a) 62%); padding: 22px; position: relative; overflow: hidden; }
.hero .lbl { font-size: 13px; opacity: .78; font-weight: 550; }
.hero .val { font-size: clamp(34px, 9vw, 46px); font-weight: 750; letter-spacing: -.035em; line-height: 1.1; margin: 2px 0 8px; }
.hero .pill { display: inline-flex; gap: 6px; align-items: center; background: rgba(255,255,255,.14); border-radius: 99px; padding: 4px 11px; font-size: 13px; font-weight: 600; }
.hero .side { display: flex; gap: 22px; flex-wrap: wrap; margin-top: 16px; font-size: 13px; }
.hero .side b { display: block; font-size: 16px; font-weight: 650; letter-spacing: -.01em; }
.hero .side span { opacity: .72; }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 8px; margin: 0 -8px; border-radius: 12px; position: relative; transition: background .15s; }
.row + .row::before { content: ""; position: absolute; left: 8px; right: 8px; top: 0; border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.row .s { font-size: 12px; color: var(--ink3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row.click { cursor: pointer; }
.row.click:hover { background: var(--field); } .row.click:active { background: var(--line); }
.datehead { font-size: 11px; color: var(--ink3); padding: 14px 0 2px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 650; padding: 3px 9px; border-radius: 99px; background: var(--field); color: var(--ink2); white-space: nowrap; }
.badge.ok { color: var(--good); background: var(--good-bg); } .badge.warn { color: var(--warn); background: var(--warn-bg); }
.notice { background: var(--warn-bg); color: var(--ink); border-radius: 14px; padding: 11px 14px; font-size: 14px; margin-bottom: 14px; }

button, .btn { font: inherit; font-weight: 550; border: 1px solid var(--line); background: var(--card); color: var(--ink); border-radius: 11px; padding: 8px 13px; cursor: pointer; transition: transform .15s var(--ease), background .15s, border-color .15s, box-shadow .15s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--ink3); } button:active, .btn:active { transform: scale(.96); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover { box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent); }
button.danger { color: var(--bad); }
button.sm, .btn.sm { padding: 6px 10px; font-size: 13px; border-radius: 9px; }
button:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid transparent; border-radius: 11px; padding: 9px 11px; width: 100%; min-width: 0; transition: border-color .15s, box-shadow .15s, background .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); background: var(--card); }
textarea { min-height: 92px; resize: vertical; }
input.amt { width: 104px; text-align: right; padding: 6px 9px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
label { display: block; font-size: 12px; font-weight: 550; color: var(--ink2); margin: 12px 0 5px; }
label.check { display: flex; gap: 9px; align-items: center; font-size: 14px; color: var(--ink); margin: 12px 0; cursor: pointer; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
@media (min-width: 900px) { .filters { grid-template-columns: 150px 1fr 1fr 130px 1.2fr; } }
.filters .wide { grid-column: 1 / -1; } @media (min-width: 900px) { .filters .wide { grid-column: auto; } }
.seg { display: inline-flex; background: var(--field); border-radius: 12px; padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.seg.full { display: flex; } .seg.full button { flex: 1; }
.seg button { border: 0; background: transparent; padding: 7px 13px; font-size: 13px; color: var(--ink2); border-radius: 9px; white-space: nowrap; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 650; box-shadow: 0 1px 3px rgba(0,0,0,.14); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 99px; background: var(--field); border-color: transparent; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.bar { height: 8px; background: var(--field); border-radius: 99px; overflow: hidden; margin-top: 7px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .6s var(--ease); }
.bar.over i { background: var(--bad); } .bar.done i { background: var(--good); }
.hbar { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; padding: 7px 8px; margin: 0 -8px; border-radius: 10px; cursor: pointer; font-size: 14px; }
.hbar:hover { background: var(--field); }
.hbar .track { height: 10px; border-radius: 99px; background: var(--field); overflow: hidden; } .hbar .track i { display: block; height: 100%; border-radius: 99px; background: var(--series-1); transition: width .6s var(--ease); }
.hbar .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tables */
.scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
.sticky th:first-child, .sticky td:first-child { position: sticky; left: 0; background: var(--card); max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }
thead th { font-size: 11px; color: var(--ink3); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; }
tbody tr:last-child td { border-bottom: 0; }
tr.grp td { font-weight: 650; } tr.sub td:first-child { padding-left: 26px; color: var(--ink2); }
tr.total td { font-weight: 750; border-top: 2px solid var(--ink3); }
tr.sect td { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink3); padding-top: 18px; font-weight: 650; }
td.drill { cursor: pointer; border-radius: 6px; } td.drill:hover { color: var(--accent); text-decoration: underline; }
td.zero { color: var(--ink3); }
table.entries td, table.entries th { text-align: left; } table.entries td:last-child, table.entries th:last-child { text-align: right; }
table.entries tbody tr { cursor: pointer; transition: background .12s; } table.entries tbody tr:hover { background: var(--field); }
table.entries td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
th.sort { cursor: pointer; user-select: none; } th.sort:hover { color: var(--ink); } th.sort.on { color: var(--accent); }

/* dialog: bottom sheet on phones */
dialog { border: 0; padding: 0; background: var(--card); color: var(--ink); width: 100%; max-width: 480px; border-radius: 22px; max-height: 92dvh; overflow: auto; box-shadow: 0 30px 80px -20px rgba(0,0,0,.5); }
dialog[open] { animation: sheet .34s var(--ease); }
dialog::backdrop { background: rgba(10,12,24,.5); backdrop-filter: blur(3px); animation: fade .25s; }
@media (max-width: 599px) { dialog { margin: auto 0 0; max-width: none; border-radius: 22px 22px 0 0; } }
dialog form { padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
dialog .dh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; } dialog .dh h2 { margin: 0; font-size: 17px; }
dialog .dh button { border: 0; background: var(--field); width: 32px; height: 32px; padding: 0; border-radius: 50%; }
dialog .actions { display: flex; gap: 8px; margin-top: 18px; } dialog .actions .grow { flex: 1; } dialog .actions button { padding: 11px 14px; }
input.big { font-size: 34px; font-weight: 700; text-align: center; padding: 12px; letter-spacing: -.02em; }
.err { color: var(--bad); font-size: 13px; margin-top: 8px; min-height: 18px; }

/* charts */
.chart svg { display: block; width: 100%; height: auto; overflow: visible; stroke: none; }
.chart text { font-size: 11px; fill: var(--ink3); stroke: none; }
.chart .gridline { stroke: var(--line); stroke-width: 1; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink2); margin-bottom: 6px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; }
.tip { position: fixed; z-index: 20; pointer-events: none; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 11px; font-size: 12px; box-shadow: var(--shadow); }
.tip b { display: block; margin-bottom: 3px; }
#toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: 150px; background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 99px; font-size: 14px; font-weight: 550; max-width: 90vw; box-shadow: var(--shadow); animation: pop .3s var(--ease); }
.steps { counter-reset: step; } .steps > .card > h2::before, .steps > .card > .ch > h2::before { counter-increment: step; content: counter(step); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 12px; margin-right: 8px; }
.exports { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.exports .btn { justify-content: flex-start; padding: 11px 13px; text-align: left; }
.exports .btn small { display: block; color: var(--ink3); font-weight: 450; }
@media (max-width: 599px) { .row input.amt { width: 84px; } .row button.sm { padding: 6px 8px; } h1 { font-size: 23px; } }
.yearpick { width: auto; font-weight: 650; padding: 7px 10px; background: var(--card); border: 1px solid var(--line); border-radius: 99px; box-shadow: var(--shadow); }
@media (max-width: 599px) { #nav a { font-size: 9.5px; } #nav a svg { width: 20px; height: 20px; } }

/* ---- phone behaviour: no zooming, no sideways drift, no rubber-band ---- */
html { touch-action: manipulation; overscroll-behavior: none; }        /* manipulation = no double-tap zoom */
body { overflow-x: clip; overscroll-behavior: none; }
@media (pointer: coarse) {
  /* iPhones zoom into any field with text under 16px when it is tapped; 16px stops that */
  input, select, textarea, .yearpick { font-size: 16px; }
  input.big { font-size: 34px; }
  button, a, .row.click, td.drill, .hbar, th.sort { touch-action: manipulation; }
}
@media (max-width: 599px) {
  .seg:not(.full) { flex-wrap: wrap; }                          /* tab strips wrap instead of scrolling sideways */
  .seg.full button { flex: 1 1 0; min-width: 0; padding: 7px 4px; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }
}
