:root {
  --bg: #F8F6FD; --panel: #FFFFFF; --side: #EFEBFC; --side-ink: #2E2650; --side-muted: #8A82A8; --side-hover: #E3DDFA;
  --ink: #2A2442; --muted: #6E6889; --faint: #9A94B2; --line: #E8E4F3; --line-strong: #D3CDE6;
  --accent: #7B6CF0; --accent-ink: #FFFFFF; --accent-soft: #EDEAFE; --butter: #F7D02F;
  --danger: #C2364B; --danger-bg: #FDECEF; --warn: #8A5B00; --warn-bg: #FFF5D9; --info: #4A55B8; --info-bg: #EBEEFD;
  --ok: #1E7A55; --ok-bg: #E4F6EE; --input: #FFFFFF; --hover: #F4F1FC; --hl: #FFF1B8;
  --t-lav: #F0ECFF; --t-mint: #E6F7EF; --t-peach: #FFEEE6; --t-sky: #E7F1FE; --t-butter: #FFF7DA; --t-pink: #FDEBF2;
  --shadow: 0 1px 2px rgba(60,45,120,.05), 0 6px 20px rgba(60,45,120,.06);
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--ink); -webkit-font-smoothing: antialiased; }
::selection { background: #DCD5FF; color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent) !important; box-shadow: 0 0 0 3px rgba(123,108,240,.22); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 16px; height: 16px; }
table { font-variant-numeric: tabular-nums; }

#app { display: grid; grid-template-columns: 214px 1fr; height: 100vh; }
.side { border-right: 1px solid var(--line); background: var(--side); color: var(--side-ink); display: flex; flex-direction: column; padding: 18px 12px 12px; gap: 4px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
.brand .rb-slot { width: 40px; }
.brand .name { font-weight: 700; font-size: 15px; }
.brand .sub { font-size: 11.5px; color: var(--side-muted); }
.side .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--side-muted); padding: 14px 8px 6px; }
.navbtn { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: 0; background: transparent; color: var(--side-ink); padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.navbtn:hover { background: var(--side-hover); }
.navbtn.active { background: #fff; color: var(--ink); font-weight: 650; box-shadow: 0 1px 2px rgba(60,45,120,.08), inset 3px 0 0 var(--accent); }
.navbtn .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.navbtn .yr { font-weight: 600; font-size: 14.5px; }
.navbtn .st { font-size: 11.5px; opacity: .75; }
.navbtn.active .st { opacity: .85; }
.side .spacer { flex: 1; }
.side .tool { font-size: 13px; color: var(--muted); }
.side .tool:hover { color: var(--ink); }
.side .folder { font-size: 11px; color: var(--side-muted); padding: 8px 10px 0; word-break: break-all; }

main { overflow-y: auto; overflow-x: hidden; }
.page { padding: 24px 28px 80px; max-width: 1500px; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.3px; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; }
.stack > * + * { margin-top: 16px; }

.yearhead { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.savestate { font-size: 12.5px; color: var(--muted); margin-left: auto; }
.savestate.err { color: var(--danger); font-weight: 600; }
.tabs { display: flex; flex-wrap: wrap; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 20px; position: sticky; top: 0; background: var(--bg); z-index: 5; padding-top: 4px; }
.tab { border: 0; background: transparent; padding: 9px 10px; cursor: pointer; color: var(--muted); border-bottom: 2.5px solid transparent; white-space: nowrap; font-weight: 500; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.tab .count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; font-size: 11px; background: var(--warn-bg); color: var(--warn); margin-left: 4px; font-weight: 700; }
.tab .count.err { background: var(--danger-bg); color: var(--danger); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card.flat { box-shadow: none; }
.grid { display: grid; gap: 14px; }
.grid.cols2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.tiles { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); }
@media (max-width: 1150px) { .grid.cols2, .grid.cols3 { grid-template-columns: 1fr; } }

.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .k { font-size: 12px; color: var(--muted); }
.tile .v { font-size: 21px; font-weight: 700; margin-top: 2px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.tile .v.neg { color: var(--danger); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line-strong); background: var(--panel); padding: 7px 13px; border-radius: 8px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 2px 8px rgba(123,108,240,.25); }
.btn.primary:hover { filter: brightness(.96); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: var(--panel); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--hover); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.iconbtn { border: 0; background: transparent; cursor: pointer; padding: 3px 6px; border-radius: 6px; color: var(--faint); font-size: 14px; line-height: 1; }
.iconbtn:hover { background: var(--hover); color: var(--ink); }
.iconbtn.del:hover { color: var(--danger); }

.note { border-radius: var(--radius); padding: 11px 14px; border: 1px solid transparent; }
.note.info { background: var(--info-bg); color: var(--info); }
.note.warn { background: var(--warn-bg); color: var(--warn); }
.note.err { background: var(--danger-bg); color: var(--danger); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.plain { background: var(--panel); border-color: var(--line); }
.note b { font-weight: 650; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--hover); color: var(--muted); font-weight: 600; white-space: nowrap; }
.pill.err { background: var(--danger-bg); color: var(--danger); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.ok { background: var(--ok-bg); color: var(--ok); }

/* form fields */
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > span { font-size: 12px; color: var(--muted); font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--faint); }
.in, .sel, textarea.in { border: 1px solid var(--line-strong); background: var(--input); border-radius: 7px; padding: 6px 8px; min-width: 0; width: 100%; }
textarea.in { resize: vertical; min-height: 70px; }
.in.num { text-align: right; font-variant-numeric: tabular-nums; }
.in.bad, .sel.bad { border-color: var(--danger) !important; background: var(--danger-bg); }
.in.warnf { border-color: #D9A400; background: var(--warn-bg); }
.formgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.radios { display: flex; gap: 8px; flex-wrap: wrap; }
.radio { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line-strong); border-radius: 9px; padding: 9px 12px; cursor: pointer; background: var(--panel); max-width: 330px; }
.radio.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(123,108,240,.18); background: var(--accent-soft); }
.radio small { display: block; color: var(--muted); }

/* tables */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.t { border-collapse: separate; border-spacing: 0; width: 100%; }
table.t th { text-align: left; font-size: 11.5px; font-weight: 650; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; white-space: nowrap; }
table.t th.r, table.t td.r { text-align: right; }
table.t td { padding: 3px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:last-child td { border-bottom: 0; }
table.t td .in, table.t td .sel { border-color: transparent; background: transparent; padding: 5px 6px; border-radius: 6px; }
table.t td .in:hover, table.t td .sel:hover { border-color: var(--line-strong); }
table.t td .in.bad { border-color: var(--danger); background: var(--danger-bg); }
table.t td .in.warnf { border-color: #D9A400; background: var(--warn-bg); }
table.t td.calc { padding: 5px 8px; text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.t td.calc.needs { color: var(--danger); font-weight: 600; font-size: 12px; }
table.t tr.hl td { background: var(--hl); }
table.t tr.flagged td:first-child { box-shadow: inset 3px 0 0 #F2B33D; }
table.t tfoot td { font-weight: 700; padding: 8px; border-top: 1px solid var(--line-strong); border-bottom: 0; }
table.t td.actions { white-space: nowrap; text-align: right; width: 1%; }
table.t td.tight { width: 1%; }
.addrow { display: flex; gap: 8px; align-items: center; padding: 10px 0 0; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.search { max-width: 260px; }
.badge-receipt { font-size: 11px; color: var(--ok); font-weight: 700; }

/* summary */
table.sum { width: 100%; border-collapse: collapse; }
table.sum td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.sum td.line { color: var(--faint); font-size: 12px; width: 80px; white-space: nowrap; }
table.sum td.amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; width: 140px; }
table.sum tr.strong td { font-weight: 700; }
table.sum tr.muted td { color: var(--muted); }
table.sum tr.indent td.lbl { padding-left: 18px; }
table.sum td.missing { color: var(--faint); font-style: italic; }
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; padding: 9px 4px; border-bottom: 1px solid var(--line); }
.checklist li:last-child { border-bottom: 0; }
.checklist li.click { cursor: pointer; }
.checklist li.click:hover { background: var(--hover); }
.checklist .lvl { flex: none; margin-top: 1px; }
.cmp td.diff { color: var(--warn); font-weight: 600; }

/* year cards */
.yearcard { cursor: pointer; transition: transform .12s ease, box-shadow .12s ease; }
.yearcard:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,.06), 0 10px 24px rgba(0,0,0,.08); }
.yearcard .big { font-size: 30px; font-weight: 800; letter-spacing: -.6px; }
.steps { counter-reset: s; list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.steps li { counter-increment: s; display: flex; gap: 12px; }
.steps li::before { content: counter(s); flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-weight: 800; display: grid; place-items: center; font-size: 12.5px; }

/* drawer and modal */
.scrim { position: fixed; inset: 0; background: rgba(46,38,80,.28); z-index: 50; display: flex; justify-content: flex-end; }
.scrim.center { justify-content: center; align-items: flex-start; padding-top: 6vh; }
.drawer { width: min(620px, 92vw); height: 100%; background: var(--panel); overflow-y: auto; padding: 22px 24px 40px; box-shadow: -10px 0 30px rgba(0,0,0,.15); }
.modal { width: min(900px, 94vw); max-height: 88vh; overflow-y: auto; background: var(--panel); border-radius: 14px; padding: 22px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.drawer h2, .modal h2 { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.files { list-style: none; padding: 0; margin: 6px 0; }
.files li { display: flex; gap: 8px; align-items: center; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #2E2650; color: #fff; padding: 10px 14px; border-radius: 10px; display: flex; gap: 14px; align-items: center; z-index: 80; box-shadow: 0 10px 30px rgba(0,0,0,.25); }
.toast button { background: var(--butter); color: #2A2442; border: 0; border-radius: 6px; padding: 4px 10px; font-weight: 700; cursor: pointer; }
.linkish { background: none; border: 0; padding: 0; color: inherit; text-decoration: underline; cursor: pointer; }
.kbd { font: 12px ui-monospace, Menlo, monospace; background: var(--hover); padding: 1px 5px; border-radius: 4px; }
.empty { padding: 26px; text-align: center; color: var(--muted); }
.card.hl { box-shadow: 0 0 0 3px var(--butter); }
table.t { font-size: 13px; }
table.t input[type=date].in { width: 128px; padding-right: 2px; }
table.t td { padding: 2px 2px; }
.rates table.t { table-layout: fixed; }
.rates table.t td .in { border-color: var(--line-strong); background: var(--input); }
.rates table.t th:nth-child(1) { width: 42%; } .rates table.t th:nth-child(2) { width: 22%; } .rates table.t th:nth-child(3) { width: 9%; text-align: center; }
table.t td .in, table.t td .sel { border-color: var(--line); }

/* pastel tiles */
.grid.tiles > .tile:nth-child(6n+1) { background: var(--t-lav); border-color: transparent; }
.grid.tiles > .tile:nth-child(6n+2) { background: var(--t-mint); border-color: transparent; }
.grid.tiles > .tile:nth-child(6n+3) { background: var(--t-sky); border-color: transparent; }
.grid.tiles > .tile:nth-child(6n+4) { background: var(--t-peach); border-color: transparent; }
.grid.tiles > .tile:nth-child(6n+5) { background: var(--t-butter); border-color: transparent; }
.grid.tiles > .tile:nth-child(6n+6) { background: var(--t-pink); border-color: transparent; }
.yearcard { border-top: 5px solid var(--accent); }
.tablewrap { box-shadow: var(--shadow); }
table.t th { background: #FBFAFE; }

/* Tally the mascot (same motion as the hub mascot family) */
.rb-slot { display: inline-block; flex: none; line-height: 0; cursor: pointer; }
.rb-slot svg { width: 100%; height: auto; display: block; overflow: visible; }
.rb-m .m-eyes { animation: m-look 7.5s ease-in-out infinite; }
.rb-m .m-eye { transform-box: fill-box; transform-origin: center; animation: m-blink 4.2s infinite; transition: opacity .15s; }
.rb-m .m-happy { transition: opacity .15s; }
.rb-m .m-fig { transform-box: fill-box; transform-origin: 50% 100%; animation: m-bob 2.8s ease-in-out infinite; }
.rb-m .m-shadow { transform-box: fill-box; transform-origin: center; animation: m-shadow 2.8s ease-in-out infinite; }
.rb-m:hover .m-eye, .rb-m.rb-joy .m-eye { opacity: 0; }
.rb-m:hover .m-happy, .rb-m.rb-joy .m-happy { opacity: 1; }
.rb-m:hover .m-fig, .rb-m.rb-hop .m-fig { animation: m-hop .75s ease-out 1, m-bob 2.8s ease-in-out .75s infinite; }
@keyframes m-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3%); } }
@keyframes m-shadow { 0%,100% { transform: scaleX(1); opacity: 1; } 50% { transform: scaleX(.88); opacity: .7; } }
@keyframes m-blink { 0%,93%,100% { transform: scaleY(1); } 95.5% { transform: scaleY(.1); } }
@keyframes m-look { 0%,30% { transform: translateX(0); } 38%,58% { transform: translateX(2.4px); } 66%,80% { transform: translateX(-2px); } 88%,100% { transform: translateX(0); } }
@keyframes m-hop { 0% { transform: translateY(0) rotate(0); } 22% { transform: translateY(-14%) rotate(-6deg); } 44% { transform: translateY(0) rotate(5deg); } 62% { transform: translateY(-7%) rotate(-3deg); } 80% { transform: translateY(0) rotate(1deg); } 100% { transform: translateY(0) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .rb-m * { animation: none !important; transition: none !important; } }
.hero { display: flex; gap: 22px; align-items: center; background: linear-gradient(120deg, #F0ECFF 0%, #FDEBF2 55%, #FFF7DA 100%); border-radius: 20px; padding: 22px 28px; }
.hero h1 { font-size: 28px; }
.bubble { position: relative; background: #fff; border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); max-width: 560px; }
.bubble::before { content: ""; position: absolute; left: -8px; top: 22px; border: 8px solid transparent; border-left: 0; border-right-color: #fff; }
.mascot-line { display: flex; gap: 14px; align-items: center; }

.progress { height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; margin-top: 6px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, #9C8FF5, #7B6CF0); border-radius: 99px; transition: width .3s ease; }
table.t tr.drop td { background: var(--accent-soft); }
.dropzone { border-radius: 10px; padding: 4px; }
.dropzone.drop { outline: 2px dashed var(--accent); background: var(--accent-soft); }
table.t td.calc.neg { color: var(--danger); }
table.t td.calc.pos { color: var(--ok); }
.card.plan.done { background: var(--t-mint); border-color: transparent; }
.suggest { max-width: 330px; display: flex; gap: 6px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--info); background: var(--info-bg); border-radius: 7px; padding: 3px 4px 3px 8px; }
.suggest span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .btn { padding: 2px 8px; font-size: 11.5px; }
.note .rb-slot { vertical-align: middle; }
.sidesearch { margin: 2px 0 8px; background: #fff; border-color: var(--line-strong); }
.legend { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-left: 8px; }
.chart { margin-top: 8px; }

/* receipt inbox */
.navcount { font-size: 11px; font-weight: 700; background: var(--accent); color: #fff; border-radius: 9px; padding: 0 7px; line-height: 18px; }
.inbox-drop { border: 2px dashed var(--line-strong); border-radius: 18px; background: var(--panel); padding: 18px; text-align: center; cursor: pointer; transition: background .12s ease, border-color .12s ease; }
.inbox-drop:hover { border-color: var(--accent); background: #FCFBFF; }
.inbox-drop.big { padding: 34px 20px 30px; background: linear-gradient(180deg, #FFFFFF 0%, var(--t-lav) 100%); }
.inbox-drop.drop { border-color: var(--accent); background: var(--accent-soft); }
.inbox-drop-text { font-weight: 650; color: var(--accent); margin-top: 10px; }
.inbox-drop.big .inbox-drop-text { font-size: 16px; margin-top: 16px; }
.rcards { display: grid; gap: 14px; }
.rcard { display: grid; grid-template-columns: 116px minmax(0, 1fr); gap: 18px; align-items: start; }
.rcard.clear { box-shadow: var(--shadow), inset 4px 0 0 #7FD3AE; }
.rcard.done { opacity: .92; }
.rcard.done .rthumb { width: 116px; height: 96px; }
.rthumb { width: 116px; height: 150px; border: 1px solid var(--line); border-radius: 10px; background: #FBFAFE; overflow: hidden; padding: 0; cursor: pointer; display: grid; place-items: center; }
.rthumb img { width: 100%; height: 100%; object-fit: cover; object-position: top; display: block; }
.rthumb:hover { border-color: var(--accent); }
.fileicon { font-size: 13px; font-weight: 800; color: var(--accent); background: var(--accent-soft); border-radius: 8px; padding: 14px 10px; letter-spacing: .04em; }
.rfields { display: grid; grid-template-columns: minmax(150px, 2fr) 150px repeat(3, minmax(80px, 1fr)) 90px; gap: 10px; margin-top: 10px; }
@media (max-width: 1250px) { .rfields { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.rnotes { margin-top: 8px; }
.rcard details { margin-top: 6px; }
.rcard summary { cursor: pointer; }
.ocrtext { white-space: pre-wrap; font: 11.5px/1.45 ui-monospace, Menlo, monospace; background: #FBFAFE; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow: auto; margin: 6px 0 0; }
.rmatches { margin-top: 12px; display: grid; gap: 6px; }
.rmatch { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #FCFBFF; }
.rmatch.clear { background: var(--ok-bg); border-color: transparent; }
