/* ============================================================================
   Scottlaine Enterprises — design system
   Every colour, space and type size is a token below. Screens compose these;
   no page-specific one-off styling.
   ========================================================================= */

@font-face {
  font-family: "InterVariable";
  src: url("/static/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* --- brand: deep navy ------------------------------------------------- */
  --navy-900: #0d2338;
  --navy-800: #12304b;
  --navy-700: #173e60;
  --navy-600: #1d4d76;
  --navy-500: #2a6699;
  --navy-200: #b9cee1;
  --navy-100: #dbe7f1;
  --navy-50:  #eef4f9;

  /* --- surfaces: clean, cool and light ---------------------------------- */
  --paper:       #f4f6f8;
  --surface:     #ffffff;
  --surface-alt: #fafbfc;
  --surface-sunk:#f3f5f7;
  --border:      #e6e9ed;
  --border-mid:  #cdd3da;
  --row-line:    #eef1f4;   /* hairline between table rows */
  --row-hover:   #f3f8f5;

  /* --- ink -------------------------------------------------------------- */
  --figure:      #111827;   /* financial figures: near-black */
  --ink:         #1f2933;
  --ink-soft:    #56616e;
  --ink-muted:   #8791a0;

  /* --- action colour: green. Buttons, focus, the current screen. -------- */
  --accent:      #1f8a4c;
  --accent-deep: #17703d;
  --accent-line: #9fd3b1;
  --accent-wash: #e9f6ee;
  --accent-glow: #6fdc97;   /* on the dark sidebar */

  /* --- accent: muted gold. Key highlights only. ------------------------- */
  --gold:        #9a7b28;
  --gold-deep:   #7d631f;
  --gold-line:   #d8c084;
  --gold-wash:   #fbf3de;

  /* --- semantic --------------------------------------------------------- */
  --danger:      #a32b25;
  --danger-deep: #85211c;
  --danger-wash: #fbeceb;
  --danger-line: #e6b4b0;
  --good:        #1f6b3f;
  --good-wash:   #e8f3eb;
  --good-line:   #a8ceb7;

  /* --- type ------------------------------------------------------------- */
  --font: "InterVariable", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  --font-doc: Garamond, "Palatino Linotype", Georgia, "Times New Roman", serif;
  --text-caption: 0.75rem;
  --text-sm:      0.8125rem;
  --text-body:    0.9375rem;
  --text-lg:      1.0625rem;
  --text-section: 1.1875rem;
  --text-title:   1.5rem;
  --text-figure:  1.75rem;

  /* --- space (4px base) ------------------------------------------------- */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* --- shape ------------------------------------------------------------ */
  --radius-sm: 7px;
  --radius:    10px;
  --radius-lg: 14px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow:    0 2px 4px rgba(16, 24, 40, .05), 0 8px 20px rgba(16, 24, 40, .07);
  --shadow-lg: 0 12px 36px rgba(16, 24, 40, .16);

  --sidebar-w: 248px;
  --focus: 0 0 0 3px rgba(31, 138, 76, .22);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-body);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* Figures line up in columns, always. */
.num, .big, .figure, table.grid td.num, table.grid th.num, input.amount {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "cv05" 1;
}

h1 { font-size: 1.625rem; line-height: 1.25; letter-spacing: -.02em;
     margin: var(--space-5) 0 var(--space-4); color: var(--figure); font-weight: 700; }
h2 { font-size: var(--text-section); line-height: 1.3; letter-spacing: -.01em;
     margin: var(--space-6) 0 var(--space-3); color: var(--ink); font-weight: 650; }
h3 { font-size: var(--text-lg); margin: var(--space-5) 0 var(--space-2);
     color: var(--navy-800); font-weight: 600; }
p  { margin: var(--space-2) 0; }
a  { color: var(--navy-600); text-decoration-color: var(--navy-200);
     text-underline-offset: 2px; }
a:hover { color: var(--navy-800); text-decoration-color: currentColor; }

.muted   { color: var(--ink-soft); font-size: var(--text-sm); }
.caption { color: var(--ink-muted); font-size: var(--text-caption); }
.neg     { color: var(--danger); }
.figure  { color: var(--figure); }

/* ============================================================ app shell === */
.layout { display: flex; min-height: 100vh; align-items: stretch; }

main {
  flex: 1; min-width: 0; max-width: 1480px;
  padding: var(--space-4) var(--space-6) var(--space-7);
}

/* Page header: the screen's name on the left, its main actions on the right. */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap;
  margin: var(--space-5) 0 var(--space-4);
}
.page-head h1 { margin: 0; }
.page-head .sub { margin: var(--space-1) 0 0; color: var(--ink-soft); font-size: var(--text-sm); }
.actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

/* A quiet row of options that sits right above a table. */
.table-tools {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); flex-wrap: wrap; margin: var(--space-5) 0 0;
}
.table-tools h2 { margin: 0; }
.table-tools + table.grid { margin-top: var(--space-3); }

.sidebar {
  flex: 0 0 var(--sidebar-w); width: var(--sidebar-w);
  background: var(--navy-900); color: var(--navy-100);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand {
  color: #fff; text-decoration: none; font-size: var(--text-lg);
  font-weight: 650; letter-spacing: -.01em;
  padding: var(--space-4) var(--space-4) var(--space-3);
  display: flex; align-items: center; gap: var(--space-2);
}
.sidebar .brand span { color: var(--navy-200); font-weight: 400; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: linear-gradient(160deg, #2aa35c, var(--accent-deep));
  border: 1px solid rgba(255,255,255,.18);
  display: grid; place-items: center;
  font-size: 9px; font-weight: 700; color: #fff; letter-spacing: .02em;
}

.side-switch {
  margin: 0 var(--space-3) var(--space-3); width: calc(100% - var(--space-5));
  background: var(--navy-800); color: #fff;
  border: 1px solid var(--navy-600); border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-family: inherit; padding: var(--space-2);
}
.side-switch:focus-visible { outline: none; box-shadow: var(--focus); }

.side-company {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); margin: 0 var(--space-3) var(--space-1);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.06);
}
.side-company a {
  color: #fff; text-decoration: none; font-weight: 600;
  font-size: var(--text-sm); line-height: 1.3;
}
.co-dot { width: 9px; height: 9px; border-radius: 50%; flex: none;
          background: var(--co-color, var(--gold)); }

.sidenav { display: flex; flex-direction: column; gap: 1px;
  padding: var(--space-2) var(--space-2); flex: 1; }
.sidenav a {
  display: flex; align-items: center; gap: var(--space-3);
  color: #c9d6e2; text-decoration: none; font-size: 0.875rem;
  padding: 0.5rem var(--space-3);
  border-radius: var(--radius-sm);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .12s ease, color .12s ease;
}
.sidenav a svg { flex: none; width: 17px; height: 17px; opacity: .75; }
.sidenav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidenav a:hover svg { opacity: 1; }
.sidenav a.active {
  background: rgba(255,255,255,.14); color: #fff; font-weight: 600;
  box-shadow: inset 3px 0 0 var(--accent-glow);
}
.sidenav a.active svg { opacity: 1; color: var(--accent-glow); }
.nav-group {
  font-size: 0.6875rem; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: #6f8aa3;
  padding: var(--space-4) var(--space-3) var(--space-1);
}

.side-bottom {
  border-top: 1px solid rgba(255,255,255,.10);
  padding: var(--space-3) var(--space-3);
  display: flex; align-items: center; gap: var(--space-1); flex-wrap: wrap;
}
.side-bottom a, .shutdown-btn {
  display: inline-flex; align-items: center; gap: var(--space-1);
  color: var(--navy-200); text-decoration: none;
  font: inherit; font-size: var(--text-caption);
  background: none; border: none; border-radius: var(--radius-sm);
  padding: var(--space-1) var(--space-2); cursor: pointer;
}
.side-bottom a svg, .shutdown-btn svg { width: 13px; height: 13px; }
.side-bottom a:hover, .shutdown-btn:hover { background: rgba(255,255,255,.10); color: #fff; }
.side-bottom a.active { color: #fff; }

/* ============================================================== back bar === */
.backbar { margin: var(--space-3) 0 0; }
.back-btn {
  display: inline-flex; align-items: center; gap: var(--space-2);
  background: var(--surface); border: 1px solid var(--border-mid);
  border-radius: var(--radius-sm); color: var(--ink-soft);
  font: inherit; font-size: var(--text-sm); cursor: pointer;
  padding: var(--space-1) var(--space-3);
  box-shadow: var(--shadow-sm);
}
.back-btn svg { width: 14px; height: 14px; }
.back-btn { border-color: var(--border); border-radius: 999px; box-shadow: none; }
.back-btn:hover { color: var(--ink); border-color: var(--border-mid); background: var(--surface-sunk); }
.back-btn:focus-visible { outline: none; box-shadow: var(--focus); }

/* =============================================================== flashes === */
.flash {
  padding: var(--space-3) var(--space-4); border-radius: var(--radius);
  margin: var(--space-4) 0; font-size: var(--text-sm);
  border: 1px solid; box-shadow: var(--shadow-sm);
}
.flash.ok  { background: var(--good-wash);   border-color: var(--good-line);   color: #14532b; }
.flash.bad { background: var(--danger-wash); border-color: var(--danger-line); color: var(--danger-deep); }

/* ================================================================= cards === */
.cards {
  display: grid; gap: var(--space-4); margin: var(--space-4) 0 var(--space-6);
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
}
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  text-decoration: none; color: inherit; box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-1);
  transition: box-shadow .14s ease, border-color .14s ease, transform .14s ease;
}
a.card:hover {
  border-color: var(--accent-line); box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.card h2 {
  margin: 0; font-size: var(--text-sm); font-weight: 600;
  letter-spacing: 0; text-transform: none; color: var(--ink-soft);
}
.card p { margin: 0; }
.card .muted { font-size: var(--text-caption); color: var(--ink-muted); }
.big {
  font-size: var(--text-figure); font-weight: 620; letter-spacing: -.02em;
  color: var(--figure); line-height: 1.15; margin: var(--space-1) 0 !important;
}

/* ====================================== home screen: company chooser ====== */
.home-head { margin-bottom: var(--space-5); }
.home-head h1 { margin-bottom: var(--space-1); }
.home-head p { margin: 0; }

.co-section { margin-bottom: var(--space-6); }
.co-group-title {
  margin: 0 0 var(--space-3);
  font-size: var(--text-caption); font-weight: 650;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-muted);
  display: flex; align-items: center; gap: var(--space-3);
}
.co-group-title::after {           /* a quiet rule running out from the label */
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.co-grid {
  display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(13.5rem, 1fr));
  margin: 0;
}
.co-card {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; align-items: center;
  gap: var(--space-3);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-4) var(--space-4);
  text-decoration: none; color: var(--navy-800);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .16s ease, transform .16s ease, border-color .16s ease;
}
.co-card::before {                 /* the company's colour, as a quiet header rule */
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--co-color, var(--navy-600));
}
.co-card:hover {
  transform: translateY(-2px); box-shadow: var(--shadow);
  border-color: var(--co-color, var(--navy-200));
}
.co-art {
  width: 118px; height: 80px; display: block;
  color: var(--co-color, var(--navy-600));
}
.co-name {
  font-weight: 600; font-size: var(--text-body); text-align: center;
  line-height: 1.35; color: var(--navy-800);
}
.co-card-new { border-style: dashed; }
.co-card-new::before { background: var(--border-mid); }
.co-plus {
  width: 118px; height: 80px; display: grid; place-items: center;
  color: var(--ink-muted);
}
.co-plus svg { width: 30px; height: 30px; }
.co-card-new:hover .co-plus { color: var(--gold); }
.co-card-new .co-name { color: var(--ink-soft); }

/* ================================================================ tables === */
/* NOTE: no `overflow: hidden` here — it would silently disable the sticky
   column headers. Corners are rounded on the corner cells instead. */
table.grid {
  border-collapse: separate; border-spacing: 0; width: 100%;
  background: var(--surface);
  margin: var(--space-3) 0 var(--space-5);
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  font-size: 0.875rem;
}
table.grid tr:first-child th:first-child { border-top-left-radius: var(--radius-lg); }
table.grid tr:first-child th:last-child  { border-top-right-radius: var(--radius-lg); }
table.grid tr:last-child  td:first-child { border-bottom-left-radius: var(--radius-lg); }
table.grid tr:last-child  td:last-child  { border-bottom-right-radius: var(--radius-lg); }
/* Headers are quiet labels, not a shaded spreadsheet bar. */
table.grid th {
  position: sticky; top: 0; z-index: 3;
  background: var(--surface); color: var(--ink-muted);
  font-size: var(--text-caption); font-weight: 600;
  letter-spacing: .03em; text-transform: uppercase;
  text-align: left; white-space: nowrap;
  padding: 0.8rem var(--space-4) 0.7rem;
  border-bottom: 1px solid var(--border);
}
/* Rows are separated by a single hairline — no stripes, no boxes. */
table.grid td {
  padding: 0.7rem var(--space-4);
  border-bottom: 1px solid var(--row-line);
  vertical-align: middle; color: var(--ink);
}
table.grid tr:last-child td { border-bottom: none; }
table.grid tbody tr:hover td { background: var(--row-hover); }
table.grid .num {
  text-align: right; white-space: nowrap; color: var(--figure);
  font-weight: 500;
}
table.grid th.num { color: var(--ink-muted); font-weight: 600; }
/* The small "View / edit" links at the end of a row stay out of the way. */
table.grid td > a:only-child { text-decoration: none; font-weight: 500; }
table.grid td > a:only-child:hover { text-decoration: underline; }

/* Tables that hold a form's line items keep tighter cells. */
table.grid td:has(> input), table.grid td:has(> select), table.grid td:has(> .combo) {
  padding: var(--space-2) var(--space-2);
}

/* Red is reserved for negatives — and must beat the figure colour above,
   which is why this is scoped rather than a bare `.neg`. */
table.grid td.neg, table.grid td.num.neg, .card .big.neg { color: var(--danger); }

/* Long free-text cells (payees, split accounts, memos) clip instead of
   wrapping, so rows keep one consistent height down the whole register and
   the table stays inside the page. Full text is in each cell's tooltip. */
.cell-clip {
  max-width: 26ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* --- bank register: fixed, roomy columns; payee over memo; whole row opens -- */
table.register { table-layout: fixed; }
table.register th, table.register td { padding-left: var(--space-3); padding-right: var(--space-3); }
table.register .c-date  { width: 6.4rem; }
table.register .c-check { width: 4.8rem; }
table.register .c-cat   { width: 19%; }
table.register .c-money { width: 6.9rem; }
table.register .c-clr   { width: 4.7rem; }
table.register .c-bal   { width: 7.9rem; }
/* the payee / memo column takes everything that's left */
table.register td.who { overflow: hidden; }
.who-name {
  color: var(--figure); font-weight: 600; text-decoration: none;
  display: inline-block; max-width: 100%; vertical-align: bottom;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-name:hover { color: var(--accent-deep); text-decoration: underline; }
.who-memo {
  display: block; color: var(--ink-soft); font-size: var(--text-sm);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.who-memo.cat { font-size: 0.875rem; }
tr[data-href] { cursor: pointer; }

/* Voided transactions are hidden until asked for (the "Show voided" switch). */
table.hide-void tr.voided { display: none; }
tr.voided td { color: var(--ink-muted); text-decoration: line-through; }
tr.voided td:last-child, tr.voided td .tag { text-decoration: none; }
tr.inactive td { color: var(--ink-muted); }

.section-row td {
  font-weight: 650; background: var(--surface-sunk) !important;
  color: var(--ink); text-transform: uppercase;
  font-size: var(--text-caption); letter-spacing: .05em;
}
.subtotal-row td {
  font-weight: 600; border-top: 1px solid var(--border-mid);
  background: var(--surface-alt) !important;
}
.total-row td {
  font-weight: 700; color: var(--figure);
  background: var(--surface-sunk) !important;
  border-top: 2px solid var(--ink);
  border-bottom: none;
  font-size: var(--text-body);
}
.indent { padding-left: var(--space-6) !important; }

/* Highlight: uncontracted cattle exposure. One of the few gold moments. */
.open-head {
  background: var(--gold-wash) !important;
  color: var(--gold-deep) !important;
  font-weight: 700;
  box-shadow: inset 3px 0 0 var(--gold-line);
}

/* Paperclip marker on rows that carry a scanned receipt */
.att-link {
  display: inline-flex; vertical-align: middle; color: var(--ink-muted);
  margin-left: var(--space-1);
}
.att-link svg { width: 14px; height: 14px; }
.att-link:hover { color: var(--gold); }

/* File / document links */
.file-link { display: inline-flex; align-items: center; gap: var(--space-2); }
.file-link svg { width: 15px; height: 15px; flex: none; color: var(--ink-muted); }
.file-link:hover svg { color: var(--gold); }

/* ================================================================= tags ==== */
.tag {
  display: inline-block; font-size: var(--text-caption); font-weight: 550;
  letter-spacing: 0; padding: 2px 0.6rem;
  border-radius: 999px; background: var(--surface-sunk);
  color: var(--ink-soft); border: 1px solid transparent;
  text-decoration: none; vertical-align: middle; white-space: nowrap;
}
.ok-tag  { background: var(--good-wash);   color: #14532b;          border-color: var(--good-line); }
.bad-tag { background: var(--danger-wash); color: var(--danger-deep); border-color: var(--danger-line); }

/* ================================================================ forms ==== */
form.stack { display: flex; flex-direction: column; gap: var(--space-4); max-width: 46em; }
form.stack > label { display: flex; flex-direction: column; gap: var(--space-1); }

label { font-weight: 600; font-size: var(--text-sm); color: var(--ink); }
form.stack label input, form.stack label select, form.stack label textarea { font-weight: 400; }

.inline-form {
  display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: flex-end;
  margin: var(--space-2) 0;
}
.inline-form label {
  display: flex; flex-direction: column; gap: var(--space-1);
  font-size: var(--text-sm);
}

input, select, textarea {
  font: inherit; font-size: var(--text-body); color: var(--ink);
  padding: 0.5rem var(--space-3); min-height: 2.375rem;
  border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color .12s ease, box-shadow .12s ease;
}
input[type=checkbox], input[type=radio] { min-height: 0; padding: 0;
  width: 16px; height: 16px; accent-color: var(--accent); vertical-align: middle; }
input:hover, select:hover, textarea:hover { border-color: #a9b3be; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--focus);
}
input::placeholder { color: var(--ink-muted); }
input[type=file] { padding: var(--space-1); font-size: var(--text-sm); }
input.amount, td.num input { text-align: right; font-variant-numeric: tabular-nums; }

label.check {
  display: flex !important; flex-direction: row !important; align-items: center;
  gap: var(--space-2); font-weight: 400 !important;
}
label.check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Table cells that hold form controls stay tidy */
table.grid td select, table.grid td input { width: 100%; }
table.grid td input[type=checkbox], table.grid td input[type=radio] { width: 16px; }

/* ============================================================== buttons ==== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: 0 var(--space-4); min-height: 2.375rem;
  border-radius: var(--radius-sm); border: 1px solid var(--border-mid);
  background: var(--surface); color: var(--ink);
  font: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: background .12s ease, border-color .12s ease, box-shadow .12s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { background: var(--surface-sunk); border-color: #a9b3be; color: var(--ink); }
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:active { box-shadow: none; transform: translateY(1px); }

.btn.primary {
  background: var(--accent); border-color: var(--accent); color: #fff;
  box-shadow: 0 1px 2px rgba(23, 112, 61, .35);
}
.btn.primary:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; }

.btn.danger { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn.danger:hover { background: var(--danger-wash); border-color: var(--danger); }

.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; box-shadow: none; }

.linklike {
  background: none; border: none; color: var(--navy-600); cursor: pointer;
  font: inherit; font-size: var(--text-sm); padding: 0;
  text-decoration: underline; text-underline-offset: 2px;
}
.linklike:hover { color: var(--navy-800); }

/* cleared / reconciled markers in the register */
.clr-btn {
  border: 1px solid var(--border-mid); background: var(--surface);
  border-radius: var(--radius-sm); width: 1.9rem; height: 1.7rem;
  cursor: pointer; color: var(--ink-muted); font-size: var(--text-sm);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
}
.clr-btn:hover { border-color: var(--navy-200); background: var(--navy-50); }
span.clr-btn { cursor: default; }
.clr-btn.cleared {
  background: var(--good-wash); color: var(--good); border-color: var(--good-line);
}

/* ============================================================== panels ===== */
details.panel, .panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  margin: var(--space-4) 0; box-shadow: var(--shadow-sm);
}
details.panel summary {
  cursor: pointer; font-weight: 600; color: var(--navy-700);
  font-size: var(--text-sm); list-style: none;
  display: flex; align-items: center; gap: var(--space-2);
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before {
  content: "＋"; color: var(--accent); font-weight: 700;
}
details.panel[open] summary::before { content: "－"; }
details.panel[open] summary { margin-bottom: var(--space-3);
  padding-bottom: var(--space-3); border-bottom: 1px solid var(--border); }

.report-forms { display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(16.5rem, 1fr)); align-items: start; }
.report-forms .panel { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
.report-forms .panel h2 { margin: 0; font-size: var(--text-lg); }
.report-forms .panel label { display: flex; flex-direction: column; gap: var(--space-1); }

/* =========================================================== issues panel === */
.issues-panel { background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4);
  margin: 0 0 var(--space-5); box-shadow: var(--shadow-sm); }
.issues-panel > h2 { display: flex; align-items: center; gap: var(--space-2);
  margin: 0 0 var(--space-3); font-size: var(--text-lg); }
.issues-panel > h2 svg { width: 20px; height: 20px; color: var(--gold); }
.issues-list { list-style: none; margin: 0; padding: 0; }
.issue { border-left: 3px solid var(--border-mid); }
.issue + .issue { margin-top: var(--space-2); }
.issue a { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2);
  padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--ink);
  border-radius: var(--radius-sm); }
.issue a:hover { background: var(--surface-2, rgba(0,0,0,.03)); }
.issue-co { font-weight: 650; color: var(--navy-900); font-size: var(--text-sm); }
.issue-text { color: var(--ink); }
.issue-high { border-left-color: #c0392b; }
.issue-med  { border-left-color: var(--gold); }
.issue-low  { border-left-color: var(--navy-200); }
.issues-clear { display: flex; align-items: center; gap: var(--space-2);
  color: var(--ink-muted); }
.issues-clear svg { width: 20px; height: 20px; color: #2e7d32; }

/* ============================================================ projector ==== */
.proj-cols { display: grid; gap: var(--space-4);
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); align-items: start; }
fieldset.panel { display: flex; flex-direction: column; gap: var(--space-3); margin: 0; }
fieldset.panel legend { font-weight: 600; color: var(--navy-700);
  font-size: var(--text-sm); padding: 0 var(--space-2); }
fieldset.panel label { display: flex; flex-direction: column; gap: var(--space-1);
  font-size: var(--text-sm); }
fieldset.panel input, fieldset.panel select { text-align: right;
  font-variant-numeric: tabular-nums; }
fieldset.panel select { text-align: left; }
.proj-cols .panel h3 { margin: 0 0 var(--space-2); font-size: var(--text-lg); }
.proj-cols .panel table { margin: 0; }

/* ====================================================== pay-bills checks ==== */
.check-list { list-style: none; margin: var(--space-2) 0; padding: 0; max-width: 30em; }
.check-list li { display: flex; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-2) 0; border-bottom: 1px solid var(--border); }
.check-list li:first-child { border-top: 1px solid var(--border); }
.check-list .num { font-variant-numeric: tabular-nums; font-weight: 650;
  color: var(--navy-900); }
#checks-heading { font-size: var(--text-base); margin: var(--space-3) 0 0; }

/* ========================================================= empty states ==== */
.empty {
  border: 1px dashed var(--border-mid); border-radius: var(--radius-lg);
  background: var(--surface-alt); padding: var(--space-6) var(--space-5);
  text-align: center; color: var(--ink-soft); margin: var(--space-4) 0;
}
.empty svg { width: 26px; height: 26px; color: var(--ink-muted); margin-bottom: var(--space-2); }
.empty h3 { margin: 0 0 var(--space-1); color: var(--navy-800); font-size: var(--text-lg); }
.empty p { margin: 0; font-size: var(--text-sm); }

/* ============================================== type-ahead comboboxes ====== */
.combo { position: relative; display: inline-block; }
.combo-hidden { display: none !important; }
/* In a table cell the box fills the column so every row is the same width. */
.combo-fill { display: block; min-width: 17em; }
.combo-fill .combo-input { width: 100%; }

/* Bill line items: fixed, roomy columns so account and group names show in
   full without opening the list. */
form.stack.bill-form { max-width: 68em; }
table.bill-lines { table-layout: fixed; min-width: 66em; }
table.bill-lines .c-amt   { width: 9.5em; }
table.bill-lines .c-class { width: 13em; }   /* fits a full group name */
table.bill-lines .c-lbs   { width: 9em; }
table.bill-lines .c-memo  { width: 22%; }
/* .c-acct takes all the remaining width */
table.bill-lines .combo-fill { min-width: 0; }
.combo-list {
  position: absolute; z-index: 60; top: 100%; left: 0; min-width: 100%;
  max-height: 16rem; overflow-y: auto; background: var(--surface);
  border: 1px solid var(--border-mid); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); margin-top: 2px;
}
.combo-item { padding: var(--space-2) var(--space-3); cursor: pointer;
  white-space: nowrap; font-size: var(--text-sm); }
.combo-item.hl, .combo-item:hover { background: var(--accent-wash); color: var(--figure); }

/* ============================================================ overview ===== */
/* Shortcuts to the things done most often. */
.quick-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.stat-row {
  display: grid; gap: var(--space-4); margin: var(--space-4) 0 var(--space-5);
  grid-template-columns: repeat(auto-fill, minmax(15.5rem, 1fr));
}
.card.attention { border-color: var(--gold-line); background: var(--gold-wash); }
.card.attention h2 { color: var(--gold-deep); }
.card .card-link { margin-top: auto; padding-top: var(--space-2);
  font-size: var(--text-sm); font-weight: 600; color: var(--accent-deep); }
/* ---------------------------------------------------------- tax center ----- */
.tax-company {
  margin-top: var(--space-6); padding-top: var(--space-2);
  border-top: 3px solid var(--co-color, var(--border-mid));
  break-inside: auto;
}
.tax-company h3 { margin-top: var(--space-4); }
.tax-company .cards { margin-bottom: var(--space-4); }
.tax-company details.panel table.grid { box-shadow: none; margin-bottom: 0; }
@media print { .tax-company { break-before: page; } .statement-note { background: #f6f6f6 !important; } }

/* A cleared marker reads as a soft pill, not a boxed cell. */
.clr-btn { border-radius: 999px; }

/* ================================================================ misc ===== */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

/* =================================== formal documents: reports & receipts ==
   These must read as printed instruments, not web pages. Serif, letterhead. */
.report-head { text-align: center; margin: var(--space-4) 0 var(--space-5);
  font-family: var(--font-doc); }
.report-head h1 { margin: 0; font-size: 1.4rem; color: var(--figure);
  font-family: var(--font-doc); font-weight: 700; letter-spacing: 0; }
.report-head h2 { margin: var(--space-1) 0; font-size: 1.1rem; font-weight: 600;
  color: var(--figure); font-family: var(--font-doc); text-transform: none; letter-spacing: 0; }
.report-head p { margin: 0; color: var(--ink-soft); font-size: var(--text-sm); }

table.grid.report { font-family: var(--font-doc); font-size: 0.95rem; }
table.grid.report th { font-family: var(--font); }

/* year-end member statement */
.statement-summary { margin: var(--space-5) 0; }
.statement-summary h3 { margin-bottom: var(--space-2); }
.statement-note {
  max-width: 44em; margin: var(--space-5) 0;
  border-left: 3px solid var(--gold-line); background: var(--gold-wash);
  padding: var(--space-3) var(--space-4); border-radius: 0 var(--radius) var(--radius) 0;
}
.statement-note p { margin: var(--space-2) 0; font-size: var(--text-sm); }

/* customer invoice (cattle sale) */
.invoice-doc {
  max-width: 46em; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-6); box-shadow: var(--shadow-sm);
}
.invoice-head { display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-4); border-bottom: 2px solid var(--navy-800);
  padding-bottom: var(--space-4); }
.invoice-from { font-size: var(--text-lg); font-weight: 650; color: var(--navy-900); }
.invoice-meta { text-align: right; font-size: var(--text-sm); color: var(--ink-soft); }
.invoice-meta h1 { margin: 0 0 var(--space-1); font-size: var(--text-title);
  letter-spacing: .12em; color: var(--navy-800); }
.invoice-billto { margin: var(--space-4) 0 0; }
.invoice-buyer { font-size: var(--text-lg); font-weight: 600; color: var(--figure); }
.invoice-foot { margin-top: var(--space-4); }
@media print { .invoice-doc { box-shadow: none; border: none; padding: 0; max-width: none; } }

/* Banker's Snapshot */
.snap-summary {
  display: flex; flex-wrap: wrap; gap: var(--space-5);
  background: var(--navy-50); border: 1px solid var(--navy-100);
  border-radius: var(--radius); padding: var(--space-4) var(--space-5);
  margin: var(--space-3) 0 var(--space-5);
}
.snap-summary > div { display: flex; flex-direction: column; }
.snap-k { font-size: var(--text-caption); text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-soft); }
.snap-v { font-size: var(--text-lg); font-weight: 650; color: var(--navy-900);
  font-variant-numeric: tabular-nums; }
.snap-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-4); box-shadow: var(--shadow-sm);
  break-inside: avoid;
}
.snap-head { display: flex; align-items: baseline; gap: var(--space-3);
  border-bottom: 1px solid var(--border); padding-bottom: var(--space-2);
  margin-bottom: var(--space-3); flex-wrap: wrap; }
.snap-head h2 { margin: 0; font-size: var(--text-section); }
.snap-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
@media (max-width: 800px) { .snap-grid { grid-template-columns: 1fr; } }
.snap-col-h { font-size: var(--text-caption); font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--gold-deep); margin-bottom: var(--space-2); }
.snap-col dl { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.snap-col dt { color: var(--ink-soft); font-size: var(--text-sm); }
.snap-col dd { margin: 0; text-align: right; color: var(--figure);
  font-size: var(--text-sm); font-variant-numeric: tabular-nums; }
.snap-col dt.snap-total, .snap-col dd.snap-total {
  border-top: 1px solid var(--border-mid); padding-top: var(--space-1);
  margin-top: var(--space-1); font-weight: 700; color: var(--navy-900); }
@media print { .snap-card { box-shadow: none; } .snap-summary { background: #f3f3f3 !important; } }

/* K-1 preparation worksheet */
.k1-banner {
  max-width: 52em; margin: 0 0 var(--space-4);
  border-left: 3px solid var(--gold-line); background: var(--gold-wash);
  padding: var(--space-3) var(--space-4); border-radius: 0 var(--radius) var(--radius) 0;
  font-size: var(--text-sm);
}
.k1-sheet {
  max-width: 54em; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: var(--space-5) var(--space-6); box-shadow: var(--shadow-sm);
}
.k1-title { border-bottom: 2px solid var(--navy-800); padding-bottom: var(--space-3);
  margin-bottom: var(--space-4); }
.k1-title h1 { margin: 0; font-size: var(--text-section); }
.k1-title p { margin: var(--space-1) 0 0; color: var(--ink-soft); font-size: var(--text-sm); }
.k1-flag { color: var(--gold-deep); font-weight: 600; }
.k1-parts { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-4);
  margin-bottom: var(--space-4); }
@media (max-width: 700px) { .k1-parts { grid-template-columns: 1fr; } }
.k1-box { margin-bottom: var(--space-4); }
.k1-box h2 { margin: 0 0 var(--space-2); font-size: var(--text-body);
  color: var(--navy-800); text-transform: none; letter-spacing: 0;
  border-bottom: 1px solid var(--border); padding-bottom: var(--space-1); }
.k1-box dl { display: grid; grid-template-columns: auto 1fr; gap: var(--space-1) var(--space-4);
  margin: 0; font-size: var(--text-sm); }
.k1-box dt { color: var(--ink-soft); font-weight: 600; }
.k1-box dd { margin: 0; color: var(--figure); }
.k1-foot { margin-top: var(--space-5); padding-top: var(--space-4);
  border-top: 1px solid var(--border); font-size: var(--text-sm); color: var(--ink-soft); }

/* ------------------------------------------------ membership certificate --- */
.certificate {
  --cert-navy: #1c2f4a;
  --cert-gold: #a8842c;
  max-width: 50em; margin: var(--space-4) auto;
  background: #fdfbf4;
  border: 4px solid var(--cert-navy);
  padding: 5px;
  box-shadow: var(--shadow-lg);
}
.cert-inner {
  border: 2px solid var(--cert-gold);
  outline: 1px solid var(--cert-navy);
  outline-offset: 3px;
  padding: 2.2rem 3.2rem 1.6rem;
  text-align: center;
  font-family: var(--font-doc);
  color: #22222a;
  background:
    radial-gradient(ellipse at top left, rgba(168,132,44,.06), transparent 45%),
    radial-gradient(ellipse at bottom right, rgba(168,132,44,.06), transparent 45%);
}
.cert-no-row {
  display: flex; justify-content: space-between;
  font-size: .82rem; letter-spacing: .12em; text-transform: uppercase;
  color: var(--cert-navy); margin-bottom: 1.4rem;
}
.cert-inner h1 {
  font-size: 1.85rem; margin: 0 0 .3rem; font-variant: small-caps;
  letter-spacing: .1em; color: var(--cert-navy); font-weight: 600;
  font-family: var(--font-doc);
}
.cert-sub { margin: .1rem 0; color: #5a5a52; font-size: .88rem; letter-spacing: .06em; }
.cert-rule { display: flex; align-items: center; gap: .8rem; margin: 1.2rem 10% 1rem;
  color: var(--cert-gold); }
.cert-rule::before, .cert-rule::after { content: ""; flex: 1; border-top: 1px solid var(--cert-gold); }
.cert-inner h2 {
  font-size: 1.3rem; margin: .4rem 0 1.2rem; letter-spacing: .28em;
  text-transform: uppercase; color: var(--cert-navy); font-weight: 600;
  font-family: var(--font-doc);
}
.cert-inner h3 {
  font-size: .82rem; letter-spacing: .18em; text-transform: uppercase;
  color: var(--cert-navy); margin: 0 0 .5rem; font-family: var(--font-doc);
}
.cert-lead { font-style: italic; font-size: 1.05rem; margin: .4rem 0 .2rem; color: #44443c; }
.cert-name {
  font-size: 1.9rem; font-weight: 600; margin: .4rem auto .5rem;
  color: var(--cert-navy); font-variant: small-caps; letter-spacing: .04em;
  border-bottom: 1px solid var(--cert-gold);
  display: inline-block; padding: 0 2.5rem .35rem;
}
.cert-body { margin: .5rem auto; font-size: 1.04rem; max-width: 38em; line-height: 1.55; }
.cert-body-small { margin: .4rem 0; font-size: .9rem; color: #5a5a52; }
.cert-amount-words {
  font-size: 1.12rem; font-weight: 600; margin: .7rem 0 .1rem;
  font-variant: small-caps; letter-spacing: .05em; color: var(--cert-navy);
}
.cert-amount { font-size: 1.05rem; margin: 0 0 .5rem; color: #44443c; }
.cert-terms {
  text-align: left; margin: 1.4rem auto .4rem; font-size: .92rem;
  max-width: 40em; line-height: 1.55;
  border-top: 1px solid var(--cert-gold); padding-top: 1rem;
}
.cert-terms p { margin: .3rem 0; }
.cert-witness { font-style: italic; font-size: .98rem; margin: 1.6rem auto .4rem;
  max-width: 36em; color: #44443c; }
.cert-bottom { display: flex; align-items: flex-end; gap: 2.5rem; margin: 1.6rem 1rem .6rem; }
.cert-seal { flex: 0 0 auto; }
.cert-seal-ring {
  width: 6.2rem; height: 6.2rem; border-radius: 50%;
  border: 2px solid var(--cert-gold);
  outline: 1px solid var(--cert-gold); outline-offset: 4px;
  display: flex; align-items: center; justify-content: center;
  color: var(--cert-gold); font-variant: small-caps;
  font-size: 1.5rem; letter-spacing: .12em; font-weight: 600;
  background: radial-gradient(circle, rgba(168,132,44,.10), rgba(168,132,44,.03));
  transform: rotate(-8deg);
}
.cert-signatures { display: flex; justify-content: space-between; gap: 3rem; flex: 1; }
.cert-signatures > div:first-child { flex: 2; }
.cert-signatures > div:last-child { flex: 1; }
.sig-line { border-bottom: 1px solid #3a3a32; height: 2.4rem; }
.cert-signatures p {
  margin: .35rem 0 0; font-size: .8rem; letter-spacing: .14em;
  text-transform: uppercase; color: var(--cert-navy);
}
.cert-footer { margin: 1.4rem 0 0; font-size: .72rem; color: #8a8a80; letter-spacing: .04em; }

/* Narrower desktop windows: tighten margins and clips before anything is
   allowed to push the page sideways. Wide tables (the register) stay whole. */
@media (max-width: 1400px) {
  main { padding-left: var(--space-4); padding-right: var(--space-4); }
  .cell-clip { max-width: 14ch; }
}

/* ============================================================== phone ====== */
@media (max-width: 760px) {
  .layout { flex-direction: column; }
  .sidebar { position: static; width: 100%; flex: none; height: auto; overflow: visible; }
  .sidenav { flex-direction: row; flex-wrap: wrap; padding: var(--space-1) var(--space-2); }
  .sidenav a { border-left: none; border-radius: var(--radius-sm);
    padding: var(--space-2) var(--space-3); }
  .sidenav a.active { border-left: none; box-shadow: inset 0 -2px 0 var(--gold-line); }
  .nav-group { width: 100%; padding: var(--space-2) var(--space-2) 0; }
  main { padding: var(--space-3) var(--space-4) var(--space-6); }
  table.grid { display: block; overflow-x: auto; }
  table.grid th { position: static; }
  .cards { grid-template-columns: 1fr; }
}

/* ============================================================== print ====== */
@media print {
  .no-print, .sidebar, .backbar { display: none !important; }
  body { background: #fff; font-size: 11.5px; color: #000; }
  .layout { display: block; }
  main { max-width: none; padding: 0; }
  table.grid { border-radius: 0; box-shadow: none; border-color: #999; }
  table.grid th { background: #eee !important; position: static;
    color: #000; border-bottom: 1px solid #999; }
  table.grid tbody tr:hover td { background: transparent; }
  table.grid tr:nth-child(even) td { background: transparent; }
  .total-row td { background: transparent !important; border-top: 2px solid #000; }
  .card, .panel { box-shadow: none; border-color: #999; }
  a { color: inherit; text-decoration: none; }
  .certificate { box-shadow: none; margin: 0 auto; max-width: none;
    print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
