/* Moolah — ledger-first styling. No frameworks; money tables want tabular numerals.
   Theming: CSS variables, light default + [data-theme=dark] override; the inline
   script in _Layout sets data-theme from localStorage / prefers-color-scheme. */
:root {
    color-scheme: light;
    --bg: #f4f6f7;
    --ink: #1d232a;
    --muted: #64707c;
    --line: #dfe4e8;
    --card: #ffffff;
    --thead: #eef2f4;
    --accent: #0d7a63;
    --accent-soft: #e2f3ee;
    --amber: #b45309;
    --amber-soft: #fdf3e4;
    --good: #15803d;
    --bad: #b42318;
    --bad-soft: #fbeae8;
    --proj: #7c8894;
    --proj-soft: #f6f1e7;
    --flash: #e7f5ee;
    --coin: #0d7a63;
    --coin-ring: #0a5c4b;
    --row-hover: #f2f7f6;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --bg: #0f141a;
    --ink: #e7edf2;
    --muted: #94a3b2;
    --line: #2a3542;
    --card: #161e27;
    --thead: #1c2632;
    --accent: #3fc9ab;
    --accent-soft: #10322c;
    --amber: #e0a35c;
    --amber-soft: #2b2418;
    --good: #5fd08a;
    --bad: #f0836f;
    --bad-soft: #33201d;
    --proj: #8496a8;
    --proj-soft: #1d242c;
    --flash: #14302a;
    --coin: #17876e;
    --coin-ring: #3fc9ab;
    --row-hover: #1a2530;
}
* { box-sizing: border-box; }
html { font-size: 15px; }
body {
    margin: 0; background: var(--bg); color: var(--ink);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.45;
}
main { max-width: 1100px; margin: 0 auto; padding: 1.25rem 1.5rem 3rem; }
h1 { font-size: 1.5rem; margin: .25rem 0 .5rem; }
h2 { font-size: 1.1rem; margin: 1.75rem 0 .5rem; }
a { color: var(--accent); }
code { font-family: ui-monospace, "Cascadia Mono", monospace; font-size: .85rem;
       background: var(--thead); padding: .05rem .3rem; border-radius: 4px; }

/* top bar */
.topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: .6rem 1.5rem; border-bottom: 1px solid var(--line);
    background: var(--card);
}
.brand { display: flex; align-items: center; gap: .55rem; text-decoration: none;
         color: var(--ink); font-weight: 700; font-size: 1.15rem; }
.brand-mark { flex: none; }
.coin { fill: var(--coin); }
.coin-ring { fill: none; stroke: var(--coin-ring); stroke-width: 1.6; }
.coin-m { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.brand-word { display: flex; flex-direction: column; line-height: 1.1; }
.brand-sub { font-weight: 400; font-size: .7rem; color: var(--muted); }
.topbar nav { display: flex; gap: 1rem; margin-left: .5rem; }
.topbar nav a { text-decoration: none; color: var(--muted); padding: .3rem 0;
                border-bottom: 2px solid transparent; }
.topbar nav a:hover { color: var(--ink); }
.topbar nav a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* Config nav group (M5): <details>/<summary>, no JS. The server adds
   open="" when a sub-item is the active page, so the highlight is visible. */
.nav-group { position: relative; display: flex; align-items: center; }
.nav-group > summary { list-style: none; cursor: pointer; color: var(--muted);
    padding: .3rem 0; border-bottom: 2px solid transparent; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--ink); }
.nav-group > summary.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.nav-group .caret { font-size: .7em; }
.nav-group .sub {
    position: absolute; top: calc(100% + .5rem); left: 0; z-index: 40;
    display: flex; flex-direction: column; gap: .1rem; min-width: 170px;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .18); padding: .45rem .9rem;
}
.nav-group .sub a { text-decoration: none; color: var(--muted);
    padding: .35rem 0; border-bottom: 1px solid transparent; white-space: nowrap; }
.nav-group .sub a:hover { color: var(--ink); }
.nav-group .sub a.on { color: var(--accent); font-weight: 600; }
.theme-btn { margin-left: auto; background: transparent; border: 1px solid var(--line);
             font-size: 1rem; line-height: 1; padding: .3rem .55rem; border-radius: 8px; }
.theme-sun { display: none; }
.theme-moon { display: inline; }
:root[data-theme="dark"] .theme-sun { display: inline; }
:root[data-theme="dark"] .theme-moon { display: none; }
footer { max-width: 1100px; margin: 0 auto; padding: 1rem 1.5rem;
         color: var(--muted); font-size: .8rem; }

/* page head */
.page-head { display: flex; justify-content: space-between; align-items: center;
             flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.acct-picker select { font-size: 1.05rem; font-weight: 600; padding: .3rem .5rem;
                      border: 1px solid var(--line); border-radius: 6px;
                      background: var(--card); color: var(--ink); }
.horizon-pick { display: flex; gap: .4rem; align-items: center; color: var(--muted); }
.chip { padding: .25rem .6rem; border: 1px solid var(--line); border-radius: 999px;
        text-decoration: none; color: var(--muted); font-size: .85rem; background: var(--card); }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
/* M14 regroup (2026-11-25, Troy): the projection-related chips — Projections,
   the View-ahead horizon select, Plans — travel as ONE cluster in the
   register's head-chips row, set off from the neighbours by a thin rule so
   the row reads as groups instead of a uniform strip. horizon-select is
   styled like a chip so the cluster looks like one control family. */
.head-chips .chip-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.head-chips .chip-group::before { content: ""; width: 1px; height: 1.05rem;
    background: var(--muted); opacity: .45; margin-right: .35rem; }
/* Export CSV is a utility, not part of the cluster: pin it to the row's
   right edge so it lines up with the table's right gutter and can never
   sit between the projection controls (Troy, M14). */
.head-chips > a.chip:last-child { margin-left: auto; }
.horizon-select { font: inherit; font-size: .85rem; padding: .22rem .5rem;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--card); color: var(--ink); cursor: pointer; }
.horizon-select:hover { border-color: var(--accent); color: var(--accent); }

/* summary cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
         gap: .75rem; margin-bottom: 1rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
        padding: .8rem 1rem; border-top: 3px solid var(--accent);
        margin-bottom: .9rem; }
/* Dashboard stat cards live in the .cards grid — its gap owns their spacing,
   so the standalone-card margin must not inflate grid rows. */
.cards .card { margin-bottom: 0; }
.card-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
              color: var(--muted); }
.card-num { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.card-note { font-size: .75rem; color: var(--muted); }
.danger-card { border-color: var(--bad); border-top-color: var(--bad); background: var(--bad-soft); }

/* tables */
table { border-collapse: collapse; width: 100%; background: var(--card);
        border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
        font-variant-numeric: tabular-nums; }
th, td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); text-align: left;
         vertical-align: baseline; }
th { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); background: var(--thead); }
tbody tr:hover td { background: var(--row-hover); }
td.num, th.num { text-align: right; font-family: ui-monospace, "Cascadia Mono", monospace; }
tr:last-child td { border-bottom: none; }
.pos { color: var(--good); }
.neg, .bad { color: var(--bad); }
.good { color: var(--good); }
tr.proj td { color: var(--proj); font-style: italic; }
tr.proj td { background: var(--proj-soft); }
tr.proj td:first-child { border-left: 3px dashed var(--amber); }
/* M1.6 planned entries: the user's own future rows — real data, so they read
   closer to solid than projected rows, but still visually "not yet happened". */
tr.planned td { background: var(--proj-soft); }
tr.planned .name-text { color: var(--muted); font-style: italic; }
tr.planned td:first-child { border-left: 3px dotted var(--accent); }
.plan-chip {
    display: inline-block; margin-left: .45rem; padding: 0 .4rem;
    border: 1px solid var(--accent); border-radius: 999px;
    color: var(--accent); background: var(--accent-soft);
    font-size: .68rem; font-style: normal; line-height: 1.5; vertical-align: baseline;
}
/* M3 transfer leg: amber pill, deliberately distinct from the accent category
   chip — it marks money moving between ledgers, not a spending category. */
.transfer-chip {
    display: inline-block; margin-left: .45rem; padding: 0 .4rem;
    border: 1px solid var(--amber); border-radius: 999px;
    color: var(--amber); background: color-mix(in srgb, var(--amber) 12%, transparent);
    font-size: .68rem; font-style: normal; line-height: 1.5; vertical-align: baseline;
}
button.pair { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 5px; }
button.pair:hover { color: var(--amber); }
.plan-toggle {
    display: inline-flex; align-items: center; gap: .3rem;
    color: var(--muted); font-size: .82rem; white-space: nowrap; cursor: pointer;
}
tr.over td { background: var(--bad-soft); }
tr.paused td { opacity: .55; }
.muted { color: var(--muted); font-weight: 400; font-size: .85rem; }
.desc { color: var(--muted); font-size: .85rem; }
.why { display: block; color: var(--proj); font-size: .74rem; font-style: italic; }
.mark { text-align: center; }
.proj-dot { color: var(--amber); }

/* ledger pager */
.pager { display: flex; align-items: center; flex-wrap: wrap; gap: .6rem;
         margin: .6rem 0; }
.pager-bottom { border-top: 1px solid var(--line); padding-top: .8rem;
                margin-top: 1.1rem; }
.pager-btn { text-decoration: none; color: var(--ink); background: var(--card);
             border: 1px solid var(--line); border-radius: 8px; padding: .3rem .7rem; }
.pager-btn:hover { border-color: var(--accent); color: var(--accent); }
.pager-btn.off { color: var(--muted); opacity: .45; pointer-events: none; }
.pager-info { color: var(--muted); font-size: .85rem; margin-inline: .3rem; }
.pager-size { display: flex; align-items: center; gap: .35rem; color: var(--muted);
              font-size: .85rem; }
/* M14 (2026-11-25): rows/page is a display setting, not navigation — pin it
   to the row's right edge (under Export CSV) so both control rows share the
   table's right gutter instead of ending ragged mid-slack. */
.pager .pager-size { margin-left: auto; }
.pager-size select { font: inherit; padding: .25rem .4rem; border: 1px solid var(--line);
                     border-radius: 6px; background: var(--card); color: var(--ink); }
/* M14 register filter (payee/notes text + category) lives in the pager row.
   The search box grows to soak up the row's slack (capped so a very wide
   screen doesn't get a runway), which also pushes rows/page to the right
   gutter where it lines up with the table. */
.pager .filter-q { flex: 1 1 15ch; max-width: 26ch; width: 15ch; min-width: 9ch; padding: .3rem .5rem;
    font: inherit; font-size: .9rem; border: 1px solid var(--line);
    border-radius: 6px; background: var(--card); color: var(--ink); }
.pager .filter-q:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.pager .filter-cat { max-width: 18ch; font: inherit; font-size: .9rem;
    padding: .3rem .4rem; border: 1px solid var(--line);
    border-radius: 6px; background: var(--card); color: var(--ink); }

/* buttons + inputs */
button { font: inherit; padding: .3rem .7rem; border: 1px solid var(--line);
         border-radius: 6px; background: var(--card); color: var(--ink); cursor: pointer; }
button:hover { border-color: var(--accent); color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.1); color: #fff; }
button.del { color: var(--bad); }
button.del.confirm { border: 1px solid var(--bad); border-radius: 6px; font-weight: 700; color: var(--bad); background: none; }
.toggle { min-width: 2rem; }
.toggle.on { background: var(--flash); border-color: var(--good); color: var(--good); }
.ops form { display: inline-block; }

/* add-row form */
.add-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .75rem 0; }
.add-row input, .add-row select, .sched-add input, .sched-add select,
.import-commit input, .import-commit select, .mine select,
.edit-form input, .edit-form select {
    font: inherit; padding: .35rem .5rem; border: 1px solid var(--line); border-radius: 6px;
    background: var(--card); color: var(--ink);
}
.add-row input.amount { width: 7rem; }
.add-row input.small { width: 6rem; }
.add-row input[name=FCategory] { width: 9rem; }
.add-row input[name=FDescription] { flex: 1 1 12rem; }

/* Add-row modal: native <dialog> gives backdrop, ESC, and focus-trap free.
   The grid reflow lives at ALL widths: 4 columns inside a 560px dialog, and
   at narrow widths the dialog itself shrinks to 92vw so the same placement
   rules become the mobile stack. minmax(0,1fr) + min-width:0 are
   load-bearing: default 1fr tracks floor at the inputs' intrinsic size and
   push the last column off-screen. The width overrides must match the base
   rules' specificity (.add-row input.amount) or the fixed widths win. */
.add-btn { background: var(--accent); color: var(--bg); border: none;
    border-radius: 8px; padding: .4rem .9rem; font-weight: 600;
    font-size: .85rem; min-height: 40px; cursor: pointer; }
.add-btn:hover { filter: brightness(1.08); }
/* M14 floating "Add transaction" button (register only): fixed to the bottom
   right of the viewport, same accent green as .add-btn. Above the nav drawer
   (40) and row menus (30); dialogs live in the top layer so they still cover
   it. main gets bottom breathing room so the pager never hides underneath. */
.fab { position: fixed; right: 1.1rem; bottom: 1.1rem; z-index: 45;
    width: 56px; height: 56px; padding: 0; border: none; border-radius: 50%;
    background: var(--accent); color: var(--bg); font-size: 1.7rem; line-height: 1;
    font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .30); }
.fab:hover { filter: brightness(1.1); color: var(--bg); }
main { padding-bottom: 5rem; }
.nav-btn { display: none; }
.add-dialog { width: min(92vw, 560px); padding: 0; border: 1px solid var(--line);
    border-radius: 12px; background: var(--card); color: var(--ink);
    box-shadow: 0 18px 48px rgba(0, 0, 0, .35); }
.add-dialog::backdrop { background: rgba(10, 14, 18, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between;
    padding: .6rem 1rem; border-bottom: 1px solid var(--line); }
.dlg-head h3 { margin: 0; font-size: 1rem; }
.dlg-close { background: none; border: none; color: var(--muted);
    font-size: 1.05rem; min-width: 40px; min-height: 40px; cursor: pointer; }
.add-dialog .add-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: .5rem; padding: 1rem; margin: 0; }
.add-dialog .add-row > * { width: 100%; min-width: 0; min-height: 40px; }
.add-dialog .add-row datalist { display: none; }
.add-dialog .add-row input.amount, .add-dialog .add-row input.small,
.add-dialog .add-row input[name=FCategory] { width: 100%; }
/* M14 refinement (Troy): payee gets the FULL row (long names were cramped at
   span-2), description full row below it, amount + check # side by side after
   description. Date/direction/category share the top row. FToAcct (transfer
   only) stays auto-placed — it lands in the first free cell, same as before. */
.add-dialog .add-row input[name=FDate] { grid-column: 1 / span 2; grid-row: 1; }
.add-dialog .add-row select[name=FDirection] { grid-column: 3; grid-row: 1; font-size: .82rem; padding: .3rem .25rem; }
.add-dialog .add-row input[name=FCategory] { grid-column: 4; grid-row: 1; }
.add-dialog .add-row input[name=FPayee] { grid-column: 1 / span 4; grid-row: 2; }
.add-dialog .add-row input[name=FDescription] { grid-column: 1 / span 4; grid-row: 3; }
.add-dialog .add-row input[name=FAmount] { grid-column: 1; grid-row: 4; }
.add-dialog .add-row input[name=FReference] { grid-column: 2; grid-row: 4; }
.add-dialog .add-row .plan-toggle { grid-column: 3; grid-row: 4; align-self: center; }
.add-dialog .add-row button[type=submit] { grid-column: 4; grid-row: 4; white-space: nowrap; }

/* Narrow dialog: 2-column reflow so placeholders and the submit label stay
   legible on phones — the 4-col grid floors out below ~520px dialog width. */
@media (max-width: 520px) {
    .add-dialog .add-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .add-dialog .add-row input[name=FDate] { grid-column: 1; grid-row: 1; }
    .add-dialog .add-row select[name=FDirection] { grid-column: 2; grid-row: 1; }
    .add-dialog .add-row input[name=FPayee] { grid-column: 1 / span 2; grid-row: 2; }
    .add-dialog .add-row input[name=FDescription] { grid-column: 1 / span 2; grid-row: 3; }
    .add-dialog .add-row input[name=FAmount] { grid-column: 1; grid-row: 4; }
    .add-dialog .add-row input[name=FReference] { grid-column: 2; grid-row: 4; }
    .add-dialog .add-row input[name=FCategory] { grid-column: 1; grid-row: 5; }
    .add-dialog .add-row .plan-toggle { grid-column: 2; grid-row: 5; }
    .add-dialog .add-row button[type=submit] { grid-column: 1 / span 2; grid-row: 6; }
}

/* schedules: inline edit row */
tr.sched-edit td { background: var(--thead); padding: 0 .6rem; border-bottom: 1px solid var(--line); }
tr.sched-edit details summary { cursor: pointer; color: var(--muted); font-size: .85rem;
                                padding: .35rem 0; }
.edit-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .5rem 0; }
.edit-form .amount-input { width: 7rem; }
.edit-form .rrule-input { flex: 1 1 18rem; font-family: ui-monospace, "Cascadia Mono", monospace;
                          font-size: .85rem; }
.edit-help { color: var(--muted); font-size: .78rem; padding-bottom: .5rem; }

/* flash + errors */
.flash { background: var(--flash); border: 1px solid var(--accent); border-radius: 8px;
         padding: .5rem .8rem; }
.flash.error { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.warn-list { color: var(--muted); font-size: .85rem; }

/* import */
.import-upload { display: flex; gap: .75rem; align-items: center; margin: 1rem 0; }
.import-upload input[type=file] { padding: .4rem; border: 1px dashed var(--line);
                                  border-radius: 8px; background: var(--card); }
.stat-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 1rem; }
.stat-list li { background: var(--card); border: 1px solid var(--line);
                border-radius: 8px; padding: .4rem .8rem; font-size: .9rem; }
table.compact th, table.compact td { padding: .25rem .5rem; font-size: .85rem; }

.empty { text-align: center; padding: 3rem 0; color: var(--muted); }
@media (max-width: 700px) {
    main { padding: 1rem .75rem 5rem; }
    .topbar { flex-wrap: wrap; }
}

/* --- round 3: head chips, category tags, inline editing, adjustments --- */
.head-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.register .head-chips { margin: .6rem 0; }
.chip-label { font-size: 12px; color: var(--muted); margin-right: 2px; }
.page-title { font-size: 22px; margin: 4px 0; }
.desc.intro { max-width: 720px; margin: 6px 0 14px; }

span.cat {
    display: inline-block; margin-left: 6px; padding: 1px 7px;
    border-radius: 9px; font-size: 10.5px; font-weight: 600;
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
}
.name-text { font-weight: 600; }

button.edit { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 5px; }
button.edit:hover { color: var(--accent); }

/* M16-B: "convert to plan" on projected rows — same shape as .edit. */
button.convert { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 5px; }
button.convert:hover { color: var(--accent); }
button.skip { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 5px; }
button.skip:hover { color: var(--bad); }
.skip-chip { display: inline-block; margin: .25rem .4rem .25rem 0; padding: .15rem .5rem; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; }
.skip-chip button { margin-left: .35rem; }

/* M14 row-action overflow menu: the register renders BOTH the inline button
   set (.row-inline) and this ⋯ <details> menu; the ~700px media query below
   picks which is visible. Opening is zero-JS (native details); ledger.js only
   closes it (click-outside / one-open / item-click, with the two-step delete's
   arm button .keep-menu exempt). Hidden by default = wide windows show inline. */
.row-menu { display: none; position: relative; }
.row-menu > summary { list-style: none; cursor: pointer; user-select: none;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: 15px; line-height: 1;
    padding: 2px 8px; border: 1px solid transparent; border-radius: 6px; }
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu > summary:hover, .row-menu[open] > summary {
    color: var(--accent); border-color: var(--line); background: var(--card); }
.row-menu-items { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30;
    display: flex; flex-direction: column; gap: .1rem; min-width: 160px;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .18); padding: .35rem; }
.row-menu-items button { display: flex; align-items: center; gap: .5rem; width: 100%;
    border: none; background: none; border-radius: 6px; padding: .5rem .6rem;
    text-align: left; color: var(--ink); font-size: .9rem; }
.row-menu-items button:hover { border-color: transparent;
    background: color-mix(in srgb, var(--accent) 10%, transparent); }
.row-menu-items button.edit:hover { color: var(--accent); }
.row-menu-items button.convert:hover { color: var(--accent); }
.row-menu-items button.pair:hover { color: var(--amber); }
.row-menu-items button.del { color: var(--bad); }
.row-menu-items button.del:hover { background: var(--bad-soft); color: var(--bad); }
.row-menu-items button.del.confirm { border: none; font-weight: 700; }

/* M14: compact (⋯ menu) form for small windows; inline buttons above 700px. */
@media (max-width: 700px) {
    table.ledger .row-inline { display: none; }
    table.ledger .row-menu { display: block; }
}

tr.editing { background: color-mix(in srgb, var(--accent) 8%, var(--bg)); }
tr.editing td { padding: 4px 6px; }
tr.editing input, tr.editing select { font: inherit; font-size: 13px; padding: 3px 6px; border: 1px solid var(--line); border-radius: 5px; background: var(--bg); color: var(--ink); }
tr.editing .e-payee { width: 34ch; }
tr.editing .e-desc { width: 20ch; }
/* M14 quick win (Troy): 8ch floored at ~43px content — "3024.01" clipped its
   tail. 10ch covers 9-glyph amounts ("123456.78"); +17px is the .5rem x2
   padding + 1px x2 border the border-box width must carry on top. */
tr.editing .e-amt { width: calc(10ch + 17px); min-width: calc(10ch + 17px);
                    text-align: right; }
tr.editing .e-cat { max-width: 14ch; }
.e-clr { font-size: 12px; color: var(--muted); white-space: nowrap; }
button.save { font-weight: 700; color: #fff; background: var(--accent); border: none; border-radius: 5px; padding: 4px 10px; cursor: pointer; }
button.save:disabled { opacity: .6; }
button.cancel { border: 1px solid var(--line); background: none; color: var(--muted); border-radius: 5px; padding: 4px 10px; cursor: pointer; }
input.invalid { border-color: var(--bad) !important; }
tr.edited { background: color-mix(in srgb, var(--good) 18%, var(--bg)); }

.months.full table { width: 100%; }

.adjust-list table { width: 100%; }
tr.paused td { opacity: .5; }
.chip-btn { border: 1px solid var(--line); background: none; color: var(--ink); border-radius: 5px; padding: 3px 9px; font-size: 12px; cursor: pointer; }
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.add-row.wrap { flex-wrap: wrap; }
label.win { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 4px; }

/* --- M7: mobile-responsive register (PLAN HIGH — primary users are phones) ---
   Three tiers:
   <=640px  Deposit+Withdraw fold into one signed Amount column (.c-amt,
            rendered always, hidden on desktop); category/description/why read
            as folded sub-lines under the name; add row becomes a stacked grid;
            40px+ touch targets for clear/edit/delete and pager controls.
   <=480px  register rows become two-line grids: [clear | date | amount] over
            [edi | name | balance], with the M14 ⋯ menu riding the row's right
            edge spanning both lines ('edi' is an empty placeholder column).
            Date + Balance always visible.
   The bottom pager (round 6) keeps paging reachable without scroll-to-top. */
table.ledger .c-amt { display: none; }

@media (max-width: 640px) {
    main { padding: 1rem 1rem 5rem; }
    table.ledger .c-amt { display: table-cell; }
    table.ledger .c-dep, table.ledger .c-wdr { display: none; }
    /* the inline editor lives inside .c-dep — bring it back while editing,
       and stand the signed cell down so the two never double up */
    table.ledger tr.editing .c-dep { display: table-cell; }
    table.ledger tr.editing .c-amt { display: none; }

    /* fold category/description/why/planned-chip under the name; the CHIPS
       (category/planned/transfer) stay inline-block so they sit beside the
       name and each other and wrap only when the line runs out — display:
       block stretched every chip to full width on its own line (Troy).
       desc/why are sentences, those stay block. */
    .c-name .cat, .c-name .plan-chip, .c-name .transfer-chip {
        display: inline-block; margin: 2px 4px 0 0;
    }
    .c-name .desc, .c-name .why {
        display: block; margin: 2px 0 0;
    }

    /* 40px+ touch targets */
    .toggle, button.edit, button.del, button.pair, button.convert { min-width: 40px; min-height: 40px; }
    .row-menu > summary { min-width: 40px; min-height: 40px; }
    /* reclaim the base .6rem side padding — six visible columns otherwise
       overflow a 560px tablet in table mode */
    table.ledger th, table.ledger td { padding-left: .3rem; padding-right: .3rem; }
    table.ledger .c-date { white-space: nowrap; font-size: .9rem; }
    /* M14: the ops column holds a single 40px ⋯ button at this tier */
    table.ledger td.ops { min-width: 44px; }
    .pager-btn, .pager .chip {
        display: inline-flex; align-items: center; justify-content: center;
        min-height: 40px; padding: .3rem .8rem;
    }
    /* M14 (2026-11-25): the head-chips row gets the same 40px targets as the
       pager (the base .chip padding is phone-small), and Prev/Next share a
       min-width so the row-count text sits centered between equal buttons
       instead of hugging the narrower one. */
    .head-chips .chip, .head-chips .horizon-select {
        display: inline-flex; align-items: center;
        min-height: 40px; padding: .3rem .8rem;
    }
    /* Phones have no hover for the select's title and no room for the label:
       drop it so the projection cluster (Projections | horizon | Plans) fits
       one line and "Plans shown" never orphans to its own row. The select
       carries aria-label for screen readers. */
    .head-chips .chip-label { display: none; }
    /* The cluster divider would lead a wrapped line and read as a stray
       mark; on phones the cluster's proximity already conveys the group. */
    .head-chips .chip-group::before { display: none; }
    .pager-btn { min-width: 5.5rem; }
    .pager-size select { min-height: 40px; }
    /* M14 filter controls: 40px touch targets; the search box claims the
       free line width on phones so long queries stay readable. */
    .pager .filter-q { flex: 1 1 120px; min-height: 40px; }
    .pager .filter-cat { min-height: 40px; max-width: none; }

    /* The add-row grid moved to .add-dialog scope (always modal now);
       Adjustments' .add-row stays flex-wrap here. */
}

/* M17: the nav gained Home, so the full topbar needs ~930px. Collapse to
   the hamburger below 950px — previously the 640–930px band overflowed the
   header horizontally and pushed the book menu off-screen. */
@media (max-width: 950px) {
    .topbar { position: relative; }
    .nav-btn { display: inline-flex; align-items: center; justify-content: center;
        min-width: 40px; min-height: 40px; background: transparent;
        border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
        font-size: 1.15rem; line-height: 1; cursor: pointer; }
    .topbar nav { display: none; }
    .topbar nav.open {
        display: flex; flex-direction: column; gap: .15rem;
        position: absolute; top: 100%; left: 0; right: 0; z-index: 40;
        background: var(--card); border-bottom: 1px solid var(--line);
        box-shadow: 0 10px 24px rgba(0, 0, 0, .18); padding: .4rem 1.5rem .8rem;
    }
    .topbar nav.open a { padding: .55rem 0; min-height: 40px; }
    /* Config group inside the hamburger dropdown: static, indented rows. */
    .nav-group { flex-direction: column; align-items: stretch; }
    .nav-group > summary { padding: .55rem 0; min-height: 40px; }
    .nav-group .sub { position: static; min-width: 0; gap: 0; padding: 0 0 .35rem 1rem;
        border: none; box-shadow: none; background: transparent; }
    .nav-group .sub a { padding: .5rem 0; min-height: 40px; }
}

@media (max-width: 480px) {
    table.ledger { border: none; }
    table.ledger thead { display: none; }
    table.ledger tbody { display: block; }
    table.ledger tr {
        display: grid;
        grid-template-columns: auto 1fr auto auto;
        grid-template-areas:
            "mark date amt del"
            "edi  name bal del";
        column-gap: .5rem;
        align-items: center;
        background: var(--card);
        border-bottom: 1px solid var(--line);
        padding: .45rem .5rem;
    }
    table.ledger tr:last-child { border-bottom: none; }
    table.ledger td { display: block; border: none; padding: 0; background: transparent; }
    table.ledger .c-mark { grid-area: mark; justify-self: center; }
    /* M14: the ops cell holds the ⋯ <details> menu (the inline set is hidden
       ≤700px). display:contents makes the details a direct grid item; it rides
       the row's right edge spanning both lines, exactly where delete used to
       sit. The 'edi' area stays as an empty placeholder so the name column
       keeps aligning under the date. */
    table.ledger tr:not(.editing) .c-ops { display: contents; }
    table.ledger tr:not(.editing) .c-ops details.row-menu { grid-area: del; align-self: start; justify-self: end; }
    table.ledger .c-date { grid-area: date; white-space: nowrap; }
    table.ledger .c-name { grid-area: name; min-width: 0; overflow-wrap: anywhere; }
    table.ledger .c-amt { grid-area: amt; white-space: nowrap; }
    table.ledger .c-bal { grid-area: bal; white-space: nowrap; }
    /* row tints/accent move from cells to the row itself */
    table.ledger tr.proj, table.ledger tr.planned { background: var(--proj-soft); }
    table.ledger tr.proj td:first-child, table.ledger tr.planned td:first-child { border-left: none; }
    table.ledger tr.proj { border-left: 3px dashed var(--amber); }
    table.ledger tr.planned { border-left: 3px dotted var(--accent); }

    /* editing row: wrapping flex stack (inputs are 40px+ per the 640 block) */
    table.ledger tr.editing { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
    table.ledger tr.editing .c-amt, table.ledger tr.editing .c-wdr,
    table.ledger tr.editing .c-bal { display: none; }
    table.ledger tr.editing .c-dep { display: flex; gap: .3rem; align-items: center; }
    table.ledger tr.editing .c-name { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: .4rem; }
    table.ledger tr.editing .c-ops { margin-left: auto; }
    table.ledger tr.editing input, table.ledger tr.editing select { min-height: 40px; }
    tr.editing .e-payee { flex: 1 1 100%; width: auto; }
    tr.editing .e-desc { flex: 1 1 14ch; width: auto; }
}

/* Payees page (M13) */
.payee-search { max-width: 20rem; margin-bottom: .5rem; }
.payee-table td.num, .payee-table th:not(:first-child):not(:last-child) { text-align: right; }
.payee-table td.p-name { text-align: left; }
.rename-input { width: 100%; min-width: 8rem; }
.p-cat { max-width: 9rem; }
button.apply-cat { margin-top: .3rem; border: 1px solid var(--accent); background: none; color: var(--accent); border-radius: 5px; padding: 3px 8px; font-size: 12.5px; cursor: pointer; }
button.apply-cat:hover { color: #fff; background: var(--accent); }
button.reapply-cat { margin-top: .3rem; border: 1px solid var(--bad); background: none; color: var(--bad); border-radius: 5px; padding: 3px 8px; font-size: 12.5px; cursor: pointer; }
button.reapply-cat:hover { color: #fff; background: var(--bad); }
.p-ops { white-space: nowrap; }
.p-ops .merge-pick, .cat-table .merge-pick { max-width: 10rem; }
.cat-table .a-ops { white-space: nowrap; }
@media (max-width: 640px) {
    .payee-table { font-size: .85rem; }
    .p-cat { max-width: 6.5rem; }
    .p-ops .merge-pick, .cat-table .merge-pick { max-width: 7rem; }
}

/* Accounts page (M3) */
.acct-add { margin-bottom: .75rem; }
/* min-width beats the input's ~175px intrinsic default, which otherwise
   inflates the flex line and pushes the button onto a second row. */
.acct-add input[name=FName] { flex: 1 1 10rem; min-width: 8rem; }
.acct-add input[name=FOpening] { width: 7rem; flex: none; }
.acct-add input.a-start-in, td input.a-start-in { width: 9.5rem; flex: none; }
.acct-table td.a-start { white-space: nowrap; }
.acct-table td.num, .acct-table th.num { text-align: right; }
.acct-table td.a-name { text-align: left; }
.acct-table .m-fold { display: none; }
.acct-table tr.archived td { opacity: .5; }
.acct-table tr.archived .chip { opacity: 1; }
.a-ops { white-space: nowrap; }
.a-ops button.archive, .a-ops button.unarchive {
    border: 1px solid var(--line); background: none; color: var(--muted);
    border-radius: 5px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.a-ops button.archive:hover, .a-ops button.unarchive:hover {
    border-color: var(--accent); color: var(--accent); }
@media (max-width: 640px) {
    .acct-table { font-size: .85rem; }
    .acct-table th, .acct-table td { padding: .3rem .3rem; }
    .acct-table .c-start, .acct-table .c-type, .acct-table .c-tx { display: none; }
    .acct-table .m-fold {
        display: block; margin-top: 2px;
        font-size: 10.5px; font-weight: 600; color: var(--muted);
    }
    .accounts { overflow-x: auto; }
    .a-ops button { min-height: 40px; padding: 4px 7px; }
}

/* Budgets page (M5) */
.budget-head { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .6rem 0; }
.budget-month { font-size: 1.05rem; font-weight: 700; min-width: 10ch; text-align: center; }
button.chip-btn { cursor: pointer; background: none; border: 1px solid var(--line);
    border-radius: 999px; color: var(--muted); font: inherit; font-size: .8rem;
    padding: .3rem .8rem; min-height: 32px; }
button.chip-btn:hover { color: var(--accent); border-color: var(--accent); }
.budget-table td.e-name, .budget-table th:first-child,
.unbudgeted-table td:first-child { text-align: left; }
.budget-table td.num, .budget-table th.num,
.unbudgeted-table td.num, .unbudgeted-table th.num { text-align: right; }
.budget-table td.neg, .unbudgeted-table td.neg { color: var(--bad); }
.e-bar { width: 7rem; }
.e-bar span { display: inline-block; height: .5rem; border-radius: 999px;
    background: var(--accent); min-width: 2px; }
.e-bar span.over { background: var(--bad); }
@media (max-width: 640px) {
    .budget-table, .unbudgeted-table { font-size: .85rem; }
    .budget-table th, .budget-table td,
    .unbudgeted-table th, .unbudgeted-table td { padding: .3rem .3rem; }
    .budget-table .e-bar, .budget-table .e-bar-h { display: none; }
    .budgets { overflow-x: auto; }
}

/* Categories page (M5) */
.cat-add { margin-bottom: .75rem; }
.cat-add input[name=FName] { flex: 1 1 12rem; min-width: 8rem; }
.cat-table td.num, .cat-table th.num { text-align: right; }
.cat-table td.a-name { text-align: left; }
.cat-table .m-fold { display: none; }
.cat-table td.c-roll, .cat-table th.c-roll { text-align: center; }
.cat-table td.c-since, .cat-table th.c-since { white-space: nowrap;
    color: var(--muted); font-size: .85rem; }
.cat-table td input.amount { width: 6.5rem; text-align: right; }
@media (max-width: 640px) {
    .cat-table { font-size: .85rem; }
    .cat-table th, .cat-table td { padding: .3rem .3rem; }
    .cat-table .c-tx, .cat-table .c-since { display: none; }
    .cat-table .m-fold {
        display: block; margin-top: 2px;
        font-size: 10.5px; font-weight: 600; color: var(--muted);
    }
    .categories { overflow-x: auto; }
}

/* Reports page (M12) */
button.chip { cursor: pointer; background: none; color: var(--ink); font: inherit; }
button.chip.on { color: #fff; }
.rep-custom { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-bottom: .5rem; }
.rep-custom label { display: flex; gap: .35rem; align-items: center; }
.rep-custom input[type="date"] { width: 9.5rem; }
.rep-range { margin: .25rem 0 .75rem; }
.rep-sec { margin-bottom: 1.5rem; }
.rep-sec h2 { font-size: 1.05rem; margin: 0 0 .5rem; }
.rep-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
            gap: 1.25rem; margin-bottom: 1.5rem; }
@media (max-width: 860px) { .rep-grid { grid-template-columns: 1fr; } }

/* chart palette: 12 hues + grey 'Other', tuned per theme; SVG fills reference
   these so the light/dark toggle re-colors charts with zero JS. ch9-ch12 fill
   the hue gaps (gold, olive, magenta, indigo) so the donut's top-11 arcs stay
   mutually distinguishable next to the original 8. */
:root {
    --ch1: #0d7a63; --ch2: #b45309; --ch3: #2563eb; --ch4: #b42318;
    --ch5: #7c3aed; --ch6: #15803d; --ch7: #c2410c; --ch8: #0e7490;
    --ch9: #8f6c00; --ch10: #a8447c; --ch11: #5f7d1f; --ch12: #4f46b5;
    --ch-o: #9aa7b4;
}
:root[data-theme="dark"] {
    --ch1: #3fc9ab; --ch2: #e0a35c; --ch3: #7fa9f0; --ch4: #f0836f;
    --ch5: #b794f4; --ch6: #5fd08a; --ch7: #f4a261; --ch8: #67c8de;
    --ch9: #e6c95c; --ch10: #e78fc0; --ch11: #a3c95c; --ch12: #9d8bff;
    --ch-o: #6b7a8a;
}
.ch1 { fill: var(--ch1); } .ch2 { fill: var(--ch2); } .ch3 { fill: var(--ch3); }
.ch4 { fill: var(--ch4); } .ch5 { fill: var(--ch5); } .ch6 { fill: var(--ch6); }
.ch7 { fill: var(--ch7); } .ch8 { fill: var(--ch8); } .ch-o { fill: var(--ch-o); }
.ch9 { fill: var(--ch9); } .ch10 { fill: var(--ch10); }
.ch11 { fill: var(--ch11); } .ch12 { fill: var(--ch12); }
.sw { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; }
.sw.ch1 { background: var(--ch1); } .sw.ch2 { background: var(--ch2); }
.sw.ch3 { background: var(--ch3); } .sw.ch4 { background: var(--ch4); }
.sw.ch5 { background: var(--ch5); } .sw.ch6 { background: var(--ch6); }
.sw.ch7 { background: var(--ch7); } .sw.ch8 { background: var(--ch8); }
.sw.ch-o { background: var(--ch-o); }
.sw.ch9 { background: var(--ch9); } .sw.ch10 { background: var(--ch10); }
.sw.ch11 { background: var(--ch11); } .sw.ch12 { background: var(--ch12); }

.chart-scroll { overflow-x: auto; }
.flow-chart, .trend-chart { display: block; width: 100%; height: auto; }
.flow-chart .dep { fill: var(--good); }
.flow-chart .wdr { fill: var(--bad); }
.trend-chart .line { fill: none; stroke: var(--accent); stroke-width: 2; }
.trend-chart .dot { fill: var(--accent); }
.flow-chart .zero, .trend-chart .zero { stroke: var(--line); stroke-width: 1; }
.flow-chart .lbl, .trend-chart .lbl { font-size: 11px; fill: var(--muted); }
.flow-chart .lbl.yr, .trend-chart .lbl.yr { font-size: 10px; }
.donut { flex: none; }
.donut-c { font-size: 15px; font-weight: 700; fill: var(--ink); }
.donut-s { font-size: 10px; fill: var(--muted); text-transform: uppercase;
           letter-spacing: .08em; }
.donut-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
table.legend { background: none; border: none; width: auto; min-width: 13rem; }
table.legend td { border-bottom: none; padding: .22rem .45rem; }
.sw-cell { width: 1.2rem; }

.hbars { display: flex; flex-direction: column; gap: .45rem; }
.hbar { display: grid; grid-template-columns: minmax(0, 11rem) 1fr auto;
        gap: .6rem; align-items: center; }
.hb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .9rem; }
.hb-track { height: 14px; background: var(--thead); border-radius: 4px; overflow: hidden; }
.hb-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.hb-amt { font-variant-numeric: tabular-nums; font-size: .9rem; white-space: nowrap; }
.hb-amt em { font-style: normal; color: var(--muted); margin-left: .4rem; font-size: .75rem; }

.mom { max-width: 26rem; }
.rollup .cat-row { cursor: pointer; }
.rollup .cat-row:hover td { background: var(--row-hover); }
.rollup .caret { color: var(--muted); font-size: .8rem; }
.rollup .sub-row td { color: var(--muted); font-size: .85rem; }
.rollup .sub-row td.sub { padding-left: 1.7rem; }

@media (max-width: 700px) {
    /* SVGs scale to fit, but below ~700px the month labels get unreadably
       small — hold a min width and let .chart-scroll pan instead. */
    .flow-chart, .trend-chart { min-width: 640px; }
    .hbar { grid-template-columns: minmax(0, 8rem) 1fr auto; }
}

/* ---- cron editor (schedules) ---- */
.cron-editor {
    display: flex; flex-wrap: wrap; gap: .6rem .9rem; align-items: end;
    margin: .6rem 0; padding: .7rem .8rem;
    border: 1px solid var(--line); border-radius: 10px; background: var(--card);
}
.cron-field { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); }
.cron-field input, .cron-field select {
    padding: .4rem .5rem; border: 1px solid var(--line); border-radius: 8px;
    background: var(--bg); color: var(--ink); font: inherit;
}
.cron-field input.cron-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; min-width: 16ch; }
.cron-field.nth input { width: 6ch; }
.cron-field input:disabled { opacity: .6; }
.cron-preview { flex: 1 1 100%; font-size: .85rem; color: var(--muted); }
.cron-preview .preview-dates { display: block; margin-top: .25rem; }
.cron-desc.bad { color: var(--bad); }
.cron-cheatsheet { margin: .8rem 0 1.4rem; }
.cron-cheatsheet summary { cursor: pointer; color: var(--accent); font-size: .9rem; }
.cron-cheatsheet pre {
    overflow-x: auto; font-size: .8rem; line-height: 1.5; margin: .6rem 0;
    background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .9rem;
}
@media (max-width: 560px) {
    .cron-field input.cron-input { min-width: 12ch; }
}

/* ---- M14 reconcile ---- */
.recon-form { margin: .6rem 0 1rem; }
.recon-form label { display: flex; flex-direction: column; gap: .25rem;
    font-size: .8rem; color: var(--muted-foreground); }
.recon-form input[type=date] { font-size: .95rem; }
.recon-panel { display: flex; flex-wrap: wrap; gap: 1.4rem; padding: .7rem .9rem;
    background: var(--card); border: 1px solid var(--border); border-radius: 10px;
    margin-bottom: 1.1rem; }
.recon-panel .k { display: block; font-size: .72rem; text-transform: uppercase;
    letter-spacing: .05em; color: var(--muted-foreground); }
.recon-panel strong { font-variant-numeric: tabular-nums; }
.recon-table td.act { text-align: right; white-space: nowrap; }
@media (max-width: 640px) {
    .recon-panel { gap: .9rem 1.2rem; }
    .recon-table { font-size: .85rem; }
}

/* ---- M4 auth ---- */
.user-chip { font-size: .8rem; color: var(--muted-foreground); padding: 0 .35rem;
    white-space: nowrap; }
.logout-form { display: inline; }
.logout-btn { background: none; border: 1px solid var(--line); color: var(--muted-foreground);
    border-radius: 8px; padding: .3rem .6rem; font-size: .8rem; cursor: pointer; }
.logout-btn:hover { color: var(--bad); border-color: var(--bad); }
.login-card { max-width: 22rem; margin: 8vh auto 0; padding: 1.4rem 1.5rem 1.6rem;
    background: var(--card); border: 1px solid var(--border); border-radius: 12px; }
.login-title { margin: 0 0 1rem; font-size: 1.3rem; }
.login-form { display: flex; flex-direction: column; gap: .35rem; }
.login-form label { font-size: .8rem; color: var(--muted-foreground); margin-top: .5rem; }
.login-form input[type=text], .login-form input[type=password] { font-size: 1rem;
    padding: .5rem .65rem; background: var(--background); color: var(--foreground);
    border: 1px solid var(--line); border-radius: 8px; }
.login-remember { flex-direction: row; align-items: center; gap: .4rem !important; }
.login-alt { margin-top: .9rem; font-size: .85rem; }
.login-alt a { color: var(--accent, inherit); }
.login-form button { margin-top: 1rem; align-self: flex-start; }

/* PLAN M4 increment 2: profile page + 2FA. Cards reuse the login-card
   surface but stack in a wider single column. */
a.user-chip { text-decoration: none; }
a.user-chip:hover { color: var(--accent); text-decoration: underline; }
.profile { max-width: 34rem; margin: 4vh auto 0; padding: 0 1rem 3rem; }
.profile-card { background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.1rem 1.3rem 1.3rem; margin-bottom: 1.1rem; }
.profile-card h2 { margin: 0 0 .4rem; font-size: 1.05rem; }
.profile-note { font-size: .8rem; color: var(--muted-foreground); margin: .5rem 0 0; }
.profile-status { font-size: .9rem; margin: .2rem 0 0; }
.profile-warn { font-size: .85rem; color: var(--bad); margin: 0 0 .5rem; }
.btn-row { display: flex; gap: .6rem; align-items: center; margin-top: .8rem; flex-wrap: wrap; }
.twofa-as { font-size: .9rem; margin: 0 0 .8rem; }
.twofa-recovery { margin-top: 1.2rem; border-top: 1px solid var(--line); padding-top: .4rem; }
.twofa-setup { margin-top: .8rem; }
.twofa-qr { display: block; margin: .5rem auto; background: #fff;
    border-radius: 8px; padding: 6px; }
.twofa-key { font-family: monospace; font-size: .85rem; text-align: center;
    letter-spacing: .05em; word-break: break-all; margin: .3rem 0 .8rem; }
.recovery-codes { margin-top: .8rem; padding: .7rem .9rem; border: 1px dashed var(--bad);
    border-radius: 8px; background: var(--bad-soft); }
.recovery-codes ul { columns: 2; gap: 1.2rem; margin: 0; padding-left: 1.2rem;
    font-family: monospace; font-size: .85rem; }
.recovery-codes li { margin: .15rem 0; }

/* PLAN M4b: book switcher (header drop-down, zero-JS details pattern) */
.book-menu { position: relative; }
.book-menu-btn {
    display: inline-flex; align-items: center; gap: .35rem;
    cursor: pointer; list-style: none;
    padding: .3rem .6rem; border-radius: 6px;
    background: var(--card, rgba(127,127,127,.12));
    border: 1px solid var(--border, rgba(127,127,127,.25));
    font-weight: 600; font-size: .9rem;
}
.book-menu-btn::-webkit-details-marker { display: none; }
.book-caret { font-size: .7rem; opacity: .7; }
.book-menu-body {
    position: absolute; right: 0; top: calc(100% + .35rem); z-index: 40;
    min-width: 14rem; max-width: 18rem;
    background: var(--card, #fff); border: 1px solid var(--border, rgba(127,127,127,.3));
    border-radius: 8px; padding: .4rem; box-shadow: 0 6px 18px rgba(0,0,0,.18);
    display: flex; flex-direction: column; gap: .15rem;
}
.book-item {
    display: flex; align-items: center; gap: .4rem; width: 100%;
    text-align: left; padding: .4rem .5rem; border-radius: 6px;
    border: none; background: none; color: inherit; font: inherit; font-size: .9rem;
    cursor: pointer;
}
.book-item-form { display: contents; }
button.book-item:hover, a.book-item:hover { background: rgba(127,127,127,.14); }
.book-item.current { font-weight: 700; opacity: .85; }
.book-owner-tag {
    font-size: .65rem; text-transform: uppercase; letter-spacing: .04em;
    padding: .1rem .35rem; border-radius: 4px;
    background: rgba(127,127,127,.18);
}
.book-menu-sep { border-top: 1px solid var(--border, rgba(127,127,127,.25)); margin: .3rem 0; }
.book-create { display: flex; gap: .35rem; padding: .25rem .15rem; }
.book-create input { flex: 1; min-width: 0; padding: .35rem .5rem; border-radius: 6px; }

/* PLAN M4b-2: member/invite management + invite landing */
.book-manage { display: block; text-align: left; padding: .4rem .5rem;
    border-radius: 6px; font-size: .9rem; text-decoration: none; color: inherit; }
.book-manage:hover { background: rgba(127,127,127,.14); }
.invite-card { max-width: 26rem; margin: 8vh auto 0; padding: 1.4rem 1.5rem 1.6rem; }
.invite-card form { display: flex; flex-direction: column; gap: .35rem; margin-top: .8rem; }
.invite-card input[type=password] { font-size: 1rem; padding: .5rem .65rem;
    background: var(--background); color: var(--foreground);
    border: 1px solid var(--line); border-radius: 8px; }
.invite-card button { margin-top: .8rem; align-self: flex-start; }
.invite-hint { font-size: .8rem; color: var(--muted-foreground); }
.invite-link-box { margin-bottom: 1rem; }
.invite-link { width: 100%; font-size: .8rem; font-family: monospace;
    padding: .4rem .5rem; border-radius: 6px; background: var(--background);
    color: var(--foreground); border: 1px solid var(--line); }
.invite-link.small { width: 22rem; min-width: 10rem; }
.invite-form { display: flex; gap: .4rem; align-items: center; }
.invite-form input { flex: 1; max-width: 16rem; padding: .4rem .5rem; border-radius: 6px; }
.inline-form { display: inline; }
.manage-table { width: 100%; border-collapse: collapse; margin-top: .5rem; }
/* Narrow viewports: scroll the table inside its card instead of squashing
   columns (dates wrapped mid-string at ~430px before this). */
.table-scroll { overflow-x: auto; }
.manage-table { min-width: max-content; }
.manage-table th, .manage-table td { text-align: left; padding: .4rem .5rem;
    border-bottom: 1px solid var(--border, rgba(127,127,127,.2)); font-size: .9rem;
    white-space: nowrap; }
.manage-table .ops { white-space: nowrap; text-align: right; }

/* ===== M17: home (landing + dashboard) + signed-out nav ===== */
.signin-link { color: var(--ink); font-weight: 600; }
.signin-link:hover { color: var(--accent); }

.hero { max-width: 46rem; margin: 3rem auto 2rem; text-align: center; }
.hero h1 { font-size: 2.4rem; margin: 0 0 .6rem; }
.hero-sub { color: var(--muted); font-size: 1.05rem; line-height: 1.55; margin: 0 0 1.4rem; }
.hero-cta { display: flex; gap: .7rem; justify-content: center; flex-wrap: wrap; }
.cta-btn { display: inline-block; padding: .55rem 1.4rem; border-radius: 8px;
    border: 1px solid var(--line); background: var(--card); color: var(--ink);
    font-weight: 600; text-decoration: none; }
.cta-btn:hover { border-color: var(--accent); color: var(--accent); }
.cta-btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.cta-btn.primary:hover { filter: brightness(1.08); color: #fff; }

.features { display: grid; gap: 1rem; max-width: 60rem; margin: 1rem auto 2.5rem;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.feature { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: 1rem 1.1rem; }
.feature h2 { font-size: 1rem; margin: 0 0 .4rem; color: var(--accent); }
.feature p { margin: 0; color: var(--muted); font-size: .9rem; line-height: 1.5; }

.dash-title { font-size: 1.35rem; margin: 1.2rem 0 .8rem; }
.acct-card { text-decoration: none; color: inherit; display: block; }
.acct-card:hover { border-color: var(--accent); }
.dash-panels { display: grid; gap: 1rem; margin-top: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    padding: .9rem 1.1rem; }
.panel h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); margin: 0 0 .6rem; display: flex; justify-content: space-between;
    align-items: baseline; gap: .5rem; }
.panel-link { text-transform: none; letter-spacing: 0; font-size: .8rem;
    color: var(--accent); text-decoration: none; }
.panel-link:hover { text-decoration: underline; }
.stat-row { display: flex; justify-content: space-between; padding: .3rem 0;
    border-bottom: 1px solid var(--line); font-size: .95rem; }
.stat-row:last-child { border-bottom: none; }
.stat-row span { color: var(--muted); }
.dash-table { width: 100%; border-collapse: collapse; }
.dash-table td { padding: .35rem .4rem; border-bottom: 1px solid var(--line);
    font-size: .9rem; }
.dash-table tr:last-child td { border-bottom: none; }
.dash-date { color: var(--muted); white-space: nowrap; }
.dash-acct { color: var(--muted); white-space: nowrap; text-align: right; }
.dash-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-empty { color: var(--muted); font-size: .9rem; margin: .2rem 0; }
@media (max-width: 640px) {
    .hero { margin: 1.6rem auto 1.4rem; }
    .hero h1 { font-size: 1.8rem; }
}

/* ===== PLAN M4-3: admin pages (users / create / settings) ===== */
.status-on { color: var(--good); }
.status-off { color: var(--bad); font-weight: 600; }
.admin-users .ops { vertical-align: middle; }
.pw-reset { display: inline-flex; gap: .3rem; align-items: center; margin-right: .5rem; }
.pw-reset input { width: 9.5rem; padding: .3rem .45rem; font-size: .85rem;
    border: 1px solid var(--line); border-radius: 6px;
    background: var(--background); color: var(--foreground); }
.admin-create { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: .6rem .8rem; align-items: end; margin-top: .5rem; }
.admin-create label { display: flex; flex-direction: column; gap: .25rem;
    font-size: .85rem; color: var(--muted-foreground); }
.admin-create input, .admin-create select { padding: .4rem .5rem; font-size: .95rem;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--background); color: var(--foreground); }
.admin-create .admin-check { flex-direction: row; align-items: center; gap: .4rem;
    color: var(--foreground); }
.admin-create .admin-check input { width: auto; }
.admin-create button { align-self: end; }
.setting-row { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center;
    justify-content: space-between; padding: .6rem 0;
    border-bottom: 1px solid var(--line); }
.setting-row:last-child { border-bottom: none; }
.setting-row h3 { font-size: .95rem; margin: 0 0 .2rem; }
.setting-row code { font-size: .8rem; color: var(--muted-foreground); }
.setting-info { flex: 1 1 22rem; min-width: 0; }
.setting-form { display: flex; gap: .4rem; align-items: center; }
.setting-form input[type=number] { width: 6.5rem; padding: .4rem .5rem; font-size: .95rem;
    border: 1px solid var(--line); border-radius: 8px;
    background: var(--background); color: var(--foreground); }

/* Timezone increment: Manage-page time zone card */
.tz-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .5rem; }
.tz-form input[list] { padding: .35rem .5rem; border: 1px solid var(--border, #ccc);
    border-radius: 6px; background: var(--card, #fff); color: inherit; }
.tz-hint { margin-top: .4rem; font-size: .9em; }
