/* =========================================================================
   Athwise Finance Portal — "the office register"
   Ledger paper, blue-black ink, a red margin rule, rubber stamps.
   Orange belongs to Athwise and is used only for actions.
   ========================================================================= */

/* ---------- Fonts (self-hosted, SIL Open Font License) ---------- */
@font-face { font-family: 'Young Serif'; src: url('../fonts/young-serif-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Public Sans'; src: url('../fonts/public-sans-latin-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Public Sans'; src: url('../fonts/public-sans-latin-ext-wght-normal.woff2') format('woff2'); font-weight: 100 900; font-display: swap;
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: 'Kalam'; src: url('../fonts/kalam-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Kalam'; src: url('../fonts/kalam-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
    --paper: #E7EAE3;          /* the desk the register sits on */
    --sheet: #FBFCF8;          /* a page */
    --sheet-2: #F2F4EF;
    --ink: #1E2A38;            /* blue-black fountain-pen ink */
    --ink-2: #3E4B5A;
    --muted: #677380;
    --faint: #9AA3AC;
    --rule: #D6DEE4;           /* blue ledger rule */
    --rule-strong: #B7C3CD;
    --margin: #CF5546;         /* red margin line */
    --red-pen: #C0392B;
    --brand: #E8631B;
    --brand-strong: #C9510F;
    --brand-tint: #FCEEE5;
    --hl: #F6E37C;             /* highlighter */
    --good: #2D7548;  --good-soft: #E1EEE5;
    --warn: #9C640A;  --warn-soft: #FAF0D8;
    --bad: #B3302A;   --bad-soft: #F7E1DE;
    --info: #2A5A9A;  --info-soft: #E2EBF5;
    --chalk-bg: #24312B;
    --serif: 'Young Serif', Georgia, 'Times New Roman', serif;
    --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --hand: 'Kalam', 'Segoe Print', 'Comic Sans MS', cursive;
    --ease: cubic-bezier(.2, .7, .2, 1);
    --sidebar-w: 248px;
    /* aliases kept for older markup */
    --surface: var(--sheet); --surface-2: var(--sheet-2); --line: var(--rule); --line-strong: var(--rule-strong);
    color-scheme: light only;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper); -webkit-font-smoothing: antialiased; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: var(--brand-strong); text-underline-offset: 3px; }
code { font-size: .85em; background: var(--sheet-2); border: 1px solid var(--rule); padding: 1px 5px; border-radius: 3px; }
mark { color: inherit; background: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num, .amt, td.r, .statement dd { font-variant-numeric: tabular-nums lining-nums; }
.mobile-only { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.pad { padding: 18px 2px; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }
::selection { background: var(--hl); color: var(--ink); }

.logo-chip { display: inline-flex; }
.logo-chip img { height: 40px; width: auto; }

/* ---------- Handwriting: used only for short margin notes ---------- */
.hand, .hand-note, .hand-greet, .margin-note { font-family: var(--hand); font-weight: 400; }
.hand-note { color: var(--muted); font-size: 15px; }
.hand-greet { color: var(--muted); font-size: 18px; line-height: 1.2; }
.margin-note { color: var(--red-pen); font-size: 18px; line-height: 1.3; margin-top: 10px; display: inline-flex; align-items: baseline; gap: 6px; transform: rotate(-1.2deg); transform-origin: left; }
.margin-note .arrow { font-family: var(--sans); font-size: 16px; }
.margin-note .pct { color: var(--muted); }
.margin-note.down { color: var(--good); }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 15px; border-radius: 6px; font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; position: relative; text-decoration: none; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
.btn-primary:hover { background: var(--brand-strong); }
.btn-primary:active { box-shadow: inset 0 1px 0 rgba(0, 0, 0, .2); transform: translateY(1px); }
.btn-ghost { background: var(--sheet); color: var(--ink); border: 1px solid var(--rule-strong); }
.btn-ghost:hover { border-color: var(--ink-2); }
.btn-quiet { color: var(--muted); padding: 0 8px; }
.btn-quiet:hover { color: var(--ink); text-decoration: underline; }
.btn-success { background: var(--good); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
.btn-danger { background: var(--bad); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18); }
.btn-block { width: 100%; }
.btn-lg { height: 46px; font-size: 15px; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; }
.btn-spinner { display: none; width: 15px; height: 15px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn.loading .btn-spinner { display: inline-block; }
.btn.loading { pointer-events: none; opacity: .85; }
.danger-ghost { color: var(--bad); }
.icon-btn { width: 34px; height: 34px; border-radius: 6px; display: inline-grid; place-items: center; color: var(--muted); transition: background .15s, color .15s; }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn:hover { background: var(--sheet-2); color: var(--ink); }
.icon-btn-brand { background: var(--brand); color: #fff; }
.icon-btn-brand:hover { background: var(--brand-strong); color: #fff; }
.link-btn { color: var(--brand-strong); font-weight: 600; font-size: 13px; text-decoration: none; }
.link-btn:hover { text-decoration: underline; }
.link-btn.danger { color: var(--bad); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Fields ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .field textarea, .input-icon, .input-prefix {
    width: 100%; min-height: 40px; border-radius: 5px; border: 1px solid var(--rule-strong); background: var(--sheet); padding: 8px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input-icon:focus-within, .input-prefix:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.input-icon, .input-prefix { display: flex; align-items: center; gap: 9px; padding: 0 11px; }
.input-icon > svg { width: 17px; height: 17px; color: var(--faint); flex: none; }
.input-icon input, .input-prefix input { border: 0; box-shadow: none !important; padding: 0; min-height: 38px; background: transparent; flex: 1; min-width: 0; width: 100%; outline: none; }
.input-prefix b { color: var(--muted); font-weight: 500; }
.input-action { color: var(--faint); display: grid; place-items: center; }
.input-action:hover { color: var(--ink); }
.input-action svg { width: 17px; height: 17px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.form-error { background: var(--bad-soft); color: var(--bad); padding: 9px 12px; border-radius: 0 5px 5px 0; font-size: 13.5px; font-weight: 500; border-left: 3px solid var(--bad); }
.form-error.warn { background: var(--warn-soft); color: var(--warn); border-left-color: var(--warn); }
.caps-warning { color: var(--warn); font-size: 12.5px; display: flex; gap: 5px; align-items: center; font-weight: 600; }
.caps-warning svg { width: 14px; height: 14px; }
.segmented { display: flex; border: 1px solid var(--rule-strong); border-radius: 5px; overflow: hidden; min-height: 40px; }
.segmented button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 13.5px; font-weight: 600; color: var(--muted); background: var(--sheet); padding: 0 12px; }
.segmented button + button { border-left: 1px solid var(--rule-strong); }
.segmented button svg { width: 15px; height: 15px; }
.segmented button.active { background: var(--ink); color: var(--sheet); }
.switch-row { display: flex; gap: 12px; align-items: center; cursor: pointer; padding: 10px 0 2px; border-top: 1px solid var(--rule); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch-row strong { display: block; font-size: 14px; }
.switch-row small { display: block; font-size: 12.5px; }
.switch { width: 38px; height: 22px; border-radius: 99px; background: var(--rule-strong); position: relative; flex: none; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch-row input:checked + .switch { background: var(--ink); }
.switch-row input:checked + .switch::after { transform: translateX(16px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }
.range { width: 100%; accent-color: var(--brand); }

/* ---------- Rubber stamps (status) ---------- */
.stamp {
    display: inline-block; font: 700 10.5px/1 var(--sans); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
    padding: 4px 6px 3px; border: 1.7px solid currentColor; border-radius: 3px; transform: rotate(-3deg); opacity: .9;
    -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='24'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.9'/%3E%3C/filter%3E%3Crect width='60' height='24' filter='url(%23n)'/%3E%3C/svg%3E");
    mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='60' height='24'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -2.2 1.9'/%3E%3C/filter%3E%3Crect width='60' height='24' filter='url(%23n)'/%3E%3C/svg%3E");
}
.stamp.paid { color: var(--good); }
.stamp.due { color: var(--info); transform: rotate(2deg); }
.stamp.overdue { color: var(--bad); transform: rotate(-4deg); }
.stamp.cancelled { color: var(--faint); text-decoration: line-through; }
.stamp.small { font-size: 9.5px; padding: 3px 5px 2px; vertical-align: 3px; }
.stamp.thunk { animation: thunk .5s var(--ease) both; }
@keyframes thunk { 0% { transform: scale(2.4) rotate(-12deg); opacity: 0; } 60% { transform: scale(.92) rotate(-2deg); opacity: 1; } 100% { transform: scale(1) rotate(-3deg); opacity: .9; } }

.swatch { display: inline-block; width: 9px; height: 9px; border-radius: 2px; background: var(--c, var(--ink)); flex: none; margin-right: 9px; vertical-align: 1px; }
.delta { font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.delta.up { color: var(--bad); }
.delta.down { color: var(--good); }
.delta.new { color: var(--info); }
.dbl { border-bottom: 3px double currentColor; padding-bottom: 1px; }
.pencil-bar { height: 5px; background: var(--rule); border-radius: 3px; overflow: hidden; max-width: 340px; margin-top: 10px; }
.pencil-bar span { display: block; height: 100%; background: var(--c, var(--ink)); border-radius: 3px; }
.pencil-bar.near span { background: var(--warn); }
.pencil-bar.over span { background: var(--bad); }

/* ---------- Boot ---------- */
.boot { position: fixed; inset: 0; background: var(--paper); display: grid; place-items: center; z-index: 9999; transition: opacity .3s; }
.boot.out { opacity: 0; pointer-events: none; }

/* =========================================================================
   LOGIN
   ========================================================================= */
.login { position: fixed; inset: 0; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); background: var(--sheet); z-index: 50; }
.login-art {
    background-color: var(--paper);
    background-image: linear-gradient(90deg, transparent 52px, var(--margin) 52px, var(--margin) 53.5px, transparent 53.5px, transparent 57px, var(--margin) 57px, var(--margin) 58.5px, transparent 58.5px),
                      repeating-linear-gradient(180deg, transparent 0 31px, color-mix(in srgb, var(--info) 18%, transparent) 31px 32px);
    display: flex; align-items: center; padding: 48px 56px 48px 96px; border-right: 1px solid var(--rule-strong); overflow: hidden;
}
.login-art-inner { max-width: 520px; }
.login-headline { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 4.4vw, 62px); line-height: 1.02; letter-spacing: -.01em; margin: 30px 0 14px; }
.login-sub { color: var(--ink-2); font-size: 16.5px; max-width: 42ch; }
.login-illustration { width: min(400px, 100%); margin: 28px 0 0 -10px; }
.login-hand { font-family: var(--hand); color: var(--red-pen); font-size: 20px; transform: rotate(-2deg); margin-top: 6px; }
.login-panel { display: grid; place-items: center; padding: 40px 24px; min-width: 0; }
.login-form { width: min(380px, 100%); display: flex; flex-direction: column; gap: 16px; }
.login-form h2 { font-family: var(--serif); font-weight: 400; font-size: 32px; line-height: 1.1; }
.login-form > p.muted { margin-top: -8px; }
.login-foot { font-size: 13px; }
.login-form.shake { animation: shake .4s; }
.login-form.step-in { animation: stepIn .35s var(--ease) both; }
@keyframes shake { 20%, 60% { transform: translateX(-7px); } 40%, 80% { transform: translateX(7px); } }
@keyframes stepIn { from { opacity: 0; transform: translateX(18px); } }

/* Telegram code step */
.otp-badge { width: 54px; height: 54px; border-radius: 50%; background: #229ED9; color: #fff; display: grid; place-items: center; position: relative; }
.otp-badge svg { width: 24px; height: 24px; transform: translate(-1px, 1px); }
.otp-ring { position: absolute; inset: -5px; border-radius: 50%; border: 2px solid #229ED9; opacity: 0; animation: ring 2.4s ease-out infinite; }
@keyframes ring { 0% { transform: scale(.92); opacity: .7; } 100% { transform: scale(1.3); opacity: 0; } }
.otp-boxes { display: flex; gap: 7px; align-items: center; }
.otp-boxes input { flex: 1; min-width: 0; width: 100%; height: 56px; text-align: center; font-family: var(--serif); font-size: 26px; border: 1px solid var(--rule-strong); border-bottom: 2px solid var(--ink-2); border-radius: 4px; background: var(--sheet); outline: none; caret-color: var(--brand); transition: border-color .15s, box-shadow .15s; }
.otp-boxes input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.otp-boxes.error input { border-color: var(--bad); animation: shake .35s; }
.otp-boxes.ok input { border-color: var(--good); color: var(--good); background: var(--good-soft); }
.otp-gap { width: 10px; height: 2px; background: var(--rule-strong); flex: none; }
.otp-timer { display: grid; gap: 5px; }
.otp-timer-bar { height: 3px; background: var(--rule); overflow: hidden; }
.otp-timer-bar span { display: block; height: 100%; width: 100%; background: #229ED9; transform-origin: left; transition: transform 1s linear; }
.otp-timer-bar span.low { background: var(--bad); }
.otp-links { display: flex; justify-content: space-between; align-items: center; }
.otp-links .link-btn { display: inline-flex; align-items: center; gap: 4px; }
.otp-links .link-btn svg { width: 15px; height: 15px; }
.otp-links .link-btn:disabled { color: var(--faint); cursor: default; text-decoration: none; }
.tg-status { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 13.5px; }
.tg-status svg { width: 16px; height: 16px; }
.tg-status.on { color: var(--good); }
.tg-status.off { color: var(--warn); }

/* =========================================================================
   SHELL — the sidebar is the thumb-index of the register
   ========================================================================= */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--sidebar-w); flex: none; background: var(--paper); display: flex; flex-direction: column; z-index: 30; border-right: 1px solid var(--rule-strong); transition: width .25s var(--ease), transform .25s var(--ease); }
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 16px 12px 10px 16px; gap: 8px; }
.nav { flex: 1; overflow-y: auto; padding: 4px 0 16px 10px; scrollbar-width: thin; }
.nav-group { margin-top: 16px; }
.nav-group:first-child { margin-top: 4px; }
.nav-group-title { font-family: var(--serif); font-size: 13.5px; color: var(--muted); padding: 0 10px 5px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 6px 18px 6px 10px; border-radius: 5px 0 0 5px; color: var(--ink-2); font-size: 14px; text-decoration: none; transition: background .12s, color .12s; }
.nav-item svg { width: 17px; height: 17px; color: var(--muted); flex: none; }
.nav-item .nav-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-amt { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.nav-item .nav-pill { font-size: 11px; font-weight: 700; color: #fff; background: var(--red-pen); border-radius: 99px; padding: 0 6px; line-height: 18px; }
.nav-item:hover { background: color-mix(in srgb, var(--sheet) 60%, transparent); color: var(--ink); }
.nav-item.active { background: var(--sheet); color: var(--ink); font-weight: 600; box-shadow: 0 1px 0 var(--rule-strong), 0 -1px 0 var(--rule-strong); margin-right: -1px; }
.nav-item.active svg { color: var(--brand); }
.nav-item .nav-tab { position: absolute; right: 0; top: 8px; bottom: 8px; width: 5px; background: var(--c); border-radius: 2px 0 0 2px; transition: width .15s var(--ease); }
.nav-item.tabbed:hover .nav-tab { width: 8px; }
.nav-item.tabbed.active .nav-tab { width: 4px; right: auto; left: 0; top: 0; bottom: 0; border-radius: 5px 0 0 5px; }
.sidebar-foot { border-top: 1px solid var(--rule-strong); padding: 10px 12px 10px 14px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who-avatar { width: 40px; height: 40px; flex: none; object-fit: contain; background: #fff; border: 1px solid var(--rule-strong); border-radius: 8px; padding: 2px; }
.who-text { min-width: 0; }
.who-text strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who-text small { color: var(--muted); font-size: 12px; }

.app.collapsed { --sidebar-w: 64px; }
.app.collapsed .nav-label, .app.collapsed .nav-amt, .app.collapsed .nav-pill, .app.collapsed .nav-group-title, .app.collapsed .who-text, .app.collapsed .sidebar-brand .logo-chip { display: none; }
.app.collapsed .sidebar-brand { justify-content: center; }
.app.collapsed .nav-item { justify-content: center; padding: 6px 0; min-height: 34px; }
.app.collapsed .nav-item.tabbed::before { content: ''; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.app.collapsed .sidebar-foot { flex-direction: column; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; background: var(--paper); }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 28px; border-bottom: 1px solid var(--rule-strong); background: var(--paper); position: relative; z-index: 20; }
.topbar-title { min-width: 0; flex: 1; }
.topbar-title h1 { font-family: var(--serif); font-weight: 400; font-size: 21px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title p { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 8px 0 11px; border: 1px solid var(--rule-strong); border-radius: 6px; background: var(--sheet); width: 250px; }
.search:focus-within { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent); }
.search svg { width: 16px; height: 16px; color: var(--faint); flex: none; }
.search input { border: 0; outline: 0; background: transparent; flex: 1; min-width: 0; font-size: 14px; }
.search kbd { font-family: inherit; font-size: 11px; color: var(--faint); border: 1px solid var(--rule-strong); border-radius: 3px; padding: 0 5px; }
.period { position: relative; }
.period-btn .chev { width: 14px; height: 14px; color: var(--faint); }
.period-menu { position: absolute; right: 0; top: calc(100% + 6px); width: 250px; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: 0 18px 40px -18px rgba(20, 28, 38, .45); padding: 5px; z-index: 40; }
.period-menu button.opt { width: 100%; text-align: left; padding: 8px 10px; border-radius: 4px; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.period-menu button.opt:hover { background: var(--sheet-2); }
.period-menu button.opt.active { font-weight: 700; }
.period-menu button.opt svg { width: 15px; height: 15px; color: var(--brand); }
.period-custom { border-top: 1px solid var(--rule); margin-top: 5px; padding: 9px 5px 3px; display: grid; gap: 7px; }
.period-custom .row { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.period-custom input { height: 34px; border: 1px solid var(--rule-strong); border-radius: 4px; padding: 0 7px; background: var(--sheet); font-size: 13px; width: 100%; }

.view { flex: 1; overflow-y: auto; padding: 24px 28px 110px; outline: none; }
.view > * + * { margin-top: 20px; }
.view-enter { animation: pageIn .2s ease-out both; }
@keyframes pageIn { from { opacity: 0; } }

/* =========================================================================
   SHEETS & HEADERS
   ========================================================================= */
.sheet, .panel { background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 18px 22px 20px; box-shadow: 0 1px 0 rgba(30, 42, 56, .05); }
.sheet-title, .panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1.5px solid var(--ink); }
.sheet-title h3, .panel-head h3 { font-family: var(--serif); font-weight: 400; font-size: 19px; line-height: 1.2; }
.sheet-title > .muted, .panel-head p { font-size: 13px; }
.sheet-title.bare { border-bottom: 0; padding-bottom: 6px; }
.panel-body { padding-top: 12px; }

/* Ruled page header with the red margin — the signature of every main page */
.sheet-head, .sec-head {
    display: grid; grid-template-columns: minmax(0, 1fr) 230px; gap: 28px; align-items: center;
    background-color: var(--sheet);
    background-image: linear-gradient(90deg, transparent 30px, var(--margin) 30px, var(--margin) 31.5px, transparent 31.5px, transparent 35px, var(--margin) 35px, var(--margin) 36.5px, transparent 36.5px),
                      repeating-linear-gradient(180deg, transparent 0 29px, color-mix(in srgb, var(--info) 14%, transparent) 29px 30px);
    border: 1px solid var(--rule-strong); border-radius: 4px; padding: 24px 28px 24px 62px; position: relative;
}
.crumb { font-size: 13px; color: var(--muted); }
.sh-title { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 3vw, 38px); line-height: 1.08; letter-spacing: -.005em; margin: 2px 0 6px; }
.sh-desc { color: var(--ink-2); max-width: 64ch; font-size: 14.5px; }
.sh-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }

.statement { display: flex; flex-wrap: wrap; gap: 6px 34px; margin-top: 16px; align-items: flex-end; }
.statement > div { min-width: 0; }
.statement dt { font-size: 12.5px; color: var(--muted); }
.statement dd { font-size: 18px; font-weight: 600; white-space: nowrap; }
.statement .lead dd { font-size: 30px; font-weight: 700; letter-spacing: -.01em; line-height: 1.15; }
.statement mark { background: linear-gradient(100deg, transparent 2%, var(--hl) 3%, var(--hl) 97%, transparent 98%) 0 72% / 100% 46% no-repeat; padding: 0 4px; margin: 0 -4px; }
.statement.compact { gap: 6px 28px; margin: 12px 0 14px; }
.statement.compact dd { font-size: 17px; }

.art { margin: 0; justify-self: end; width: 100%; max-width: 230px; position: relative; }
.art img { width: 100%; height: auto; }
.art.is-photo img { aspect-ratio: 5 / 4; object-fit: cover; background: #fff; padding: 8px 8px 26px; border: 1px solid var(--rule); box-shadow: 0 10px 22px -12px rgba(20, 28, 38, .5); transform: rotate(2deg); }
.art.is-photo::before { content: ''; position: absolute; z-index: 1; top: -9px; left: 50%; width: 76px; height: 20px; margin-left: -38px; background: rgba(246, 227, 124, .65); transform: rotate(-4deg); }

/* =========================================================================
   DASHBOARD
   ========================================================================= */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.dash-cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.dash-side { display: grid; gap: 20px; }

/* Ledger table: the section split */
.ledger { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.ledger th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 10px 8px 6px; border-bottom: 1px solid var(--rule-strong); }
.ledger td { padding: 9px 8px; border-bottom: 1px solid var(--rule); }
.ledger .r, .ledger th.r { text-align: right; }
.ledger td.nil { color: var(--faint); }
.ledger tbody tr.link-row { cursor: pointer; }
.ledger tbody tr.link-row:hover td { background: color-mix(in srgb, var(--hl) 28%, transparent); }
.ledger tfoot td { border-bottom: 0; border-top: 1.5px solid var(--ink); font-weight: 700; padding-top: 11px; }
.ledger .share { width: 150px; white-space: nowrap; }
.ledger .share small { color: var(--muted); font-size: 12px; margin-left: 8px; }
.share-bar { display: inline-block; width: 92px; height: 6px; background: var(--rule); vertical-align: 1px; }
.share-bar span { display: block; height: 100%; background: var(--c); }
.share-h { width: 150px; }

/* Due-soon chits: little paper slips */
.chits { display: grid; gap: 8px; margin: 4px 0 10px; }
.chit { display: grid; grid-template-columns: 50px minmax(0, 1fr) auto; gap: 12px; align-items: center; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 2px; padding: 9px 12px 9px 0; box-shadow: 0 1px 0 rgba(30, 42, 56, .06); }
.chit:nth-child(odd) { transform: rotate(-.35deg); }
.chit:nth-child(even) { transform: rotate(.3deg); }
.chit-date { text-align: center; line-height: 1; border-right: 1.5px dashed var(--rule-strong); padding: 3px 0; }
.chit-date b { display: block; font-family: var(--serif); font-weight: 400; font-size: 22px; }
.chit-date small { font-size: 11.5px; color: var(--muted); }
.chit.soon .chit-date b { color: var(--warn); }
.chit.late .chit-date b { color: var(--bad); }
.chit.late { border-color: color-mix(in srgb, var(--bad) 45%, var(--rule-strong)); }
.chit-main { min-width: 0; }
.chit-main strong { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chit-main small { color: var(--muted); font-size: 12.5px; }
.chit-end { text-align: right; display: grid; gap: 1px; justify-items: end; }
.chit-end b { font-size: 14px; }
.chit.done { grid-template-columns: 1fr; padding: 12px 14px; }
.chit.done .hand { color: var(--good); font-size: 17px; }

.fixed-mini { cursor: pointer; }
.fixed-mini:hover { border-color: var(--ink-2); }
.fixed-mini h3 { font-family: var(--serif); font-weight: 400; font-size: 18px; }
.fm-amt { font-size: 24px; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.fm-amt small { font-size: 13px; font-weight: 500; color: var(--muted); }
.fixed-mini .muted { font-size: 13px; }
.dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.dots span { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--ink-2); }
.dots span.on { background: var(--ink-2); }

.seg-mini { display: flex; gap: 2px; }
.seg-mini button { font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 3px; color: var(--muted); }
.seg-mini button.active { background: var(--ink); color: var(--sheet); }
.chart-box { position: relative; height: 280px; margin-top: 12px; }

/* Dotted-leader lists (payees, sub-categories) */
.leaders { list-style: none; display: grid; margin-top: 4px; }
.leaders li { display: flex; align-items: baseline; padding: 8px 2px; cursor: pointer; }
.leaders li:hover .l-name { color: var(--brand-strong); }
.l-name { display: inline-flex; align-items: baseline; min-width: 0; font-size: 14.5px; }
.l-name small { color: var(--faint); font-size: 12px; margin-left: 8px; white-space: nowrap; }
.l-dots { flex: 1; border-bottom: 2px dotted var(--rule-strong); margin: 0 8px; transform: translateY(-4px); min-width: 20px; }
.l-amt { font-weight: 600; font-size: 14.5px; white-space: nowrap; }
.leaders li.l-total { cursor: default; border-top: 1.5px solid var(--ink); margin-top: 4px; padding-top: 10px; font-weight: 700; }
.leaders li.l-total:hover .l-name { color: inherit; }
.leaders li.l-total .l-dots { border: 0; }

/* Entry lists */
.entry-list { display: grid; }
.entry { display: grid; grid-template-columns: 62px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.entry:last-child { border-bottom: 0; }
.entry-date { font-size: 12.5px; color: var(--muted); }
.entry-main { min-width: 0; }
.entry-main strong { display: block; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-main small { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; overflow: hidden; white-space: nowrap; }
.entry-main .swatch { width: 7px; height: 7px; margin-right: 6px; }
.entry-end { display: flex; align-items: center; gap: 12px; }
.entry-end b { font-size: 14px; }

/* =========================================================================
   SECTION PAGES
   ========================================================================= */
.sec-head .crumb::after { content: ''; display: block; width: 28px; height: 3px; background: var(--c); margin-top: 6px; border-radius: 2px; }

/* Bill-style six month history */
.history { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; height: 200px; padding-top: 14px; }
.h-col { display: grid; grid-template-rows: auto 1fr auto; height: 100%; text-align: center; gap: 5px; min-height: 0; }
.h-val { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.h-bar { display: flex; align-items: flex-end; justify-content: center; border-bottom: 1.5px solid var(--ink); min-height: 0; }
.h-bar span { width: 62%; max-width: 44px; background: repeating-linear-gradient(-45deg, var(--rule-strong) 0 1.5px, transparent 1.5px 5px); border: 1px solid var(--rule-strong); border-bottom: 0; }
.h-col.current .h-bar span { background: var(--c); border-color: var(--c); }
.h-col.current .h-val { color: var(--ink); font-weight: 700; }
.h-mon { font-size: 12.5px; color: var(--muted); }
.h-col.current .h-mon { color: var(--ink); font-weight: 600; }

/* Table sheet (all transactions & section tables) */
.table-sheet { padding: 0; overflow: hidden; }
.table-sheet > .sheet-title { padding: 16px 22px 10px; margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; padding: 14px 18px 12px 22px; border-bottom: 1.5px solid var(--ink); }
.pills { display: flex; flex-wrap: wrap; gap: 4px 2px; }
.pill { height: 30px; padding: 0 10px; border-radius: 4px; font-size: 13.5px; color: var(--ink-2); display: inline-flex; align-items: center; gap: 5px; }
.pill .count { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.pill:hover { background: var(--sheet-2); }
.pill.active { background: var(--ink); color: var(--sheet); }
.pill.active .count { color: color-mix(in srgb, var(--sheet) 65%, transparent); }
.toolbar-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mini-search { height: 32px; display: flex; align-items: center; gap: 6px; border: 1px solid var(--rule-strong); border-radius: 5px; padding: 0 9px; background: var(--sheet); }
.mini-search svg { width: 15px; height: 15px; color: var(--faint); }
.mini-search input { border: 0; outline: 0; background: transparent; width: 160px; font-size: 13.5px; }
.mini-select { height: 32px; border: 1px solid var(--rule-strong); border-radius: 5px; padding: 0 26px 0 9px; background: var(--sheet); font-size: 13.5px; }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 10px 14px 8px; border-bottom: 1px solid var(--rule-strong); white-space: nowrap; user-select: none; }
.table th:first-child, .table td:first-child { padding-left: 22px; }
.table th.sortable { cursor: pointer; }
.table th.sortable:hover { color: var(--ink); }
.table th .sort-ind { display: inline-block; width: 12px; color: var(--brand-strong); }
.table th.r, .table td.r { text-align: right; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--rule); vertical-align: middle; }
.table tbody tr:hover td { background: color-mix(in srgb, var(--hl) 22%, transparent); }
.table tbody tr:hover .row-actions { opacity: 1; }
.table tfoot td { font-weight: 700; border-top: 1.5px solid var(--ink); border-bottom: 0; padding-top: 12px; padding-bottom: 12px; }
.cell-main { display: flex; align-items: baseline; min-width: 190px; }
.cell-main strong { display: block; font-weight: 600; }
.cell-main small { color: var(--muted); font-size: 12.5px; display: block; }
.muted-cell { color: var(--ink-2); font-size: 13.5px; }
.date-cell { color: var(--ink-2); white-space: nowrap; }
.amt { font-weight: 600; white-space: nowrap; }
.amt small { display: block; font-weight: 400; color: var(--faint); font-size: 11.5px; }
.row-actions { display: flex; justify-content: flex-end; opacity: .45; transition: opacity .15s; }
.row-actions .icon-btn { width: 30px; height: 30px; }
.row-actions .icon-btn svg { width: 16px; height: 16px; }
.row-actions .pay:hover { color: var(--good); }
.row-actions .del:hover { color: var(--bad); }
.row-actions .edit:hover { color: var(--brand-strong); }
.receipt-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--info); }
.receipt-link svg { width: 15px; height: 15px; }
.cycle { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; white-space: nowrap; }
.cycle svg { width: 13px; height: 13px; }
.table-foot { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding: 10px 22px 14px; font-size: 13px; color: var(--muted); }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 8px; }
.empty-img { width: 150px; margin-bottom: 2px; }
.empty strong { color: var(--ink); font-family: var(--serif); font-weight: 400; font-size: 18px; }
.empty p { max-width: 40ch; font-size: 14px; }
.skeleton { background: linear-gradient(90deg, var(--sheet-2) 25%, var(--rule) 37%, var(--sheet-2) 63%); background-size: 400% 100%; animation: shimmer 1.3s ease infinite; border-radius: 4px; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }

/* ---------- Fixed costs register ---------- */
.fixed-panel { padding-bottom: 8px; }
.fixed-panel .panel-head { align-items: flex-end; }
.fixed-summary { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; margin-top: 2px; }
.fixed-summary b { font-size: 22px; font-variant-numeric: tabular-nums; }
.fixed-summary .muted { font-size: 13px; }
.fixed-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fixed-progress { margin: 6px 0 2px; }
.fixed-list { display: flex; flex-direction: column; }
.fixed-row { display: grid; grid-template-columns: 14px minmax(0, 1.4fr) minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--rule); }
.fixed-row:last-child { border-bottom: 0; }
.fixed-row.paused { opacity: .5; }
.fixed-row .swatch { margin: 0; }
.fx-main strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-main small { color: var(--muted); font-size: 12.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fx-when { font-size: 13px; color: var(--ink-2); }
.fx-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fx-amt small { display: block; font-weight: 400; color: var(--faint); font-size: 11.5px; }
.fx-tools { display: flex; align-items: center; gap: 4px; }
.post-chip { font: 700 10px/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; padding: 4px 6px 3px; border: 1.5px solid currentColor; border-radius: 3px; display: inline-block; transform: rotate(-2deg); }
.post-chip.done { color: var(--good); }
.post-chip.due { color: var(--info); }
.post-chip.todo { color: var(--brand-strong); border-style: dashed; transform: none; }
.post-chip.off { color: var(--faint); border-color: transparent; text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; transform: none; padding-left: 0; }
.fixed-group-title { display: flex; align-items: center; padding: 16px 2px 6px; font-family: var(--serif); font-size: 16px; border-bottom: 1px solid var(--rule-strong); }
.fixed-group-title small { margin-left: auto; color: var(--muted); font-family: var(--sans); font-size: 13px; font-variant-numeric: tabular-nums; }
.fixed-group-title .link-btn { font-family: var(--sans); }
.fixed-empty { padding: 20px 10px 14px; }
.fixed-row.pulse { animation: rowFlash 1.4s ease; }
@keyframes rowFlash { 0%, 40% { background: color-mix(in srgb, var(--hl) 60%, transparent); } 100% { background: transparent; } }
.mini-switch { position: relative; display: inline-flex; cursor: pointer; }
.mini-switch input { position: absolute; opacity: 0; }
.mini-switch .switch { width: 32px; height: 19px; }
.mini-switch .switch::after { width: 13px; height: 13px; }
.mini-switch input:checked + .switch { background: var(--good); }
.mini-switch input:checked + .switch::after { transform: translateX(13px); }
.mini-switch input:focus-visible + .switch { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- Hospitality: the chaiwala's chalkboard ---------- */
.chai-counter { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.chai-card {
    background-color: var(--chalk-bg); color: #EEF1E8; border-radius: 6px; padding: 18px 22px 22px;
    border: 10px solid #8A5A3B; box-shadow: inset 0 0 40px rgba(0, 0, 0, .35), 0 1px 0 rgba(0, 0, 0, .1);
    background-image: radial-gradient(rgba(255,255,255,.035) 1px, transparent 1px); background-size: 5px 5px;
}
.chai-card .sheet-title h3 { font-family: var(--hand); font-weight: 700; font-size: 26px; color: #FFF8E6; }
.chai-card .hand-note { color: rgba(238, 241, 232, .6); }
.chai-card .field > span, .tally-label { font-family: var(--hand); font-size: 16px; color: rgba(238, 241, 232, .75); font-weight: 400; }
.chai-card .field input, .chai-card .input-prefix { background: transparent; color: #FFF8E6; border: 1.5px dashed rgba(238, 241, 232, .4); }
.chai-card .input-prefix b { color: rgba(238, 241, 232, .6); }
.chai-card .field input:focus, .chai-card .input-prefix:focus-within { border-color: #FFF8E6; box-shadow: none; }
.chai-card input[type="date"] { color-scheme: dark; }
.chai-card ::placeholder { color: rgba(238, 241, 232, .4); }
.tea-form { display: grid; gap: 14px; margin-top: 8px; }
.tally-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.tally-box { display: grid; gap: 6px; }
.counter { display: flex; align-items: center; height: 44px; border: 1.5px dashed rgba(238, 241, 232, .4); border-radius: 5px; }
.counter button { width: 44px; height: 100%; display: grid; place-items: center; color: #FFF8E6; }
.counter button:hover { background: rgba(255, 255, 255, .08); }
.counter button svg { width: 17px; height: 17px; }
.counter input { flex: 1; text-align: center; border: 0 !important; background: transparent; width: 40px; padding: 0; font-family: var(--hand); font-weight: 700; font-size: 24px; color: #FFF8E6; outline: none; -moz-appearance: textfield; }
.counter input::-webkit-inner-spin-button { -webkit-appearance: none; }
.tally { min-height: 28px; display: flex; align-items: center; }
.tally svg { height: 24px; width: auto; stroke: #FFF8E6; stroke-width: 2.4; stroke-linecap: round; fill: none; }
.tally .hand-note { font-size: 14px; }
.tally.sm { display: inline-flex; min-height: 0; vertical-align: middle; margin-right: 8px; }
.tally.sm svg { height: 18px; stroke: var(--ink-2); stroke-width: 2; }
.tea-total { display: flex; align-items: baseline; justify-content: space-between; border-top: 1.5px dashed rgba(238, 241, 232, .35); padding-top: 12px; font-family: var(--hand); font-size: 18px; color: rgba(238, 241, 232, .8); }
.tea-total b { font-family: var(--hand); font-weight: 700; font-size: 32px; color: #FFD9A0; }
.chai-card .btn-primary { justify-self: start; }
.chai-month .statement { margin-top: 10px; }
.heat { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.heat .day { aspect-ratio: 1; border-radius: 50%; border: 1.5px solid var(--rule-strong); position: relative; }
.heat .day[data-l="1"] { background: color-mix(in srgb, #8A5A3B 25%, var(--sheet)); border-color: transparent; }
.heat .day[data-l="2"] { background: color-mix(in srgb, #8A5A3B 50%, var(--sheet)); border-color: transparent; }
.heat .day[data-l="3"] { background: color-mix(in srgb, #8A5A3B 75%, var(--sheet)); border-color: transparent; }
.heat .day[data-l="4"] { background: #8A5A3B; border-color: transparent; }
.heat .day.today { outline: 2px solid var(--brand); outline-offset: 1px; }
.heat .day.blank { visibility: hidden; }
.heat-head { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; font-size: 11px; color: var(--faint); text-align: center; margin-bottom: 4px; }
.chai-cal { max-width: 300px; }

/* ---------- Budgets: limits sheet + a real-looking calculator ---------- */
.budget-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); gap: 20px; align-items: start; }
.limit-head, .limit-row, .limit-total { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) 140px; gap: 16px; align-items: center; }
.limit-head { font-size: 12.5px; color: var(--muted); font-weight: 600; padding: 10px 0 6px; border-bottom: 1px solid var(--rule-strong); }
.limit-row { padding: 9px 0; border-bottom: 1px solid var(--rule); }
.limit-name { font-weight: 600; font-size: 14px; display: flex; align-items: baseline; flex-wrap: wrap; }
.limit-name small { color: var(--faint); font-weight: 400; font-size: 12px; margin-left: 8px; }
.limit-spent { font-size: 14px; }
.limit-spent .num.over { color: var(--bad); font-weight: 700; }
.limit-spent .pencil-bar { margin-top: 5px; }
.limit-row .input-prefix { min-height: 36px; }
.limit-row .input-prefix input { min-height: 34px; text-align: right; }
.limit-total { padding: 12px 0 2px; border-top: 1.5px solid var(--ink); margin-top: -1px; font-weight: 700; }
.limit-total strong { grid-column: 3; text-align: right; }

.calc { background: #2C3541; border-radius: 22px 22px 16px 16px; padding: 16px 16px 18px; color: #DDE3E8; box-shadow: inset 0 2px 0 rgba(255,255,255,.08), inset 0 -4px 0 rgba(0,0,0,.25), 0 18px 34px -18px rgba(10, 16, 24, .7); position: sticky; top: 0; }
.calc-top { display: flex; justify-content: space-between; align-items: center; padding: 2px 6px 10px; }
.calc-brand { font-size: 10.5px; letter-spacing: .18em; color: #9AA6B2; font-weight: 700; }
.calc-solar { display: flex; gap: 2px; background: #1A1F26; padding: 3px; border-radius: 3px; }
.calc-solar i { width: 14px; height: 10px; background: linear-gradient(135deg, #4A3B2E, #2E2620); }
.lcd { background: #B9C6AE; border-radius: 6px; padding: 8px 14px 6px; text-align: right; box-shadow: inset 0 3px 6px rgba(0, 0, 0, .3); color: #1F2A1A; }
.lcd small { display: block; text-align: left; font-size: 10px; letter-spacing: .14em; font-weight: 700; opacity: .6; }
.lcd b { display: block; font-size: 36px; font-weight: 600; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.calc-keys { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 14px; }
.ckey { background: #3C4757; border-radius: 9px; padding: 7px 10px 6px; display: grid; gap: 1px; box-shadow: inset 0 1px 0 rgba(255,255,255,.1), 0 3px 0 #1A1F26; cursor: text; }
.ckey:focus-within { background: #4A5869; }
.ckey span { font-size: 11px; color: #A9B4BF; }
.ckey span b { color: #FFC08F; }
.ckey input { background: transparent; border: 0; outline: none; color: #F3F6F8; font-size: 18px; font-weight: 600; width: 100%; font-variant-numeric: tabular-nums; }
.ckey.wide { grid-column: 1 / -1; background: #E8631B; box-shadow: inset 0 1px 0 rgba(255,255,255,.2), 0 3px 0 #9E3F0B; }
.ckey.wide span { color: #FFE7D6; }
.ckey.wide span b { color: #fff; }
.ckey .range { accent-color: #fff; }
.calc-tape { margin: 16px 6px 0; background: var(--sheet); color: var(--ink); padding: 12px 14px 22px;
    -webkit-mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, transparent 90deg, #000 0) bottom / 14px 8px repeat-x;
    mask: linear-gradient(#000 0 0) top / 100% calc(100% - 8px) no-repeat, conic-gradient(from -45deg at bottom, transparent 90deg, #000 0) bottom / 14px 8px repeat-x; }
.calc-tape dl { display: grid; gap: 3px; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.calc-tape dl div { display: flex; justify-content: space-between; gap: 10px; }
.calc-tape dt { color: var(--ink-2); }
.calc-tape .sub { color: var(--muted); font-size: 12.5px; padding-left: 10px; }
.calc-tape .tot { border-top: 1px dashed var(--rule-strong); padding-top: 5px; margin-top: 3px; font-weight: 700; font-size: 15px; }
.calc-tape .tot dd { border-bottom: 3px double currentColor; }
.tape-note { margin-top: 10px; font-family: var(--hand); font-size: 16px; color: var(--muted); }
.tape-note.ok { color: var(--good); }
.tape-note.bad { color: var(--red-pen); }

/* ---------- Reminders ---------- */
.notice { margin-top: 14px; padding: 10px 14px; border-left: 3px solid var(--info); background: var(--info-soft); font-size: 13.5px; border-radius: 0 4px 4px 0; max-width: 62ch; }
.notice.good { border-left-color: var(--good); background: var(--good-soft); }

/* ---------- Settings ---------- */
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.settings-form { display: grid; gap: 14px; max-width: 440px; }
.kv { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--rule); font-size: 14px; gap: 12px; }
.kv:last-child { border-bottom: 0; }
.kv > span:first-child { color: var(--muted); }

/* =========================================================================
   DRAWER & MODALS
   ========================================================================= */
.drawer-wrap { position: fixed; inset: 0; z-index: 100; }
.drawer-scrim, .modal-scrim { position: absolute; inset: 0; background: rgba(17, 22, 28, .42); animation: fade .2s both; }
.drawer { position: absolute; right: 0; top: 0; bottom: 0; width: min(560px, 100%); background: var(--sheet); display: flex; flex-direction: column; box-shadow: -20px 0 50px -24px rgba(10, 16, 24, .6); animation: slideIn .28s var(--ease) both; border-left: 1px solid var(--rule-strong); }
.drawer-wrap.closing .drawer { animation: slideOut .2s ease both; }
.drawer-wrap.closing .drawer-scrim, .modal-wrap.closing .modal-scrim { animation: fade .2s reverse both; }
.drawer-head, .modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; padding: 18px 22px 12px; border-bottom: 1.5px solid var(--ink); }
.drawer-head h3, .modal-head h3 { font-family: var(--serif); font-weight: 400; font-size: 22px; line-height: 1.2; }
.drawer-head p, .modal-head p { font-size: 13.5px; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 22px 24px; display: grid; gap: 15px; align-content: start; grid-auto-rows: max-content; }
.drawer-foot, .modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px; border-top: 1px solid var(--rule-strong); background: var(--sheet-2); }
@keyframes slideIn { from { transform: translateX(100%); } }
@keyframes slideOut { to { transform: translateX(100%); } }
@keyframes fade { from { opacity: 0; } }

.cat-picker { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 10px; }
.cat-opt { display: flex; align-items: center; padding: 7px 9px; border-radius: 4px; font-size: 13.5px; color: var(--ink-2); text-align: left; border: 1px solid transparent; }
.cat-opt:hover { background: var(--sheet-2); }
.cat-opt.active { border-color: var(--ink-2); background: var(--sheet); color: var(--ink); font-weight: 600; box-shadow: inset 3px 0 0 var(--c); }

.mini-drop { border: 1.5px dashed var(--rule-strong); border-radius: 5px; padding: 11px 13px; cursor: pointer; font-size: 14px; }
.mini-drop:hover, .mini-drop.drag { border-color: var(--ink-2); background: var(--sheet-2); }
.mini-drop > div { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.mini-drop svg { width: 17px; height: 17px; color: var(--ink-2); flex: none; }
.mini-drop u { color: var(--brand-strong); text-decoration: underline; font-weight: 600; }
.mini-drop-full { color: var(--ink) !important; }
.mini-drop-full span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.modal-wrap { position: fixed; inset: 0; z-index: 110; display: grid; place-items: center; padding: 20px; }
.modal { position: relative; background: var(--sheet); border-radius: 6px; width: min(900px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: 0 30px 70px -24px rgba(10, 16, 24, .6); animation: modalIn .25s var(--ease) both; overflow: hidden; border: 1px solid var(--rule-strong); }
.modal-wrap.closing .modal { animation: modalOut .18s ease both; }
.modal-sm { width: min(440px, 100%); }
.modal-md { width: min(620px, 100%); }
.modal-md .modal-body { overflow-y: auto; }
.modal-body { padding: 16px 22px; display: grid; gap: 14px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px); } }
@keyframes modalOut { to { opacity: 0; transform: translateY(6px); } }
.confirm-body { padding: 24px 24px 16px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.confirm-icon { width: 48px; height: 48px; border-radius: 50%; border: 1.5px solid var(--bad); color: var(--bad); display: grid; place-items: center; margin-bottom: 6px; }
.confirm-icon svg { width: 22px; height: 22px; }
.confirm-body h3 { font-family: var(--serif); font-weight: 400; font-size: 21px; }

/* ---------- Scanner (the scanning animation is kept) ---------- */
.scan-body { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 22px; padding: 18px 22px; overflow-y: auto; }
.scan-stage { min-height: 370px; display: flex; }
.scan-drop { flex: 1; border: 2px dashed var(--rule-strong); border-radius: 6px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; padding: 26px; cursor: pointer; transition: border-color .15s, background .15s; background: var(--sheet-2); }
.scan-drop:hover, .scan-drop.drag { border-color: var(--ink-2); background: color-mix(in srgb, var(--hl) 18%, var(--sheet)); }
.scan-drop strong { font-family: var(--serif); font-weight: 400; font-size: 18px; }
.scan-drop-art { width: 150px; margin-bottom: 4px; transition: transform .3s var(--ease); }
.scan-drop:hover .scan-drop-art { transform: rotate(-3deg) translateY(-3px); }
.scan-drop span { font-size: 13px; max-width: 36ch; }
.scan-preview { flex: 1; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.scan-doc { position: relative; flex: 1; min-height: 330px; max-height: 520px; border-radius: 4px; overflow: hidden; background: repeating-conic-gradient(var(--sheet-2) 0 25%, var(--sheet) 0 50%) 0 0 / 16px 16px; border: 1px solid var(--rule-strong); display: grid; place-items: center; }
.scan-doc img { max-width: 100%; max-height: 100%; object-fit: contain; transition: filter .4s; }
.scan-pdf { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); }
.scan-pdf svg { width: 60px; height: 60px; color: var(--bad); }
.scan-file-row { display: flex; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--muted); }
.scan-fx { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .3s; }
.scan-grid { position: absolute; inset: 0; background-image: linear-gradient(color-mix(in srgb, var(--brand) 20%, transparent) 1px, transparent 1px), linear-gradient(90deg, color-mix(in srgb, var(--brand) 20%, transparent) 1px, transparent 1px); background-size: 24px 24px; }
.scan-beam { position: absolute; left: 0; right: 0; height: 90px; top: -90px; background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--brand) 28%, transparent)); border-bottom: 2px solid var(--brand); box-shadow: 0 6px 22px 2px color-mix(in srgb, var(--brand) 60%, transparent); }
.corner { position: absolute; width: 24px; height: 24px; border: 3px solid var(--brand); }
.corner.tl { top: 12px; left: 12px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 12px; right: 12px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 12px; left: 12px; border-right: 0; border-top: 0; }
.corner.br { bottom: 12px; right: 12px; border-left: 0; border-top: 0; }
.scan-tags { position: absolute; inset: 0; }
.scan-tag { position: absolute; background: var(--ink); color: var(--sheet); font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 3px; display: flex; gap: 6px; align-items: center; box-shadow: 0 6px 16px -8px rgba(0,0,0,.6); animation: tagIn .4s var(--ease) both; white-space: nowrap; }
.scan-tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--brand); }
@keyframes tagIn { from { opacity: 0; transform: translateY(5px); } }
.scan-done-badge { position: absolute; width: 70px; height: 70px; border-radius: 50%; background: var(--good); color: #fff; display: grid; place-items: center; transform: scale(0); opacity: 0; }
.scan-done-badge svg { width: 34px; height: 34px; stroke-width: 3; }
.scan-body[data-step="scanning"] .scan-fx { opacity: 1; }
.scan-body[data-step="scanning"] .scan-beam { animation: beam 1.8s cubic-bezier(.45, 0, .55, 1) infinite; }
.scan-body[data-step="scanning"] .corner { animation: cornerPulse 1.2s ease-in-out infinite; }
.scan-body[data-step="scanning"] .scan-doc img { filter: saturate(.6) brightness(.93); }
.scan-body[data-step="done"] .scan-doc img { filter: blur(1px) brightness(.88); }
.scan-body[data-step="done"] .scan-done-badge { animation: doneIn .5s var(--ease) forwards; }
.scan-body[data-step="done"] .scan-doc { border-color: var(--good); }
@keyframes beam { 0% { top: -90px; } 50% { top: calc(100% - 90px); } 100% { top: -90px; } }
@keyframes cornerPulse { 50% { transform: scale(1.15); opacity: .6; } }
@keyframes doneIn { 0% { transform: scale(0); opacity: 0; } 60% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.scan-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.scan-hint h4 { font-family: var(--serif); font-weight: 400; font-size: 18px; margin-bottom: 8px; }
.hint-list { list-style: none; display: grid; }
.hint-list li { font-size: 14px; color: var(--ink-2); padding: 7px 0 7px 22px; border-bottom: 1px solid var(--rule); position: relative; }
.hint-list li::before { content: '✓'; position: absolute; left: 2px; color: var(--good); font-weight: 700; }
.progress-list { list-style: none; display: grid; }
.progress-list li { display: flex; align-items: center; gap: 12px; padding: 9px 4px; font-size: 14px; color: var(--faint); border-bottom: 1px solid var(--rule); transition: color .2s; }
.progress-list .dot { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--rule-strong); flex: none; position: relative; }
.progress-list li.active { color: var(--ink); font-weight: 600; }
.progress-list li.active .dot { border-color: var(--brand); border-right-color: transparent; animation: spin .8s linear infinite; }
.progress-list li.done { color: var(--ink-2); }
.progress-list li.done .dot { background: var(--good); border-color: var(--good); }
.progress-list li.done .dot::after { content: ''; position: absolute; left: 4px; top: 1px; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.scan-meter { height: 4px; background: var(--rule); overflow: hidden; }
.scan-meter span { display: block; height: 100%; width: 0; background: var(--brand); transition: width .4s var(--ease); }
.scan-result { display: flex; flex-direction: column; gap: 10px; animation: pageIn .3s ease both; }
.result-head { display: flex; align-items: center; gap: 12px; }
.result-head > div { flex: 1; min-width: 0; }
.result-head strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 20px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-head small { font-size: 12.5px; }
.cat-dot { width: 6px; height: 38px; border-radius: 2px; background: var(--c, var(--brand)); flex: none; }
.confidence { font-size: 12px; font-weight: 700; color: var(--good); }
.confidence.mid { color: var(--warn); }
.confidence.low { color: var(--bad); }
.result-amount { font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; border-bottom: 3px double var(--ink); align-self: flex-start; }
.result-grid { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--rule-strong); }
.result-grid div { padding: 7px 2px; border-bottom: 1px solid var(--rule); }
.result-grid dt { font-size: 12px; color: var(--muted); }
.result-grid dd { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result-summary { font-family: var(--hand); font-size: 16px; }

/* =========================================================================
   TOASTS & ASK-THE-REGISTER
   ========================================================================= */
.toasts { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; min-width: 270px; max-width: 370px; background: var(--ink); color: var(--sheet); border-radius: 5px; padding: 11px 14px; display: flex; gap: 10px; align-items: flex-start; box-shadow: 0 18px 40px -18px rgba(10, 16, 24, .7); animation: toastIn .3s var(--ease) both; position: relative; overflow: hidden; }
.toast.out { animation: toastOut .25s ease both; }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.success svg { color: #7FD6A2; }
.toast.error svg { color: #FF9A90; }
.toast.info svg { color: #FFC08F; }
.toast strong { display: block; font-size: 14px; }
.toast p { font-size: 13px; opacity: .8; }
.toast::after { content: ''; position: absolute; left: 0; bottom: 0; height: 2px; background: var(--brand); animation: toastTimer var(--t, 4s) linear forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-6px); } }
@keyframes toastTimer { from { width: 100%; } to { width: 0; } }

.copilot { position: fixed; right: 22px; bottom: 22px; z-index: 90; }
.copilot-fab { height: 44px; padding: 0 16px 0 13px; border-radius: 22px; background: var(--ink); color: var(--sheet); display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; box-shadow: 0 12px 26px -12px rgba(10, 16, 24, .7); }
.copilot-fab svg { width: 18px; height: 18px; color: #FFC08F; }
.copilot-fab:hover { background: var(--ink-2); }
.copilot-panel { position: absolute; right: 0; bottom: 56px; width: min(390px, calc(100vw - 32px)); height: min(540px, calc(100vh - 120px)); background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: 0 30px 70px -24px rgba(10, 16, 24, .6); display: flex; flex-direction: column; overflow: hidden; animation: modalIn .25s var(--ease) both; }
.copilot-panel header { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px 16px; border-bottom: 1.5px solid var(--ink); }
.copilot-panel header > div { flex: 1; }
.copilot-panel header strong { display: block; font-family: var(--serif); font-weight: 400; font-size: 18px; }
.copilot-panel header small { font-size: 12px; }
.copilot-body { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 90%; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.bot { align-self: flex-start; padding: 2px 0 2px 12px; border-left: 2px solid var(--rule-strong); }
.msg.me { align-self: flex-end; background: var(--sheet-2); border: 1px solid var(--rule); padding: 8px 12px; border-radius: 6px; }
.msg ul { padding-left: 18px; margin: 4px 0; }
.msg p + p { margin-top: 6px; }
.msg.typing { display: flex; gap: 4px; align-items: center; }
.msg.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); animation: bounce 1.2s infinite; }
.msg.typing i:nth-child(2) { animation-delay: .15s; } .msg.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }
.chips { display: flex; flex-direction: column; }
.chips button { font-size: 13.5px; padding: 7px 0; color: var(--brand-strong); text-align: left; border-bottom: 1px solid var(--rule); }
.chips button:hover { text-decoration: underline; }
.copilot-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--rule-strong); }
.copilot-input input { flex: 1; height: 38px; border-radius: 5px; border: 1px solid var(--rule-strong); padding: 0 11px; background: var(--sheet); outline: none; }
.copilot-input input:focus { border-color: var(--ink-2); }
.copilot-input .icon-btn { width: 38px; height: 38px; }

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 1280px) { .search { width: 190px; } }
@media (max-width: 1100px) {
    .dash-cols, .dash-cols.even, .chai-counter, .budget-grid, .settings-grid { grid-template-columns: minmax(0, 1fr); }
    .search { display: none; }
    #open-scan span, #open-add span { display: none; }
    #open-scan, #open-add { width: 38px; padding: 0; }
    .calc { position: static; }
}
@media (max-width: 860px) {
    .mobile-only { display: inline-grid !important; }
    .desktop-only { display: none !important; }
    .sidebar { position: fixed; inset: 0 auto 0 0; transform: translateX(-100%); width: 270px; box-shadow: 20px 0 50px -20px rgba(0,0,0,.5); }
    .app.nav-open .sidebar { transform: none; }
    .sidebar-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 25; opacity: 0; pointer-events: none; transition: opacity .25s; }
    .app.nav-open .sidebar-scrim { opacity: 1; pointer-events: auto; }
    .app.collapsed { --sidebar-w: 270px; }
    .topbar { padding: 10px 14px; gap: 6px; }
    .topbar-title p { display: none; }
    .period-btn span, .period-btn .chev { display: none; }
    .period-btn { width: 38px; padding: 0; }
    .view { padding: 14px 12px 100px; }
    .sheet-head, .sec-head { grid-template-columns: minmax(0, 1fr) 92px; gap: 12px; padding: 18px 16px 18px 40px; align-items: start;
        background-image: linear-gradient(90deg, transparent 18px, var(--margin) 18px, var(--margin) 19.5px, transparent 19.5px, transparent 22px, var(--margin) 22px, var(--margin) 23.5px, transparent 23.5px),
                          repeating-linear-gradient(180deg, transparent 0 29px, color-mix(in srgb, var(--info) 14%, transparent) 29px 30px); }
    .sheet-head .art, .sec-head .art { grid-row: 1; grid-column: 2; }
    .statement { gap: 6px 22px; }
    .statement .lead { flex-basis: 100%; }
    .statement .lead dd { font-size: 26px; }
    .sheet, .panel { padding: 14px 14px 16px; }
    .table th:first-child, .table td:first-child { padding-left: 14px; }
    .ledger .c-hide, .ledger .share-h { display: none; }
    .history { height: 170px; gap: 6px; }
    .scan-body { grid-template-columns: 1fr; }
    .scan-stage, .scan-doc { min-height: 250px; }
    .login { grid-template-columns: minmax(0, 1fr); }
    .login-art { display: none; }
    .login .mobile-only { display: inline-flex !important; align-self: flex-start; }
    .toolbar { padding: 12px 14px; }
    .toolbar-right { width: 100%; } .mini-search { flex: 1; } .mini-search input { width: 100%; }
    .limit-head { display: none; }
    .limit-row { grid-template-columns: minmax(0, 1fr) 120px; }
    .limit-spent { grid-column: 1; grid-row: 2; }
    .limit-row .input-prefix { grid-column: 2; grid-row: 1 / 3; }
    .limit-total { grid-template-columns: 1fr auto; } .limit-total strong { grid-column: 2; }
    .table.stack thead { display: none; }
    .table.stack, .table.stack tbody, .table.stack tr, .table.stack td { display: block; width: 100%; }
    .table.stack tr { border-bottom: 1px solid var(--rule); padding: 10px 14px; display: grid; grid-template-columns: 1fr auto; gap: 3px 12px; }
    .table.stack td { border: 0; padding: 1px 0 !important; }
    .table.stack td.c-main { grid-column: 1 / -1; }
    .table.stack td.c-hide { display: none; }
    .table.stack td.r { text-align: left; }
    .table.stack tbody tr:hover td { background: none; }
    .table.stack tfoot { display: block; } .table.stack tfoot tr { display: flex; justify-content: space-between; }
    .row-actions { opacity: 1; justify-content: flex-start; }
    .fixed-row { grid-template-columns: 12px minmax(0, 1fr) auto; }
    .fixed-row .fx-when { grid-column: 2; grid-row: 2; }
    .fixed-row .fx-chip { grid-column: 2; grid-row: 3; }
    .fixed-row .fx-amt { grid-column: 3; grid-row: 1; }
    .fixed-row .fx-tools { grid-column: 3; grid-row: 2 / 4; justify-content: flex-end; }
    .grid-3 { grid-template-columns: 1fr 1fr; }
    .chai-card { border-width: 7px; padding: 14px 14px 18px; }
    .copilot { right: 12px; bottom: 12px; }
}
@media (max-width: 520px) {
    .grid-2 { grid-template-columns: 1fr; }
    .tally-row { grid-template-columns: 1fr 1fr; }
    #theme-toggle { display: none; }
    .entry { grid-template-columns: 50px minmax(0, 1fr) auto; }
    .entry-end { flex-direction: column; align-items: flex-end; gap: 3px; }
    .chit { grid-template-columns: 44px minmax(0, 1fr) auto; }
    .copilot-fab span { display: none; } .copilot-fab { padding: 0 13px; }
    .cat-picker { grid-template-columns: 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
    .scan-body[data-step="scanning"] .scan-beam { animation: none; top: 40%; }
}

/* ---------- fixes after review ---------- */
.chai-card .field > input { background: transparent; color: #FFF8E6; border: 1.5px dashed rgba(238, 241, 232, .4); }
.chai-card .input-prefix input { border: 0 !important; color: #FFF8E6; }
.chai-cal { max-width: 230px; }
.heat .day { border-width: 1px; }
.fixed-empty { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 0 6px; color: var(--ink-2); font-size: 14px; flex-wrap: wrap; }
.fixed-empty p { max-width: 70ch; }
.statement dd .set-link { font-size: 14px; font-weight: 600; }
.fixed-panel .panel-head { margin-bottom: 0; }
.margin-note { display: inline-block; }
.margin-note .arrow { margin-right: 5px; }
.ckey input::-webkit-inner-spin-button, .ckey input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ckey input { -moz-appearance: textfield; }

/* =========================================================================
   LOADING
   ========================================================================= */
/* Thin bar across the top whenever data is loading or saving */
.topline { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 400; pointer-events: none; overflow: hidden; opacity: 0; transition: opacity .25s; }
.topline.on { opacity: 1; }
.topline span { position: absolute; top: 0; bottom: 0; left: 0; width: 40%; background: linear-gradient(90deg, transparent, var(--brand) 30%, var(--brand) 70%, transparent); animation: topline 1.1s cubic-bezier(.45, 0, .55, 1) infinite; }
@keyframes topline { from { transform: translateX(-100%); } to { transform: translateX(260%); } }

/* Logo with ledger lines being written underneath */
.loader { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader.in-view { min-height: 58vh; justify-content: center; }
.loader-logo { width: 150px; height: auto; animation: logoBreathe 1.8s ease-in-out infinite; }
.loader-lines { width: 170px; display: grid; gap: 7px; }
.loader-lines i { display: block; height: 2px; background: var(--rule-strong); border-radius: 1px; position: relative; overflow: hidden; }
.loader-lines i::after { content: ''; position: absolute; inset: 0; background: var(--ink); transform: scaleX(0); transform-origin: left; animation: writeLine 1.8s var(--ease) infinite; }
.loader-lines i:nth-child(2)::after { animation-delay: .25s; background: var(--brand); }
.loader-lines i:nth-child(3)::after { animation-delay: .5s; }
.loader-lines i:nth-child(3) { width: 62%; }
.loader-text { font-family: var(--hand); font-size: 19px; color: var(--muted); }
.loader-text::after { content: ''; display: inline-block; width: 1.2em; text-align: left; animation: dots 1.2s steps(4) infinite; }
@keyframes writeLine { 0% { transform: scaleX(0); } 45%, 70% { transform: scaleX(1); } 100% { transform: scaleX(1); opacity: 0; } }
@keyframes logoBreathe { 50% { transform: scale(1.03); } }
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '...'; } }
.boot { background: var(--sheet); }

/* Logo shown as-is, no white box */
.logo-chip { background: none; border: 0; padding: 0; border-radius: 0; }
.sidebar-brand .logo-chip img { height: 46px; }
.login-art .logo-chip img { height: 72px; }
.login .mobile-only img { height: 56px; }
@media (prefers-reduced-motion: reduce) { .topline span { animation: none; width: 100%; } }
.scan-body[data-step="pick"] { grid-template-columns: minmax(0, 1fr); }
.scan-body[data-step="pick"] .scan-side { display: none; }

/* =========================================================================
   v3 — INCOME, PROFIT & SAVED CATEGORIES
   ========================================================================= */
:root { --in: #2E7D4F; --in-soft: #E2F0E6; --out: #B5542A; --out-soft: #F7E7DF; }

/* ---------- Sidebar: collapsible headings ---------- */
.nav-group.top { margin-top: 4px; }
.nav-group.acc { margin-top: 6px; }
.nav-head {
    width: calc(100% - 10px); display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 8px; border-radius: 6px;
    text-align: left; color: var(--ink); position: relative; overflow: hidden; transition: background .18s, box-shadow .18s, color .18s;
}
.nav-head::before { content: ''; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand); transform: scaleY(0); transition: transform .2s var(--ease); }
.nav-head:hover { background: var(--sheet); box-shadow: 0 1px 0 var(--rule-strong), 0 6px 14px -10px rgba(30, 42, 56, .35); }
.nav-head:hover::before, .nav-group.acc.open > .nav-head::before { transform: scaleY(1); }
.nav-head:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nh-lead { width: 27px; height: 22px; display: grid; place-items: center; flex: none; }
.nh-swatches { position: relative; width: 27px; height: 18px; }
.nh-swatches i { position: absolute; top: 2px; left: calc(var(--i) * 5px); width: 12px; height: 12px; border-radius: 3px; background: var(--c); box-shadow: 0 0 0 1.5px var(--paper); transition: transform .25s var(--ease); }
.nav-head:hover .nh-swatches i, .nav-group.acc.open .nh-swatches i { transform: translateX(calc(var(--i) * 2px)) rotate(calc((var(--i) - 1.5) * 7deg)); }
.nh-icon { width: 17px; height: 17px; color: var(--muted); }
.nh-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.nh-label { font-family: var(--serif); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nh-amt { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; margin-top: 1px; }
.nh-amt:empty { display: none; }
.nh-chev { width: 16px; height: 16px; color: var(--muted); flex: none; transition: transform .25s var(--ease), color .15s; }
.nav-head:hover .nh-chev { color: var(--ink); }
.nav-group.acc.open > .nav-head .nh-chev { transform: rotate(180deg); color: var(--brand); }
.nav-group.acc.open > .nav-head { background: var(--sheet); }
.nav-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .3s var(--ease); }
.nav-group.acc.open > .nav-body { grid-template-rows: 1fr; }
.nav-body-inner { overflow: hidden; padding-left: 14px; }
.nav-group.acc.open .nav-body-inner { padding-top: 4px; padding-bottom: 6px; }
.nav-body-inner .nav-item { min-height: 33px; font-size: 13.5px; }
.nav-group.acc .nav-body-inner { border-left: 1.5px dotted var(--rule-strong); margin-left: 16px; padding-left: 4px; }
.app.collapsed .nh-text, .app.collapsed .nh-chev { display: none; }
.app.collapsed .nav-head { justify-content: center; padding: 7px 0; }
.app.collapsed .nav-group.acc .nav-body-inner { margin-left: 0; border-left: 0; padding-left: 0; }

/* ---------- Setup banner ---------- */
.setup-banner { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--rule)); border-left: 4px solid var(--warn); padding: 11px 14px; border-radius: 0 4px 4px 0; font-size: 14px; }

/* ---------- Profit & loss header ---------- */
.pnl-head .statement .in dd { color: var(--in); }
.pnl-head .statement .out dd { color: var(--out); }
.statement .lead.loss dd mark { background: linear-gradient(100deg, transparent 2%, #F3C3BC 3%, #F3C3BC 97%, transparent 98%) 0 72% / 100% 46% no-repeat; color: var(--bad); }

/* ---------- Needs attention ---------- */
.insights { list-style: none; display: grid; margin-top: 6px; }
.insight { display: grid; grid-template-columns: 16px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 11px 4px; border-bottom: 1px solid var(--rule); }
.insight:last-child { border-bottom: 0; }
.insight[data-go] { cursor: pointer; transition: background .15s; }
.insight[data-go]:hover { background: color-mix(in srgb, var(--hl) 22%, transparent); }
.insight strong { display: block; font-size: 14.5px; font-weight: 600; }
.insight p { font-size: 13.5px; color: var(--muted); margin-top: 1px; }
.ins-mark { width: 12px; height: 12px; margin-top: 4px; border-radius: 50%; border: 2px solid currentColor; }
.insight.bad .ins-mark { color: var(--bad); background: var(--bad); }
.insight.warn .ins-mark { color: var(--warn); }
.insight.good .ins-mark { color: var(--good); background: var(--good); }
.insight.info .ins-mark { color: var(--info); border-style: dotted; }
.ins-go { width: 16px; height: 16px; color: var(--faint); margin-top: 3px; transition: transform .15s, color .15s; }
.insight[data-go]:hover .ins-go { color: var(--ink); transform: translateX(3px); }

/* ---------- Chart legend ---------- */
.chart-legend { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); margin-top: 10px; flex-wrap: wrap; }
.chart-legend span { display: inline-flex; align-items: center; gap: 7px; }
.chart-legend i { width: 12px; height: 12px; background: var(--c); display: inline-block; }
.chart-legend i.line { width: 18px; height: 0; border-top: 2px solid var(--ink); position: relative; }
.chart-legend i.line::after { content: ''; position: absolute; left: 6px; top: -4px; width: 6px; height: 6px; border-radius: 50%; background: var(--ink); }

/* ---------- Money in / out marks ---------- */
.signed.in, .num.signed.in { color: var(--in); }
.signed.out, .num.signed.out { color: var(--ink); }
.dbl.neg { color: var(--bad); }
.dir { display: inline-block; font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; padding: 1px 5px; border-radius: 3px; margin-right: 7px; vertical-align: 1px; }
.dir.in { background: var(--in-soft); color: var(--in); }
.dir.out { background: var(--out-soft); color: var(--out); }
.chit.income .chit-date { border-right-color: color-mix(in srgb, var(--in) 45%, var(--rule-strong)); }
.chit.income .chit-end .link-btn { color: var(--in); }
.entry.income .entry-date { color: var(--in); }

/* ---------- Income / expense switch ---------- */
.kind-switch { display: grid; grid-template-columns: 1fr 1fr; border: 1.5px solid var(--ink); border-radius: 7px; overflow: clip; }
.kind-switch button { display: flex; align-items: center; justify-content: center; gap: 7px; height: 40px; font-weight: 600; font-size: 14px; color: var(--ink-2); background: var(--sheet); transition: background .2s var(--ease), color .2s; }
.kind-switch button + button { border-left: 1.5px solid var(--ink); }
.kind-switch button svg { width: 16px; height: 16px; }
.kind-switch button:hover { background: var(--sheet-2); }
.kind-switch button.active[data-kind="income"] { background: var(--in); color: #fff; }
.kind-switch button.active[data-kind="expense"] { background: var(--out); color: #fff; }
.kind-switch.big button { height: 44px; font-size: 15px; }
#expense-drawer[data-kind="income"] .drawer-head { border-bottom-color: var(--in); }
#expense-drawer[data-kind="income"] .btn-primary#f-save { background: var(--in); }
#scan-modal[data-kind="income"] #scan-save { background: var(--in); border-color: var(--in); }
.kind-reason { font-family: var(--hand); font-size: 15.5px; color: var(--muted); margin: -2px 0 0; min-height: 1em; }
.scan-result[data-kind="income"] .result-amount { color: var(--in); border-bottom-color: var(--in); }
.scan-result[data-kind="income"] .result-amount::before { content: '+ '; }

/* ---------- Inline "add new" in the entry form ---------- */
.cat-opt.add { color: var(--brand-strong); font-weight: 600; border: 1.5px dashed var(--rule-strong); justify-content: center; gap: 6px; }
.cat-opt.add svg { width: 15px; height: 15px; }
.cat-opt.add:hover { border-color: var(--brand); background: var(--brand-tint); }
.inline-add { margin-top: 8px; padding: 10px 12px; border: 1px solid var(--rule-strong); border-left: 3px solid var(--brand); border-radius: 0 5px 5px 0; background: var(--sheet-2); display: grid; gap: 6px; animation: pageIn .2s ease both; }
.inline-add > span { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.inline-row { display: flex; gap: 8px; align-items: center; }
.inline-row input { flex: 1; min-width: 0; height: 36px; border: 1px solid var(--rule-strong); border-radius: 5px; padding: 0 10px; background: var(--sheet); outline: none; }
.inline-row input:focus { border-color: var(--ink-2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }

/* ---------- Categories & sources page ---------- */
.cat-list { display: grid; }
.cat-row { display: grid; grid-template-columns: 54px minmax(0, 1fr) auto auto auto; gap: 14px; align-items: center; padding: 10px 2px; border-bottom: 1px solid var(--rule); position: relative; }
.cat-row:last-child { border-bottom: 0; }
.cat-row::before { content: ''; position: absolute; left: -22px; top: 10px; bottom: 10px; width: 4px; background: var(--c); border-radius: 0 3px 3px 0; }
.cat-art { width: 54px; height: 45px; object-fit: contain; }
.cat-main strong { display: block; font-weight: 600; }
.chips-ro { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.chips-ro span { font-size: 12px; color: var(--ink-2); background: var(--sheet-2); border: 1px solid var(--rule); border-radius: 3px; padding: 1px 6px; }
.chips-ro .more { color: var(--muted); }
.cat-count { font-size: 12.5px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.cat-group h4 { font-family: var(--serif); font-weight: 400; font-size: 16px; padding: 14px 0 4px; border-bottom: 1px solid var(--rule-strong); }

.swatch-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.swatch-pick .sw { width: 26px; height: 26px; border-radius: 5px; background: var(--c); box-shadow: inset 0 0 0 2px rgba(255,255,255,.35); transition: transform .12s; }
.swatch-pick .sw:hover { transform: scale(1.1); }
.swatch-pick .sw.active { box-shadow: 0 0 0 2px var(--sheet), 0 0 0 4px var(--ink); }
.art-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; }
.art-opt { border: 1px solid var(--rule); border-radius: 5px; padding: 4px; background: var(--sheet); transition: border-color .12s, background .12s; }
.art-opt img { width: 100%; height: 40px; object-fit: contain; }
.art-opt:hover { border-color: var(--ink-2); }
.art-opt.active { border: 2px solid var(--ink); background: color-mix(in srgb, var(--hl) 25%, var(--sheet)); padding: 3px; }
.chip-edit { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; background: var(--sheet-2); border: 1px solid var(--rule-strong); border-radius: 4px; padding: 3px 4px 3px 8px; }
.chip button { width: 20px; height: 20px; border-radius: 3px; color: var(--muted); font-size: 15px; line-height: 1; }
.chip button:hover { background: var(--bad-soft); color: var(--bad); }

@media (max-width: 860px) {
    .cat-row { grid-template-columns: 44px minmax(0, 1fr) auto; }
    .cat-row .cat-count, .cat-row .link-btn { display: none; }
    .cat-row::before { left: -14px; }
    .insight { grid-template-columns: 14px minmax(0, 1fr); }
    .ins-go { display: none; }
}

/* ---------- v3.1 — Expenses group with sub-headings, open Planning, Money out page ---------- */
.nav-sub { margin: 1px 0; }
.nav-sub-head {
    width: calc(100% - 8px); display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 6px 8px; border-radius: 5px;
    text-align: left; font-size: 13.5px; font-weight: 600; color: var(--ink-2); transition: background .15s, color .15s;
}
.nav-sub-head:hover { background: var(--sheet); color: var(--ink); }
.nav-sub-head:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; }
.nav-sub.open > .nav-sub-head { color: var(--ink); }
.ns-dots { display: flex; flex: none; }
.ns-dots i { width: 8px; height: 8px; border-radius: 2px; background: var(--c); margin-right: -2px; box-shadow: 0 0 0 1.5px var(--paper); transition: margin .2s var(--ease); }
.nav-sub-head:hover .ns-dots i, .nav-sub.open .ns-dots i { margin-right: 1px; }
.ns-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ns-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-amt:empty { display: none; }
.ns-amt { font-size: 11px; font-weight: 400; margin-top: 1px; color: var(--faint); font-variant-numeric: tabular-nums; }
.ns-chev { width: 14px; height: 14px; flex: none; color: var(--muted); transition: transform .22s var(--ease); }
.nav-sub.open > .nav-sub-head .ns-chev { transform: rotate(90deg); color: var(--brand); }
.nav-sub-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .25s var(--ease); }
.nav-sub.open > .nav-sub-body { grid-template-rows: 1fr; }
.nav-sub-inner { overflow: hidden; margin-left: 10px; padding-left: 4px; border-left: 1.5px dotted var(--rule-strong); }
.nav-sub.open .nav-sub-inner { padding-top: 2px; padding-bottom: 4px; }
.app.collapsed .ns-text, .app.collapsed .ns-chev { display: none; }
.app.collapsed .nav-sub-head { justify-content: center; padding: 6px 0; }
.app.collapsed .nav-sub-inner { margin-left: 0; border-left: 0; padding-left: 0; }

.nav-group.static { margin-top: 18px; padding-top: 12px; border-top: 1px dashed var(--rule-strong); margin-right: 10px; }
.nav-group.static .nav-group-title { display: flex; align-items: center; gap: 8px; padding: 0 10px 6px; font-size: 14px; color: var(--ink); }
.nav-group.static .nav-group-title svg { width: 16px; height: 16px; color: var(--muted); }
.nav-group.static .nav-item { margin-right: -10px; }

.head-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-bottom: 18px; }
.head-card {
    display: grid; gap: 4px; text-align: left; padding: 14px 16px 13px; background: var(--sheet); border: 1px solid var(--rule-strong);
    border-top: 4px solid var(--c); border-radius: 4px; box-shadow: var(--shadow-sm, 0 1px 2px rgba(30, 42, 56, .06)); transition: transform .18s var(--ease), box-shadow .18s;
}
.head-card:hover { transform: translateY(-2px); box-shadow: 0 8px 18px -12px rgba(30, 42, 56, .45); }
.hc-dots { display: flex; gap: 3px; }
.hc-dots i { width: 9px; height: 9px; border-radius: 2px; background: var(--c); }
.hc-name { font-family: var(--serif); font-size: 16px; color: var(--ink); margin-top: 4px; }
.hc-amt { font-size: 22px; color: var(--ink); }
.head-card small { color: var(--muted); font-size: 12.5px; }
.app.collapsed .nav-group.static .nav-group-title { display: none; }
.app.collapsed .nav-group.static { margin-right: 0; }
.msg.bot.error { color: var(--bad); }
.msg.bot.error .link-btn { margin-left: 4px; }
.msg-note { align-self: flex-start; font-size: 12.5px; color: var(--muted); font-style: italic; margin: -4px 0 0 4px; }

/* ---------- v3.2 — Export menus, print / PDF, offline backup, chat tools ---------- */
.xmenu { position: relative; display: inline-block; }
.xmenu .chev { width: 14px; height: 14px; margin-left: -2px; opacity: .7; transition: transform .2s var(--ease); }
.xmenu.open .chev { transform: rotate(180deg); }
.xmenu-list {
    position: absolute; top: calc(100% + 6px); right: 0; z-index: 60; width: 250px; padding: 6px; background: var(--sheet);
    border: 1px solid var(--rule-strong); border-radius: 6px; box-shadow: 0 18px 40px -18px rgba(10, 16, 24, .45);
    display: none; animation: modalIn .18s var(--ease) both;
}
.xmenu.left .xmenu-list { right: auto; left: 0; }
.xmenu.open .xmenu-list { display: grid; gap: 2px; }
.xmenu-list button { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 4px; text-align: left; color: var(--ink); }
.xmenu-list button:hover, .xmenu-list button:focus-visible { background: var(--sheet-2); outline: none; }
.xmenu-list button svg { width: 18px; height: 18px; margin-top: 1px; color: var(--muted); flex: none; }
.xmenu-list button:hover svg { color: var(--brand); }
.xmenu-list b { display: block; font-size: 13.5px; font-weight: 600; }
.xmenu-list small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 1px; }
.xmenu.up .xmenu-list { top: auto; bottom: calc(100% + 6px); }
.sheet-tools { display: flex; align-items: center; gap: 8px; }
.page-export .btn { gap: 6px; }
@media (max-width: 1280px) { .page-export .x-label, .page-export .chev { display: none; } }
@media (max-width: 860px) { .page-export .btn { width: 38px; padding: 0; justify-content: center; } .page-export .xmenu-list { position: fixed; top: 60px; right: 12px; } }

.backup-panel { grid-column: 1 / -1; }
.backup-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0 8px; }
.hint-line { font-size: 12.5px; color: var(--muted); }

/* Image capture: show the whole page, hide controls */
.capturing .no-export, .capturing .xmenu, .capturing .sh-actions .btn, .capturing .link-btn, .capturing .icon-btn { visibility: hidden; }

/* PDF / print: only the chosen panel is printed */
.print-head { display: none; }
.chat-print { display: none; }
@media print {
    @page { margin: 12mm; }
    body.print-one { background: #fff !important; }
    body.print-one * { visibility: hidden; }
    body.print-one .print-target, body.print-one .print-target * { visibility: visible; }
    body.print-one .print-target .no-export, body.print-one .print-target .no-export *, body.print-one .print-target .xmenu, body.print-one .print-target .xmenu *,
    body.print-one .print-target button, body.print-one .print-target button * { visibility: hidden !important; }
    html, body.print-one, body.print-one .app, body.print-one .main, body.print-one .view { height: auto !important; overflow: visible !important; }
    body.print-one .sidebar, body.print-one .topbar, body.print-one .copilot, body.print-one .toasts { display: none !important; }
    body.print-one .print-target { position: absolute; left: 0; top: 0; width: 100%; padding: 0 !important; overflow: visible !important; }
    body.print-one .print-head { display: flex !important; align-items: center; gap: 12px; padding-bottom: 10px; margin-bottom: 14px; border-bottom: 2px solid #1E2A38; }
    body.print-one .print-head img { height: 34px; }
    body.print-one .print-head strong { display: block; font-family: var(--serif); font-size: 18px; font-weight: 400; }
    body.print-one .print-head span { font-size: 11px; color: #555; }
    body.print-one .chat-print.print-target { display: block !important; }
    body.print-one .sheet, body.print-one .panel, body.print-one tr, body.print-one .chit, body.print-one .head-card { break-inside: avoid; box-shadow: none !important; }
    body.print-one .table-wrap { overflow: visible !important; max-height: none !important; }
}
.chat-print h2 { font-family: var(--serif); font-weight: 400; font-size: 20px; }
.chat-print .cp-msg { margin: 12px 0; padding-left: 10px; border-left: 2px solid #ccc; font-size: 13px; line-height: 1.55; }
.chat-print .cp-msg.user { border-color: #E8691E; }
.chat-print .cp-msg b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: #666; margin-bottom: 2px; }

/* Chat tools */
.copilot-tools { display: flex; align-items: center; gap: 2px; padding: 6px 8px; border-bottom: 1px solid var(--rule); background: var(--sheet-2); }
.copilot-tools button { position: relative; display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 8px; border-radius: 4px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.copilot-tools button svg { width: 15px; height: 15px; }
.copilot-tools button:hover:not(:disabled), .copilot-tools button.active { background: var(--sheet); color: var(--ink); box-shadow: inset 0 0 0 1px var(--rule-strong); }
.copilot-tools button:disabled { opacity: .4; cursor: default; }
.copilot-tools [data-chat="clear"] { margin-left: auto; }
.copilot-tools [data-chat="clear"]:hover:not(:disabled) { color: var(--bad); }
.tool-count { font-style: normal; font-size: 10.5px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--ink); color: var(--sheet); display: inline-grid; place-items: center; }
.ct-dl { position: relative; }
.ct-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 5; width: 170px; padding: 4px; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: 5px; box-shadow: 0 12px 30px -14px rgba(10, 16, 24, .5); display: grid; }
.ct-menu.hidden { display: none; }
.ct-menu button { width: 100%; justify-content: flex-start; font-weight: 500; }
@media (max-width: 420px) { .copilot-tools button span { display: none; } }

.msg.bot { position: relative; padding-right: 26px; }
.msg-copy { position: absolute; top: 0; right: 0; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 4px; color: var(--faint); opacity: 0; transition: opacity .15s; }
.msg.bot:hover .msg-copy, .msg-copy:focus-visible, .msg-copy.done { opacity: 1; }
.msg-copy:hover { color: var(--ink); background: var(--sheet-2); }
.msg-copy.done { color: var(--good, #2E7D4F); }
.msg-copy svg { width: 14px; height: 14px; }
@media (hover: none) { .msg-copy { opacity: .7; } }

.copilot-history { flex: 1; overflow-y: auto; padding: 10px 12px 14px; }
.copilot-history.hidden { display: none; }
.ch-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.ch-head .link-btn { display: inline-flex; align-items: center; gap: 5px; }
.ch-head .link-btn svg { width: 14px; height: 14px; }
.ch-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.ch-list li { display: flex; align-items: center; gap: 4px; border: 1px solid var(--rule); border-radius: 5px; background: var(--sheet); }
.ch-list li.current { border-color: var(--brand); }
.ch-list li:hover { border-color: var(--rule-strong); background: var(--sheet-2); }
.ch-open { flex: 1; min-width: 0; text-align: left; padding: 8px 10px; }
.ch-open strong { display: block; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-open small { font-size: 12px; color: var(--muted); }
.ch-list .icon-btn { margin-right: 4px; color: var(--faint); }
.ch-list .icon-btn:hover { color: var(--bad); }
.ch-empty { padding: 24px 6px; text-align: center; color: var(--muted); font-size: 13.5px; }
.ch-note { margin-top: 10px; font-size: 11.5px; color: var(--faint); text-align: center; }
.copilot-input.hidden, .copilot-body.hidden { display: none; }

/* Period menu: custom dates stay inside the box */
.period-menu { width: 260px; box-sizing: border-box; overflow: hidden; }
.period-custom { padding: 9px 5px 4px; }
.pc-field { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.period-custom input { min-width: 0; max-width: 100%; box-sizing: border-box; }
.period-custom .btn { width: 100%; justify-content: center; box-sizing: border-box; }
