/* Dhanu's Desk — DESK-1 (02 Oct 2026). Hand-written, no build step, no CDN, no web font.
   Dark first; light follows the device setting. Every tap target is at least 44 px;
   every text colour is at least 4.5:1 on its background (scripts/test_desk1_glass.py measures both). */

:root {
  --bg: #0f1216; --panel: #12161b; --surface: #171b21; --surface2: #141920;
  --line: #222831; --line2: #2f3944;
  --tx: #e9ecf0; --tx-strong: #f3f5f8; --mut: #aeb7c2; --dim: #8f99a6;
  --link: #7fb8ff; --ok: #6fcf97; --bad: #ff8a80; --warn: #f0c05a;
  --primary: #1f6fbf; --green: #1a7a42; --on-solid: #ffffff;
  --btn: #1d232b; --focus: #9cc9ff; --logo: #6b1f3a;
  --chip-on-bg: #f3f5f8; --chip-on-tx: #0f1216;
  --amber-bg: #2a2417; --amber-tx: #f0c05a; --green-bg: #163422; --green-tx: #6fcf97;
  --grey-bg: #22272f; --grey-tx: #c6cdd6; --blue-bg: #17324a; --blue-tx: #7fb8ff;
  --purple-bg: #2a2140; --purple-tx: #c9a6f0; --red-bg: #3a1e1e; --red-tx: #ff8a80;
  --d-amber: #e0a437; --d-green: #2fa35f; --d-grey: #8a94a6; --d-blue: #4b9be6; --d-purple: #9c5fd0;
  --shadow: 0 12px 32px rgba(0, 0, 0, .5);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --top: 61px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6f8; --panel: #ffffff; --surface: #ffffff; --surface2: #eef1f4;
    --line: #dde2e8; --line2: #c3cbd4;
    --tx: #1b2026; --tx-strong: #0f1216; --mut: #4b5663; --dim: #5d6875;
    --link: #0f5aa8; --ok: #146c36; --bad: #a8231a; --warn: #7a5200;
    --primary: #1a63ad; --green: #17703c; --on-solid: #ffffff;
    --btn: #ffffff; --focus: #0f5aa8; --logo: #6b1f3a;
    --chip-on-bg: #1b2026; --chip-on-tx: #ffffff;
    --amber-bg: #fff1cf; --amber-tx: #6f4a00; --green-bg: #dcf3e4; --green-tx: #125a2c;
    --grey-bg: #e6eaee; --grey-tx: #3a4450; --blue-bg: #dbe9fa; --blue-tx: #114b87;
    --purple-bg: #ebe2f9; --purple-tx: #552b91; --red-bg: #fde3e1; --red-tx: #96190f;
    --shadow: 0 12px 32px rgba(15, 18, 22, .18);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--tx); font-family: var(--sans); font-size: 14px; line-height: 1.4;
       overflow-wrap: normal; word-break: normal; }
a { color: var(--link); }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
strong { font-weight: 600; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ico { flex: 0 0 auto; }

/* ── header ───────────────────────────────────────────────────────────── */
.top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px; min-height: 60px;
       padding: 8px 24px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }
.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--logo); color: #ffffff; font-size: 12px;
        font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.brand-name { font-size: 16px; font-weight: 700; color: var(--tx-strong); white-space: nowrap; }
.tabs { display: flex; gap: 4px; flex: 0 0 auto; }
.tab, .toplink { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px;
                 color: var(--mut); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none;
                 background: transparent; border: 0; cursor: pointer; white-space: nowrap; }
.tab.on, .toplink.on { color: var(--tx-strong); background: var(--surface); }
.search { flex: 1 1 auto; display: flex; align-items: center; gap: 4px; min-width: 0; }
.search-box { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px;
              border-radius: 10px; border: 1px solid var(--line2); background: var(--surface); color: var(--mut); }
.search-box:focus-within { border-color: var(--focus); outline: 2px solid var(--focus); outline-offset: 2px; }
.search-box input { flex: 1 1 auto; min-width: 0; height: 40px; background: transparent; border: 0; outline: 0;
                    color: var(--tx); font: inherit; font-size: 15px; }
.search-box input::placeholder { color: var(--dim); }
.search-box input::-webkit-search-cancel-button { display: none; }   /* ONE clear control: the labelled button beside the box */
.clear { width: 44px; height: 44px; flex: 0 0 auto; border: 0; border-radius: 50%; background: transparent;
         color: var(--mut); font: inherit; font-size: 22px; line-height: 1; cursor: pointer; }
.who { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; font-size: 13px; color: var(--mut); }
.perf { font-family: var(--mono); font-size: 12px; color: var(--ok); white-space: nowrap; }
.me { white-space: nowrap; padding: 0 6px; }
.logout { display: inline-flex; margin: 0; }
.parity { margin: 0; padding: 10px 24px; background: var(--red-bg); color: var(--red-tx); font-weight: 600; }

/* ── search results (overlay sheet) ───────────────────────────────────── */
.results { position: fixed; z-index: 35; top: calc(var(--top) + 4px); left: 50%; transform: translateX(-50%);
           width: min(720px, calc(100vw - 28px)); max-height: calc(100vh - var(--top) - 24px); overflow-y: auto;
           border-radius: 12px; border: 1px solid var(--line2); background: var(--surface); box-shadow: var(--shadow); }
.results:empty { display: none; }
.results.htmx-request:empty { display: block; }
.results.htmx-request:empty::after { content: "Searching…"; display: block; padding: 14px; color: var(--mut); }
.res-head { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: 12px; color: var(--mut); }
.sec { padding: 8px 14px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
       color: var(--dim); background: var(--surface2); }
.res { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 8px 14px;
       border-top: 1px solid var(--line); text-decoration: none; color: var(--tx); }
.res-l { display: flex; flex-direction: column; min-width: 0; }
.res .t { font-size: 14px; font-weight: 600; color: var(--tx-strong); }
.res .s { font-size: 12px; color: var(--mut); margin-top: 2px; }
.res .r { font-family: var(--mono); font-size: 12px; color: var(--mut); text-align: right; white-space: nowrap; }
.res-empty { padding: 10px 14px 12px; font-size: 13px; color: var(--dim); border-top: 1px solid var(--line); }

/* ── chips + the sum line ─────────────────────────────────────────────── */
.chipbar { padding: 16px 24px 12px; display: flex; flex-direction: column; gap: 10px; border-bottom: 1px solid var(--line); }
.chiprow { display: flex; align-items: center; gap: 10px; }
.chips { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 10px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.newq { flex: 0 0 auto; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px;
        border-radius: 10px; border: 1px solid var(--line2); background: var(--surface); color: var(--tx);
        font-size: 14px; font-weight: 500; text-decoration: none; white-space: nowrap; }
.chip strong { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.chip.on { background: var(--chip-on-bg); color: var(--chip-on-tx); border-color: var(--chip-on-bg); }
.lbl-s { display: none; }
.sum { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; display: inline-block; }
.dot-amber { background: var(--d-amber); } .dot-green { background: var(--d-green); }
.dot-grey { background: var(--d-grey); } .dot-blue { background: var(--d-blue); } .dot-purple { background: var(--d-purple); }
.freshbar:empty { display: none; }
.fresh { display: flex; align-items: center; min-height: 44px; padding: 0 24px; background: var(--blue-bg); color: var(--blue-tx);
         font-weight: 600; text-decoration: none; }

/* ── the two columns ──────────────────────────────────────────────────── */
.cols { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
.list { min-width: 0; position: relative; }
.list.htmx-request { opacity: .55; }
/* the loading state floats: it never takes space, so nothing under her finger moves */
.list.htmx-request::before { content: "Loading…"; position: fixed; z-index: 25; top: calc(var(--top) + 8px); left: 50%;
                             transform: translateX(-50%); padding: 8px 16px; border-radius: 8px;
                             background: var(--blue-bg); color: var(--blue-tx); font-weight: 600; box-shadow: var(--shadow); }
.group { border-bottom: 1px solid var(--line); }
.grp { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 10px; min-height: 40px; padding: 8px 16px;
       background: var(--surface2); font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase;
       color: var(--mut); }
.grp .n { font-family: var(--mono); color: var(--tx-strong); }
.grp .cap { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--dim); }
.subgrp { padding: 8px 16px 4px; font-size: 12px; font-weight: 600; color: var(--dim); border-top: 1px solid var(--line); }
.empty { padding: 14px 16px; color: var(--dim); font-size: 13px; border-top: 1px solid var(--line); }
.row, .person, .paidrow { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.rowlink { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 140px minmax(0, 1fr) 170px 92px;
           align-items: center; gap: 16px; min-height: 56px; padding: 8px 16px; color: inherit; text-decoration: none; }
a.rowlink:hover { background: var(--surface); }
.num { font-family: var(--mono); font-size: 13px; color: var(--mut); white-space: nowrap; }
.body { display: flex; flex-direction: column; min-width: 0; }
.name { font-size: 15px; font-weight: 600; color: var(--tx-strong); }
.country { font-weight: 400; color: var(--mut); }
.sub { font-size: 13px; color: var(--mut); margin-top: 2px; }
.hi { color: var(--ok); font-weight: 600; }
.tag { font-family: var(--mono); font-size: 12px; white-space: nowrap; }
.note { font-size: 13px; color: var(--warn); margin-top: 2px; }
.note.boxed { display: block; padding: 8px 12px; border-radius: 8px; background: var(--amber-bg); color: var(--amber-tx); }
.pill { display: inline-block; padding: 3px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; line-height: 1.3; }
.tone-amber { background: var(--amber-bg); color: var(--amber-tx); } .tone-green { background: var(--green-bg); color: var(--green-tx); }
.tone-grey { background: var(--grey-bg); color: var(--grey-tx); } .tone-blue { background: var(--blue-bg); color: var(--blue-tx); }
.tone-purple { background: var(--purple-bg); color: var(--purple-tx); } .tone-red { background: var(--red-bg); color: var(--red-tx); }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.amt { font-family: var(--mono); font-size: 14px; color: var(--tx); white-space: nowrap; }
.age { font-size: 13px; color: var(--mut); white-space: nowrap; }
.actcell { flex: 0 0 auto; display: flex; align-items: center; justify-content: flex-end; width: 176px; padding: 8px 16px 8px 0; }
.btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; min-height: 44px;
       padding: 4px 14px; border-radius: 8px; border: 1px solid var(--line2); background: var(--btn); color: var(--tx-strong);
       font: inherit; font-size: 13px; font-weight: 600; line-height: 1.2; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-solid); }
.btn.green { background: var(--green); border-color: var(--green); color: var(--on-solid); }
.btn.big { min-height: 48px; font-size: 14px; width: 100%; }
.btn[disabled] { cursor: not-allowed; background: var(--grey-bg); border-color: var(--grey-bg); color: var(--grey-tx); }
.btn .ext { font-size: 11px; font-weight: 500; color: var(--mut); }
.btn.primary .ext, .btn.green .ext { color: var(--on-solid); }
.morebar { border-top: 1px solid var(--line); }
.more { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; font-size: 13px; font-weight: 600; }
.older > summary, .codes > summary { cursor: pointer; }
.older > summary { display: flex; align-items: center; min-height: 44px; padding: 0 16px; border-top: 1px solid var(--line);
                   font-size: 13px; font-weight: 600; color: var(--link); }
.perf-foot, .foot-note { padding: 10px 16px; font-size: 12px; color: var(--dim); }
.perf-foot { font-family: var(--mono); }
.foot-note { font-size: 13px; color: var(--mut); }
.plain-line { margin: 12px 16px; padding: 10px 12px; border-radius: 8px; background: var(--red-bg); color: var(--red-tx); font-weight: 600; }
.okline { margin: 12px 0; padding: 10px 12px; border-radius: 8px; background: var(--green-bg); color: var(--green-tx); font-weight: 600; }
.loading { padding: 16px; color: var(--mut); }

/* ── the right pane ───────────────────────────────────────────────────── */
.pane { background: var(--panel); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.pane > * { flex: 0 0 auto; }                 /* a pane scrolls; its cards are never squeezed or clipped */
.pane-ref { font-family: var(--mono); font-size: 13px; color: var(--mut); }
.nowrap { white-space: nowrap; }
.pane.htmx-request > * { opacity: .5; }
.pane.htmx-request::before { content: "Loading…"; position: absolute; z-index: 2; top: 10px; right: 12px;
                             color: var(--blue-tx); background: var(--blue-bg); padding: 8px 12px;
                             border-radius: 8px; font-weight: 600; }
.pane-top { display: flex; }
.back { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px 0 4px; font-size: 14px;
        font-weight: 600; text-decoration: none; }
.pane-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.pane-name { font-size: 20px; font-weight: 700; color: var(--tx-strong); margin-top: 4px; }
.card { border: 1px solid var(--line2); border-radius: 10px; overflow: hidden; }
.card.pad { padding: 16px; margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.card-h { padding: 10px 14px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .02em;
          color: var(--mut); background: var(--surface); }
.card-h.plain { padding: 0; background: transparent; }
.ln { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.ln-t { font-size: 14px; font-weight: 600; color: var(--tx-strong); }
.ln-r { text-align: right; flex: 0 0 auto; }
.stock { font-family: var(--mono); font-size: 13px; color: var(--mut); white-space: nowrap; }
.ln-p { padding: 8px 14px; border-top: 1px solid var(--line); font-size: 13px; color: var(--mut); }
.ln.total { background: var(--surface2); font-weight: 700; }
.ln.total .amt { font-size: 16px; font-weight: 600; }
.badge { display: inline-block; padding: 1px 6px; border-radius: 5px; font-size: 11px; font-weight: 600;
         background: var(--blue-bg); color: var(--blue-tx); }
.pane-acts { display: flex; flex-direction: column; gap: 8px; }
.pane-acts-2 { display: flex; gap: 8px; }
.pane-acts-2 .btn { flex: 1 1 0; }
.happened, .stamps { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.tl { display: flex; gap: 10px; font-size: 13px; }
.when { font-family: var(--mono); font-size: 12px; color: var(--dim); flex: 0 0 auto; width: 164px; white-space: nowrap; }

/* ── Today ────────────────────────────────────────────────────────────── */
.daybar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 24px; border-bottom: 1px solid var(--line); }
.day { font-size: 18px; font-weight: 700; color: var(--tx-strong); margin-right: 8px; }
.person .rowlink, .paidrow .rowlink { grid-template-columns: minmax(0, 1fr) auto; }
.codes { flex: 0 1 auto; max-width: 55%; padding: 6px 16px 6px 0; }
.codes > summary { list-style: none; display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 6px;
                   min-height: 44px; min-width: 44px; }
.codes > summary::-webkit-details-marker { display: none; }
.code { display: inline-block; padding: 3px 8px; border-radius: 6px; font-family: var(--mono); font-size: 12px; font-weight: 600;
        background: var(--grey-bg); color: var(--grey-tx); white-space: nowrap; }
.person { flex-wrap: wrap; }
.codes[open] { flex: 1 1 100%; max-width: none; padding: 0 16px 8px; }     /* spelled out: the full width, under her name */
.codes[open] > summary { justify-content: flex-start; }
.events { padding: 6px 0 8px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.events li { display: flex; gap: 10px; }

/* ── login + account ──────────────────────────────────────────────────── */
body.bare { display: flex; flex-direction: column; min-height: 100vh; }
.login { width: min(400px, calc(100vw - 32px)); margin: 8vh auto 24px; display: flex; flex-direction: column; gap: 12px; }
.login-h, .page-h { font-size: 22px; font-weight: 700; color: var(--tx-strong); }
.page { padding: 20px 24px 40px; }
.page.narrow { max-width: 560px; }
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 13px; font-weight: 600; color: var(--mut); margin-top: 6px; }
.form input[type="text"], .form input[type="password"] { height: 44px; padding: 0 12px; border-radius: 8px;
  border: 1px solid var(--line2); background: var(--surface); color: var(--tx); font: inherit; font-size: 15px; }
.form .check { display: flex; align-items: center; gap: 10px; min-height: 44px; margin-top: 4px; color: var(--tx); cursor: pointer; }
.form .check input { width: 20px; height: 20px; accent-color: var(--primary); }
.hint { font-size: 13px; color: var(--mut); }
.htmx-request.btn { opacity: .7; }

/* ── bottom bar (phone only) ──────────────────────────────────────────── */
.bar { display: none; }

/* ── wide: the pane sits beside the list ──────────────────────────────── */
@media (min-width: 1180px) {
  .cols:not(.today) { grid-template-columns: minmax(0, 1fr) 400px; }
  .cols:not(.today) > .list { border-right: 1px solid var(--line); }
  .cols:not(.today) > .pane { position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto; }
  .cols:not(.today) > .pane:empty::before { content: "Tap a row to see it here."; color: var(--dim); }
  .cols:not(.today) .pane-top { display: none; }
  .cols.today > .list { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; }
  .cols.today > .list > .foot-note, .cols.today > .list > .perf-foot { grid-column: 1 / -1; }
  .cols.today > .list > .group + .group { border-left: 1px solid var(--line); }
}
/* ── a drawer (Today on a wide screen) or a full-height sheet (everything narrower) ── */
@media (min-width: 1180px) {
  .cols.today > .pane { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: 440px; overflow-y: auto;
                        border-left: 1px solid var(--line2); box-shadow: var(--shadow); }
  .cols.today > .pane:empty { display: none; }
}
@media (max-width: 1179.98px) {
  :root { --top: 113px; }
  .top { flex-wrap: wrap; row-gap: 8px; }
  .search { order: 5; flex: 1 1 100%; }
  .who { margin-left: auto; }
  .pane { position: fixed; z-index: 40; inset: 0; overflow-y: auto; }
  .pane:empty { display: none; }
}
@media (max-width: 899.98px) { .me { display: none; } }
@media (max-width: 759.98px) {
  .rowlink { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 10px 8px 10px 14px; }
  .meta { flex-direction: row; align-items: baseline; gap: 10px; }
  .actcell { width: auto; padding: 8px 14px 8px 0; }
  .events li, .tl { flex-direction: column; gap: 0; }
  .codes[open] { padding: 0 14px 8px; }
}
@media (max-width: 699.98px) {
  :root { --top: 111px; }
  body { padding-bottom: 72px; }
  .top { flex-wrap: wrap; gap: 10px; padding: 12px 14px 10px; }
  .tabs, .who .toplink, .who .logout, .me, .newq { display: none; }
  .brand { order: 1; flex: 1 1 auto; }
  .brand-name { font-size: 15px; }
  .who { order: 2; }
  .chipbar { padding: 10px 14px; }
  .chips { gap: 8px; }
  .chip { padding: 0 12px; font-size: 13px; }
  .chip strong { font-size: 16px; }
  .lbl { display: none; } .lbl-s { display: inline; }
  .grp { padding: 8px 14px; }
  .daybar { padding: 10px 14px; }
  .page { padding: 16px 14px 32px; }
  .codes { max-width: 48%; padding-right: 14px; }
  .bar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; height: 64px; display: flex; align-items: stretch;
         justify-content: space-around; background: var(--panel); border-top: 1px solid var(--line); }
  .bar-i { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
           min-height: 44px; color: var(--mut); font-size: 11px; font-weight: 600; text-decoration: none; cursor: pointer; }
  .bar-i.on { color: var(--tx-strong); }
  .bar-n { font-family: var(--mono); font-size: 16px; }
}
