:root {
  /* White theme (R16): white surfaces, light-grey borders, charcoal text. There is no dark variant. */
  --canvas: #fafafa;
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f7f7f7;
  --selected: #ededed;
  --ink: #212121;
  --muted: #595959;
  --line: #dedede;
  --divide: #e9e9e9;
  --field: #a2a2a2;
  --accent: #252525;
  --accent-hover: #3d3d3d;
  --accent-ink: #ffffff;
  --accent-soft: #ededed;
  --warn: #8a4800;
  --warn-soft: #fdf3e3;
  --danger: #a92019;
  --in: #1d6b45;
  --ok: #1d6b45;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 6px 24px rgb(0 0 0 / 5%);
  --frost: rgb(255 255 255 / 90%);
  --heading: Georgia, "Times New Roman", serif;
  --side: 220px;
  /* Seamless 480 × 144 tile of soft sine-wave lines. */
  --wave: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAACQCAQAAAB6iHBrAAAMj0lEQVR42u2d2ZbiSAwFjRcwGLzy/986TinlDZiGbhYvEX6Yoboe6hhfS6lU6gYBbIEwiIIkOATHIAsuQRFUwTWogzLIg3P7s0P7byE3aRFEQdp+a9f2OzwGsfvBuf36dtyXlbBrhRgH+06qeSvSWsRatV/5pf2ZyjXiVi2cpP0u3Xfb6vkSNO3/ntofwVJkGnUyPbWvYBdT3ZfZtJfGVZPqvv09YuuaMytP3D4IRfumzi0ww2xEmrbfjUXTSuJp0/7XZHpq/93FVCdUMqnNs5fA3LSPRkqa9aWEN7kRaTMS6bn9N4umEfEUnnmwDu1j4972CPk9iU40kuk44S1uREokhTc9eCrkhtT66Ts2LCEVkxKSyZSEF74ckTW1dsXrrP1/0rherKmUkfpq77CElFBCgnmRtA9m3j6mLrk+tp92mxfrWcpIVHthccl11sZjV2q5tI/wuqLytOmhQaywVqL2UT9JVG7ah/0scXlJj/e92DptemC1CptYKSetEFxcrqU15CLxak5yHou1IBEGeCTmWCLz2ctEY5qJ5LMx7XZ3tfANEGOx0v8L8NKq0tLUarIHms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3aSR/vy/R75EcBz16jfQz6BSxmEgN8GqETfwUzVL2+0uZVK1yCr/yyohGf0G9yOZhgK9G2YMYkw4FM5f4Fw6ah2s5aov/IiDazuGw6nrq55+yhnLU9uK9opAybIyoM0trOofDpUog9lJW21D8f2G1a9q9POqlHHdZn1naTmxDc3klufnrrJRhFQly6odB1FKEOmxg2los89dreU0xJhIWmCDvpRRV+Wi0pXFM04XC2TscEZFh9glkKifCG/E5PFHYGQjZInLGGhnmlSxqBdlGLKUbjbXPCvkoa+QCayP4rWhP3gbcKsikh6+QiLWROqJw5+AL6fFUtCdswN9wV90K2RJrgDene27T5zwaWohoP5dYq9Ug9xf+SbKp74m6SiEqm9mc0XXj/FC0Yk08hicIu9GDNks0ly0f4uxvX6Mp8RjuyTX2EfbSzcguZjjNG/4nHv8Hyd+WAZSiTFYAAAAASUVORK5CYII=");
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.48;
  color-scheme: light;
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; background: var(--canvas) var(--wave) repeat; background-size: 480px 144px; color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--heading); line-height: 1.12; letter-spacing: -0.02em; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---- layout: sidebar beside the page ---- */
.shell { max-width: 1580px; margin: clamp(0px, 1.4vw, 24px) auto; width: calc(100% - clamp(0px, 2.8vw, 48px)); min-height: calc(100vh - clamp(0px, 2.8vw, 48px)); display: grid; grid-template-columns: var(--side) minmax(0, 1fr); align-items: stretch; border: 1px solid var(--divide); border-radius: 24px; background: var(--canvas) var(--wave) repeat; background-size: 480px 144px; box-shadow: var(--shadow); }
/* Corners are rounded on the parts, not clipped by the frame, so nothing too wide can ever be cut off. */
.sidebar { background: var(--surface-2); border-right: 1px solid var(--line); border-radius: 23px 0 0 23px; min-width: 0; }
.side-in { position: sticky; top: 0; max-height: 100vh; max-height: 100dvh; overflow: auto; scrollbar-width: thin; padding: 22px 14px 20px; display: flex; flex-direction: column; gap: 18px; }
.side-head { display: flex; align-items: center; gap: 10px; padding: 0 4px; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-family: var(--heading); font-size: 1.4rem; font-weight: 700; line-height: 1; }
.mark { display: grid; grid-template-columns: repeat(2, 7px); gap: 3px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px; flex: none; }
.mark i { height: 8px; border-radius: 4px; background: #292929; }
.mark i:nth-child(2) { background: #737373; }
.mark i:nth-child(3) { background: #8a8a8a; }
.mark i:nth-child(4) { background: #4d4d4d; }
.nav-toggle.btn { display: none; }
.org { display: flex; gap: 9px; align-items: center; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 0.8rem; line-height: 1.3; font-weight: 700; min-width: 0; }
.org-mark { flex: none; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--selected); }
.org-name { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.org select.input { font-size: 0.8rem; font-weight: 700; min-height: 36px; padding: 4px 6px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; min-height: 42px; padding: 4px 10px; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.side-nav a:hover { background: var(--selected); color: var(--ink); }
.side-nav a.section-active { background: var(--selected); color: var(--ink); }
.side-nav svg { width: 19px; height: 19px; flex: none; }
.side-nav .badge { margin-left: auto; }
.subnav { display: grid; gap: 2px; margin: 3px 0 8px 18px; padding-left: 8px; border-left: 1px solid var(--line); }
.side-nav .subnav a { min-height: 34px; padding: 4px 8px; font-size: 0.83rem; }
.side-nav a[aria-current] { background: var(--selected); color: var(--ink); font-weight: 750; }
.side-nav .subnav a[aria-current] { box-shadow: inset 3px 0 0 var(--accent); }
.subnav .category { font-size: 0.72rem; font-weight: 700; color: var(--muted); padding: 8px 8px 2px; }
.subnav .subnav { margin: 1px 0 4px 8px; }
.work { min-width: 0; display: flex; flex-direction: column; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 10px 16px; flex-wrap: wrap; padding: 11px clamp(15px, 2.2vw, 36px); border-bottom: 1px solid var(--line); border-radius: 0 23px 0 0; background: var(--surface); }
.crumb { color: var(--muted); font-size: 0.85rem; }
.crumb b { color: var(--ink); }
.who { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; color: var(--muted); font-size: 0.85rem; min-width: 0; }
.who-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.skip { position: absolute; left: 12px; top: -120px; z-index: 20; }
.skip:focus { top: 10px; }
main { width: 100%; max-width: 1260px; min-width: 0; padding: clamp(20px, 2.4vw, 34px) clamp(15px, 2.2vw, 36px) 96px; }
main:focus { outline: none; }
h1 { font-size: clamp(2rem, 4.2vw, 3.25rem); margin: 0 0 8px; overflow-wrap: anywhere; }
.lede { margin: 0 0 20px; color: var(--muted); max-width: 66ch; }

@media (max-width: 860px) {
  .shell { display: block; width: 100%; margin: 0; border: 0; border-radius: 0; min-height: 100vh; }
  .sidebar { position: relative; z-index: 8; border-right: 0; border-bottom: 1px solid var(--line); border-radius: 0; }
  .top { border-radius: 0; }
  .side-in { position: static; max-height: none; overflow: visible; padding: 10px 15px; gap: 0; }
  .nav-toggle.btn { display: inline-flex; width: 44px; padding: 0; }
  .nav-toggle svg { width: 20px; height: 20px; }
  .brand { font-size: 1.2rem; }
  .side-panel { display: none; position: absolute; top: 100%; left: 9px; width: min(300px, calc(100vw - 18px)); max-height: 75vh; max-height: 75dvh; overflow: auto; overscroll-behavior: contain; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); box-shadow: 0 12px 36px rgb(0 0 0 / 14%); }
  .side-panel.is-open { display: grid; gap: 10px; }
  .side-nav a, .side-nav .subnav a { min-height: 44px; }
  .who-name { display: none; }
}
@media (min-width: 861px) { .side-panel { display: contents; } }

/* ---- buttons ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 7px 13px; cursor: pointer; font-size: 0.88rem; font-weight: 650; line-height: 1.2; text-align: center; text-decoration: none; color: var(--ink); }
.btn:hover:not(:disabled):not(.primary):not(.confirm) { background: var(--surface-2); border-color: var(--field); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover:not(:disabled):not(.confirm) { background: var(--accent-hover); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn.quiet:hover:not(:disabled) { color: var(--ink); background: var(--selected); border-color: transparent; }
.btn.confirm { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.btn.sm { min-height: 34px; padding: 5px 10px; font-size: 0.82rem; }
@media (pointer: coarse) { .btn.sm { min-height: 42px; } }

/* ---- forms / sign-in ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.auth { width: calc(100% - 32px); max-width: 400px; margin: 10vh auto 0; padding: 28px 24px 24px; box-shadow: var(--shadow); }
.auth h1 { margin-bottom: 16px; font-size: 2rem; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 0.84rem; font-weight: 650; }
.field input, .field select, .field textarea, .input { width: 100%; min-height: 42px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--field); background: var(--surface); }
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), select, textarea { background-color: var(--surface); }
.field input:focus, .input:focus, select:focus { border-color: var(--accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
.err { color: var(--danger); margin: 8px 0 0; font-size: 0.93em; }
.note { color: var(--muted); font-size: 0.88rem; }

/* ---- summary + filters ---- */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { padding: 13px 16px; min-width: 160px; }
.stat b { display: block; font-family: var(--heading); font-size: 1.45rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 0.85em; }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.bar .grow { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: none; min-height: 38px; padding: 6px 12px; cursor: pointer; color: var(--muted); font-size: 0.86rem; }
.seg button:focus-visible { outline-offset: -3px; }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.search { width: 240px; max-width: 100%; }

.working { background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius); padding: 9px 14px; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; }
.spin { width: 14px; height: 14px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 3s; } }

/* ---- groups ---- */
.groups { display: grid; gap: 8px; }
.g { overflow: hidden; }
.g-head { display: grid; grid-template-columns: auto minmax(0, 1.6fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 14px; }
.g-check { width: 18px; height: 18px; accent-color: var(--accent); }
.g-name { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; display: block; width: 100%; }
.g-name strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-sub { color: var(--muted); font-size: 0.86em; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.g-amt { text-align: right; font-variant-numeric: tabular-nums; }
.g-amt b { display: block; font-size: 1.02rem; }
.g-amt .in { color: var(--in); }
.g-sugg { display: block; color: var(--muted); font-size: 0.84em; }
.g-act { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 0.8em; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.ok { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.g-body { border-top: 1px solid var(--line); background: var(--surface-2); padding: 14px; display: grid; gap: 14px; }
.explain { margin: 0; max-width: 78ch; }
.choose { display: flex; gap: 8px; flex-wrap: wrap; align-items: end; }
.choose .field { margin: 0; min-width: 260px; flex: 1; max-width: 420px; }
.lines { width: 100%; border-collapse: collapse; font-size: 0.88rem; background: var(--surface); }
.lines th { text-align: left; color: var(--muted); background: var(--surface-2); font-size: 0.78rem; font-weight: 700; padding: 7px 8px; border-bottom: 1px solid var(--line); }
.lines td { padding: 5px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.lines td.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.lines .desc { word-break: break-word; }
.scroll { max-height: 320px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* ---- bulk bar + dialog + toast ---- */
.bulk { position: sticky; bottom: 12px; margin-top: 14px; padding: 10px 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; box-shadow: 0 6px 24px rgb(0 0 0 / 18%); }
dialog { border: 1px solid var(--line); border-radius: 17px; background: var(--surface); color: var(--ink); max-width: min(580px, 94vw); max-height: 85vh; max-height: 85dvh; padding: 20px; box-shadow: 0 18px 50px rgb(0 0 0 / 14%); }
dialog::backdrop { background: rgb(0 0 0 / 35%); }
dialog h2 { margin: 0 0 10px; font-size: 1.4rem; }
.sum { margin: 10px 0 16px; padding: 0; list-style: none; display: grid; gap: 4px; max-height: 40vh; overflow: auto; }
.sum li { display: flex; justify-content: space-between; gap: 12px; }
.row-end { display: flex; gap: 8px; justify-content: flex-end; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 10; max-width: min(420px, 92vw); }
.toast { padding: 10px 14px; background: var(--ink); color: #fff; border-radius: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / 25%); }
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 760px) {
  .g-head { grid-template-columns: auto minmax(0, 1fr); }
  .g-amt { text-align: left; grid-column: 2; }
  .g-act { grid-column: 1 / -1; justify-content: flex-start; }
  .stat { min-width: 0; flex: 1 1 140px; }
}

/* ---- reports ---- */
.rhead { display: flex; gap: 16px; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; margin-bottom: 14px; }
.date { width: auto; padding: 5px 8px; }
.rtable { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 0.9rem; }
.rtable th { text-align: left; font-size: 0.78rem; font-weight: 700; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.rtable td { padding: 8px 12px; border-bottom: 1px solid var(--divide); }
.rtable tbody tr:not(.sec):not(.sub):hover td { background: var(--surface-2); }
.rtable tr:last-child td { border-bottom: 0; }
.rtable .amt, .rtable th.amt, .lines th.amt { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.rtable tr.sec td { background: var(--surface-2); font-weight: 600; padding-top: 10px; }
.rtable tr.sub td { font-weight: 700; background: var(--selected); border-top: 1px solid var(--line); }
.rtable tr.tot td { font-weight: 700; border-top: 2px solid var(--ink); }
.rtable td a, .lines td a { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--muted); }
.rtable td a:hover, .lines td a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.rtable .ind { padding-left: 28px; }
.ok-line { color: var(--in); font-weight: 600; }
.bad-line { color: var(--danger); font-weight: 600; }
.entry { margin-bottom: 8px; overflow: hidden; }
.entry-head { display: flex; gap: 12px; justify-content: space-between; align-items: baseline; padding: 9px 14px; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; }
.entry-head:hover { background: var(--surface-2); }
.entry .lines { margin: 0 0 4px; }
dialog.wide { max-width: min(760px, 94vw); width: 100%; }
.scroll-x { overflow-x: auto; }
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; align-items: end; margin-bottom: 12px; padding: 12px; }
@media print {
  :root { font-size: 15px; }
  .sidebar, .top, .skip, .noprint, .toasts, .bulk { display: none !important; }
  body, .shell { background: #fff !important; background-image: none !important; color: #000; }
  .shell { display: block; width: auto; max-width: none; min-height: 0; margin: 0; border: 0; border-radius: 0; box-shadow: none; overflow: visible; }
  main { max-width: none; padding: 0; }
  h1, h2, h3 { font-family: inherit; letter-spacing: normal; }
  h1 { font-size: 1.35rem; margin-bottom: 4px; }
  .card, .rtable, .lines { box-shadow: none; border-color: #bbb; background: #fff !important; -webkit-backdrop-filter: none !important; backdrop-filter: none !important; }
  .rtable tr.sub td { background: #eee; }
  a { color: inherit !important; border: 0 !important; }
}
.row-end { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lines td.ind { padding-left: 24px; }
.seg { max-width: 100%; overflow-x: auto; }

tr.off td { color: var(--muted); }
tr.off td a { color: var(--muted); }
.input.amt { text-align: right; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; background: var(--ink); color: #fff; font-size: 0.78em; font-weight: 700; text-align: center; }
.h2 { font-size: 1.35rem; margin: 26px 0 10px; }
.h3 { font-size: 0.95rem; margin: 8px 0 0; color: var(--muted); font-weight: 600; }
textarea.input { resize: vertical; font: inherit; }

/* ---- invoices ---- */
.inv-foot { display: grid; grid-template-columns: 1fr minmax(260px, 380px); gap: 10px; margin-top: 10px; align-items: start; }
@media (max-width: 760px) { .inv-foot { grid-template-columns: 1fr; } }
.invoice-doc { padding: 26px 28px; max-width: 900px; margin: 0 auto 16px; }
.inv-head { display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap; border-bottom: 2px solid var(--ink); padding-bottom: 12px; margin-bottom: 12px; }
.inv-seller { margin: 0 0 4px; font-size: 1.25rem; }
.inv-title { text-align: right; }
.inv-kind { font-weight: 800; letter-spacing: 0.08em; font-size: 1.1rem; margin-bottom: 4px; }
.inv-parties { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 14px; }
.inv-label { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 2px; }
.inv-lines th { background: var(--surface-2); }
.inv-totals { display: grid; grid-template-columns: 1fr minmax(240px, 340px); gap: 16px; margin: 12px 0; align-items: start; }
.inv-tax { margin: 6px 0 12px; max-width: 520px; }
.inv-bottom { display: grid; grid-template-columns: 1fr auto; gap: 24px; border-top: 1px solid var(--line); padding-top: 12px; }
.inv-sign { text-align: right; align-self: end; }
.inv-sigline { margin-top: 38px; border-top: 1px solid var(--ink); padding-top: 4px; min-width: 200px; }
@media (max-width: 760px) { .inv-parties, .inv-totals, .inv-bottom { grid-template-columns: 1fr; } .inv-title, .inv-sign { text-align: left; } .invoice-doc { padding: 16px; } }
@media print {
  .invoice-doc { border: 0; box-shadow: none; padding: 0; max-width: none; }
  @page { size: A4; margin: 14mm; }
}

/* Ask your books: chat beside the thread list on wide screens, stacked on narrow ones. */
.assist-grid { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
@media (max-width: 760px) { .assist-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---- chat box ---- */
.chat-open { position: fixed; right: 16px; bottom: 16px; z-index: 9; border-radius: 999px; padding: 11px 20px; box-shadow: 0 6px 24px rgb(0 0 0 / 22%); }
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 9; width: min(390px, calc(100vw - 32px)); height: min(540px, calc(100dvh - 32px)); display: flex; flex-direction: column; box-shadow: 0 10px 40px rgb(0 0 0 / 28%); }
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--line); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 14px; overscroll-behavior: contain; }
.chat-turn { margin-bottom: 14px; }
.chat-turn p { margin: 0 0 6px; overflow-wrap: anywhere; }
.chat-turn .chat-asked { background: var(--surface-2); border-radius: 10px; padding: 7px 11px; width: fit-content; max-width: 92%; margin-left: auto; }
.chat-turn .chat-reply { white-space: pre-wrap; }
.chat-links { display: flex; flex-wrap: wrap; gap: 6px; }
.chat-links .btn { text-align: left; max-width: 100%; overflow-wrap: anywhere; color: inherit; }
.chat-form { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
.chat-form .input { flex: 1; min-width: 0; }
.chat.over { outline: 2px dashed var(--accent); outline-offset: -6px; }
.chat-attach { padding-left: 8px; padding-right: 8px; flex: none; }
.chat-file .uplist { margin: 0 0 6px; }
.chat-file .uprow { border-top: 0; padding: 0; margin: 0; }
.chat-file .card { padding: 10px 12px; margin-bottom: 8px; box-shadow: none; }
.billcard > .pill { margin-left: 8px; }
.billcard p { margin: 6px 0 0; }
.billcard .chat-links { margin-top: 10px; }
.billlines { list-style: none; margin: 8px 0 0; padding: 0; }
.billlines li { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding: 5px 0; overflow-wrap: anywhere; }
.billlines .note { display: block; margin: 0; }
.billlines .num { white-space: nowrap; }
.billsums { margin: 0; border-top: 1px solid var(--line); padding-top: 5px; }
.billsums div { display: flex; justify-content: space-between; gap: 10px; }
.billsums dt { color: var(--muted); }
.billsums dd { margin: 0; font-variant-numeric: tabular-nums; white-space: nowrap; }
.billsums .billtotal, .billsums .billtotal dt { font-weight: 600; color: inherit; }
.billcard label.note { display: block; margin-top: 8px; }
.toasts { bottom: 72px; }
.bulk { bottom: 70px; }
@media (max-width: 760px) {
  .chat { inset: 0; width: auto; height: 100dvh; border: 0; border-radius: 0; z-index: 11; }
}

/* Original files (R13a) */
.linklike { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; cursor: pointer; font: inherit; text-align: left; }
.linklike.note { font-size: 0.9em; }
.filerow { display: flex; gap: 10px; align-items: flex-start; flex-wrap: wrap; padding: 10px 0; border-top: 1px solid var(--line); }
.filerow:first-child { border-top: 0; }
.filekind { flex: 0 0 52px; text-align: center; padding: 6px 0; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.75em; color: var(--muted); }
.filemain { flex: 1 1 200px; min-width: 0; }
.filename { font-weight: 600; overflow-wrap: anywhere; }
.fileacts { display: flex; gap: 6px; margin-left: auto; }
.fileuses { display: flex; flex-wrap: wrap; gap: 4px 12px; align-items: center; margin-top: 4px; }
.attach { margin-top: 8px; }
.attachlist { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.attachlist .btn { text-align: left; white-space: normal; }
.clip { border: 0; background: none; padding: 0 4px; cursor: pointer; font: inherit; font-size: 0.85em; color: var(--muted); white-space: nowrap; }
.clip.none { opacity: 0.45; }
.statements { padding: 10px 14px; margin-bottom: 12px; }
.statement { padding: 8px 0 0; }

/* Uploading (R13b) */
.upload { padding: 10px 14px; margin-bottom: 12px; border-style: dashed; }
.upload.over { border-color: var(--accent); background: var(--accent-soft); }
.uphead { display: flex; gap: 8px 10px; flex-wrap: wrap; align-items: center; }
.uphead > .note { flex: 1 1 220px; }
.uplist { list-style: none; margin: 8px 0 0; padding: 0; }
.uprow { padding: 8px 0 0; margin-top: 8px; border-top: 1px solid var(--line); }
.upname { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
.upask { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.upask .input { width: min(280px, 100%); }
.touchonly { display: none; }
@media (pointer: coarse) { .touchonly { display: inline-block; } .mouseonly { display: none; } }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
label.btn:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
label.btn.off { opacity: 0.6; }

/* Sorting other files (R13c) */
.readout { display: flex; flex-wrap: wrap; gap: 6px 22px; margin: 0; }
.readout dt { font-size: 12px; color: var(--muted); }
.readout dd { margin: 0; overflow-wrap: anywhere; }
.matchrow { display: flex; gap: 10px; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); padding: 8px 0 0; margin-top: 8px; }
.paidbox { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-top: 8px; }

/* ---- Today ---- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { display: grid; align-content: start; gap: 2px; min-width: 0; padding: 14px 16px; color: inherit; text-decoration: none; overflow-wrap: anywhere; }
.kpi strong { font: 700 clamp(1.35rem, 2.4vw, 1.9rem) / 1.2 var(--heading); font-variant-numeric: tabular-nums; }
.kpi span { color: var(--muted); font-size: 0.82rem; }
.kpi .go { color: var(--ink); font-weight: 700; margin-top: 6px; }
a.kpi:hover .go { text-decoration: underline; }
.kpi.late { border-left: 4px solid var(--warn); }
.panel { min-width: 0; padding: 17px 19px; }
.panel h2 { margin: 0; font-size: 1.45rem; }
.panel-title { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; flex-wrap: wrap; margin-bottom: 12px; }
.textlink { display: inline-flex; align-items: center; min-height: 34px; color: var(--ink); font-size: 0.84rem; font-weight: 700; text-decoration: none; }
.textlink:hover { text-decoration: underline; }
.overview { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: 14px; margin-bottom: 16px; }
.overview > :only-child { grid-column: 1 / -1; }
.glance { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.glance li { display: grid; grid-template-columns: minmax(80px, 120px) minmax(20px, 1fr) auto; gap: 10px; align-items: center; font-size: 0.83rem; }
.glance .track { display: block; height: 12px; border-radius: 15px; background: var(--selected); overflow: hidden; }
.glance .fill { display: block; height: 100%; border-radius: 15px; background: #525252; }
.glance li:nth-child(2) .fill { background: #7a7a7a; }
.glance b { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.glance b.loss { color: var(--danger); }
.glance li .fill.loss { background: var(--danger); }
.split { display: grid; grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); gap: 14px; align-items: start; }
.queue-filter { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; font-size: 0.82rem; font-weight: 650; color: var(--muted); }
.queue-filter select { width: auto; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.queue td { vertical-align: top; }
.queue .detail { display: block; color: var(--muted); font-size: 0.82rem; max-width: 46ch; }
.queue .textlink { min-height: 24px; white-space: nowrap; border-bottom: 0; }
.queue .pill { white-space: nowrap; }
.pill.late { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); font-weight: 700; }
.reminders { list-style: none; margin: 0; padding: 0; }
.reminders a { display: block; padding: 11px 0; border-top: 1px solid var(--line); color: inherit; text-decoration: none; }
.reminders a:hover strong { text-decoration: underline; }
.reminders strong { display: block; font-size: 0.9rem; }
.reminders span { display: block; color: var(--muted); font-size: 0.8rem; }
@media (max-width: 1180px) { .split { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) {
  .overview, .kpis { grid-template-columns: minmax(0, 1fr); }
  .panel { padding: 14px 13px; }
  /* The queue reads as a list on a phone, so no column is off the screen. */
  .queue thead { display: none; }
  .queue tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 10px 12px; border-bottom: 1px solid var(--divide); }
  .queue tr:last-child { border-bottom: 0; }
  .queue td { display: block; padding: 0; border: 0; }
  .queue td:first-child { grid-column: 1 / -1; }
  .queue tbody tr:hover td { background: none; }
}

/* ---- frosted chrome over the waves; tables, ledger rows and fields stay solid white ---- */
.rtable, .lines, .scroll, .entry, .g { background-color: var(--surface); }
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .sidebar, .top, .card, dialog { background: var(--frost); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
  .card .card, .entry, .g, .invoice-doc { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .entry, .g, .invoice-doc, .chat, .rtable, .lines { background-color: var(--surface); }
  .bulk { background: var(--frost); }
  dialog::backdrop { background: rgb(0 0 0 / 28%); -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }
}
@media (prefers-reduced-transparency: reduce), (forced-colors: active) {
  .sidebar, .top, .card, dialog, .bulk, dialog::backdrop { -webkit-backdrop-filter: none; backdrop-filter: none; }
  .top, .card, dialog, .bulk { background: var(--surface); }
  .sidebar { background: var(--surface-2); }
  dialog::backdrop { background: rgb(0 0 0 / 40%); }
}
@media (forced-colors: active) {
  body, .shell { background-image: none; }
  .glance .fill { background: CanvasText; }
  .side-nav a[aria-current] { outline: 2px solid Highlight; outline-offset: -2px; }
}

[hidden] { display: none !important; }
.attachlist .btn, .chat-links .btn { justify-content: flex-start; }
.btn { gap: 6px; }
.subgroup { display: grid; gap: 2px; }
.subnav .category { margin: 0; }

/* A form laid out in columns goes to one column on a phone, and a table inside it scrolls by itself. */
.filters > * { min-width: 0; }
@media (max-width: 560px) {
  .filters { grid-template-columns: minmax(0, 1fr); }
  .filters > * { grid-column: 1 / -1 !important; }
  .filters > table.rtable { display: block; overflow-x: auto; }
}

/* A status beside a page title stays label-sized. */
h1 .pill { font: 650 0.8rem / 1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; letter-spacing: 0; vertical-align: middle; }
/* Line tables being typed into stay compact, so every column is in view on a laptop. */
.rtable td:has(> .input) { padding: 6px 5px; }
.rtable th { padding-left: 10px; padding-right: 10px; }
.rtable td .input { min-height: 38px; padding: 6px 8px; font-size: 0.86rem; }
.stat b { overflow-wrap: anywhere; }
/* One figure to a row on a phone, so a large amount is never broken in two. */
@media (max-width: 560px) { .stats > .stat { flex: 1 1 100%; } }
