/* Sowmya Feeds website. Paper white, ballpoint blue, bill-number red; yellow carbon slips for bills.
   Phone first: a bottom tab bar under 900px wide, a left rail above. */
@import url("https://fonts.googleapis.com/css2?family=Hind+Guntur:wght@400;500;600;700&display=swap");

:root {
  --paper: #ffffff;
  --ground: #f3f4f6;
  --ink: #1d2230;
  --ink-2: #4d5466;
  --ink-3: #7a8194;
  --rule: #e2e4ea;
  --rule-2: #cdd1da;
  --blue: #22388c;        /* ballpoint ink: actions, links, Factory */
  --blue-soft: #e8ecf8;
  --red: #c42b2b;         /* the printed bill number; delete and reject */
  --red-soft: #fbeaea;
  --carbon: #fbeba0;      /* yellow carbon copy */
  --carbon-edge: #e6cf63;
  --ponds: #2e7d6f;
  --ponds-soft: #e3f1ee;
  --factory: #22388c;
  --factory-soft: #e8ecf8;
  --misc: #77706a;
  --misc-soft: #efedea;
  --ok: #2d7a3e;
  --ok-soft: #e5f3e8;
  --warn: #9a5b00;
  --warn-soft: #fdf1dc;
  --s-ponds: #1baf7a; --s-factory: #2a78d6; --s-misc: #eb6834;
  --s-sales: #6250d6; --s-costs: #e87ba4; --s-buy: #eda100; --s-profit: #1d2230;
  --good: #006300; --bad: #c42b2b;
  --font: "Hind Guntur", "Noto Sans Telugu", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171a22; --ground: #0f1117; --ink: #e9ebf1; --ink-2: #b9bfcc; --ink-3: #8a91a2;
    --rule: #2a2f3b; --rule-2: #3a4050; --blue: #9db0f2; --blue-soft: #232c48; --red: #f08a8a; --red-soft: #3a1f22;
    --carbon: #4a4220; --carbon-edge: #6b5f2a; --ponds: #6cc3b2; --ponds-soft: #1c3330; --factory: #9db0f2;
    --factory-soft: #232c48; --misc: #b8b0a8; --misc-soft: #2c2a28; --ok: #7dcc8e; --ok-soft: #1c3322;
    --warn: #f0b860; --warn-soft: #3a2c14; color-scheme: dark;
    --s-ponds: #199e70; --s-factory: #3987e5; --s-misc: #d95926;
    --s-sales: #9085e9; --s-costs: #d55181; --s-buy: #c98500; --s-profit: #e9ebf1; --good: #0ca30c; --bad: #f08a8a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--ground); color: var(--ink); font-family: var(--font);
  font-size: 16px; line-height: 1.45; font-variant-numeric: tabular-nums;
}
body.sheet-open { overflow: hidden; }
a { color: var(--blue); text-underline-offset: 2px; }
h1, h2 { line-height: 1.2; margin: 0; }
h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; font-weight: 600; }
input, select, button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--red); }
.muted { color: var(--ink-3); }
.block { display: block; }
.red { color: var(--red); }
.grow { flex: 1; }
s { color: var(--ink-3); }

/* ── Shell ─────────────────────────────────────────────────────────────── */
.shell { min-height: 100vh; }
.rail {
  position: fixed; inset: auto 0 0 0; z-index: 20; background: var(--paper); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom);
}
.rail .brand, .rail .rail-foot { display: none; }
.rail ul { list-style: none; margin: 0; padding: 0; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.rail a {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; font-size: 0.75rem;
  color: var(--ink-3); text-decoration: none; font-weight: 500;
}
.rail a.active { color: var(--blue); }
.rail a.active svg { stroke-width: 2.2; }
.main { padding: 16px 16px 96px; max-width: 1180px; }

@media (min-width: 900px) {
  .rail {
    inset: 0 auto 0 0; width: 220px; border-top: 0; border-right: 1px solid var(--rule);
    display: flex; flex-direction: column; padding: 20px 12px;
  }
  .rail .brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
  .rail ul { grid-auto-flow: row; gap: 2px; }
  .rail a { flex-direction: row; gap: 12px; padding: 9px 10px; font-size: 0.98rem; border-radius: var(--r); color: var(--ink-2); }
  .rail a:hover { background: var(--ground); }
  .rail a.active { background: var(--blue-soft); color: var(--blue); font-weight: 600; }
  .rail .rail-foot { display: flex; flex-direction: column; gap: 12px; margin-top: auto; padding: 0 8px; font-size: 0.9rem; }
  .main { margin-left: 220px; padding: 28px 36px 48px; }
}
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  border: 2px solid var(--blue); color: var(--blue); font-weight: 700; font-size: 0.85rem; letter-spacing: 0.02em;
}
.brand-name { font-weight: 700; font-size: 1.05rem; }
.who { display: flex; flex-direction: column; }
.who small { color: var(--ink-3); }

/* ── Page frame ────────────────────────────────────────────────────────── */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.page-sub { margin: 4px 0 0; color: var(--ink-2); max-width: 62ch; }
.page-actions { display: flex; gap: 8px; align-items: center; }

/* ── Controls ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px;
  border-radius: var(--r); border: 1px solid var(--rule-2); background: var(--paper); cursor: pointer; font-weight: 600;
}
.btn:hover:not(:disabled) { border-color: var(--ink-3); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.1); border-color: var(--blue); }
.btn-approve { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-approve:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--ok); }
.btn-danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, var(--rule)); }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); border-color: var(--red); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary, :root:not([data-theme="light"]) .btn-approve { color: #10131a; } }
.link { background: none; border: 0; padding: 4px 0; color: var(--blue); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.link:disabled { opacity: 0.5; }
.icon-btn { background: none; border: 0; width: 36px; height: 36px; border-radius: var(--r); cursor: pointer; color: var(--ink-3); }
.icon-btn:hover:not(:disabled) { background: var(--ground); color: var(--ink); }
.icon-btn:disabled { opacity: 0.3; }
.spin {
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2s; } }

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.field-hint { font-size: 0.8rem; color: var(--ink-3); }
.field input, .field select, .filters input, .lines-edit input, .lines-edit select {
  min-height: 40px; padding: 6px 10px; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--paper); width: 100%;
}
.field input:focus, .field select:focus, .lines-edit input:focus { border-color: var(--blue); outline: none; box-shadow: 0 0 0 3px var(--blue-soft); }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; color: var(--ink-2); }
.switch input { width: 18px; height: 18px; accent-color: var(--blue); }

.notice { padding: 10px 14px; border-radius: var(--r); margin: 0 0 14px; border-left: 4px solid var(--ink-3); background: var(--ground); }
.notice-error { border-color: var(--red); background: var(--red-soft); }
.notice-ok { border-color: var(--ok); background: var(--ok-soft); }
.notice-warn { border-color: var(--warn); background: var(--warn-soft); }
.notice-info { border-color: var(--blue); background: var(--blue-soft); }
.loading { display: flex; align-items: center; gap: 10px; color: var(--ink-3); padding: 24px 0; }
.empty { padding: 32px 20px; text-align: center; color: var(--ink-2); background: var(--paper); border: 1px dashed var(--rule-2); border-radius: var(--r); }
.aside { color: var(--ink-2); font-size: 0.92rem; max-width: 72ch; }

.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.78rem; font-weight: 600;
  background: var(--ground); color: var(--ink-2); white-space: nowrap; vertical-align: 1px;
}
.chip-ponds { background: var(--ponds-soft); color: var(--ponds); }
.chip-factory { background: var(--factory-soft); color: var(--factory); }
.chip-misc { background: var(--misc-soft); color: var(--misc); }
.chip-ok { background: var(--ok-soft); color: var(--ok); }
.chip-warn { background: var(--warn-soft); color: var(--warn); }
.chip-waiting { background: var(--blue-soft); color: var(--blue); }

.tabs { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 16px; border-bottom: 1px solid var(--rule); }
.tabs button {
  background: none; border: 0; padding: 8px 12px 10px; cursor: pointer; color: var(--ink-2); font-weight: 500;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tabs button.on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.count { background: var(--red); color: #fff; border-radius: 999px; padding: 0 7px; font-size: 0.78rem; line-height: 1.5; }
.count-quiet { background: var(--rule-2); color: var(--ink); }

/* ── Sign-in and gates ─────────────────────────────────────────────────── */
.login, .gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate { place-content: center; gap: 12px; text-align: center; max-width: 440px; margin: 0 auto; }
.login-card {
  width: 100%; max-width: 380px; background: var(--paper); border: 1px solid var(--rule); border-radius: 10px;
  padding: 28px 24px; display: flex; flex-direction: column; gap: 14px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 6px; }
.login-brand h1 { font-size: 1.35rem; }
.login-brand p { margin: 0; color: var(--ink-3); }
.login .btn { margin-top: 4px; }

/* ── Profit ────────────────────────────────────────────────────────────── */
.month-step { display: flex; align-items: center; gap: 6px; }
.month-step span { min-width: 5.5em; text-align: center; font-weight: 600; }
.month-step .btn { min-width: 40px; padding: 0; font-size: 1.2rem; }
.waiting-strip {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; padding: 12px 16px; margin-bottom: 16px;
  background: var(--carbon); border: 1px solid var(--carbon-edge); border-radius: var(--r); color: var(--ink); text-decoration: none;
}
.waiting-strip strong { color: var(--red); }
.waiting-strip span { color: var(--ink-2); font-size: 0.92rem; }
.statement { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; margin-bottom: 10px; }
.st-row { display: grid; grid-template-columns: 1.1fr repeat(4, 1fr); align-items: baseline; padding: 10px 14px; gap: 8px; }
.st-row + .st-row { border-top: 1px solid var(--rule); }
.st-row > span:first-child { color: var(--ink-2); }
.st-head { padding-top: 12px; padding-bottom: 8px; }
.st-c { text-align: right; font-weight: 700; font-size: 0.95rem; }
.st-ponds { color: var(--ponds); }
.st-factory { color: var(--factory); }
.st-overhead { color: var(--misc); }
.st-total { color: var(--ink); }
.st-net { background: var(--ground); font-weight: 700; font-size: 1.12rem; }
.st-net > span:first-child { color: var(--ink); }
.st-row > span:last-child { border-left: 1px solid var(--rule); padding-left: 8px; }
@media (max-width: 560px) {
  .st-row { grid-template-columns: 4.4em repeat(4, minmax(0, 1fr)); padding: 9px 10px; gap: 4px; font-size: 0.86rem; }
  .st-net { font-size: 0.94rem; }
  .st-c { font-size: 0.8rem; }
}
.two-col { display: grid; gap: 16px; margin-top: 16px; }
@media (min-width: 1000px) { .two-col { grid-template-columns: 1.4fr 1fr; } }
.panel { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 16px; min-width: 0; }
.panel h2 { margin-bottom: 10px; }
.chart { margin: 0; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; }
.chart .grid { stroke: var(--rule); }
.chart .zero { stroke: var(--ink-3); }
.chart .tick { fill: var(--ink-3); font-size: 12px; font-family: var(--font); }
.chart .tick-on { fill: var(--ink); font-weight: 700; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .bar-group.on .hit { fill: var(--ground); }
.chart .bar-ponds { fill: var(--ponds); }
.chart .bar-factory { fill: var(--factory); }
.chart .bar-overhead { fill: var(--misc); }
.legend { display: flex; gap: 16px; font-size: 0.85rem; color: var(--ink-2); margin-top: 6px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw-ponds { background: var(--ponds); } .sw-factory { background: var(--factory); } .sw-overhead { background: var(--misc); }
.heads { list-style: none; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.heads li { display: grid; grid-template-columns: minmax(7em, 1fr) 1.2fr auto; align-items: center; gap: 10px; font-size: 0.94rem; }
.heads-bar { height: 8px; background: var(--ground); border-radius: 4px; overflow: hidden; }
.heads-bar i { display: block; height: 100%; background: var(--ink-3); border-radius: 4px; }
.more { font-size: 0.92rem; }

/* ── Bills: yellow carbon slips ────────────────────────────────────────── */
.slips { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
@media (min-width: 700px) { .slips { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); } }
.slip {
  width: 100%; text-align: left; cursor: pointer; display: grid; gap: 4px; padding: 14px 16px 12px;
  background: var(--paper); border: 1px solid var(--rule); border-radius: 4px;
}
.slip:hover { border-color: var(--rule-2); }
.slip-waiting {
  background: var(--carbon); border-color: var(--carbon-edge);
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, color-mix(in srgb, var(--carbon-edge) 45%, transparent) 27px 28px);
}
.slip-top { display: flex; justify-content: space-between; align-items: baseline; }
.slip-no { color: var(--red); font-weight: 700; font-size: 1.05rem; }
.slip-date { color: var(--ink-2); font-size: 0.9rem; }
.slip-party { font-weight: 600; font-size: 1.08rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slip-total { font-size: 1.4rem; font-weight: 700; text-align: left; color: var(--blue); }
.slip-type { color: var(--ink-2); font-size: 0.92rem; }
.slip-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px; font-size: 0.85rem; color: var(--ink-2); margin-top: 4px; }
.slip-state { display: inline-flex; gap: 4px; flex-wrap: wrap; }

/* ── Slide-over panel ──────────────────────────────────────────────────── */
.sheet-wrap { position: fixed; inset: 0; z-index: 40; background: rgb(15 17 23 / 0.45); display: flex; justify-content: flex-end; }
.sheet { background: var(--paper); width: 100%; max-width: 980px; height: 100%; display: flex; flex-direction: column; }
@media (min-width: 900px) { .sheet { border-left: 1px solid var(--rule); } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--rule); }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { overflow: auto; padding: 16px; flex: 1; }
.sheet-foot { padding: 12px 16px; border-top: 1px solid var(--rule); }
@media (prefers-reduced-motion: no-preference) { .sheet { animation: slide 0.18s ease-out; } }
@keyframes slide { from { transform: translateX(24px); opacity: 0.6; } }

.bill-view { display: grid; gap: 18px; }
@media (min-width: 900px) { .bill-view { grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: start; } }
.photo {
  display: block; padding: 0; border: 1px solid var(--rule); border-radius: var(--r); background: var(--ground);
  overflow: auto; cursor: zoom-in; max-height: 72vh; width: 100%;
}
@media (min-width: 900px) { .photo { position: sticky; top: 0; } }
.photo img { display: block; width: 100%; height: auto; }
.photo.zoom { cursor: zoom-out; }
.photo.zoom img { width: 200%; max-width: none; }
.photo-none { display: grid; place-items: center; min-height: 200px; color: var(--ink-3); cursor: default; padding: 16px; text-align: center; }
.bill-meta { margin: 0 0 12px; color: var(--ink-2); }
.type-line { font-weight: 600; margin: 0 0 8px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0 0 14px; }
.facts dt { color: var(--ink-3); }
.facts dd { margin: 0; }
.facts dd.num { text-align: left; }
.lines { width: 100%; border-collapse: collapse; margin-bottom: 12px; font-size: 0.94rem; }
.lines th { text-align: left; font-size: 0.82rem; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--rule); padding: 6px 4px; }
.lines th.num { text-align: right; }
.lines td { padding: 7px 4px; border-bottom: 1px solid var(--rule); }
.lines tfoot td { font-weight: 700; border-bottom: 0; }

.bill-form, .entry-edit, .person-form { display: flex; flex-direction: column; gap: 14px; }
.type-pick { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.type-pick legend { font-weight: 600; margin-bottom: 8px; padding: 0; }
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (min-width: 560px) { .type-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.type-opt {
  position: relative; display: flex; flex-direction: column; padding: 8px 10px 8px 12px; border: 1px solid var(--rule-2);
  border-radius: var(--r); cursor: pointer; background: var(--paper); border-left-width: 4px;
}
.type-opt input { position: absolute; opacity: 0; pointer-events: none; }
.type-opt span { font-weight: 600; font-size: 0.94rem; }
.type-opt small { color: var(--ink-3); font-size: 0.78rem; line-height: 1.3; }
.type-ponds { border-left-color: var(--ponds); }
.type-factory { border-left-color: var(--factory); }
.type-misc { border-left-color: var(--misc); }
.type-opt.on { background: var(--blue-soft); border-color: var(--blue); border-left-width: 4px; }
.type-opt.type-ponds.on { background: var(--ponds-soft); border-color: var(--ponds); }
.type-opt.type-misc.on { background: var(--misc-soft); border-color: var(--misc); }
.type-opt:has(input:focus-visible) { outline: 2px solid var(--blue); outline-offset: 2px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.field-wide { grid-column: 1 / -1; }
@media (max-width: 480px) { .form-grid { grid-template-columns: 1fr; } }

.lines-edit { display: flex; flex-direction: column; gap: 6px; }
.lines-head, .lines-row { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(0, 0.9fr) minmax(0, 0.7fr) minmax(0, 0.9fr) minmax(0, 1.1fr) 36px; gap: 6px; align-items: center; }
.lines-head.with-head, .lines-row.with-head { grid-template-columns: minmax(0, 1.8fr) minmax(0, 0.8fr) minmax(0, 0.6fr) minmax(0, 0.8fr) minmax(0, 1fr) minmax(0, 1.2fr) 36px; }
.lines-head { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.lines-row input, .lines-row select { min-height: 38px; padding: 4px 8px; }
.lines-row input[inputmode="decimal"] { text-align: right; }
.lines-charge .span3 { grid-column: span 3; font-size: 0.88rem; }
.lines-add { display: flex; gap: 16px; }
.lines-total { display: flex; justify-content: flex-end; align-items: center; gap: 10px; font-weight: 600; }
.lines-total input { width: 9em; text-align: right; font-weight: 700; min-height: 40px; padding: 6px 10px; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--paper); }
@media (max-width: 600px) {
  .lines-head { display: none; }
  .lines-row, .lines-row.with-head { grid-template-columns: repeat(4, minmax(0, 1fr)) 36px; padding-bottom: 8px; border-bottom: 1px solid var(--rule); }
  .lines-row > input:first-child, .lines-row.with-head > select { grid-column: 1 / -2; }
  .lines-row > .icon-btn { grid-row: 1; grid-column: -2; }
}
.flags { margin: 0; padding: 10px 14px; list-style: none; background: var(--warn-soft); border-radius: var(--r); color: var(--warn); display: grid; gap: 4px; font-size: 0.94rem; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.reject-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--red-soft); border-radius: var(--r); }
.reject-box p { margin: 0; }
.history { margin-top: 18px; font-size: 0.92rem; }
.history summary { cursor: pointer; font-weight: 600; color: var(--ink-2); }
.history ol { padding-left: 18px; }
.history li { margin: 8px 0; }
.history q { display: block; font-style: italic; color: var(--ink-2); }
.history ul { margin: 2px 0 0; padding-left: 16px; color: var(--ink-2); }

/* ── Ledger and tables ─────────────────────────────────────────────────── */
.filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
@media (min-width: 760px) { .filters { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.filters .quick { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.filters-tight { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filters-tight input { max-width: 320px; flex: 1 1 220px; min-height: 40px; }
.filters-tight .tabs { margin-bottom: 0; border-bottom: 0; }
.totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 14px; background: var(--rule); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
@media (min-width: 760px) { .totals { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.totals > div { background: var(--paper); padding: 10px 14px; }
.totals dt { font-size: 0.85rem; color: var(--ink-3); }
.totals dd { margin: 0; font-weight: 700; font-size: 1.15rem; text-align: left; }
.ledger { width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); overflow: hidden; }
.ledger th { text-align: left; font-size: 0.82rem; font-weight: 600; color: var(--ink-3); padding: 10px 12px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.ledger th.num { text-align: right; }
.ledger td { padding: 10px 12px; border-bottom: 1px solid var(--rule); vertical-align: top; }
.ledger tbody tr { cursor: pointer; }
.ledger tbody tr:hover, .ledger tbody tr:focus-visible { background: var(--ground); }
.ledger tr.void td { color: var(--ink-3); }
.ledger .kind { font-weight: 600; }
.amt-sale { color: var(--ok); font-weight: 600; }
.amt-expense { color: var(--ink); }
.amt-purchase { color: var(--ink-2); }
@media (max-width: 600px) {
  .hide-sm { display: none; }
  .ledger td, .ledger th { padding: 9px 8px; font-size: 0.92rem; }
}
.entry { display: flex; flex-direction: column; gap: 6px; }

/* ── People ────────────────────────────────────────────────────────────── */
.people { list-style: none; padding: 0; margin: 0 0 12px; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); }
.people li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 14px; }
.people li + li { border-top: 1px solid var(--rule); }
.people li.off .person > strong, .people li.off .phone { color: var(--ink-3); }
.person { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.person strong { font-size: 1.02rem; }
.phone { color: var(--ink-2); }
.person-role { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.person-actions { display: flex; gap: 8px; }
.role-pick { border: 0; padding: 0; margin: 0; display: grid; gap: 8px; }
.role-pick legend { font-weight: 600; font-size: 0.85rem; color: var(--ink-2); margin-bottom: 6px; }
.role-pick label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--rule-2); border-radius: var(--r); cursor: pointer; }
.role-pick label.on { border-color: var(--blue); background: var(--blue-soft); }
.role-pick input { margin-top: 4px; accent-color: var(--blue); }
.role-pick span { display: flex; flex-direction: column; }
.role-pick small { color: var(--ink-2); }

/* Phone: the statement as one row per centre */
.statement-sm { display: none; width: 100%; border-collapse: collapse; background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); margin-bottom: 10px; }
.statement-sm th, .statement-sm td { padding: 10px 10px; border-bottom: 1px solid var(--rule); text-align: left; }
.statement-sm thead th { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.statement-sm .num { text-align: right; }
.statement-sm tr.st-net th, .statement-sm tr.st-net td { font-weight: 700; border-bottom: 0; }
.statement-sm th.st-all { color: var(--ink); }
.show-sm { display: none; }
@media (max-width: 600px) {
  .statement { display: none; }
  .statement-sm { display: table; }
  .show-sm { display: block; }
  span.show-sm { display: inline; }
  .parties td .show-sm { display: block; }
}

/* ── Dashboards ────────────────────────────────────────────────────────── */
.dash-filters { display: flex; flex-wrap: wrap; gap: 10px 12px; align-items: end; margin-bottom: 14px; }
.dash-filters .field { min-width: 150px; flex: 0 1 190px; }
a[role="tab"] { text-decoration: none; padding: 8px 12px 10px; color: var(--ink-2); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
a[role="tab"].on { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.dash { transition: opacity 0.15s; }
.dash.refreshing { opacity: 0.55; }
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
@media (min-width: 760px) { .stats { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.stat { background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r); padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat-label { font-size: 0.88rem; color: var(--ink-2); }
.stat-value { font-size: 1.45rem; font-weight: 700; font-variant-numeric: proportional-nums; line-height: 1.2; overflow-wrap: anywhere; }
.stat-hero { grid-column: 1 / -1; }
@media (min-width: 760px) { .stat-hero { grid-column: span 2; } }
.stat-hero .stat-value { font-size: 2.6rem; letter-spacing: -0.01em; }
.stat-delta { font-size: 0.84rem; color: var(--ink-3); }
.stat-delta.good { color: var(--good); }
.stat-delta.bad { color: var(--bad); }
.stat-note { font-size: 0.84rem; color: var(--ink-3); }
.spark { height: 28px; margin-top: 4px; }
.spark-line { fill: none; stroke: var(--ink-3); stroke-width: 1.5; stroke-linejoin: round; stroke-linecap: round; }
.dash-grid { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .card-wide { grid-column: 1 / -1; } }
.card { display: flex; flex-direction: column; gap: 8px; }
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.card-head h2 { margin: 0; }
.card-sub { margin: 2px 0 0; font-size: 0.86rem; color: var(--ink-3); }
.card-actions { display: flex; gap: 12px; align-items: center; flex-shrink: 0; }
.card-h3 { font-size: 0.95rem; font-weight: 600; margin: 10px 0 6px; }
.mini-select { min-height: 32px; padding: 2px 8px; border: 1px solid var(--rule-2); border-radius: var(--r); background: var(--paper); max-width: 150px; }
.chart-box { position: relative; width: 100%; min-width: 0; }
.chart-box svg { display: block; overflow: visible; }
.chart-box line.grid { stroke: var(--rule); stroke-width: 1; }
.chart-box line.zero { stroke: var(--ink-3); stroke-width: 1; }
.chart-box .tick { fill: var(--ink-3); font-size: 11.5px; font-family: var(--font); font-variant-numeric: tabular-nums; }
.chart-box .hit { fill: transparent; cursor: pointer; outline: none; }
.chart-box .col:hover .hit, .chart-box .hit:focus-visible, .chart-box .col.on .hit { fill: var(--ground); }
.chart-box .hit:focus-visible { stroke: var(--blue); stroke-width: 1.5; }
.chart-box .mark { pointer-events: none; }
.chart-box .col:hover .mark { filter: brightness(1.08); }
.chart-box .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-box .dot { stroke: var(--paper); stroke-width: 2; }
.chart-box .crosshair { stroke: var(--ink-3); stroke-width: 1; }
.chart-box .end-label { fill: var(--ink-2); font-size: 11.5px; font-family: var(--font); }
.chart-box svg:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px; max-width: 220px; padding: 8px 10px;
  background: var(--paper); border: 1px solid var(--rule-2); border-radius: var(--r); box-shadow: 0 4px 14px rgb(0 0 0 / 0.12); font-size: 0.86rem;
}
.tip-title { color: var(--ink-3); margin-bottom: 4px; }
.tip-row { display: grid; grid-template-columns: 12px auto 1fr; gap: 6px; align-items: center; }
.tip-row i { width: 12px; height: 2px; border-radius: 1px; }
.tip-row strong { font-variant-numeric: tabular-nums; }
.tip-row span { color: var(--ink-2); }
.legend .key-box { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.legend .key-line { width: 14px; height: 2px; border-radius: 1px; display: inline-block; }
.legend { flex-wrap: wrap; }
.rank { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rank-row { display: grid; grid-template-columns: minmax(0, 11em) minmax(0, 1fr) 7.5em; gap: 10px; align-items: center; padding: 6px 4px; border-radius: var(--r); color: var(--ink); text-decoration: none; }
a.rank-row:hover, a.rank-row:focus-visible { background: var(--ground); }
.rank-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.94rem; }
.rank-name small { display: block; color: var(--ink-3); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-bar { height: 10px; }
.rank-bar i { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.rank-val { font-size: 0.94rem; }
@media (max-width: 480px) { .rank-row { grid-template-columns: minmax(0, 1fr) auto; } .rank-bar { grid-column: 1 / -1; grid-row: 2; } }
.seg-bar { display: flex; gap: 2px; height: 28px; }
.seg-bar span { display: flex; align-items: center; padding-left: 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; min-width: 2px; overflow: hidden; }
.seg .legend { margin-top: 8px; gap: 6px 16px; }
.multiples { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 18px; }
.multiple .card-h3 { margin-top: 4px; display: flex; justify-content: space-between; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.data-table th, .data-table td { padding: 7px 8px; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; }
.data-table thead th { font-size: 0.8rem; color: var(--ink-3); font-weight: 600; }
.data-table .num { text-align: right; }
.data-table tr.total th, .data-table tr.total td { font-weight: 700; border-bottom: 0; background: var(--ground); }
.data-table .up { color: var(--good); }
.data-table .down { color: var(--bad); }
.statement-table th .key-box { width: 10px; height: 10px; border-radius: 2px; display: inline-block; margin-right: 8px; }
.sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; }
.sortable th[aria-sort] { color: var(--ink); }
.party-head { margin: 0 0 12px; }
.party-head h2 { font-size: 1.35rem; }
.party-head p { margin: 2px 0 0; }
@media (max-width: 600px) {
  .dash-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .dash-filters .field { min-width: 0; }
  .dash-filters select, .dash-filters input { padding: 6px 6px; font-size: 0.92rem; }
  .stat-hero .stat-value { font-size: 2.1rem; }
}
