/* ===========================================================
   HoneyHealth: interface styles
   Principle: honey marks where you act (buttons, entry
   panels). Records sit quietly in ink on white.
   =========================================================== */

:root {
    color-scheme: light;

    --bg: #F2F3EE;
    --surface: #FFFFFF;
    --surface-2: #F8F8F4;
    --ink: #231C12;
    --ink-2: #4F4A40;
    --muted: #6F6A60;
    --line: #E1E2DA;
    --line-strong: #C9CAC0;

    --honey: #F0B323;
    --honey-hover: #E2A20F;
    --honey-edge: #D99C10;
    --honey-ink: #7A5200;
    --honey-wash: #FDF4DA;
    --honey-line: #EED89A;

    --in: #1E7448;
    --in-wash: #E5F2EA;
    --in-line: #BFDCCB;
    --out: #B0362B;
    --out-wash: #FBEAE6;
    --out-line: #EBC0B9;

    --focus: 0 0 0 3px rgba(240, 179, 35, .55);
    --r-lg: 16px;
    --r-md: 10px;
    --r-sm: 7px;

    --font-ui: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --font-display: "Bricolage Grotesque", "Public Sans", system-ui, sans-serif;

    --sidebar-w: 256px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: var(--font-ui);
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; color: var(--ink); }
p { margin: 0; }
a { color: inherit; }
img, svg { display: block; }
button { font: inherit; }

.icon { width: 18px; height: 18px; flex: none; }

.skip-link {
    position: absolute; left: 12px; top: -48px; z-index: 100;
    background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-md);
    text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 12px; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }

/* ---------------- Shell ---------------- */

.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky; top: 0;
    height: 100vh;
    display: flex; flex-direction: column;
    padding: 22px 14px 16px;
    overflow-y: auto;
}

.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 8px; }

.brand {
    display: inline-flex; align-items: center; gap: 10px;
    text-decoration: none; color: var(--ink);
    font-family: var(--font-display); font-weight: 700; font-size: 20px; letter-spacing: -.01em;
}
.brand-mark { width: 30px; height: 30px; }

.icon-btn.sidebar-close { display: none; }

.nav { margin-top: 18px; flex: 1; }
.nav-group + .nav-group { margin-top: 22px; }
.nav-label { font-size: 13px; color: var(--muted); padding: 0 12px 6px; font-weight: 500; }

.nav a {
    position: relative;
    display: flex; align-items: center; gap: 12px;
    padding: 9px 12px; margin-bottom: 2px;
    border-radius: var(--r-md);
    color: var(--ink-2); text-decoration: none;
    font-size: 15px; font-weight: 500;
}
.nav a:hover { background: rgba(35, 28, 18, .05); color: var(--ink); }
.nav a[aria-current="page"] {
    background: var(--surface); color: var(--ink); font-weight: 600;
    box-shadow: 0 0 0 1px var(--line), 0 1px 2px rgba(35, 28, 18, .05);
}
.nav a[aria-current="page"] .nav-icon { color: var(--honey-ink); }
.nav a[aria-current="page"]::after {
    content: ""; margin-left: auto;
    width: 9px; height: 10px; background: var(--honey);
    clip-path: polygon(50% 0, 100% 25%, 100% 75%, 50% 100%, 0 75%, 0 25%);
}

.sidebar-foot { border-top: 1px solid var(--line); padding: 14px 4px 0; margin-top: 16px; }
.me { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.me-text { display: flex; flex-direction: column; min-width: 0; }
.me-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-role { font-size: 13px; color: var(--muted); }
.signout {
    display: flex; align-items: center; gap: 10px; margin-top: 10px;
    padding: 9px 12px; border-radius: var(--r-md);
    color: var(--ink-2); text-decoration: none; font-size: 15px; font-weight: 500;
}
.signout:hover { background: var(--out-wash); color: var(--out); }

.avatar {
    width: 34px; height: 34px; border-radius: 50%; flex: none;
    display: grid; place-items: center;
    background: #E7E8DF; color: var(--ink-2);
    font-weight: 700; font-size: 14px;
}
.avatar-honey { background: var(--honey-wash); color: var(--honey-ink); }

.topbar { display: none; }
.scrim { display: none; }

.main { min-width: 0; padding: 30px 40px 72px; }
.main:focus { outline: none; box-shadow: none; }
.main-inner { max-width: 1180px; margin: 0 auto; }
.stack > * + * { margin-top: 20px; }
.stack > .page-head + * { margin-top: 0; }

/* ---------------- Page heading ---------------- */

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 16px 24px;
    padding-bottom: 24px;
}
.page-title { min-width: 0; }
.page-head h1 {
    font-family: var(--font-display);
    font-size: 32px; line-height: 1.1; font-weight: 650; letter-spacing: -.02em;
}
.lede { margin-top: 6px; color: var(--muted); font-size: 16px; max-width: 64ch; }
.crumb {
    display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px;
    color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
}
.crumb .icon { width: 16px; height: 16px; }
.crumb:hover { color: var(--ink); }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- Panels ---------------- */

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    min-width: 0;
}
.panel-head {
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
    gap: 8px 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.panel-head .meta { color: var(--muted); font-size: 14px; }
.panel-body { padding: 20px; }
.panel > .table-wrap:last-child { border-radius: 0 0 var(--r-lg) var(--r-lg); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-aside { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }

/* Entry panels: the honey surface where things get recorded */
.entry {
    background: var(--honey-wash);
    border: 1px solid var(--honey-line);
    border-radius: var(--r-lg);
    padding: 18px 20px 20px;
    min-width: 0;
}
.entry-head {
    display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap;
    gap: 4px 16px; margin-bottom: 16px;
}
.entry-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.entry-head p { color: var(--ink-2); font-size: 14px; }

/* ---------------- Forms ---------------- */

.form-grid {
    display: grid; gap: 14px;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    align-items: end;
}
.form-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-stack > * + * { margin-top: 16px; }
.choice-group { display: flex; flex-direction: column; gap: 6px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.span-all { grid-column: 1 / -1; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--ink-2); }
.hint { font-size: 13px; color: var(--muted); }
.optional { font-weight: 400; color: var(--muted); }

.input {
    width: 100%; height: 44px; padding: 0 12px;
    font: inherit; font-size: 16px; color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-md);
    transition: border-color .15s, box-shadow .15s;
}
.input::placeholder { color: #9A958A; }
.input:hover { border-color: #ADAEA3; }
.input:focus { outline: none; border-color: var(--ink); box-shadow: var(--focus); }
textarea.input { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.45; }
select.input {
    appearance: none; -webkit-appearance: none;
    padding-right: 38px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234F4A40' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
input[type="date"].input { padding-right: 8px; }
input[type="number"].input { -moz-appearance: textfield; appearance: textfield; }
input[type="number"].input::-webkit-inner-spin-button,
input[type="number"].input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="file"].input { height: auto; padding: 10px 12px; font-size: 14px; }
input[type="file"].input::file-selector-button {
    font: inherit; font-weight: 600; font-size: 14px;
    margin-right: 12px; padding: 6px 12px;
    border: 1px solid var(--line-strong); border-radius: var(--r-sm);
    background: var(--surface-2); color: var(--ink); cursor: pointer;
}

.input-money { position: relative; }
.input-money > span {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--muted); font-weight: 600; pointer-events: none;
}
.input-money .input { padding-left: 30px; font-variant-numeric: tabular-nums; font-weight: 600; }

.input-icon { position: relative; }
.input-icon .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.input-icon .input { padding-left: 38px; }

.password-wrap { position: relative; }
.password-wrap .input { padding-right: 76px; }
.password-toggle {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    height: 32px; padding: 0 10px; border: 0; border-radius: var(--r-sm);
    background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer;
}
.password-toggle:hover { background: var(--surface-2); }

.fixed-date {
    height: 44px; display: flex; align-items: center; gap: 8px;
    padding: 0 12px; border-radius: var(--r-md);
    background: rgba(255, 255, 255, .55);
    border: 1px dashed #D6B868;
    color: var(--ink-2); font-weight: 600; font-size: 15px;
}
.fixed-date .icon { width: 16px; height: 16px; color: var(--honey-ink); }

.segmented {
    display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
    padding: 4px; background: #fff;
    border: 1px solid var(--line-strong); border-radius: var(--r-md);
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
    display: flex; align-items: center; justify-content: center; text-align: center;
    min-height: 36px; padding: 4px 8px; border-radius: var(--r-sm);
    font-size: 14px; font-weight: 600; color: var(--ink-2); cursor: pointer;
}
.segmented label:hover { background: var(--surface-2); }
.segmented input:checked + label { background: var(--ink); color: #fff; }
.segmented input:focus-visible + label { box-shadow: var(--focus); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { flex: 1 1 170px; max-width: 260px; }
.filters .field-wide { max-width: 340px; flex-basis: 240px; }

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 44px; padding: 0 18px;
    border: 1px solid transparent; border-radius: var(--r-md);
    font-size: 15px; font-weight: 600; line-height: 1;
    text-decoration: none; white-space: nowrap; cursor: pointer;
    transition: background-color .15s, border-color .15s, color .15s;
}
.btn .icon { width: 17px; height: 17px; }
.btn-primary { background: var(--honey); border-color: var(--honey-edge); color: var(--ink); }
.btn-primary:hover { background: var(--honey-hover); }
.btn-quiet { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-quiet:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--surface); border-color: var(--out-line); color: var(--out); }
.btn-danger:hover { background: var(--out-wash); }
.btn-danger-solid { background: var(--out); border-color: var(--out); color: #fff; }
.btn-danger-solid:hover { background: #962C22; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-sm .icon { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: rgba(35, 28, 18, .06); color: var(--ink); }

.icon-btn {
    display: inline-grid; place-items: center;
    width: 40px; height: 40px; border-radius: var(--r-md);
    border: 1px solid transparent; background: transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { background: rgba(35, 28, 18, .06); }
.icon-btn .icon { width: 20px; height: 20px; }

.link { color: var(--honey-ink); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

.inline-form { display: inline; margin: 0; }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }

.ledger { width: 100%; border-collapse: collapse; font-size: 15px; }
.ledger th {
    padding: 11px 16px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    color: var(--muted); font-size: 13px; font-weight: 600; text-align: left; white-space: nowrap;
}
.ledger td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ledger tbody tr:last-child td { border-bottom: 0; }
.ledger tbody tr:not(.empty-row):hover { background: #FBFBF7; }
.ledger .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ledger .nowrap { white-space: nowrap; }
.ledger .actions { text-align: right; white-space: nowrap; }
.ledger tfoot td {
    padding: 13px 16px; background: var(--surface-2);
    border-top: 1px solid var(--line); font-weight: 700;
}
.panel > .table-wrap:first-child .ledger th:first-child { border-top-left-radius: var(--r-lg); }
.panel > .table-wrap:first-child .ledger th:last-child { border-top-right-radius: var(--r-lg); }

.cell-main { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: 13px; color: var(--muted); margin-top: 1px; }
.cell-person { display: flex; align-items: center; gap: 10px; }
.cell-person .avatar { width: 30px; height: 30px; font-size: 13px; }
.muted { color: var(--muted); }

.amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt-in { color: var(--in); }
.amt-out { color: var(--out); }

.row-actions { display: inline-flex; gap: 6px; justify-content: flex-end; }

.empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { color: var(--ink); font-size: 16px; font-weight: 600; }

/* ---------------- Tags ---------------- */

.tag {
    display: inline-flex; align-items: center; gap: 6px;
    height: 26px; padding: 0 10px; border-radius: 999px;
    background: #EDEEE6; color: var(--ink-2);
    font-size: 13px; font-weight: 500; white-space: nowrap;
}
.tag .dot { width: 8px; height: 8px; border-radius: 2px; }
.tag-honey { background: var(--honey-wash); color: var(--honey-ink); }
.tag-in { background: var(--in-wash); color: var(--in); }
.tag-out { background: var(--out-wash); color: var(--out); }
.tag-ink { background: var(--ink); color: #fff; }

/* ---------------- Notices ---------------- */

.notice {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border: 1px solid; border-radius: var(--r-md);
    font-size: 15px;
}
.notice > .icon { margin-top: 2px; }
.notice > span { flex: 1; }
.notice-success { background: var(--in-wash); border-color: var(--in-line); color: #14532F; }
.notice-error { background: var(--out-wash); border-color: var(--out-line); color: #7E2219; }
.notice-info { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.notice-info > .icon { color: var(--honey-ink); }
.notice-close {
    margin: -4px -6px -4px 0; width: 30px; height: 30px; display: grid; place-items: center;
    border: 0; background: transparent; color: inherit; border-radius: var(--r-sm); cursor: pointer; opacity: .7;
}
.notice-close:hover { opacity: 1; background: rgba(0, 0, 0, .05); }
.notice-close .icon { width: 16px; height: 16px; }

/* ---------------- Figures ---------------- */

.figures {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--r-lg);
    overflow: hidden;
}
/* Dividers drawn outside each cell; the outer ones are clipped by overflow. */
.figure { padding: 16px 20px; min-width: 0; box-shadow: -1px 0 0 var(--line), 0 -1px 0 var(--line); }
.figure-label { color: var(--muted); font-size: 14px; }
.figure-value {
    margin-top: 4px;
    font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -.01em;
    font-variant-numeric: tabular-nums; white-space: nowrap;
}
/* Long amounts shrink to fit their cell instead of wrapping */
.figures .figure { container-type: inline-size; }
.figures .figure-value { font-size: clamp(17px, 11.5cqi, 26px); }
.figure-note { margin-top: 2px; font-size: 13px; color: var(--muted); }

/* ---------------- Overview ---------------- */

.today { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr); gap: 20px; align-items: stretch; }
.today-main { padding: 24px 24px 22px; }
.today-label { color: var(--ink-2); font-size: 15px; font-weight: 500; }
.big {
    margin-top: 6px;
    font-family: var(--font-display);
    font-size: clamp(38px, 5.2vw, 56px); font-weight: 650; letter-spacing: -.025em; line-height: 1;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}
.splitbar {
    display: flex; gap: 3px; height: 12px; margin: 22px 0 16px;
    border-radius: 999px; overflow: hidden; background: #ECEDE5;
}
.splitbar span { display: block; height: 100%; min-width: 4px; }
.legend { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px 24px; }
.legend li { display: grid; grid-template-columns: 10px minmax(0, 1fr); column-gap: 8px; row-gap: 2px; align-items: center; font-size: 14px; min-width: 0; }
.legend .dot { width: 10px; height: 10px; border-radius: 3px; }
.legend .name { color: var(--ink-2); }
.legend .share { color: var(--muted); margin-left: 6px; }
.legend .val { grid-column: 2; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; }
.today-foot { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.today-foot > div { padding: 14px 24px; }
.today-foot > div + div { border-left: 1px solid var(--line); }

.balances { display: flex; flex-direction: column; }
.balance { padding: 20px 24px; flex: 1; }
.balance + .balance { border-top: 1px solid var(--line); }
.balance .figure-value { font-size: 30px; }
.balance .link { display: inline-block; margin-top: 8px; font-size: 14px; }

.quick { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- Ledger header (customer/vendor) ---------------- */

.account {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: center;
    padding: 22px 24px;
}
.account-who { display: flex; align-items: center; gap: 16px; min-width: 0; }
.account-who .avatar { width: 52px; height: 52px; font-size: 22px; font-family: var(--font-display); }
.account-meta { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 4px; color: var(--muted); font-size: 14px; }
.account-meta span { display: inline-flex; align-items: center; gap: 6px; }
.account-meta .icon { width: 15px; height: 15px; }
.account-balance { text-align: right; }
.account-balance .figure-value { font-size: 32px; }

/* ---------------- Dialogs ---------------- */

dialog.modal {
    border: 0; padding: 0;
    width: min(460px, calc(100vw - 32px));
    border-radius: var(--r-lg);
    background: var(--surface); color: var(--ink);
    box-shadow: 0 24px 64px rgba(35, 28, 18, .28);
}
dialog.modal::backdrop { background: rgba(35, 28, 18, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-title { font-family: var(--font-display); font-size: 20px; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-text { margin-top: 8px; color: var(--ink-2); }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.list-plain li:last-child { border-bottom: 0; }

/* ---------------- Sign-in & message pages ---------------- */

.auth-body { background: var(--bg); }
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-mark { width: 52px; height: 52px; }
.auth-card h1 { margin-top: 22px; font-family: var(--font-display); font-size: 34px; line-height: 1.1; font-weight: 650; letter-spacing: -.02em; }
.auth-card .lede { margin-top: 8px; }
.auth-form { margin-top: 28px; }
.auth-foot { margin-top: 22px; font-size: 14px; color: var(--muted); }
.message-card .btn { margin-top: 24px; }

/* ---------------- Responsive ---------------- */

@media (max-width: 1100px) {
    .form-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-aside { grid-template-columns: minmax(0, 1fr); }
    .today { grid-template-columns: minmax(0, 1fr); }
    .balances { flex-direction: row; }
    .balance + .balance { border-top: 0; border-left: 1px solid var(--line); }
}

@media (max-width: 960px) {
    .app { grid-template-columns: minmax(0, 1fr); }

    .topbar {
        position: sticky; top: 0; z-index: 40;
        display: flex; align-items: center; justify-content: space-between;
        height: 60px; padding: 0 10px 0 16px;
        background: rgba(242, 243, 238, .94);
        backdrop-filter: blur(8px);
        border-bottom: 1px solid var(--line);
    }
    .topbar .brand { font-size: 18px; }
    .topbar .brand-mark { width: 26px; height: 26px; }

    .sidebar {
        position: fixed; inset: 0 auto 0 0; z-index: 70;
        width: min(86vw, 300px); height: 100%;
        background: var(--bg);
        box-shadow: 0 0 0 1px var(--line), 24px 0 48px rgba(35, 28, 18, .18);
        transform: translateX(-104%);
        transition: transform .22s ease;
        visibility: hidden;
    }
    body.nav-open .sidebar { transform: none; visibility: visible; }
    .icon-btn.sidebar-close { display: inline-grid; }
    .scrim { position: fixed; inset: 0; z-index: 60; background: rgba(35, 28, 18, .4); }
    body.nav-open .scrim { display: block; }

    .main { padding: 20px 16px 56px; }
    .page-head { padding-bottom: 18px; }
    .page-head h1 { font-size: 27px; }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    .balances { flex-direction: column; }
    .balance + .balance { border-left: 0; border-top: 1px solid var(--line); }
    .today-foot { grid-template-columns: minmax(0, 1fr); }
    .today-foot > div + div { border-left: 0; border-top: 1px solid var(--line); }
    .today-main { padding: 20px; }
    .today-foot > div, .balance { padding: 14px 20px; }
    .account { grid-template-columns: minmax(0, 1fr); }
    .account-balance { text-align: left; }
    .form-row-2, .form-grid-4 { grid-template-columns: minmax(0, 1fr); }
    .figures { grid-template-columns: minmax(0, 1fr); }
    .figures .figure { container-type: normal; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; padding: 12px 16px; }
    .figures .figure-value { margin-top: 0; font-size: 20px; text-align: right; }
    .figures .figure-note { width: 100%; margin-top: 0; }
    .filters .field { max-width: none; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1 1 auto; }

    /* Tables become stacked rows on phones */
    .ledger.stack-sm thead { display: none; }
    .ledger.stack-sm, .ledger.stack-sm tbody, .ledger.stack-sm tfoot, .ledger.stack-sm tr, .ledger.stack-sm td { display: block; width: 100%; }
    .ledger.stack-sm tbody tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .ledger.stack-sm tbody tr:last-child { border-bottom: 0; }
    .ledger.stack-sm td {
        display: flex; justify-content: space-between; align-items: center; gap: 16px;
        padding: 3px 0; border: 0; text-align: right;
    }
    .ledger.stack-sm td::before { content: attr(data-label); color: var(--muted); font-size: 14px; text-align: left; flex: none; }
    .ledger.stack-sm td.lead { display: block; text-align: left; padding-bottom: 6px; }
    .ledger.stack-sm td.lead::before, .ledger.stack-sm td.actions::before, .ledger.stack-sm .empty-row td::before { content: none; }
    .ledger.stack-sm td.actions { justify-content: flex-start; padding-top: 8px; }
    .ledger.stack-sm .empty-row td { display: block; }
    .ledger.stack-sm tfoot tr { padding: 12px 16px; background: var(--surface-2); border-top: 1px solid var(--line); border-radius: 0 0 var(--r-lg) var(--r-lg); }
    .ledger.stack-sm tfoot td { padding: 3px 0; border: 0; background: none; }
}

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

/* ---------------- Print (reports, ledgers) ---------------- */

@media print {
    body { background: #fff; font-size: 12px; }
    .sidebar, .topbar, .scrim, .no-print, .notice, .skip-link { display: none !important; }
    .app { display: block; }
    .main { padding: 0; }
    .main-inner { max-width: none; }
    .panel, .figures { border-color: #bbb; break-inside: avoid; }
    .ledger th { background: #f2f2f2; }
    .grid-2 { grid-template-columns: 1fr 1fr; }
    a { text-decoration: none; }
}

/* ---------------- Report bars & misc ---------------- */

.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.bars-row { display: flex; justify-content: space-between; gap: 12px; font-size: 15px; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 999px; background: #ECEDE5; overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: inherit; }
.scroll-y { max-height: 420px; overflow-y: auto; }
.scroll-y .ledger thead th { position: sticky; top: 0; z-index: 1; }

.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

@media print {
    .scroll-y { max-height: none; overflow: visible; }
}
