/* Ranch Manager - one stylesheet, no build step.
   Sized so the same layout works on a desktop window and a phone at the chute. */

:root {
  color-scheme: light dark;

  /* Set by theme.js; the fallbacks keep the page correct before JS runs. */
  --accent-light: #3f6b3f;
  --accent-dark: #6ea36b;
  --accent-soft-light: #e6efe4;
  --accent-soft-dark: #24322a;

  --pad: 16px;
  --row-pad: 9px;
  --gap: 14px;
  --control-pad: 8px;
  --font-size: 14px;

  --bg:        #f6f5f1;
  --surface:   #ffffff;
  --surface-2: #f0efe9;
  --border:    #ddd9cd;
  --text:      #22201b;
  --muted:     #6f6a5e;
  --date-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%236f6a5e' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E");

  --accent:      var(--accent-light);
  --accent-soft: var(--accent-soft-light);
  --accent-text: #ffffff;

  --good:        #2e7d32;
  --danger:      #a5372c;
  --danger-soft: #f7e5e2;
  --warn:        #9a6a1e;
  --warn-soft:   #f7eeda;
  --info:        #35607f;
  --info-soft:   #e3edf4;

  --radius: 10px;
  --radius-sm: calc(var(--radius) - 3px);
  --shadow: 0 1px 2px rgba(30, 28, 22, .07), 0 6px 20px rgba(30, 28, 22, .07);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* System preference, unless an explicit light choice overrides it. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:        #16181a;
    --surface:   #1e2124;
    --surface-2: #262a2e;
    --border:    #343a3f;
    --text:      #e8e6e1;
    --muted:     #9aa0a6;
    --date-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239aa0a6' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E");

    --accent:      var(--accent-dark);
    --accent-soft: var(--accent-soft-dark);
    --accent-text: #10160f;

    --good:        #6cc070;
    --danger:      #e08579;
    --danger-soft: #35211f;
    --warn:        #d6a851;
    --warn-soft:   #332a1a;
    --info:        #7fb2d4;
    --info-soft:   #1c2a33;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}

/* Explicit choice wins in both directions. */
:root[data-theme="dark"] {
    --bg:        #16181a;
    --surface:   #1e2124;
    --surface-2: #262a2e;
    --border:    #343a3f;
    --text:      #e8e6e1;
    --muted:     #9aa0a6;
    --date-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%239aa0a6' stroke-width='1.4' stroke-linecap='round'%3E%3Crect x='2' y='3' width='12' height='11' rx='2'/%3E%3Cpath d='M2 6.5h12M5.5 1.5v3M10.5 1.5v3'/%3E%3C/svg%3E");

    --accent:      var(--accent-dark);
    --accent-soft: var(--accent-soft-dark);
    --accent-text: #10160f;

    --good:        #6cc070;
    --danger:      #e08579;
    --danger-soft: #35211f;
    --warn:        #d6a851;
    --warn-soft:   #332a1a;
    --info:        #7fb2d4;
    --info-soft:   #1c2a33;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
  color-scheme: dark;
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
/* Hidden is hidden, whatever display a class gives (a .form-grid's grid, a
   .btn's flex): the screens hide and show by this attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: var(--font-size)/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 620; letter-spacing: -.01em; }
h1 { font-size: 21px; }
h2 { font-size: 16px; }
h3 { font-size: 13px; }

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex; align-items: center; gap: 9px;
  font-weight: 660; font-size: 15px; white-space: nowrap;
}
/* The outline bull head, in the accent colour. */
.brand .mark { color: var(--accent); width: 24px; height: 24px; flex: none; }
.brand { cursor: pointer; border-radius: 8px; }
.brand:hover .mark { transform: scale(1.08); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
/* About: the program, its data and the space it takes. */
.about-head { display: flex; gap: 16px; align-items: center; margin-bottom: 6px; }
.about-head .mark { color: var(--accent); flex: none; }
.about-name { font-size: 20px; font-weight: 680; }
.about-version { font-weight: 600; }
.about h3 { margin: 18px 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.about-total { margin-bottom: 8px; }
.about-bar { display: flex; gap: 2px; height: 12px; border-radius: 6px; overflow: hidden; margin-bottom: 8px; }
.about-seg { min-width: 3px; }
.about-seg.seg-0, .about-swatch.seg-0 { background: var(--series-1, #3f6b3f); }
.about-seg.seg-1, .about-swatch.seg-1 { background: var(--series-2, #b8863b); }
.about-seg.seg-2, .about-swatch.seg-2 { background: var(--series-3, #4a7fa8); }
.about-seg.seg-3, .about-swatch.seg-3 { background: var(--muted); }
.about-legend { display: flex; gap: 6px 16px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.about-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.about-path { font-family: ui-monospace, Consolas, monospace; font-size: 12px; word-break: break-all; }
.about-urls { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.about-url { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.about-url code { font-family: ui-monospace, Consolas, monospace; font-size: 14px; user-select: all; }
.about-warn { color: var(--warn); font-size: 13px; }
/* Lots: a card opens its animals. */
.lot-card-link { cursor: pointer; transition: border-color .12s; }
.lot-card-link:hover { border-color: var(--accent); }
.modal-card[data-size="lotdetail"] { width: min(1200px, 100%); }
.modal-card[data-size="rules"] { width: min(1100px, 100%); }
.modal-card[data-size="party"] { width: min(1480px, 100%); }
.lot-detail .lot-stats { margin-bottom: 10px; }
.lot-actions { margin: 6px 0 8px; }
.lot-add-list { max-height: 55vh; overflow: auto; }
.lot-add-list tbody tr { cursor: pointer; }
/* Herd > Complete data. */
.complete-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 14px; }
.miss-chip { display: inline-flex; gap: 8px; align-items: center; padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: inherit; font: inherit; cursor: pointer; }
.miss-chip.has strong { color: var(--warn); }
.miss-chip.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fill-summary { margin: 8px 0; }
.fill-preview { max-height: 40vh; overflow: auto; }
.fill-preview tfoot td { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); }
.fill-totals { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 8px; margin: 8px 0; }
.fill-total { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.fill-total strong { font-size: 16px; }
.fill-invoice-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 4px 0 10px; }
.fill-invoice { width: 160px; }
.fill-invoice-says { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* The lot's expense entries, to tick. */
.lot-entries { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 4px; }
.lot-entries-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.lot-entry { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; }
.lot-entry.on { border-color: var(--accent); background: var(--accent-soft, transparent); }
.lot-entry input { width: auto; }
.lot-entry-desc { flex: 1; min-width: 0; }
.cattle-note .btn { white-space: nowrap; }
.field-inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.conn-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--muted); opacity: .5; }
.conn-dot.on { background: var(--accent); opacity: 1; box-shadow: 0 0 0 3px var(--accent-soft); }
tr.conn-off td { color: var(--muted); }

.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }

.tab {
  appearance: none; border: 0; background: none;
  padding: 7px 13px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 520; color: var(--muted);
  cursor: pointer; white-space: nowrap;
}
.tab:hover { background: var(--surface-2); color: var(--text); }
.tab.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
/* The main menu's groups: like a tab, with the page open in them beside the name. */
.tabg {
  appearance: none; border: 0; background: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 520; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabg:hover, .tabg[aria-expanded="true"] { background: var(--surface-2); color: var(--text); }
.tabg.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabg[hidden] { display: none; }
/* "More"'s pages on the bar itself on a wide screen; the group on narrower ones. */
.tabflat {
  appearance: none; border: 0; background: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 520; color: var(--muted); cursor: pointer; white-space: nowrap;
}
.tabflat:hover { background: var(--surface-2); color: var(--text); }
.tabflat.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.tabflat[hidden] { display: none; }
@media (min-width: 1181px) { .tabg[data-group="more"] { display: none; } }
@media (max-width: 1180px) { .tabflat { display: none; } }
.tg-sub { font-size: 12px; font-weight: 500; opacity: .8; }
.tg-sub:empty { display: none; }
.tg-sub::before { content: '· '; }
.tg-caret { font-size: 10px; opacity: .7; }
.tab, .tabg { display: inline-flex; align-items: center; gap: 6px; }
.nav-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.nav-menu { position: fixed; z-index: 600; min-width: 190px; padding: 6px; display: flex; flex-direction: column; gap: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.nav-menu-item { appearance: none; border: 0; background: none; text-align: left; font: inherit; color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; }
.nav-menu-item:hover, .nav-menu-item:focus { background: var(--surface-2); outline: none; }
.nav-menu-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.langswitch { display: flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.langswitch button {
  appearance: none; border: 0; background: var(--surface);
  padding: 6px 11px; font: inherit; font-size: 12px; font-weight: 600;
  color: var(--muted); cursor: pointer;
}
.langswitch button.active { background: var(--accent); color: var(--accent-text); }

/* ---------- layout ---------- */

.view { padding: var(--pad); margin: 0 auto; }   /* the whole window's width, on any screen */

.page-head {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.page-head .spacer { flex: 1; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad);
}
.card + .card { margin-top: 14px; }
/* Cards side by side in a grid: the grid's gap spaces them, so none sits lower. */
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.card-head .spacer { flex: 1; }

.grid { display: grid; gap: var(--gap); }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

/* ---------- stats ---------- */

.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  /* The figure is sized to the tile, so a phone's narrow tile still holds
     "R$ 2.684.812,10" on one line. */
  container-type: inline-size; min-width: 0;
}
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.stat .value { font-size: min(30px, 12.5cqi); font-weight: 650; line-height: 1.15; margin-top: 4px;
  letter-spacing: -.02em; white-space: nowrap; }
.stat .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
/* a result: profit green, loss red, each with its mark */
/* A profit green, a loss red - in every company (not its own colour). */
.tone-good { color: var(--good); }
.tone-bad { color: var(--danger); }
.tone-mark { font-size: .55em; margin-right: .35em; vertical-align: .2em; }

/* ---------- bar rows ---------- */

.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr auto; gap: 10px; align-items: center; }
.bar-row .k { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; line-height: 1.25; }
.bar-row .track { background: var(--surface-2); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-row .fill { background: var(--accent); height: 100%; border-radius: 4px; min-width: 2px; }
.bar-row .v { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; min-width: 34px; text-align: right; }

/* ---------- movement chart ---------- */

.chart { display: flex; align-items: stretch; gap: 6px; height: 132px; padding-top: 8px; }
.chart .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.chart .stack { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; gap: 3px; }
.chart .b { width: 44%; border-radius: 3px 3px 0 0; min-height: 2px; }
.chart .b.in  { background: var(--accent); }
.chart .b.out { background: var(--danger); }
.chart .m { font-size: 10px; color: var(--muted); white-space: nowrap; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- herd evolution chart ---------- */

/* Line colours, in a fixed order checked for colour-blind separation.
   Dark mode uses its own steps of the same hues, not an inversion. */
.evo-card {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a;
  --series-4: #eda100; --series-5: #e87ba4; --series-6: #008300;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .evo-card {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
    --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
  }
}
:root[data-theme="dark"] .evo-card {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70;
  --series-4: #c98500; --series-5: #d55181; --series-6: #008300;
}

.evo-card .card-head { flex-wrap: wrap; }
.evo-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.seg.small button { padding: 5px 11px; font-size: 12.5px; }
/* A payment's day, one tap: today or the invoice's. */
.inv-pay-days { margin-bottom: 10px; flex-wrap: wrap; }
/* A tick's whole cell ticks it (the shared table). */
td.pick { cursor: pointer; }
/* The lines that look like the one given a supplier, offered the same. */
.st-alike { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; padding: 8px 12px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft); }

.evo-plot { position: relative; height: 240px; transition: opacity .15s; }
.evo-plot.loading { opacity: .5; }
.evo-plot .empty { height: 100%; display: flex; align-items: center; justify-content: center; }
.evo-plot svg { display: block; overflow: visible; }
.evo-metric { width: auto; }
.evo-note { margin-top: 6px; }
/* How a lot is going: the slaughter weight as a dashed line, named. */
.prog-card { margin: 12px 0; }
.prog-target { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.prog-target-label { text-anchor: start; }
.prog-foot { margin-top: 6px; }
.prog-table { margin-top: 10px; max-height: 260px; overflow: auto; }
/* The herd in groups. */
.herd-group-sel { width: auto; }
.herd-group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 8px; }
.herd-group-bar { display: flex; gap: 8px; align-items: center; padding: 6px 10px; }
.herd-group-bar .spacer { flex: 1; }
.herd-group-head { display: flex; gap: 10px; align-items: center; background: none; border: 0; color: inherit;
  cursor: pointer; padding: 4px 0; font: inherit; text-align: left; }
.herd-group-body { padding: 0 10px 10px; }
.evo-plot svg:focus { outline: none; }
.evo-plot svg:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 4px; }

.evo-grid { stroke: var(--border); stroke-width: 1; opacity: .6; }
.evo-grid.base { opacity: 1; }
.evo-axis { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.evo-end { fill: var(--text); font-size: 12px; font-weight: 600; }
.evo-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.evo-dot { stroke: var(--surface); stroke-width: 2; }
.evo-cross { stroke: var(--muted); stroke-width: 1; }

.evo-key { display: inline-block; flex: none; width: 14px; height: 2px; border-radius: 1px; }
.cf-plot { height: 220px; }
.period-presets { flex-wrap: wrap; }
.cf-swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 2px; }
.cf-key { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.cf-shade { fill: var(--text); opacity: .05; }
/* The P&L's months (as the cash flow): revenue and costs bars, the profit a
   line with hollow points; a long period scrolls sideways. */
.pl-plot { height: 240px; }
.pl-plot-scroll { height: 100%; overflow-x: auto; overflow-y: hidden; }
.cf-card .evo-legend { display: flex; gap: 16px; margin-top: 6px; }
/* herd by weight range: one hue, light -> dark with the weight (ordinal
   ramps validated for light and dark surfaces) */
.wr-card {
  --wr-1: #86b6ef; --wr-2: #5598e7; --wr-3: #2a78d6; --wr-4: #1c5cab; --wr-5: #104281;
  --wr-ink-1: #0d2a4d; --wr-ink-2: #0d2a4d; --wr-ink-3: #ffffff; --wr-ink-4: #ffffff; --wr-ink-5: #ffffff;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .wr-card {
    --wr-1: #1c5cab; --wr-2: #2a78d6; --wr-3: #5598e7; --wr-4: #86b6ef; --wr-5: #b7d3f6;
    --wr-ink-1: #ffffff; --wr-ink-2: #ffffff; --wr-ink-3: #0d2a4d; --wr-ink-4: #0d2a4d; --wr-ink-5: #0d2a4d;
  }
}
:root[data-theme="dark"] .wr-card {
  --wr-1: #1c5cab; --wr-2: #2a78d6; --wr-3: #5598e7; --wr-4: #86b6ef; --wr-5: #b7d3f6;
  --wr-ink-1: #ffffff; --wr-ink-2: #ffffff; --wr-ink-3: #0d2a4d; --wr-ink-4: #0d2a4d; --wr-ink-5: #0d2a4d;
}
.wr-card .share-row { grid-template-columns: 12px minmax(0, 1fr) auto 52px 78px; }
.wr-card .share-row[disabled] { opacity: .45; cursor: default; }
.wr-slice-pct { font-size: 12px; font-weight: 700; pointer-events: none; font-variant-numeric: tabular-nums; }
.wr-lot { width: auto; padding: 5px 8px; font-size: 12.5px; }
.wr-note { padding: 6px 8px 0; }
.share-plot.wr-bars-plot { width: 420px; max-width: 100%; }
.wr-bars { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.wr-bar-row { display: grid; grid-template-columns: 110px 1fr 90px; align-items: center; gap: 10px; font-size: 13px;
  cursor: pointer; transition: opacity .12s; }
.wr-bar-row.dim { opacity: .35; }
.wr-bar-track { height: 18px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.wr-bar-track i { display: block; height: 100%; border-radius: 0 4px 4px 0; }
.wr-bar-v { text-align: right; font-variant-numeric: tabular-nums; }

/* category share: donut + its list */
.share-card { --share-other: #9a9a94; --share-grey-1: #5f5f5a; --share-grey-2: #73736e; --share-grey-3: #868681;
  --share-grey-4: #aeaea8; --share-grey-5: #c2c2bc; }
.share-card .card-head { flex-wrap: wrap; }
.share-body { display: flex; align-items: center; gap: 28px; flex-wrap: wrap; padding-top: 6px; }
.share-plot { flex: none; width: 220px; min-height: 220px; display: flex; align-items: center; justify-content: center; }
.share-plot.loading { opacity: .5; }
.share-plot svg { display: block; overflow: visible; }
.share-slice { stroke: var(--surface); stroke-width: 2; cursor: pointer; transition: opacity .12s; }
.share-slice.dim { opacity: .35; }
.share-total { fill: var(--text); font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.share-sub { fill: var(--muted); font-size: 11px; }
.share-list { flex: 1 1 320px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.share-row { appearance: none; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer;
  display: grid; grid-template-columns: 12px minmax(0, 1fr) auto 52px; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: var(--radius-sm); text-align: left; font-size: 13px; }
.share-row:hover, .share-row.lit { background: var(--surface-2); }
.share-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-amt, .share-pct { font-variant-numeric: tabular-nums; text-align: right; }
.share-pct { color: var(--muted); }
.share-foot { display: flex; justify-content: space-between; padding: 8px 8px 0; margin-top: 4px;
  border-top: 1px solid var(--border); font-size: 13px; }

.evo-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 150px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 8px 10px; font-size: 12px;
}
.evo-tip .when { color: var(--muted); font-size: 11px; margin-bottom: 4px; }
.evo-tip .row { display: flex; align-items: center; gap: 8px; line-height: 1.7; }
.evo-tip .row b { font-variant-numeric: tabular-nums; min-width: 30px; text-align: right; }
.evo-tip .row span { color: var(--muted); }
.evo-tip .row.sum { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.evo-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; font-size: 12px; }
.evo-legend button {
  appearance: none; border: 0; background: none; font: inherit; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 0; cursor: pointer;
}
.evo-legend button:hover { color: var(--text); }
.evo-legend button.off { opacity: .45; text-decoration: line-through; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

/* ---------- controls ---------- */

.btn {
  appearance: none; font: inherit; font-weight: 550;
  padding: var(--control-pad) 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn.danger:hover { background: var(--danger-soft); }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.icon-btn {
  appearance: none; border: 0; background: none; color: var(--muted);
  font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; border-radius: 6px;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--control-pad) 10px; width: 100%; min-width: 0;
}
/* Ticks and round choices keep their own size, wherever they are (one left
   to stretch drew a box as wide as the list beside its words). */
input[type=checkbox], input[type=radio] { width: auto; flex: none; padding: 0; }
/* Numbers are typed, never stepped: no up/down arrows in any number box
   (they took room from the figure and stepped it by 1 on a stray click). */
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent);
}
textarea { resize: vertical; min-height: 66px; }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
label.field[hidden] { display: none; }
label.check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text); }
label.check input { width: auto; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters .search { flex: 1; min-width: 200px; }
/* Every search box (app.js paintSearch): orange while it holds words - a
   list cut down by a search is never taken for the whole - and an ✕ inside
   it to empty it: the engine's own clear button, kept in sight while there
   are words (it hides once the box loses focus) and drawn in the orange. */
input[type=search].searching { border-color: var(--warn); background: var(--warn-soft); box-shadow: 0 0 0 1px var(--warn); }
input[type=search].searching:focus { outline-color: var(--warn); border-color: var(--warn); }
input[type=search]::-webkit-search-cancel-button {
  -webkit-appearance: none; appearance: none; width: 20px; height: 20px; margin: 0 -4px 0 6px; flex: none;
  cursor: pointer; border-radius: 50%; background-color: var(--warn);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 4.5l7 7M11.5 4.5l-7 7' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 15px no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.5 4.5l7 7M11.5 4.5l-7 7' stroke='black' stroke-width='2.2' stroke-linecap='round'/%3E%3C/svg%3E") center / 15px no-repeat;
  opacity: 1 !important; pointer-events: auto !important; visibility: visible !important; display: block !important;
}
input[type=search]::-webkit-search-cancel-button:hover { background-color: var(--text); }
input[type=search]:not(.searching)::-webkit-search-cancel-button,
input[type=search]:placeholder-shown::-webkit-search-cancel-button { display: none !important; }
/* The last searches still drop down on a click; their arrow would crowd the ✕. */
input[type=search]::-webkit-calendar-picker-indicator { display: none !important; }
/* On a list's own bar (Entries): narrower, as tall as the buttons beside it. */
.table-tools .search.in-tools { flex: 0 1 300px; min-width: 170px; width: auto; padding-top: 5px; padding-bottom: 5px; font-size: 13px; }
@media (max-width: 640px) { .table-tools .search.in-tools { flex: 1 1 100%; order: -1; } }
/* The papers a list reads (listPapers), on its bar after the search - the
   same place on every page: dashed, as a place to drop them. */
.doc-chip { display: inline-flex; align-items: center; gap: 6px; border-style: dashed; border-color: var(--accent);
  color: var(--accent); font-weight: 600; }
.doc-chip .clip-icon, .doc-chip-phone .paste-ico { width: 15px; height: 15px; flex: none; fill: none;
  stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.doc-chip:hover, .doc-chip.drop-over, .drop-over .doc-chip { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.st-chip, .doc-chip-phone { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.doc-chip-phone .btn { display: inline-flex; align-items: center; gap: 6px; }
.filters select { width: auto; min-width: 132px; }
/* Entries: the filters and buttons on one line, the search on the next. */
.filters-tight { margin-bottom: 9px; }
.filters-tight select { min-width: 0; }

/* ---------- table ---------- */

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
/* dragged sideways with the mouse (app.js, watchPanning) */
.table-wrap.panning, .table-wrap.panning * { cursor: grabbing !important; user-select: none; }
/* columns the user moved and resized */
th.dt-head { cursor: grab; user-select: none; }
th.dt-head.dt-dragging { opacity: .4; }
th.dt-head.drop-before { box-shadow: inset 3px 0 0 var(--accent); }
th.dt-head.drop-after { box-shadow: inset -3px 0 0 var(--accent); }
table.dt-fixed { table-layout: fixed; }
/* A list's long words cut on one line - the columns as narrow as they can
   be; a column widened by hand shows what its width holds. */
.dt-text { display: block; max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
td[data-col=description] .dt-text, td[data-col=name] .dt-text { max-width: 300px; }
table.dt-fixed .dt-text { max-width: none; }
table.dt-fixed td { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.dt-fixed th { overflow: hidden; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 650; padding: 10px 12px;
  border-bottom: 1px solid var(--border); background: var(--surface-2);
  position: sticky; top: 0;
  /* A long heading goes onto a second line rather than widening the table. */
  white-space: normal; vertical-align: bottom; line-height: 1.25; min-width: 64px;
}
tbody td { padding: var(--row-pad) 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel { background: var(--accent-soft); }
td.tag { font-family: var(--mono); font-weight: 620; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
/* A number column's heading over its numbers, on the right. */
th.num { text-align: right; }
/* A totals row spaced like the rows above it, so it lines up with them. */
tfoot td { padding: var(--row-pad) 12px; font-variant-numeric: tabular-nums; }
th.pick, td.pick { width: 34px; }
th.pick input, .dt-pick-all { width: auto; margin: 0; cursor: pointer; }
/* The select-all box above the cards, on a phone only. */
.dt-pick-all-phone { display: none; }
/* A chart's bars and columns open what they count. */
.bar-row.click, .chart .col.click { cursor: pointer; border-radius: 6px; }
.bar-row.click:hover { background: var(--surface-2, rgba(127, 127, 127, .08)); }
.bar-row.on { background: var(--accent-soft, rgba(127, 127, 127, .12)); }
/* A supplier's or client's page. */
.party-page { display: flex; flex-direction: column; gap: 12px; }
.party-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.party-facts { display: flex; gap: 16px; flex-wrap: wrap; }
.party-head .spacer { flex: 1; }
.party-page .grid > .card { margin: 0; }
/* Supplements. */
.supp-in { width: 90px; }
.supp-row .supp-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.supp-card { margin-bottom: 14px; }
.supp-card .card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.supp-card .card-head h2 { margin: 0; }
.supp-card .card-head select { width: auto; max-width: 240px; }
.supp-card.supp-warn { border-color: var(--warn); }
.supp-card .stat.warn .value { color: var(--warn); }
.supp-settings { margin: 8px 0; }
.supp-settings summary { cursor: pointer; color: var(--muted); }
.supp-lots { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 8px 0; }
.supp-count { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.supp-fill { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.supp-fill[hidden] { display: none; }
.supp-fill .supp-in { width: 70px; }
.supp-fill .supp-size { width: 60px; }
.supp-unused summary { cursor: pointer; }
.supp-unused ul { margin: 8px 0 0; padding-left: 18px; }
.supp-bar { margin-bottom: 12px; }
.batch-docnote { font-size: 12px; color: var(--accent); margin-top: 2px; }
.docpair { margin-bottom: 10px; }
.pg-form .fl-table { margin-bottom: 10px; }
.pg-cands { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
/* An entry paying a supplier: its open invoices beside it. */
.txn-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-items: start; }
.txn-split:has(> .pb-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(300px, 420px); }
.modal-card.with-bills { width: min(1320px, 100%); }
.pb-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: var(--surface-2);
  position: sticky; top: 0; max-height: 75vh; overflow: auto; }
.pb-panel[hidden] { display: none; }
.pb-panel h3 { margin: 0 0 4px; font-size: 14px; }
.pb-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.pb-row { grid-template-columns: auto 1fr auto auto auto; }
.pb-list { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; }
.pb-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.pb-row.on { border-color: var(--accent); background: var(--accent-soft); }
.pb-text { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.pb-foot { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--border); padding: 8px 0 4px;
  position: sticky; bottom: -10px; background: var(--surface-2); }
.pb-text strong { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pb-diff { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.pb-diff.warn { color: var(--warn); }
.reg-search { max-width: 320px; }
.reg-search-row .reg-search { max-width: none; flex: 1 1 360px; }
.quit-ask { position: fixed; inset: 0; z-index: 10000; background: rgba(0, 0, 0, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 16px; }
.quit-card { background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 10px; padding: 18px 20px; width: min(380px, 100%); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
.quit-card h3 { margin: 0 0 6px; }
.parcel-wrap { margin: 6px 0; }
.peek-top { display: flex; gap: 6px; align-items: baseline; flex-wrap: nowrap; }
.peek-top > span:not(.pill) { flex: 1 1 auto; min-width: 0; }
.peek-top > .pill, .peek-top > .peek-toggle { flex: 0 0 auto; }
.peek-toggle { border: 0; background: transparent; color: var(--muted); cursor: pointer; padding: 0 2px; font-size: 13px; }
.peek-toggle:hover { color: var(--text); }
.peek-line { margin-left: 20px; }
.peek-more { margin: 6px 0 2px 20px; display: flex; flex-direction: column; gap: 6px; white-space: normal; }
.inst-actions.acc-actions { flex-wrap: nowrap; gap: 4px; white-space: nowrap; width: max-content; }
/* A long nota description wraps in a column of its own width, not the whole row. */
.peek { max-width: 460px; min-width: 240px; white-space: normal; }
.peek-top > span:not(.pill) { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.peek-line { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 440px; }
.acc-actions .btn.small { padding: 3px 8px; font-size: 12px; }
.acc-actions .icon-btn { min-width: 30px; }
.names-table td { vertical-align: middle; }
.names-table .names-new { width: 100%; min-width: 260px; }
/* The day's quotes: up in green, down in red (with the arrow and the
   figure, so not by colour alone). */
.q-strip { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: space-between;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); margin: 8px 0; }
.q-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.q-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); font-variant-numeric: tabular-nums; }
.q-chip .q-name { color: var(--muted); font-size: 12px; }
.q-chip.q-up { border-color: var(--accent); }
.q-chip.q-up .q-val, .q-chip.q-up .q-ch { color: var(--accent); }
.q-chip.q-down { border-color: var(--danger); }
.q-chip.q-down .q-val, .q-chip.q-down .q-ch { color: var(--danger); }
.q-chip .q-ch { font-size: 12px; font-weight: 600; }
.q-chip.q-same .q-ch { color: var(--muted); }
.q-when { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.est-sel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 10px; margin: 4px 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.est-sel-label { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-right: 4px; }
.est-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px; border-radius: 999px;
  border: 1px solid var(--accent); background: var(--accent-soft); font-size: 13px; }
.est-tag-x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 6px; }
.est-tag-x:hover { color: var(--danger); }
.est-drop { position: relative; display: inline-block; }
.est-drop > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; width: auto; }
.est-drop > summary::-webkit-details-marker { display: none; }
.est-drop-panel { position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; min-width: 240px; max-height: 320px; overflow: auto;
  display: flex; flex-direction: column; gap: 6px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); }
.off-state { padding: 8px 12px; border-radius: var(--radius-sm); margin: 6px 0 10px; font-weight: 600; }
.off-state.ok { background: var(--accent-soft); color: var(--accent); }
.off-state.warn { background: var(--warn-soft); color: var(--warn); }
.off-state.bad { background: var(--danger-soft); color: var(--danger); }
.off-folder { min-width: 380px; }
.pend-bar.off-bar { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
/* Bank accounts: a card each, the one chosen outlined. */
.bank-cards { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 8px; }
.search-row .bank-date { flex: 0 0 auto; width: 160px; }
.bank-desc { display: inline-block; max-width: 380px; white-space: normal; }
.bank-card { flex: 0 0 300px; text-align: left; display: flex; flex-direction: column; gap: 6px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.bank-card:hover { border-color: var(--accent); }
.bank-card.on { border: 2px solid var(--accent); padding: 11px 13px; }
.bank-card.off { opacity: .6; }
.bank-card.warn { border-color: var(--warn); background: var(--warn-soft); }
.bank-card.add { flex-basis: 160px; align-items: center; justify-content: center; color: var(--muted); border-style: dashed; }
.bank-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bank-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bank-ok { color: var(--accent-text); background: var(--accent); border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; }
.bank-bad { color: #fff; background: var(--danger); border-radius: 50%; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; }
.bank-line { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; font-variant-numeric: tabular-nums; }
.bank-line strong { font-size: 18px; }
.bank-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 10px; }
.bank-head h2 { margin: 0 0 8px; }
.bank-figs { display: flex; flex-wrap: wrap; gap: 22px; }
.bank-figs > div { display: flex; flex-direction: column; gap: 2px; font-variant-numeric: tabular-nums; }
.bank-figs strong { font-size: 17px; }
.bank-in { color: var(--accent); }
.bank-out { color: var(--danger); }
/* An international account's amount over its other side (the bill in reais,
   the transfer's other account); one still to type, asked for. */
.fx-cell { display: inline-flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.btn.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-soft); }
/* A loan's candidates, and an entry whose statement line is another account's. */
.loan-list { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow: auto; }
.loan-cand { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.loan-cand.good { border-color: var(--accent); }
.loan-cand-top { display: flex; justify-content: space-between; gap: 12px; }
.loan-cand-act { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loan-cand-act input { width: 130px; }
.line-elsewhere { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.bank-opening { padding: 8px 12px; border: 1px dashed var(--border); border-top: 0; border-radius: 0 0 var(--radius-sm) var(--radius-sm); font-size: 13px; }
.tr-swap { justify-content: flex-end; }
.st-acts { display: flex; flex-wrap: wrap; gap: 4px; }
.seg button.seg-alert:not(.active) { color: var(--warn); font-weight: 700; }
/* Tabs that can be dragged into another order. */
.tab-dragging { opacity: .45; outline: 2px dashed var(--accent); outline-offset: -2px; }
.tab-armed { outline: 2px dashed var(--accent); outline-offset: -2px; cursor: grabbing; transform: scale(1.04); transition: transform .12s; }
tr.ind-strong td { background: var(--accent-soft); }
tr.ind-apart td { color: var(--muted); }
.settle-when { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.settle-opt { display: flex; align-items: center; gap: 8px; }
.settle-opt input[data-date] { max-width: 180px; }
.peek-files { display: flex; flex-wrap: wrap; gap: 6px; }
.peek-file { display: inline-flex; align-items: center; gap: 2px; }
.peek-notes { font-size: 12px; color: var(--muted); }
.inv-finder-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; max-height: 60vh; overflow: auto; }
.inv-cand { padding: 10px 12px; }
.inv-cand.good { border-color: var(--accent); }
.inv-cand-top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.inv-finder-box { margin: 6px 0 10px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }
.parcel-strip { display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.parcel-head { padding: 4px 8px; font-size: 11px; font-weight: 700; letter-spacing: .04em; color: var(--text-muted, var(--muted));
  background: var(--surface-2); border-right: 1px solid var(--border); display: flex; align-items: center; }
.parcel { display: inline-flex; gap: 10px; align-items: center; padding: 4px 10px; font: inherit; font-size: 13px;
  font-variant-numeric: tabular-nums; background: transparent; color: var(--text); border: 0; border-right: 1px solid var(--border); }
button.parcel { cursor: pointer; }
button.parcel:hover { background: var(--surface-2); }
.parcel.on { outline: 2px solid var(--accent); outline-offset: -2px; font-weight: 600; }
.parcel.paid { opacity: .7; }
.parcel-no { font-weight: 700; }
.parcel-tag { font-size: 11px; padding: 1px 6px; border-radius: 9px; background: var(--surface-2); }
.parcel-tag.ok { color: var(--good, var(--accent)); }
.parcel-off { margin-top: 4px; }
.parcel-pick { margin-top: 8px; padding: 8px; border: 1px dashed var(--border); border-radius: 6px; }
.parcel-pick h4 { margin: 10px 0 2px; font-size: 13px; }
.parcel-pick-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.bill-lines { display: flex; flex-direction: column; gap: 3px; margin: 6px 0; width: 100%; }
.bill-line { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 10px; align-items: center;
  padding: 3px 8px; border-left: 3px solid var(--border); font-size: 13px; }
.bill-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 900px) { .txn-split:has(> .pb-panel:not([hidden])) { grid-template-columns: 1fr; }
  /* Above the form, one column: it scrolls with it, never over its fields. */
  .pb-panel { position: static; max-height: none; } }
.docpair > div { margin: 4px 0; }
.supp-acts { white-space: nowrap; text-align: right; }
.supp-acts .btn { margin-left: 4px; }
.supp-notes { max-width: 360px; white-space: pre-line; }
.supp-remove h3 { margin: 16px 0 4px; font-size: 14px; }
.supp-bar[hidden] { display: none; }
/* Feedlot. */
.fl-card { cursor: pointer; margin-bottom: 14px; }
.fl-card:hover { border-color: var(--accent); }
.fl-card .card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fl-card .card-head h2 { margin: 0; }
.fl-progress { height: 6px; border-radius: 3px; background: var(--border); margin: 4px 0 12px; overflow: hidden; }
.fl-progress i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.fl-intro-list { margin: 8px 0 14px; padding-left: 20px; line-height: 1.6; }
.fl-plot { height: 260px; }
.fl-charts { margin-top: 14px; align-items: start; }
.fl-chart .evo-key.dash { background: none !important; border-top: 2px dashed var(--muted); height: 0; }
.fl-legend .evo-key.dash { background: none !important; border-top-width: 2px; border-top-style: dashed; height: 0; }
.fl-legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 6px; font-size: 12px; color: var(--muted); }
.fl-next { margin: 12px 0; }
.fl-split { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.fl-result { position: sticky; top: 70px; max-height: calc(100vh - 90px); overflow: auto; }
.fl-result h3 { margin: 14px 0 6px; font-size: 14px; }
.fl-group { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px 12px; margin: 0 0 12px; }
.fl-group legend { padding: 0 6px; color: var(--muted); font-size: 13px; }
.fl-inline { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.fl-inline input { flex: none; width: 90px; text-align: right; }
.fl-num { width: 90px; text-align: right; }
.fl-diet { margin-bottom: 12px; }
.fl-diet-head { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 8px; }
.fl-diet-head label { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); }
.fl-items .fl-ing { min-width: 150px; }
.fl-items .fl-num { width: 72px; }
.fl-items .fl-cat { min-width: 180px; max-width: 240px; }
.fl-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fl-table td, .fl-table th { padding: 5px 6px; border-bottom: 1px solid var(--border); }
.fl-table th { text-align: left; color: var(--muted); font-weight: 600; }
.fl-table th.num, .fl-table td.num { text-align: right; white-space: nowrap; }
/* Pay together: a long nota description wraps, its dates stay in sight. */
.pg-form .fl-table td:first-child { white-space: normal; min-width: 180px; max-width: 320px; overflow-wrap: anywhere; }
.pg-form .fl-table td, .pg-form .fl-table th { white-space: nowrap; }
.pg-form .fl-table td:first-child { white-space: normal; }
.pg-form .pg-day { max-width: 150px; }
.fl-table tr.sum td { font-weight: 700; }
.fl-scores { display: flex; gap: 4px; }
.fl-score { min-width: 36px; }
.fl-score.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.fl-bunk-help { margin: 10px 0; }
.fl-bunk-help summary { cursor: pointer; color: var(--muted); }
.fl-input { margin-bottom: 14px; }
.fl-input .card-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.fl-input .card-head h2 { margin: 0; }
tr.fl-slow td { background: color-mix(in srgb, var(--danger) 8%, transparent); }
.pend-bar.bad { border-color: var(--danger); }
/* Confinement estimate. */
.est-card { margin-bottom: 14px; }
.est-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: start; margin: 8px 0; }
.est-label { color: var(--muted); font-size: 13px; padding-top: 4px; }
.est-row .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.est-count { margin: 10px 0 6px; }
.est-list { max-height: 420px; overflow: auto; }
.est-verdict { padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); margin-bottom: 10px; }
.est-verdict.ok { border-color: var(--accent); background: var(--accent-soft); }
.est-verdict.warn { border-color: var(--warn); }
.est-verdict.bad { border-color: var(--danger); }
.fl-sheet.busy { opacity: .55; transition: opacity .2s; }
.fl-paid { display: block; font-size: 11px; padding: 0; margin-top: 2px; white-space: nowrap; }
tr.est-click { cursor: pointer; }
.fl-guide { font-size: 12px; margin-top: 4px; max-width: 360px; line-height: 1.35; }
.fl-items .fl-ing-cell { min-width: 260px; }
.fl-items .fl-ing-cell .picker > label { display: none; }
.fl-guide .pill { font-size: 11px; padding: 1px 7px; }
.fl-add-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.fl-from-cat { max-width: 420px; }
tr.est-click:hover td { background: var(--surface-2); }
.est-more { color: var(--accent); font-weight: 700; }
.est-cost-btn { margin: 8px 0 4px; }
.est-bar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; min-width: 80px; }
.est-bar i { display: block; height: 100%; background: var(--accent); }
.est-bar-cell { width: 120px; }
.est-left { margin: 8px 0; }
.est-quotes { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; margin: 10px 0; }
.est-quotes summary { cursor: pointer; font-weight: 600; }
.est-quotes .fl-inline { margin-top: 8px; }
.est-auto { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.est-left summary { cursor: pointer; color: var(--muted); }
@media (max-width: 720px) { .est-row { grid-template-columns: 1fr; gap: 4px; } }
@media (max-width: 900px) {
  .fl-split { grid-template-columns: 1fr; }
  .fl-result { position: static; max-height: none; }
}
/* A supplier's page: the record to edit on the left, the history on the right. */
.party-split { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); gap: 16px; align-items: start; }
.party-record { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.party-record .field { margin: 0; }
.party-record-head { display: flex; align-items: center; justify-content: space-between; }
.party-record-head h3 { margin: 0; font-size: 15px; }
.party-record-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.party-record .form-actions { flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.party-history { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
/* Their Pix keys, accounts and contacts, above their history. */
.party-details { display: flex; flex-direction: column; gap: 8px; }
.party-details h3 { margin: 0; font-size: 15px; }
.pd-list { display: flex; flex-direction: column; gap: 4px; }
.pd-row { display: grid; grid-template-columns: 70px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 4px 0; border-bottom: 1px solid var(--border); }
.pd-row:last-child { border-bottom: 0; }
.pd-kind { color: var(--muted); font-size: 12px; }
.pd-val { display: flex; flex-direction: column; min-width: 0; overflow-wrap: anywhere; }
.pd-add { display: flex; flex-wrap: wrap; gap: 6px; }
.pd-add > select { flex: 0 0 110px; }
.pd-add > input { flex: 1 1 130px; min-width: 0; }
.pd-add > button { margin-left: auto; }
@media (max-width: 900px) { .party-split { grid-template-columns: 1fr; } .party-record { position: static; } }
/* What documents say of a party. */
.party-info-note { flex-direction: column; align-items: flex-start; gap: 4px; }
.pinfo-list { display: flex; flex-direction: column; gap: 10px; max-height: 60vh; overflow: auto; }
.pinfo-party { display: flex; flex-direction: column; gap: 3px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.pinfo-line { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.chart .col.click:hover .b { filter: brightness(1.15); }
.evo-tip .tip-hint { margin-top: 6px; font-size: 11px; color: var(--muted); }
/* Deleting categories: what goes, and where its entries go. */
.catdel { display: flex; flex-direction: column; gap: 14px; }
.catdel-list { display: flex; flex-direction: column; gap: 6px; }
.catdel-item { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.catdel-item .spacer { flex: 1; }
.catdel-block { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.catdel-warn { border-color: var(--warn); background: var(--warn-soft); }
.catdel-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.catdel-row select { width: auto; min-width: 220px; }
.creg-del { padding: 2px 8px; opacity: .7; }
.creg-del:hover { opacity: 1; }
/* Entries ticked: one category for all - stays in view while scrolling. */
.bulk-bar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 10px 12px; margin-bottom: 10px; border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--surface); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.bulk-bar[hidden] { display: none; }
.bulk-bar > strong { align-self: center; }
.bulk-bar > .picker { min-width: 260px; flex: 1 1 260px; }
.bulk-bar select { width: auto; }
/* Investments not in the Inventory, and what an item was paid with. */
.inv-out { margin-bottom: 14px; border-color: var(--warn); }
.inv-out tbody tr { cursor: pointer; }
.inv-out td { white-space: normal; }
.inv-match { margin-top: 4px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.inv-out td:nth-child(4) { font-size: 12px; color: var(--muted); }
.inv-out td.num { white-space: nowrap; }
.inv-out .bulk-bar { margin: 10px 0; }
/* Open on the other computer: view only here - a bar across the top. */
.ho-bar { position: sticky; top: 0; z-index: 30; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  padding: 8px 16px; background: var(--warn-soft); color: var(--text); border-bottom: 2px solid var(--warn); font-weight: 600; }
.ho-bar .ho-say { flex: 1 1 auto; }
/* A hand-over (or load) as it goes, then what to do next. */
.ho-progress { display: grid; gap: 6px; margin: 10px 0; }
.ho-progress-bar { width: 100%; height: 14px; accent-color: var(--accent); }
.ho-next { margin: 10px 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--text); }
.ho-next strong { color: var(--accent); }
.ho-steps { margin: 8px 0 6px 18px; padding: 0; display: grid; gap: 4px; }
/* Why a category was not put (on all): a line that stays, not a toast. */
.bulk-bar .bulk-note { flex-basis: 100%; max-width: none; margin-top: 0; }
.entries-table > .bulk-note { max-width: none; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; }
.inv-links { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; gap: 6px; }
.inv-link-list { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow: auto; }
.inv-link { display: flex; gap: 10px; align-items: center; }
.inv-link .spacer { flex: 1; }
.invest-onto { width: auto; max-width: 280px; }
.suggest-price { font-style: italic; color: var(--muted-strong, var(--text)); }
.suggest-cell { cursor: help; display: inline-block; }
.suggest-card { position: fixed; z-index: 400; max-width: 460px; padding: 10px 12px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: 0 8px 24px rgba(0, 0, 0, .28);
  font-size: 12px; pointer-events: none; }
.suggest-card .when { font-weight: 600; margin-bottom: 6px; }
.suggest-card table { width: 100%; margin-bottom: 6px; }
.suggest-card th, .suggest-card td { padding: 3px 6px; font-size: 12px; white-space: nowrap; }
.inv-file { padding: 2px 8px; font-size: 12px; display: inline-flex; align-items: center; gap: 2px; }
.inv-file .clip-icon { width: 13px; height: 13px; }
.inv-entry-docs { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; gap: 6px; }
.inv-entry-doc-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow: auto; }
td.pick input { width: auto; }

/* ---------- pills ---------- */

.pill {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 620; white-space: nowrap;
  background: var(--surface-2); color: var(--muted);
}
/* A pill that is a sentence of its own wraps, like the text it is. */
p.pill, div.pill { display: block; width: fit-content; max-width: 100%; white-space: normal; border-radius: 12px; padding: 5px 11px; }
.pill.ok   { background: var(--accent-soft); color: var(--accent); }
.pill.bad   { background: var(--danger-soft); color: var(--danger); }
.pill.warn  { background: var(--warn-soft);   color: var(--warn); }
.pill.info  { background: var(--info-soft);   color: var(--info); }

/* ---------- lots ---------- */

.lot-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 15px; }
.lot-card .top { display: flex; align-items: baseline; gap: 8px; }
.lot-card .head { font-size: 26px; font-weight: 650; letter-spacing: -.02em; }
.lot-card .meta { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.lot-card .acts { display: flex; gap: 6px; margin-top: 12px; }

/* ---------- timeline ---------- */

.timeline { display: flex; flex-direction: column; }
.tl-item { display: grid; grid-template-columns: 108px 1fr auto; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--border); }
.tl-item:last-child { border-bottom: 0; }
.tl-item .when { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-item .what { font-size: 13.5px; }
.tl-item .what .det { color: var(--muted); }

/* ---------- detail ---------- */

.dl { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 13px 20px; }
.dl .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; }
.dl .v { font-size: 14px; margin-top: 2px; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.muted { color: var(--muted); }
.right { text-align: right; }

/* ---------- modal ---------- */

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 18px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(20, 18, 14, .5); backdrop-filter: blur(2px); }
.modal-card {
  position: relative; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(780px, 100%); max-height: calc(100vh - 36px); display: flex; flex-direction: column;
  /* Drag the bottom-right corner to resize; the entry form remembers it. */
  resize: both; overflow: hidden; min-width: min(360px, 100%); min-height: 200px;
  max-width: calc(100vw - 16px);
}
.modal-card.maximized {
  width: calc(100vw - 24px) !important; height: calc(100vh - 24px) !important;
  max-height: none; resize: none;
}
.modal-max { font-size: 18px; }
/* The entries behind a cost figure: a wide list. */
.modal-card[data-size="costdetail"] { width: min(1180px, 100%); }
@media (max-width: 720px) {
  .modal-card { resize: none; }
  .modal-max { display: none; }
}
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; }
/* The window's own buttons in its header (a phone's Save, a line's Done). */
.modal-acts { display: flex; align-items: center; gap: 6px; }
.modal-acts:empty { display: none; }
/* A scroll that reaches the end of the window stops there - never the page behind. */
.modal-body { padding: 16px; overflow-y: auto; flex: 1; min-height: 0; container-type: inline-size; overscroll-behavior: contain; }
/* A phone: a window fills what is seen of the screen (Safari's bars and the
   keyboard left out - watchViewport), its header in sight, the page behind
   it held still. */
@media (max-width: 640px) {
  #modal { padding: 0; top: var(--vvt, 0px); bottom: auto; height: var(--vvh, 100dvh); align-items: stretch; }
  #modal .modal-card { width: 100% !important; height: 100% !important; max-width: none; max-height: none;
    min-width: 0; min-height: 0; border: 0; border-radius: 0; box-shadow: none; }
  #modal .modal-head { padding: max(10px, env(safe-area-inset-top)) 12px 10px; gap: 8px; }
  #modal .modal-head h2 { font-size: 17px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #modal .modal-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  html:has(#modal:not([hidden])), html:has(#modal:not([hidden])) body { overflow: hidden; overscroll-behavior: none; }
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; }
.form-grid .wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.form-actions .spacer { flex: 1; }
/* In a window, the buttons stay in sight however far down the form is scrolled. */
.modal-body .form-actions {
  position: sticky; bottom: -16px; z-index: 2; background: var(--surface);
  margin-bottom: -16px; padding-bottom: 16px;
}
/* ...and what is brought into sight (a box focused, a line just added) stops
   above those buttons, not behind them. */
.modal-body:has(.form-actions) { scroll-padding-bottom: 100px; }
.form-top { display: flex; justify-content: flex-end; margin-bottom: 12px; }
/* A window holding a long list: the list scrolls inside, the buttons stay at
   the bottom, whatever the window's size (drag its corner when not maximized). */
.modal-body:has(> .fill) { overflow: hidden; display: flex; flex-direction: column; }
.modal-body > .fill { flex: 1; min-height: 0; }
.modal-card:has(.fill):not(.maximized) { height: calc(100vh - 36px); }
.batch-form.fill > .batch-wrap { flex: 1 1 auto; min-height: 120px; overflow: auto; }
.split { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.split-top { flex: 0 0 auto; max-height: 50%; overflow: auto; display: flex; flex-direction: column;
  gap: 10px; padding-right: 4px; }
.split-top.sized { max-height: none; }
.split-bar { flex: none; height: 14px; margin: 2px 0; cursor: row-resize; touch-action: none;
  display: flex; align-items: center; justify-content: center; border-radius: 7px; }
.split-bar::before { content: ''; width: 56px; height: 4px; border-radius: 2px; background: var(--border); }
.split-bar:hover, .split-bar:focus-visible { background: var(--accent-soft); outline: none; }
.split-bar:hover::before, .split-bar:focus-visible::before { background: var(--accent); }
.split-bottom { flex: 1 1 auto; min-height: 110px; display: flex; flex-direction: column; gap: 8px; }
.split-bottom > .table-wrap { flex: 1; min-height: 0; overflow: auto; }

/* ---------- herd value & slaughter forecast ---------- */

.val-price-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 12px; }
.val-history { margin-top: 12px; font-size: 13px; }
.val-history summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.val-history .table-wrap { margin-top: 8px; }
.val-notes { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px;
  font-size: 12px; color: var(--muted); }
.val-settings { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; }
.val-settings label.field { flex: 1 1 180px; }
.val-settings .btn { flex: none; }
.val-bar { width: 40%; min-width: 80px; }
.val-bar .track { background: var(--surface-2); border-radius: 4px; height: 8px; overflow: hidden; }
.val-bar .fill { background: var(--accent); height: 100%; border-radius: 4px; min-width: 2px; }
.val-hint { margin-top: 8px; font-size: 12px; }
.val-list { margin-top: 14px; }
.val-list > summary { cursor: pointer; font-weight: 600; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.val-list[open] > summary { margin-bottom: 10px; }

/* ---------- installments ---------- */

.form-grid label.field[hidden], .form-grid label.check[hidden], .inst-box[hidden],
.rep-hint[hidden] { display: none; }
.rep-hint { font-size: 12px; margin-top: -4px; }
.rep-pill { margin-left: 4px; white-space: nowrap; }
.pay-mode { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.pay-mode .seg { align-self: flex-start; }
.inst-box { display: flex; flex-direction: column; gap: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.inst-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.inst-table { width: 100%; }
.inst-table th, .inst-table td { padding: 4px 6px; }
.inst-table td:first-child { width: 1%; white-space: nowrap; }
.inst-table input { width: 100%; min-width: 0; }
.inst-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.open-amount { color: var(--warn); }
/* The right-click copy menu. */
.copy-menu { position: fixed; z-index: 2000; min-width: 180px; max-width: 360px; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; }
.copy-menu[hidden] { display: none; }
.copy-menu button { background: none; border: 0; text-align: left; padding: 7px 10px; border-radius: 6px;
  font: inherit; color: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.copy-menu button:hover, .copy-menu button:focus { background: var(--accent-soft); outline: none; }
.copy-menu .copy-file { font-weight: 600; }
/* An invoice and its payment, side by side. */
.twin-pair { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: stretch; margin: 10px 0; }
.twin-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.twin-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.twin-arrow { align-self: center; font-size: 22px; color: var(--muted); }
.twins-note { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--warn-soft); border: 1px solid var(--warn); }
.twins-note[hidden] { display: none; }
.invest-note { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px;
  padding: 10px 12px; border-radius: var(--radius); background: var(--info-soft, var(--surface-2)); border: 1px solid var(--border); }
.invest-note[hidden] { display: none; }
.dep-fields { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; }
.dep-fields[hidden] { display: none; }
.dep-fields legend { font-weight: 600; padding: 0 6px; }
.dep-fields .form-grid { margin-top: 6px; }
.dep-says { margin-top: 8px; font-weight: 500; }
.dep-box { margin-bottom: 16px; }
.dep-box tr.clickable { cursor: pointer; }
.twin-dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 720px) { .twin-pair { grid-template-columns: 1fr; } .twin-arrow { display: none; } }
/* Signing in. */
.tab[hidden] { display: none; }
.login { position: fixed; inset: 0; z-index: 1000; background: var(--bg, var(--surface));
  display: grid; place-items: center; padding: 16px; overflow: auto; }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; }
.login-head { display: flex; flex-direction: column; align-items: center; gap: 8px; margin-bottom: 4px; }
.login-head .mark { color: var(--accent); }
.login-help summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.login-help p { font-size: 13px; margin: 8px 0 0; }
.login-card .link-btn { align-self: center; background: none; border: 0; padding: 2px 4px; cursor: pointer;
  color: var(--accent); font: inherit; font-size: 13px; text-decoration: underline; text-underline-offset: 3px; }
.login-card .reset-step { display: flex; flex-direction: column; gap: 14px; }
.login-card[hidden], .login-card .reset-step[hidden] { display: none; }
.login-card input[readonly] { opacity: .75; }
.userbox { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.nav-back, .undo-btn { font-size: 18px; flex: none; }
.nav-back[hidden], .modal-back[hidden] { display: none; }
.modal-back { font-size: 18px; }
.undo-list .undo-row { display: grid; grid-template-columns: 22px 90px 1fr auto; gap: 12px; align-items: center;
  padding: 10px 4px; border-bottom: 1px solid var(--border); }
.undo-list .undo-row.undone { opacity: .55; }
.undo-what { min-width: 0; overflow-wrap: anywhere; }
.userbox[hidden] { display: none; }
/* An offline copy's state, by the user (ranch/syncclient.py) - a pill that opens its panel. */
.syncpill { border: 0; font: inherit; font-size: 12px; cursor: pointer; white-space: nowrap; }
/* An offline copy with no internet, on the money's screens (ranch/outbox.py). */
.offline-banner { margin: var(--pad) var(--pad) 0; padding: 8px 12px; border-radius: var(--radius-sm);
  background: var(--info-soft); color: var(--text); border: 1px solid var(--border); font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.offline-banner[hidden] { display: none; }
.offline-banner.warn { background: var(--warn-soft); }
.offline-banner .btn { margin-left: auto; }
.ob-list { display: grid; gap: 6px; margin: 8px 0 12px; }
.ob-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); }
.ob-item .ob-what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.ob-item .ob-err { color: var(--danger); font-size: 12px; margin-top: 2px; }
.ob-item .amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.syncpill[hidden] { display: none; }
.syncpill:not(.ok):not(.bad):not(.warn) { background: var(--surface-2, var(--border)); color: var(--muted); }
.sync-c { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-top: 10px; background: var(--surface); }
.sync-c-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.sync-c table { width: 100%; margin-top: 8px; }
.sync-c td { vertical-align: top; padding: 4px 6px; }
.sync-c .pick { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.sync-c .form-actions { margin-top: 10px; }
.user-name { background: none; border: 0; font: inherit; font-weight: 600; color: inherit; cursor: pointer;
  max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.user-name:hover { color: var(--accent); }
.user-areas-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.user-limited .check { margin-top: 10px; }
/* A tile that filters the list below it. */
.stat-link { cursor: pointer; transition: border-color .12s; }
.stat-link:hover, .stat-link:focus-visible { border-color: var(--accent); outline: none; }
.stat-link.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.period-select { width: auto; }
.pays-list { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.pays-opt { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; }
.pays-opt:has(input:checked) { border-color: var(--accent); }
.pays-opt input[type=radio] { width: auto; flex: none; margin: 0; }
.pays-opt .btn { flex: none; }
.pays-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.batch-pays-row td { padding-top: 0 !important; border-top: 0 !important; }
.batch-pays { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; padding: 6px 10px;
  border-left: 3px solid var(--accent); background: var(--surface-2, transparent); }
.batch-pays select { max-width: 560px; }
.cost-drill { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
  text-decoration: underline dotted; text-underline-offset: 3px; }
.cost-drill:hover, .cost-drill:focus-visible { color: var(--accent); text-decoration-style: solid; }
.cost-detail-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.cost-detail-bar { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.cost-detail-bar > label, .cost-detail-bar > .picker { min-width: 260px; flex: 1 1 260px; }
.inst-actions .btn { white-space: nowrap; }
.boleto-drop { margin: 10px 0; }
.boleto-file { margin: 10px 0; }
.boleto-file .review-list li.ok { color: var(--good, inherit); }
.boleto-file .review-list li.bad { color: var(--bad, inherit); }
.inst-foot { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.inst-diff { color: var(--danger); font-weight: 600; }

/* On a phone each installment stacks: its number, then due date and amount
   side by side, then the payment date - each labelled, as the header row is
   hidden. */
@media (max-width: 720px) {
  .inst-table thead { display: none; }
  .inst-table, .inst-table tbody { display: block; }
  .inst-table tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 8px; padding: 8px 6px; }
  .inst-table tr + tr { border-top: 1px solid var(--border); }
  .inst-table td { display: flex; flex-direction: column; gap: 3px; padding: 0; border: 0; }
  .inst-table td:first-child { grid-column: 1 / -1; width: auto; text-align: left; font-weight: 600; }
  .inst-table td.inst-boleto { grid-column: 1 / -1; }
  .inst-table td:last-child { grid-column: 1 / -1; }
  .inst-table td[data-label]::before { content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--muted); }
}

/* ---------- register picker ---------- */

.picker { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.picker > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.picker-box { position: relative; }
.picker-box input { width: 100%; }
.picker-list {
  position: absolute; z-index: 20; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 260px; overflow-y: auto; padding: 4px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
}
.picker-list[hidden], .picker-ask[hidden] { display: none; }
/* Never sideways: a long "Group › Item" ends in … (the whole name on hover). */
.picker-list { overflow-x: hidden; }
/* The group gives way (…), the name itself stays whole. */
.picker-what { display: flex; align-items: baseline; min-width: 0; white-space: nowrap; }
.picker-group { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.picker-name { flex: 0 0 auto; }
.picker-group + .picker-name { margin-left: 4px; }
.picker-opt {
  display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
  padding: 7px 9px; border-radius: 5px; cursor: pointer; font-size: 13px;
}
.picker-opt .muted { font-size: 11px; white-space: nowrap; }
.picker-opt.active, .picker-opt:hover { background: var(--accent-soft); }
.picker-opt.add { color: var(--accent); font-weight: 600; justify-content: flex-start; }
.picker-list .picker-opt.add:not(:first-child) { border-top: 1px solid var(--border); border-radius: 0 0 5px 5px; }
.picker-ask {
  display: flex; flex-direction: column; gap: 8px; padding: 10px;
  border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-soft);
  font-size: 13px;
}
.picker-q { font-weight: 600; }
.picker-actions { display: flex; gap: 8px; }
.picker-fields { display: flex; flex-direction: column; gap: 8px; }
.picker-row { display: flex; gap: 6px; align-items: stretch; }
.picker-row .picker-box { flex: 1; min-width: 0; }
.picker-browse { flex: none; }
.picker-tree { margin-top: 6px; }
.picker-tree[hidden] { display: none; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .picker.browsing { grid-column: 1 / -1; }
/* A form too narrow for two columns keeps the field to one. */
@container (max-width: 440px) { .form-grid .span-2 { grid-column: auto; } }

/* due / paid dates following the entry date */
.link-tag { font-size: 10px; font-weight: 700; color: var(--accent); background: var(--accent-soft);
  padding: 0 5px; border-radius: 4px; align-self: flex-start; }
.link-tag[hidden] { display: none; }

/* ---------- reading documents ---------- */

.review-banner { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px;
  padding: 10px 12px; font-size: 13px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: var(--radius-sm); }
.review-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.review-list { margin: 0; padding-left: 18px; color: var(--warn); }
.review-list li.bad { color: var(--danger); font-weight: 600; }
.review-list li.muted { color: var(--muted); }
.review-similar { color: var(--danger); }
.review-similar ul { margin: 2px 0 0; padding-left: 18px; }
.flag-chip { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 11px; font-weight: 700; }
.flag-chip.check { background: var(--warn-soft); color: var(--warn); border: 1px solid var(--warn); }
.flag-chip.missing { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.flag-check input, .flag-check select { border-color: var(--warn); background: var(--warn-soft); }
.flag-missing input, .flag-missing select { border-color: var(--danger); background: var(--danger-soft); }
.flag-note { font-size: 11px; font-weight: 700; color: var(--warn); text-transform: uppercase; letter-spacing: .03em; }
.flag-missing .flag-note { color: var(--danger); }
.doc-drop { min-height: 60vh; }
.doc-drop.drop-over { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius); }

.catx-from { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 4px 0 12px; }
.catx-from label { display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.catx-result details { margin: 8px 0; }
.catx-result summary { cursor: pointer; font-weight: 600; }
.catx-list { list-style: none; margin: 6px 0; padding: 0; max-height: 260px; overflow-y: auto; }
.catx-list li { padding: 4px 0; border-bottom: 1px solid var(--border); }
.catx-list li:last-child { border-bottom: 0; }
.names-caps-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0 0 10px; }
.pinfo-track { height: 6px; margin: 4px 0 8px; border-radius: 3px; background: var(--border); overflow: hidden; }
.pinfo-track i { display: block; height: 100%; background: var(--accent); transition: width .4s; }
.sl-entry { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding: 8px 12px; margin: 8px 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sl-papers { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 6px 0 10px; }
.sl-out-pill { margin-top: 3px; white-space: nowrap; }
.chart-list-acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.entries-add { display: flex; gap: 10px; align-items: stretch; margin: 0 0 12px; }
.entries-add .doc-dropbar { flex: 1; min-width: 0; margin: 0; }
.entries-add > .btn { flex: none; align-self: stretch; padding: 0 22px; }
@media (max-width: 720px) { .entries-add { flex-direction: column; } .entries-add > .btn { padding: 12px; } }
.doc-dropbar { display: block; width: 100%; margin: 14px 0 0; padding: 14px 16px;
  font: inherit; font-size: 13px; color: var(--muted); text-align: left; cursor: pointer;
  background: var(--surface); border: 2px dashed var(--border); border-radius: var(--radius); }
.doc-dropbar:hover, .doc-drop.drop-over .doc-dropbar { border-color: var(--accent); color: var(--text); }
.doc-dropbar strong { color: var(--accent); }
/* On a phone: the bar split - choose files | paste the copied one. */
.doc-split { display: flex; align-items: stretch; padding: 0; cursor: default; }
/* A herd file's columns: a menu over each, its name, its first rows. */
.herd-map { display: grid; gap: 6px; margin-top: 8px; min-width: 0; }
.herd-map-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; max-width: 100%; }
.herd-map-table { border-collapse: collapse; font-size: 12.5px; }
.herd-map-table th, .herd-map-table td { padding: 4px 8px; border-right: 1px solid var(--border); white-space: nowrap;
  max-width: 170px; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.herd-map-table thead tr:first-child th { background: var(--surface-2); padding: 5px 6px; }
.herd-map-table select { font-size: 12px; padding: 2px 4px; height: auto; max-width: 160px; }
.herd-map-is.is-extra select, .herd-map-is.is-ignore select, .herd-map-is.is-wpart select { color: var(--muted); }
.herd-map-is:not(.is-extra):not(.is-ignore):not(.is-wpart) select { border-color: var(--accent); font-weight: 600; }
.herd-map-name { font-weight: 700; border-bottom: 1px solid var(--border); }
.herd-map-table td { color: var(--muted); }
.herd-map-only { display: grid; gap: 10px; }
/* A home's own name on top, in place of the app's. */
.brand .farm-badge.small { width: 24px; height: 24px; }
.brand-home { font-weight: 700; }
.doc-split > button { appearance: none; border: 0; background: none; font: inherit; color: inherit; cursor: pointer; }
.doc-split .doc-pick { flex: 1; min-width: 0; padding: 14px 16px; text-align: left; }
.doc-split .doc-paste { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 10px 20px; border-left: 2px dashed var(--border); color: var(--accent); font-weight: 650; }
.doc-split > button:hover, .doc-split > button:active { background: var(--surface-2); color: var(--text); }
.doc-split .doc-paste:hover, .doc-split .doc-paste:active { color: var(--accent); }
.doc-split .doc-paste .paste-ico { width: 22px; height: 22px; }
/* ...and the camera first: a receipt scanned. */
.doc-split .doc-scan { flex: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  padding: 10px 18px; border-right: 2px dashed var(--border); color: var(--accent); font-weight: 650; }
.doc-split .doc-scan:hover, .doc-split .doc-scan:active { color: var(--accent); }
.doc-split .doc-scan .paste-ico { width: 22px; height: 22px; }
/* The scan fitted to the paper: the photo, its four corners to drag. */
.ask-card.trim-card { width: min(620px, 100%); justify-items: stretch; text-align: left; max-height: calc(100vh - 40px); overflow-y: auto; }
.trim-card .ask-text, .trim-card .muted { margin: 0; }
.trim-stage { display: flex; justify-content: center; min-width: 0; }
.trim-view { position: relative; touch-action: none; user-select: none; }
.trim-canvas { display: block; border-radius: 6px; }
.trim-handle { position: absolute; width: 30px; height: 30px; margin: -15px 0 0 -15px; border-radius: 50%; touch-action: none; cursor: grab;
  border: 3px solid var(--accent); background: color-mix(in srgb, var(--surface) 55%, transparent); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); }
.trim-handle:active { cursor: grabbing; }
.trim-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.trim-actions .spacer { flex: 1; }
.paste-ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn .paste-ico { margin-right: 5px; vertical-align: -3px; }
/* The box a phone pastes into: touch and hold, "Paste". */
.paste-pad { min-height: 110px; padding: 14px; margin: 4px 0 8px; display: grid; place-items: center; text-align: center;
  border: 2px dashed var(--accent); border-radius: var(--radius); background: var(--accent-soft); color: var(--text);
  font-size: 15px; caret-color: transparent; -webkit-user-select: text; user-select: text; outline: none; overflow: hidden; }
.paste-pad:empty::before { content: attr(data-ph); color: var(--muted); pointer-events: none; }
.paste-pad img { max-width: 100%; max-height: 90px; }
/* The iPhone's Shortcut, step by step. */
.ask-card.ss-card { width: min(560px, 100%); max-height: calc(100vh - 40px); overflow-y: auto; overflow-x: hidden; justify-items: stretch; text-align: left; }
.ask-card.paste-card { justify-items: stretch; }
.ss-where { margin: 4px 0 6px; display: flex; width: 100%; }
.ss-where button { flex: 1 1 0; min-width: 0; white-space: normal; }
.ss-steps { margin: 6px 0 10px; padding-left: 22px; display: flex; flex-direction: column; gap: 8px; }
.ss-copy { display: flex; gap: 8px; align-items: center; margin: 5px 0 3px; }
.ss-copy code { flex: 1; min-width: 0; overflow-wrap: anywhere; font-size: 12px; padding: 6px 8px;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
#modal form.drop-over { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }
.att-read { flex: none; }
.read-box { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; padding: 10px 12px;
  font-size: 13px; background: var(--accent-soft); border: 1px solid var(--accent);
  border-radius: var(--radius-sm); }
.read-box[hidden] { display: none; }
.read-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.read-conflicts table { width: auto; margin: 4px 0; }
.read-conflicts td { padding: 2px 10px 2px 0; border: 0; background: none; }
.read-actions { display: flex; gap: 8px; }

/* ---------- supplier / client details ---------- */

.party-info { font-size: 12px; min-height: 0; }
.party-info:empty { display: none; }
.party-panel:empty { display: none; }
.party-editor { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; padding: 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-weight: 400; }
.party-editor-head { display: flex; align-items: center; justify-content: space-between; }
.cell-sub { font-size: 11px; color: var(--muted); }

/* ---------- category tree ---------- */

.ctree { display: flex; flex-direction: column; gap: 8px; }
.ctree-tools { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ctree-tools .ctree-search { flex: 1 1 200px; width: auto; }
.ctree-list { border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); max-height: 55vh; overflow-y: auto; padding: 4px 0; }
.picker-tree .ctree-list { max-height: 340px; }
.ctree-kind { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px 12px 4px; }
.ctree-row { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 34px;
  font-size: 13px; font-weight: 400; color: var(--text); cursor: pointer; }
.ctree-row:hover { background: var(--surface-2); }
.ctree-row input { width: auto; margin: 0; flex: none; }
.ctree-row.group { font-weight: 600; padding-left: 8px; }
.ctree-row.child { padding-left: 56px; }
.ctree-row.inactive .ctree-name { color: var(--muted); text-decoration: line-through; }
.ctree-name { flex: 1; min-width: 0; }
.ctree-meta { font-size: 11px; color: var(--muted); white-space: nowrap; font-weight: 400; }
.ctree-toggle { appearance: none; border: 0; background: none; width: 22px; height: 22px; padding: 0;
  color: var(--text); cursor: pointer; font-size: 15px; line-height: 1; flex: none; border-radius: 4px; }
.ctree-toggle:hover { background: var(--border); }
.ctree-empty { padding: 12px; }

/* categories register: the same tree, to organise */
.creg .ctree-tools .ctree-search { flex: 1 1 180px; }
.creg .spacer { flex: 1; }
.creg-hint { font-size: 12px; }
.creg-list { max-height: none; }
.creg .ctree-row.group { padding-top: 7px; padding-bottom: 7px; }
.creg .ctree-row .btn.small { padding: 3px 9px; font-weight: 500; }
.creg-row { padding-left: 12px; }
.creg-row.child { padding-left: 38px; }
.creg-row[draggable="true"] { cursor: grab; }
.creg-grip { color: var(--muted); font-size: 15px; line-height: 1; letter-spacing: -5px; width: 14px; flex: none; }
.creg-row:not([draggable="true"]) .creg-grip { visibility: hidden; }
.creg-empty { font-style: italic; cursor: default; }
.creg-group.drop-on, .creg-row.drop-on {
  background: var(--surface-2); outline: 2px dashed var(--accent); outline-offset: -2px;
}
.creg-out { display: none; border: 2px dashed var(--border); border-radius: var(--radius-sm);
  padding: 10px; text-align: center; color: var(--muted); font-size: 13px; }
.creg.dragging .creg-out { display: block; }
.creg-out.drop-on { border-color: var(--accent); color: var(--accent); background: var(--surface-2); }
.creg-bulk { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px;
  padding: 8px 10px; border: 1px solid var(--accent); border-radius: var(--radius-sm);
  background: var(--surface-2); }
.creg-bulk[hidden] { display: none; }
.creg-bulk-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 4px; }
.creg-bulk select { width: auto; min-width: 180px; }
.btn.filter-on { border-color: var(--accent); color: var(--accent); }
/* Every "clear" button looks the same and stands out: amber, a ✕ before. */
.btn.btn-clear { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); font-weight: 600; }
.btn.btn-clear::before { content: "✕"; margin-right: 6px; font-weight: 700; }
.btn.btn-clear-icon::before { margin-right: 0; }
.btn.btn-clear:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 0 0 2px var(--warn-soft); }
.btn.btn-clear:disabled { background: transparent; border-color: var(--border); color: var(--muted); font-weight: 500; }

/* cost statement: items under their group */
tr.group-row td { font-weight: 600; background: var(--surface-2); }
/* The cost statement: totals told apart by colour - a class of cost (green)
   heading its groups (blue), each group heading its own categories. */
tbody tr.class-row td, .no-zebra tbody tr.class-row td {
  border-top: 2px solid var(--border); font-weight: 600;
  background: var(--accent-soft); color: var(--accent);
}
tbody tr.group-row td, .no-zebra tbody tr.group-row td {
  background: var(--info-soft); color: var(--info);
}
.who-opts { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.who-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 10px 14px; flex: 1 1 220px; }
.own-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 6px 4px 10px;
  border: 1px solid var(--border); border-radius: 999px; }
.own-add { display: flex; gap: 8px; margin-top: 10px; max-width: 520px; }
tr.group-row td:first-child { padding-left: 18px; }
.cls-select { width: auto; margin-left: 8px; padding: 1px 4px; font-size: 12px; height: auto;
  color: var(--muted); background: transparent; border-color: transparent; }
.cls-select:hover, .cls-select:focus { border-color: var(--border); color: inherit; }
tr.sub-row td:first-child { padding-left: 28px; }

/* ---------- attachments ---------- */

.clip-icon { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -2px; }
.att-box { display: flex; flex-direction: column; gap: 7px; font-size: 12px; font-weight: 600; color: var(--muted); }
.att-list { display: flex; flex-direction: column; gap: 4px; font-weight: 400; transition: opacity .15s; }
.att-list.busy { opacity: .5; }
.att-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px;
  background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; color: var(--text); }
.att-row a, .att-row .att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-row a { color: var(--accent); }
.att-row .muted { font-size: 12px; white-space: nowrap; }
.att-remove { appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 0 4px; }
.att-remove:hover { color: var(--danger); }
.att-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 400; }
.att-actions .btn { display: inline-flex; align-items: center; gap: 6px; }
.att-count { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-variant-numeric: tabular-nums; }
.form-err { color: var(--danger); font-size: 13px; margin-top: 10px; }
.section-title { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin: 20px 0 10px; }

/* ---------- toast ---------- */

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: 999px; font-size: 13px; font-weight: 550; z-index: 200;
  box-shadow: var(--shadow);
}
.toast[hidden] { display: none; }
.toast.err { background: var(--danger); color: #fff; }

/* ---------- phone ---------- */

/* What only a computer shows, and what only a phone does (the bottom bar's width). */
.phone-only { display: none !important; }
.fin-title { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer;
  display: inline-flex; align-items: baseline; gap: 2px; }
.fin-title-caret { font-size: .6em; color: var(--muted); }
.fin-menu { min-width: 230px; }
.fin-menu .nav-menu-item { display: flex; align-items: center; gap: 8px; }
.fin-menu-tick { width: 1em; flex: none; color: var(--accent); font-weight: 700; }
.fin-menu-label { flex: 1; min-width: 0; }
@media (max-width: 720px) {
  .phone-only { display: revert !important; }
  .fin-title.phone-only { display: inline-flex !important; }
  .desk-only { display: none !important; }
  /* Financial's sections: the pop-up over its button, not rows of buttons. */
  .fin-subtabs { display: none !important; }
  /* Scan, read and paste live in the + only - the one way papers come in on a phone. */
  .doc-chip-phone { display: none !important; }
  /* A list with summary rows (dataTable phoneRow): each row its two lines,
     a coloured edge for money in or out; opened, everything under it. */
  table.dt-phonerows tbody tr:not(.dt-expand) { padding: 0; overflow: hidden; }
  table.dt-phonerows tbody tr:not(.dt-expand) > td:not(.dt-phone) { display: none !important; }
  table.dt-phonerows tbody tr:not(.dt-expand) > td.dt-phone { display: block !important; padding: 0 !important; }
  table.dt-phonerows tbody tr.dt-open { border-bottom-left-radius: 0; border-bottom-right-radius: 0; margin-bottom: 0; }
  table.dt-phonerows tbody tr.dt-expand { margin-top: 0; border-top: 0; border-top-left-radius: 0; border-top-right-radius: 0; }
  .table-tools:has(+ .table-wrap table.dt-phonerows) .dt-pick-all-phone { display: none; }
  .pr { display: flex; flex-direction: column; gap: 4px; padding: 11px 12px; border-left: 4px solid var(--border); }
  .pr-rec { border-left-color: var(--good); }
  .pr-exp { border-left-color: var(--danger); }
  tr.dt-open .pr { background: var(--accent-soft); }
  .pr-top, .pr-sub { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-width: 0; }
  .pr-name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pr-amt { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
  .pr-exp .pr-amt { color: var(--danger); }
  .pr-meta { color: var(--muted); font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .pr-tags { display: inline-flex; align-items: center; gap: 6px; flex: none; }
  .pr-clip { color: var(--muted); display: inline-flex; }
  .pr-clip svg { width: 14px; height: 14px; }
  .pr-bal { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
  .pr-acts { padding-top: 4px; }
  .pr-acts .st-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
  .pr-why { font-size: 13px; color: var(--muted); text-align: left; }
  .pr-tags .pp-list { display: inline-flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
  /* The computer's paper button too: on a phone papers come in by the +. */
  .doc-chip { display: none !important; }
  /* A clear-filters button with nothing to clear takes no room. */
  .fin-clear-all:disabled { display: none; }
  /* What opens under a row: read from the left, as a form is. */
  table.dt tbody tr.dt-expand > td { display: block !important; text-align: left; }
  /* An entry or a receipt opened on a phone: two columns - its kind and
     amount, its dates, then each box across. */
  :root .pe-form.pe-receipt {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "kind amount"
      "date date"
      "due paid"
      "left left"
      "right right"
      "desc desc"
      "notes notes"
      "svc svc";
  }
  :root .pe-form.pe-receipt > .ga-dates { grid-row: auto; grid-column: 1 / -1; }
  :root .pe-form:not(.pe-receipt) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
td.dt-phone { display: none; }
/* Payable & receivable: to pay in red, to receive in green (theme colours). */
.ap-pay { color: var(--danger); font-weight: 600; }
.ap-rec { color: var(--good); font-weight: 600; }
table.dt tbody tr.ap-row-pay > td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
table.dt tbody tr.ap-row-rec > td:first-child { box-shadow: inset 3px 0 0 var(--good); }
@media (max-width: 720px) {
  table.dt tbody tr.ap-row-pay > td:first-child, table.dt tbody tr.ap-row-rec > td:first-child { box-shadow: none; }
  table.dt tbody tr.ap-row-pay { border-left: 4px solid var(--danger); }
  table.dt tbody tr.ap-row-rec { border-left: 4px solid var(--good); }
}
/* The one period box: ‹ month ▾ › (periodBox) - on a phone the width of
   the screen, its dates under it; on the computer beside it. */
.pbox-wrap { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pbox-wrap .pbox { min-width: 260px; }
.pbox-wrap .pbox-arrow { height: 34px; width: 40px; font-size: 22px; }
.pbox-wrap .pbox-name { height: 34px; font-size: 15px; }
.pbox-wrap .pbox-dates { margin-top: 0; }
.pbox-wrap .pbox-dates input { width: 150px; flex: none; }
@media (hover: hover) { .pbox-arrow:not(:disabled):hover, .pbox-name:hover { background: var(--surface-2); } }
.bank-per { display: inline-flex; }
@media (max-width: 720px) {
  .pbox-wrap { display: block; width: 100%; }
  .pbox-wrap .pbox { min-width: 0; }
  .pbox-wrap .pbox-arrow { height: 42px; width: 46px; font-size: 24px; }
  .pbox-wrap .pbox-name { height: 42px; font-size: 16px; }
  .pbox-wrap .pbox-dates { margin-top: 8px; }
  .pbox-wrap .pbox-dates input { width: auto; flex: 1; min-width: 0; }
  .bank-per { display: block; width: 100%; }
}
.pbox { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); }
.pbox-arrow { appearance: none; border: 0; background: none; color: var(--text); font-size: 24px; line-height: 1;
  width: 46px; height: 42px; border-radius: var(--radius-sm); cursor: pointer; flex: none; }
.pbox-arrow:active { background: var(--surface-2); }
.pbox-arrow:disabled { opacity: .3; cursor: default; }
.pbox-name { appearance: none; border: 0; background: none; color: var(--text); font: inherit; font-weight: 600;
  font-size: 16px; flex: 1; min-width: 0; height: 42px; cursor: pointer; border-radius: var(--radius-sm); }
.pbox-caret { color: var(--muted); font-size: 12px; }
.pbox-dates { display: flex; gap: 8px; margin-top: 8px; }
.pbox-dates input { flex: 1; min-width: 0; }

@media (max-width: 720px) {
  .topbar { height: auto; flex-wrap: wrap; padding: 9px 12px; gap: 10px; }
  .brand { font-size: 14px; }
  /* The main menu as an app's bar at the bottom: an icon over each name,
     big enough for a thumb; the page scrolls above it. */
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; order: 3; width: 100%; flex: none;
    gap: 0; overflow: visible; padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 14px rgba(0, 0, 0, .18);
    -webkit-mask-image: none !important; mask-image: none !important; }
  .tabs > .tab, .tabs > .tabg { flex: 1 1 0; min-width: 0; flex-direction: column; justify-content: center; gap: 3px;
    padding: 6px 2px; font-size: 11px; text-align: center; }
  .tabs .nav-ico { width: 22px; height: 22px; }
  .tabs .nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .tabs .tg-sub, .tabs .tg-caret { display: none; }
  .tab.money::before { content: none; }
  .tab.money { border-left: 0; margin-left: 0; }
  body { padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  /* Lists as cards: each row a card, each value beside its column's name -
     nothing to scroll sideways for. */
  .table-wrap:has(> table.dt) { overflow-x: visible; border: 0; background: none; }
  table.dt, table.dt tbody, table.dt tfoot, table.dt tr { display: block; width: 100% !important; }
  table.dt { table-layout: auto !important; }
  table.dt thead, table.dt colgroup { display: none; }
  table.dt tbody tr { margin: 0 0 8px; padding: 6px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface); }
  table.dt tbody tr:hover { background: var(--surface); }
  table.dt td { display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
    padding: 5px 0 !important; border: 0 !important; white-space: normal !important; overflow: visible !important;
    overflow-wrap: anywhere;   /* a 44-digit NF-e key breaks instead of widening the page */
    text-align: right; min-height: 0; }
  table.dt td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left;
    color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
  table.dt td[data-label=""]::before { content: none; }
  table.dt td[data-label=""] { justify-content: flex-end; }
  table.dt .dt-text { max-width: none; white-space: normal; overflow: visible; }
  table.dt td.pick { justify-content: flex-start; }
  table.dt tfoot tr { padding: 6px 12px; }
  /* Sub-menus wrap onto a second line instead of scrolling sideways. */
  .subtabs { flex-wrap: wrap; overflow: visible !important; -webkit-mask-image: none !important; mask-image: none !important; }
  .topbar ~ .view .subtabs, .subtabs.subtabs { gap: 6px; box-shadow: none; }
  .subtabs > .subtab { padding: 6px 11px; font-size: 13px; border: 1px solid var(--border); border-radius: 999px; }
  .subtabs > .subtab.active { background: var(--accent-soft); border-color: var(--accent); }
  table.dt td.dt-empty { display: none; }
  .dt-pick-all-phone { display: inline-flex; margin-right: 6px; }
  .nav-menu { min-width: 200px; }
  .nav-menu-item { padding: 13px 14px; font-size: 15px; }
  .view { padding: 13px; }
  .filters select { flex: 1; min-width: 122px; }
  .tl-item { grid-template-columns: 1fr; gap: 2px; }
  /* Bigger touch targets for gloved hands at the chute. */
  .btn { padding: 11px 16px; }
  input, select, textarea { padding: 11px 10px; font-size: 16px; }
  tbody td { padding: 12px; }
}

/* checkbox cluster inside a form grid */
.checks { display: flex; flex-direction: column; gap: 8px; justify-content: flex-end; padding-bottom: 6px; }
.filters .check { white-space: nowrap; }

/* ---------- appearance ---------- */

tbody tr:nth-child(even) { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.no-zebra tbody tr:nth-child(even) { background: none; }
tbody tr:hover { background: var(--surface-2); }
tbody tr.sel, .no-zebra tbody tr.sel { background: var(--accent-soft); }

.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); padding: 0;
}
.swatch.active { border-color: var(--text); box-shadow: 0 0 0 3px var(--accent-soft); }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  appearance: none; border: 0; background: var(--surface); color: var(--muted);
  font: inherit; font-weight: 550; padding: 8px 15px; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent); color: var(--accent-text); }

/* Scrolls sideways on a phone rather than widening the whole page. The
   baseline is an inset shadow so the active tab's underline can sit on it
   without spilling outside the scrolling box. */
.subtabs { display: flex; gap: 4px; margin-bottom: 16px; box-shadow: inset 0 -1px 0 var(--border);
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtab {
  appearance: none; border: 0; background: none; font: inherit; font-weight: 550;
  color: var(--muted); padding: 9px 15px; cursor: pointer;
  border-bottom: 2px solid transparent; flex: none; white-space: nowrap;
}
.subtab.active { color: var(--accent); border-bottom-color: var(--accent); }
.subtab:hover { color: var(--text); }

/* Menu bars too wide for the window: dragged sideways (app.js,
   watchScrollers), fading at an edge where more tabs wait. */
.tabs, .subtabs { user-select: none; }
.tabs.dragging, .subtabs.dragging, .tabs.dragging *, .subtabs.dragging * { cursor: grabbing; }
.tabs.more-right, .subtabs.more-right {
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 48px), transparent);
}
.tabs.more-left, .subtabs.more-left {
  -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to left, #000 calc(100% - 48px), transparent);
}
.tabs.more-left.more-right, .subtabs.more-left.more-right {
  -webkit-mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
  mask-image: linear-gradient(to right, transparent, #000 48px, #000 calc(100% - 48px), transparent);
}

.preview-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- manejo (chute sessions) ---------- */

.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip-check {
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 13px; cursor: pointer; font-size: 13px;
  background: var(--surface); white-space: nowrap;
}
.chip-check:hover { background: var(--surface-2); }
.chip-check input { width: auto; margin: 0; }
.chip-check:has(input:checked) {
  background: var(--accent-soft); border-color: var(--accent); color: var(--accent);
  font-weight: 600;
}
.proc-grid { display: flex; gap: 8px; flex-wrap: wrap; }

.proc-block {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px; margin-bottom: 10px; background: var(--surface);
}
.proc-block:has(input[type=checkbox]:checked) { border-color: var(--accent); }
.proc-head { margin-bottom: 10px; font-size: 14px; }
.proc-block .form-grid { gap: 10px; }

.chute-id {
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  padding: 14px; margin-bottom: 16px;
  background: var(--surface-2); border-radius: var(--radius);
}
.big-tag {
  font-family: var(--mono); font-size: 34px; font-weight: 700;
  letter-spacing: -.02em; line-height: 1;
}
tbody tr.done-row td { opacity: .55; }

/* ---------- settings rows ---------- */

.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
  padding: 14px 0; border-bottom: 1px solid var(--border);
}
.setting-row:last-of-type { border-bottom: 0; }
.setting-row .k { font-weight: 600; font-size: 14px; }

@media (max-width: 720px) {
  .big-tag { font-size: 44px; }
  .chip-check { padding: 11px 16px; font-size: 15px; }
  .proc-block { padding: 14px; }
  .setting-row { flex-direction: column; align-items: stretch; }
}

/* ---------- reproduction ---------- */

.row-acts { display: flex; gap: 5px; }
.row-acts .btn { padding: 4px 9px; font-size: 12px; }
.filters .field { flex-direction: row; align-items: center; gap: 8px; }
.filters .field select { width: auto; }

@media (max-width: 720px) {
  .row-acts { flex-wrap: wrap; }
}

/* grouped column headers on the calf performance report */
thead tr:first-child th.grp {
  text-align: center; border-left: 1px solid var(--border);
  background: var(--accent-soft); color: var(--accent);
}
thead tr:first-child th[colspan] { text-align: center; }

/* ---------- sanitary calendar ---------- */

table.cal td.cal-cell {
  text-align: center; font-variant-numeric: tabular-nums;
  border-left: 1px solid var(--border); min-width: 42px;
}
table.cal td.cal-planned { color: var(--muted); font-size: 18px; line-height: 1; }
table.cal td.cal-done {
  background: var(--accent-soft); color: var(--accent); font-weight: 650;
}
table.cal th.num { text-align: center; }

/* ---------- reports ---------- */

tbody tr.total-row td, .no-zebra tbody tr.total-row td {
  background: var(--surface-2); border-top: 2px solid var(--border);
}
tbody tr.move-row td:first-child { color: var(--muted); }

/* ---------- financeiro ---------- */

/* The financial side is a different application; mark its tab. */
.tab.money { border-left: 1px solid var(--border); margin-left: 6px; }
/* The $ is its icon now. */
.tab.money::before { content: none; }
.tab.money.active { background: var(--warn-soft); color: var(--warn); }

/* ---------- spreadsheet import ---------- */

.steps { margin: 0; padding-left: 20px; color: var(--muted); line-height: 1.9; }
.steps li { padding-left: 4px; }

table.imp td.imp-cell { padding: 3px 5px; }
table.imp td.imp-cell input,
table.imp td.imp-cell select {
  padding: 5px 7px; font-size: 13px; min-width: 110px; border-radius: 5px;
}
table.imp th .req { color: var(--danger); }
tbody tr.row-bad td, .no-zebra tbody tr.row-bad td {
  background: var(--danger-soft);
}
tbody tr.row-bad:hover td { background: var(--danger-soft); }

/* ---------- farm picker & table tools ---------- */

/* The farm in the top menu: one button (the whole of it opens the menu),
   and the menu of the farms. */
.farmpicker { position: relative; }
.farmchip { position: relative; display: flex; align-items: center; gap: 9px; padding: 4px 32px 4px 6px; min-width: 150px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: border-color .12s, background .12s, box-shadow .12s; }
.farmchip:hover, .farmchip.open { border-color: var(--accent); background: var(--surface); }
.farmchip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.farmchip.open { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.farm-badge { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex: none;
  color: #fff; background: linear-gradient(135deg, #4f8f4b, #2f6a35); }
.farm-badge.small { width: 34px; height: 34px; font-size: 11px; font-weight: 800; letter-spacing: .02em; }
.farm-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.farmchip-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.farmchip-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.farmchip-name { font-size: 15px; font-weight: 750; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.farmchip-caret { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 12px; transition: transform .15s; }
.farmchip.open .farmchip-caret { transform: translateY(-50%) rotate(180deg); }
.farm-menu { position: absolute; right: 0; top: calc(100% + 8px); z-index: 80; width: min(280px, calc(100vw - 16px)); padding: 6px;
  border-radius: 14px; background: var(--surface); border: 1px solid var(--border); box-shadow: 0 16px 44px rgba(0, 0, 0, .28);
  display: flex; flex-direction: column; gap: 2px; animation: farmmenu .14s ease-out; }
.farm-menu[hidden] { display: none; }
@keyframes farmmenu { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.farm-menu-head { padding: 8px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.farm-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.farm-item:hover, .farm-item:focus-visible { background: var(--surface-2); outline: none; }
.farm-item.on { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.farm-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.25; }
.farm-item-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.farm-check { width: 18px; text-align: center; color: var(--accent); font-weight: 800; }
.farm-menu-foot { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }
.farm-manage { width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.farm-manage:hover { background: var(--surface-2); color: var(--text); }
.farmpicker[hidden] { display: none; }

/* The ear tag button beside the farm: read a tag, find the animal. */
.scanbtn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.scanbtn:hover { border-color: var(--accent); background: var(--surface); }
.scanbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.scanbtn[hidden] { display: none; }
.scan-ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ask-card.scan-card { width: min(520px, 100%); justify-items: stretch; text-align: left; max-height: calc(100vh - 40px); overflow-y: auto; }
.scan-photo { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 14px; font-size: 16px; }
.scan-row { display: flex; gap: 8px; }
.scan-input { flex: 1; min-width: 0; font-size: 17px; font-family: ui-monospace, Consolas, monospace; }
.scan-out { display: flex; flex-direction: column; gap: 10px; }
.scan-out:empty { display: none; }
.scan-result { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); }
.scan-code { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.scan-code code { font-size: 15px; overflow-wrap: anywhere; }
.scan-hits { display: flex; flex-direction: column; gap: 6px; }
.scan-hit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--surface); border: 1px solid var(--border); }
.scan-hit.gone { opacity: .7; }
.scan-hit-id { flex: 1; min-width: 160px; }
.scan-ids { overflow-wrap: anywhere; }
.scan-hit-acts { display: flex; gap: 6px; flex-wrap: wrap; }
/* Each identifier box, checked as it is read. */
.id-scan { font-size: 12.5px; font-weight: 600; margin-top: 3px; }
.id-scan.ok { color: var(--accent); }
.id-scan.bad { color: var(--danger); }
.id-scan[hidden] { display: none; }
/* A model's setup steps in the equipment form. */
.dv-steps { margin: 4px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--accent-soft);
  border: 1px solid var(--border); font-size: 13px; line-height: 1.5; }
.dv-steps-text { margin-top: 4px; color: var(--text); }
@media (max-width: 720px) {
  .scanbtn { order: 2; padding: 8px 10px; }
  .scanbtn-label { font-size: 13px; }
}

.table-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 10px;
}
.table-tools .spacer { flex: 1; }

@media (max-width: 720px) {
  .farmpicker { order: 2; }
  .farmchip-label { display: none; }
  .farm-badge { width: 26px; height: 26px; }
}

/* ---------- farm map ---------- */

.kind-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block;
  background: var(--kind); }
.kind-pasto { --kind: #3d8b37; }
.kind-curral { --kind: #b0612b; }
.kind-confinamento { --kind: #c28a12; }
.kind-reserva { --kind: #1f5f3a; }
.kind-galpao { --kind: #6b6b6b; }
.kind-sede { --kind: #2d6cc0; }
.kind-estrada { --kind: #7a5c99; }
.map-card { margin-top: 14px; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.map-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.map-bar .spacer { flex: 1; }
.map-bar select { width: auto; }
.map-name { font-size: 15px; }
.map-hint { font-size: 12px; }
.map-scroll { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); position: relative; }
.map-card:not(.big) .map-scroll { max-height: 70vh; }
.map-stage { position: relative; width: 100%; user-select: none; }
.map-stage img { display: block; width: 100%; height: auto; }
.map-stage.big { min-width: 900px; }
.map-stage.placing, .map-stage.placing .map-pin { cursor: crosshair; }
.map-stage.moving .map-pin { cursor: grab; }
.map-pins { position: absolute; inset: 0; }
.map-pin { position: absolute; transform: translate(-50%, -50%);
  display: flex; flex-direction: column; align-items: center; gap: 0;
  padding: 2px 8px; border-radius: 8px; border: 2px solid var(--kind, var(--accent));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text); font: inherit; font-size: 11px; line-height: 1.2; white-space: nowrap;
  cursor: pointer; box-shadow: 0 1px 4px rgba(0, 0, 0, .25); }
.map-pin strong { font-size: 12px; color: var(--kind, var(--accent)); }
.map-pin:hover { z-index: 2; }
.map-pin.inactive { opacity: .45; }
.map-pin.unsure { border-style: dashed; border-color: var(--warn); }
.map-pin.active { outline: 3px solid var(--accent); z-index: 3; }
.map-pin-head { color: var(--muted); }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.map-key { display: inline-flex; align-items: center; gap: 5px; }
.map-key.strong { color: var(--text); font-weight: 600; }
.map-busy { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 24px; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--border);
  border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.map-review-form { display: flex; flex-direction: column; gap: 12px; min-height: 100%; }
.map-review-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.map-review-head .field { flex: 0 1 280px; }
.map-notes { flex: 1 1 320px; font-size: 13px; color: var(--muted); }
.map-notes p { margin: 0 0 4px; }
.map-review { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; flex: 1; min-height: 0; }
.map-review .map-scroll { max-height: calc(100vh - 260px); }
.map-side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.map-side .table-wrap { max-height: calc(100vh - 320px); overflow: auto; }
.map-table { font-size: 13px; }
.map-table th, .map-table td { padding: 5px 6px; vertical-align: middle; }
.map-table input, .map-table select { width: 100%; min-width: 0; padding: 5px 6px; }
.map-table td:nth-child(2) { min-width: 72px; }
.map-table td:nth-child(3) select { min-width: 118px; }
.map-table td:nth-child(4) { min-width: 86px; }
.map-table td:nth-child(5) select { min-width: 92px; }
.map-table tr.off td { opacity: .5; }
.map-table tr.off td:first-child { opacity: 1; }
.map-ha { white-space: nowrap; font-weight: 600; }
.map-status { font-size: 12px; color: var(--accent); white-space: nowrap; }
.map-status.updates { color: var(--warn); }
.map-row-acts { white-space: nowrap; }
.map-side-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.map-totals { font-size: 13px; font-weight: 600; }
.map-placing { position: sticky; top: 0; z-index: 4; padding: 6px 10px; font-size: 13px; font-weight: 600;
  background: var(--accent); color: var(--accent-text); }
@container (max-width: 820px) {
  .map-review { grid-template-columns: 1fr; }
  .map-review .map-scroll, .map-side .table-wrap { max-height: none; }
}

/* names on file like the one typed */
.picker-alike { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.picker-alike .picker-q { margin: 0; }
.picker-alike-btn { font-weight: 600; }
.picker-similar-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--warn); border: 1px solid var(--warn); border-radius: 4px; padding: 0 4px; }

/* ---------- herd files ---------- */

.herd-drop { margin-bottom: 14px; }
.herd-intro { margin: 0; font-size: 13px; }
.herd-head { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.herd-cols { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.herd-chip { font-size: 12px; padding: 2px 8px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); white-space: nowrap; }
.herd-chip.unsure { border-color: var(--warn); }
.herd-chip.empty { opacity: .55; border-style: dashed; }
.herd-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px;
  align-items: start; }
.herd-form div.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.herd-form div.field > label { font-size: 12px; font-weight: 600; color: var(--muted); }
.herd-form div.field.herd-nodate > label { color: var(--danger); }
.herd-settings .field { margin: 0; }
.herd-parts { display: flex; flex-direction: column; gap: 4px; }
.herd-nodate label { color: var(--danger); }
.herd-codes { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); }
.herd-code-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.herd-code { display: flex; gap: 8px; align-items: flex-end; min-width: 0; }
.herd-code > .field, .herd-code > .picker { flex: 1; min-width: 0; margin: 0; }
.herd-code-raw { flex: none; min-width: 42px; padding: 7px 8px; margin-bottom: 1px; font-weight: 700;
  text-align: center; font-family: ui-monospace, monospace; background: var(--warn-soft); color: var(--warn);
  border-radius: var(--radius-sm); }
.herd-listbar { display: flex; align-items: center; gap: 10px; }
.herd-listbar select { width: auto; }
.herd-table { font-size: 13px; }
.herd-table th { white-space: nowrap; position: sticky; top: 0; z-index: 2; }
.herd-table td { vertical-align: top; padding: 5px 8px; }
.herd-table tr.herd-off td { opacity: .5; }
.herd-weights div { white-space: nowrap; }
.herd-old { color: var(--muted); text-decoration: line-through; }
.herd-bad { color: var(--danger); font-weight: 600; }
.herd-done ul { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.small { font-size: 12px; }
.sl-report { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: baseline; padding: 10px 12px;
  font-size: 13px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sl-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sl-tools input[type=search] { width: 180px; }
.sl-tools select { width: auto; }
.sl-tools .spacer { flex: 1; }
.sl-n { width: 80px; }
.herd-table tr.sl-on td { background: var(--danger-soft); }
.sl-count { font-size: 13px; }

/* quick view: a receipt docked at the right, the rest of the app beside it */
.quickview { position: fixed; top: 0; right: 0; bottom: 0; width: var(--qv-w, 42vw); z-index: 150;
  display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -8px 0 24px rgba(0, 0, 0, .25); }
.quickview[hidden] { display: none; }
.qv-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.qv-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qv-tools { display: flex; gap: 4px; flex: none; }
.qv-body { flex: 1; overflow: auto; padding: 12px; background: var(--bg); --qv-zoom: 1; }
.qv-page { display: block; width: calc(100% * var(--qv-zoom)); max-width: none; margin: 0 auto 12px;
  background: #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }
.qv-msg { padding: 24px; display: flex; align-items: center; gap: 8px; }
.qv-resize { position: absolute; left: -5px; top: 0; bottom: 0; width: 10px; cursor: ew-resize; touch-action: none; }
.qv-resize:hover { background: var(--accent-soft); }
body.qv-open { padding-right: var(--qv-w); }
body.qv-open #modal { padding-right: calc(var(--qv-w) + 18px); }
body.qv-open .modal-card.maximized { width: calc(100vw - var(--qv-w) - 36px) !important; }
.qv-btn { margin-top: 4px; }
.batch-file .qv-btn { padding: 1px 8px; font-size: 11px; }
.qv-chip { cursor: pointer; }
.qv-chip:hover { border-color: var(--accent); }
.imp-card { margin-bottom: 14px; }
.sl-live { font-size: 13px; font-weight: 600; }
.sl-final-kg { font-size: 15px; font-weight: 700; }
td.sl-final { white-space: nowrap; }
.sl-final-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 8px 12px; font-size: 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.sl-final-line { flex: 1 1 auto; }
.sl-weigh-box .check { font-weight: 600; }
.sl-list-pill { margin-left: 6px; font-size: 10px; }
.wh-table { font-size: 13px; }
.wh-table th.num, .wh-table td.num { text-align: right; white-space: nowrap; }
.wh-dot { color: var(--info); font-size: 9px; vertical-align: 2px; }
.wh-last { margin-left: 6px; font-size: 10px; }
.np-missing { border-color: var(--danger) !important; background: var(--danger-soft) !important; }
.herd-table input.np-date { width: 150px; padding: 4px 6px; }
.herd-table select { width: auto; padding: 4px 6px; }
.np-unknown { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px;
  border: 1px solid var(--danger); border-radius: var(--radius-sm); }
.np-unknown .table-wrap { max-height: 320px; overflow: auto; }
.np-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.check.small { font-size: 12px; font-weight: 400; }

/* ---------- receipts batch ---------- */

.batch-form { display: flex; flex-direction: column; gap: 10px; min-height: 100%; }
.batch-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; }
.spinner.small { width: 16px; height: 16px; border-width: 2px; }
.batch-wrap { flex: 1; overflow: auto; }
.batch-table { font-size: 13px; }
.batch-table th { white-space: nowrap; position: sticky; top: 0; z-index: 2; }
.batch-table td { padding: 5px 5px; vertical-align: top; }
.batch-table input, .batch-table select { padding: 5px 6px; min-width: 0; width: 100%; }
.batch-table input[type=checkbox] { width: auto; margin-top: 8px; }
.batch-table { table-layout: fixed; }
.batch-table th { position: sticky; }
.batch-table th, .batch-table td { overflow: hidden; }
.batch-table td.batch-picker { overflow: visible; }
.batch-picker .picker { width: 100%; min-width: 0; }
.batch-picker .picker-tree { min-width: 0; }
.batch-table .bc-amount input { text-align: right; }
.batch-dates label { display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted); }
.col-grip { position: absolute; top: 0; right: 0; width: 9px; height: 100%; cursor: col-resize; }
/* Each heading's right edge shows it can be dragged: a short bar, brighter on hover. */
.col-grip::after { content: ''; position: absolute; right: 3px; top: 28%; height: 44%; width: 2px;
  border-radius: 1px; background: var(--border-strong, var(--muted)); opacity: .45; }
.col-grip:hover::after, .col-grip:active::after { background: var(--accent); opacity: 1; top: 10%; height: 80%; }
.batch-top { display: flex; align-items: center; gap: 10px; }
.batch-top .batch-head { flex: 1; }
.batch-cols { padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-2); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.batch-cols[hidden] { display: none; }
.batch-table.hide-file .bc-file, .batch-table.hide-kind .bc-kind, .batch-table.hide-date .bc-date,
.batch-table.hide-description .bc-description, .batch-table.hide-party .bc-party,
.batch-table.hide-category .bc-category, .batch-table.hide-amount .bc-amount,
.batch-table.hide-dates .bc-dates, .batch-table.hide-account .bc-account { display: none; }
.batch-dates label + label { margin-top: 3px; }
.batch-paid > span { display: inline-flex; align-items: center; gap: 4px; }
.batch-paid input[type=checkbox] { width: auto; margin: 0; }
.paid-check { display: inline-flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 12px; cursor: pointer; }
.paid-check input { width: auto; margin: 0; }
input[data-date]:disabled { opacity: .5; }
/* A field that cannot be changed looks it (a typed number, a list, a note). */
input:not([type=checkbox]):not([type=radio]):disabled, select:disabled, textarea:disabled { opacity: .55; cursor: not-allowed; }
.batch-picker .picker > label { display: none; }
.batch-picker .picker-row { gap: 4px; }
.batch-picker .picker-tree { min-width: 340px; }
.batch-picker .picker-ask, .batch-picker .picker-q { white-space: normal; overflow-wrap: anywhere; }
.batch-file { max-width: 190px; }
.batch-file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.batch-file-meta { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; font-size: 11px; margin-top: 2px; }
.batch-status { display: contents; }
.batch-error { color: var(--danger); font-weight: 600; }
.batch-acts { white-space: nowrap; }
.batch-row.off td { opacity: .75; }
.batch-row.off td:first-child, .batch-row.off td.bc-file { opacity: 1; }
.batch-dup { flex-basis: 100%; font-size: 11px; line-height: 1.3; white-space: normal;
  color: var(--text); background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 4px; padding: 3px 5px; }
.batch-dup strong { color: var(--warn); }
.batch-row.posted td { opacity: .5; }
.batch-details td { background: var(--surface-2); }
.batch-detail-box { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.batch-summary { font-size: 13px; font-weight: 600; }
.batch-table td.flag-check input, .batch-table td.flag-check select { border-color: var(--warn); background: var(--warn-soft); }
.batch-table td.flag-missing input, .batch-table td.flag-missing select { border-color: var(--danger); background: var(--danger-soft); }

/* receipts kept for later */
.batch-choice { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px;
  border: 1px solid var(--warn); background: var(--warn-soft); border-radius: var(--radius-sm); font-size: 13px; }
.batch-choice[hidden] { display: none; }
.batch-choice .spacer { flex: 1; }
.tab-count { display: inline-block; margin-left: 6px; min-width: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.pend-bar { display: block; width: 100%; text-align: left; margin: 10px 0; padding: 9px 12px; font: inherit;
  font-size: 13px; font-weight: 600; cursor: pointer; border-radius: var(--radius-sm);
  border: 1px solid var(--warn); background: var(--warn-soft); color: var(--text); }
.pend-bar:hover { filter: brightness(0.97); }
/* A notice with nothing to say is not shown (the review's, until it finds something). */
.pend-bar[hidden] { display: none; }
.pend-intro { margin: 0; max-width: 760px; }

/* ---------- inventory photos ---------- */
.inv-photos-hint { font-size: 11px; font-weight: 400; margin-left: 6px; }
.inv-photos { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.inv-photo { position: relative; width: 108px; height: 108px; border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); }
.inv-photo img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.inv-photo-del { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.inv-photo-add { width: 108px; height: 108px; border-radius: var(--radius-sm); border: 2px dashed var(--border);
  background: none; color: var(--muted); font: inherit; font-size: 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; }
.inv-photo-add span { font-size: 26px; line-height: 1; }
.inv-photo-add:hover { border-color: var(--accent); color: var(--accent); }
.inv-thumb-col { width: 58px; padding-right: 0 !important; }
.batch-del { padding: 3px 8px; }
.alias-check { margin-top: 4px; font-size: 12px; font-weight: 400; align-items: flex-start; line-height: 1.35; }
.alias-check input { margin-top: 2px; flex: none; }
.batch-table .alias-check { font-size: 11px; white-space: normal; }
.alias-block { display: flex; flex-direction: column; gap: 6px; }
.alias-list { display: flex; flex-wrap: wrap; gap: 6px; }
.alias-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface-2); font-size: 12.5px; }
.alias-chip button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; padding: 0 4px; }
.alias-chip button:hover { color: var(--danger); }
.alias-add { display: flex; gap: 6px; max-width: 520px; }
th.dt-sortable { cursor: pointer; user-select: none; }
th.dt-sortable:hover { color: var(--text); }
th.dt-sorted { color: var(--accent); }
.dt-sort { font-size: 9px; margin-left: 4px; vertical-align: 1px; }
.bk-points { margin: 0 0 12px; padding-left: 18px; }
.bk-danger { border-color: var(--danger); }
.bk-danger h2 { color: var(--danger); }
.rs-warn { padding: 12px 14px; border: 1px solid var(--danger); border-radius: var(--radius-sm);
  background: var(--danger-soft); color: var(--text); }
.rs-warn strong { color: var(--danger); font-size: 15px; }
.rs-warn ul { margin: 6px 0; padding-left: 20px; }
.rs-safety { font-size: 13px; }
.rs-form .check { margin: 10px 0; font-weight: 600; }
.rs-word { max-width: 220px; font-weight: 700; letter-spacing: .08em; }
.inv-docs { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.inv-docs .qv-btn { margin-top: 0; }
.inv-doc-add { align-self: flex-start; margin-top: 4px; }
.inv-docs-box.drop-over { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius-sm); }
.inv-doc-pill { margin-left: 8px; display: inline-flex; align-items: center; gap: 3px; font-size: 11px; }
.inv-doc-pill .clip-icon { width: 11px; height: 11px; }
.inv-thumb { position: relative; display: inline-block; width: 44px; height: 44px; vertical-align: middle; }
.inv-thumb img { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.inv-thumb b { position: absolute; right: -6px; bottom: -6px; min-width: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--accent); color: var(--accent-text); font-size: 10px; line-height: 18px; text-align: center; }
.photo-viewer { position: fixed; inset: 0; z-index: 200; background: rgba(10, 10, 8, .88);
  display: flex; align-items: center; justify-content: center; }
.photo-viewer img { max-width: 92vw; max-height: 88vh; object-fit: contain; border-radius: 6px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .5); }
.photo-viewer button { position: absolute; border: 0; background: rgba(255, 255, 255, .14); color: #fff;
  cursor: pointer; border-radius: 50%; width: 46px; height: 46px; font-size: 28px; line-height: 1; }
.photo-viewer button:hover { background: rgba(255, 255, 255, .28); }
.pv-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.pv-next { right: 20px; top: 50%; transform: translateY(-50%); }
.pv-close { top: 18px; right: 20px; }
.pv-count { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 13px; opacity: .8; }

/* The four kinds of paper (ranch/papers.py): a nota is the cost or the sale,
   a boleto when to pay it, a payment the proof, an estimate only that. */
.paper-chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 10px;
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid; line-height: 18px; }
.paper-nota { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }
.paper-boleto { color: var(--text); border-color: var(--info); background: var(--info-soft); }
.paper-pagamento { color: var(--text); border-color: var(--border); background: var(--surface); }
.paper-estimativa { color: var(--text); border-color: var(--warn); background: var(--warn-soft); }

/* Reviewing the entries: each finding a card, its entries one a line. */
.rv-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.rv-tabs { margin-bottom: 4px; }
.rv-tabs .tab-count { margin-left: 6px; }
.btn.rv-open .tab-count { margin-left: 6px; }
.mi-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.mi-intro { margin: 0; }
.mi-card { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.mi-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.mi-what { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--warn);
  background: var(--warn-soft); border-radius: 9px; padding: 1px 8px; }
.mi-text { overflow-wrap: anywhere; }
.mi-entries { display: flex; flex-direction: column; gap: 2px; }
.mi-entry { display: grid; grid-template-columns: auto auto 1fr auto auto; align-items: center; gap: 10px;
  font-size: 13px; padding: 3px 0; cursor: pointer; }
.mi-date { color: var(--muted); white-space: nowrap; }
.mi-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mi-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mi-files { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.mi-files .qv-btn { padding: 2px 8px; font-size: 12px; }
.mi-from { font-style: italic; }
/* Matching a paper to entries: the paper at the left, the entries with a
   tick each at the right; Post as new at the bottom left, the main button
   at the bottom right. */
.modal-card[data-size="match"] { width: min(1280px, 100%); }
.mp-window { display: flex; flex-direction: column; gap: 8px; }
.mp-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; min-width: 0; }
.mp-file { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-step { display: inline-flex; align-items: center; gap: 6px; margin-left: auto; flex: none; }
.cmp-wrap.mp-wrap { height: calc(100vh - 300px); min-height: 380px; }
.mp-side .cmp-side-body { gap: 8px; }
.mp-read { margin: 0; font-weight: 600; }
.mp-side .muted.small { margin: 0; }
.mp-group { display: flex; flex-direction: column; gap: 4px; }
.mp-glabel { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: 4px; }
.mp-rows { display: flex; flex-direction: column; gap: 6px; }
.mp-row { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer; background: var(--surface); }
.mp-row:hover { border-color: var(--accent); }
.mp-row:has(input:checked) { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
.mp-row input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }
.mp-main { display: flex; flex-direction: column; min-width: 0; }
.mp-title { overflow: hidden; text-overflow: ellipsis; }
.mp-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.mp-row .qv-btn { padding: 2px 8px; }
.mp-nofile { width: 30px; text-align: center; }
.mp-more { align-self: flex-start; }
.mp-search { width: 100%; }
.mp-foot { align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 0; }
.mp-sum { font-variant-numeric: tabular-nums; }
.mp-day { display: inline-flex; align-items: center; gap: 6px; }
.mp-day .pr-day { width: 160px; }
.mp-new-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 900px) {
  .cmp-wrap.mp-wrap { height: auto; min-height: 0; }
  .mp-wrap > .cmp-pane { height: 50vh; }
}
@media (max-width: 560px) {
  .mp-row { grid-template-columns: auto 1fr auto; }
  .mp-row .mp-amt { grid-column: 2; grid-row: 2; }
  .mp-foot .mp-sum { flex: 1 1 100%; order: -1; }
}
@media (max-width: 560px) {
  .mi-entry { grid-template-columns: auto auto 1fr auto; }
  .mi-files { grid-column: 2 / -1; grid-row: 2; justify-content: flex-start; }
  .mi-files:empty { display: none; }
}
.mi-suggest, .mi-other, .mi-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.mi-other > :first-child { flex: 1 1 240px; min-width: 0; }
.mi-new-name { flex: 1 1 200px; min-width: 0; }
.rv-card { padding: 12px 14px; }
.rv-head { margin-bottom: 4px; }
.rv-text { margin: 4px 0 8px; }
.rv-sides { display: flex; flex-direction: column; gap: 6px; }
.rv-side { display: grid; grid-template-columns: 112px 84px minmax(0, 1fr) minmax(0, 170px) 120px; gap: 8px;
  align-items: center; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.rv-side .rv-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-side .rv-party { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-side .rv-amount { text-align: right; font-variant-numeric: tabular-nums; }
.rv-side .rv-files { grid-column: 2 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.rv-side .rv-files:empty { display: none; }
.rv-does { margin: 8px 0 0; }
.rv-clean { font-weight: 600; color: var(--accent); padding: 16px 0; }
@media (max-width: 640px) {
  .rv-side { grid-template-columns: auto 1fr auto; }
  .rv-side .rv-party, .rv-side .rv-date { display: none; }
}

/* The inbox: each document's kind of paper, chosen on its row. */
.paper-sel { width: 100%; margin-bottom: 4px; font-weight: 600; font-size: 12px; padding: 2px 6px; border-radius: 10px; border: 1px solid; }
.paper-sel.paper-nota { border-color: var(--accent); background: var(--accent-soft); color: var(--text); }
.paper-sel.paper-boleto { border-color: var(--info); background: var(--info-soft); color: var(--text); }
.paper-sel.paper-pagamento { border-color: var(--border); background: var(--surface); color: var(--text); }
.paper-sel.paper-estimativa { border-color: var(--warn); background: var(--warn-soft); color: var(--text); }

/* A slaughter's results (Reports > Slaughters). */
.slr h3 { margin: 16px 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.slr-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; }
.slr-group { margin-top: 6px; }
.slr-group table, .slr-carcasses table { width: 100%; }
.slr-carcasses { margin-top: 14px; }
.slr-carcasses summary { cursor: pointer; font-weight: 600; }

/* How a figure came up (Financial > Indicators): its sum, line by line. */
.modal-card[data-size="how"] { width: min(900px, 100%); }
.how-steps, .how-groups { width: 100%; }
.how-steps td:first-child { white-space: normal; }
.how-steps td.num { text-align: right; vertical-align: top; }
.how-steps td { padding: 6px 10px; }
.how-steps td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.how-steps .how-total td { font-weight: 700; border-top: 2px solid var(--border); }
.how-sign { display: inline-block; width: 1.4em; color: var(--muted); font-weight: 700; }
.how-groups { margin-top: 12px; }
.how-groups .how-group td { background: var(--surface); }
.how-groups .how-cat { padding-left: 24px; }
.how-i { color: var(--muted); font-size: 12px; }
.dl .stat-link { cursor: pointer; border-radius: var(--radius-sm); }
.dl .stat-link:hover { background: var(--accent-soft); }

/* Statement lines posted many at a time (Banks > Statement). */
.st-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.st-bulk-all { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; white-space: nowrap; }
.st-bulk-all input { width: auto; }
.stb-lines { margin: 8px 0 12px; }
.stb-lines td.num { white-space: nowrap; }
.stb-rule { margin-top: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.stb-rule .check input { width: auto; }
.stb-rule-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.stb-rule-row input { flex: 1; }

/* A new category from the tree (Browse). */
.ctree-add { display: block; width: 100%; text-align: left; margin: 2px 0 6px; padding: 6px 10px; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); background: transparent; color: var(--accent); font: inherit; cursor: pointer; }
.ctree-add.child { margin-left: 26px; width: calc(100% - 26px); }
.ctree-add:hover { background: var(--accent-soft); }

/* A statement line that may already be an entry (Banks > Statement). */
.st-maybe { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 4px; }
.st-link tr.clickable { cursor: pointer; }
.st-link tr.clickable:hover td { background: var(--accent-soft); }

/* A statement line's actions: the one the facts point to, the rest under More. */
.st-acts { align-items: center; }
.st-warn { flex-basis: 100%; margin-top: 4px; padding: 6px 8px; border-radius: var(--radius-sm); font-size: 12px;
  background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn); max-width: 460px; }
.stb-modes { margin-bottom: 10px; }

/* Lines listed to see before acting on them, each with its box. */
.stb-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 6px 0 10px; }
.stb-list .stb-lines { margin: 0; }
.stb-lines td.pick { width: 30px; }
.stb-lines td.pick input { width: auto; }
.stb-others { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* Picking an entry for a line (or a line for an entry): day, amount, what -
   the amount always in sight. */
.st-link { table-layout: fixed; width: 100%; }
.st-link td:nth-child(1) { width: 150px; }
.st-link td:nth-child(2) { width: 150px; white-space: nowrap; }
.st-link td:nth-child(3) { white-space: normal; overflow-wrap: anywhere; }

/* A line to check, as on Receipts to post: ready or what it lacks, then its
   buttons - Post, Open entry, More. */
.st-acts-a { flex-direction: column; align-items: flex-start; gap: 6px; }
.st-btns { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
td.nowrap { white-space: nowrap; }
/* The rule an entry was posted by, in its trail, with Edit. */
.trail-rule { color: var(--text); }
.trail-rule .btn { margin-left: 4px; }
/* The review's list: words wrap, so the fix button stays in sight. */
.brv-table td { white-space: normal; vertical-align: middle; }
.brv-table td:nth-child(3) { min-width: 12rem; }
.brv-acts { display: flex; flex-wrap: wrap; gap: 6px; }
/* What is already posted that the app now knows better: to review. */
.st-review { margin: 0 0 10px; max-width: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
/* A rule's Posts: by itself / only suggests - wide enough to read. */
select.stb-auto { min-width: 8.5rem; width: auto; }
/* Lines that repeat, each group offered as a rule. */
.st-repeats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 0 0 10px; padding: 8px 10px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
/* Its other actions: small icons, each of its own colour - open (green),
   already entered / matches (blue), transfer (amber), rule (grey),
   exclude (red). */
.st-ic { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--muted);
  cursor: pointer; flex: none; }
.st-ic svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.st-ic.ic-open, .st-ic.ic-new, .st-ic.ic-bill { color: var(--accent); }
.st-ic.ic-link, .st-ic.ic-match { color: var(--info); }
.st-ic.ic-transfer { color: var(--warn); }
.st-ic.ic-ignore { color: var(--danger); }
.st-ic:hover, .st-ic:focus-visible { background: var(--accent-soft); border-color: currentColor; outline: none; }
.st-ic.ic-link:hover, .st-ic.ic-match:hover { background: var(--info-soft); }
.st-ic.ic-transfer:hover { background: var(--warn-soft); }
.st-ic.ic-ignore:hover { background: var(--danger-soft); }
/* A supplier or category to be made when the line is posted. */
.st-new { font-size: 11px; font-weight: 600; color: var(--warn); }

/* A statement line's other actions: in sight, small, under its button. */
.st-acts-more { flex-basis: 100%; display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 4px; }
.st-acts-more button { appearance: none; background: none; border: 0; padding: 2px 0; font: inherit; font-size: 12.5px;
  color: var(--accent); cursor: pointer; white-space: nowrap; }
.st-acts-more button:hover, .st-acts-more button:focus-visible { text-decoration: underline; outline: none; }

/* A tied line: what its entries add up to, beside the bank's amount. */
.st-matched { flex-wrap: wrap; }
.st-books { flex-basis: 100%; font-size: 12px; color: var(--muted); margin-top: 2px; }
.st-books.off { color: var(--text); }

/* Supplements: the purchases fit the page - no sideways scrolling. */
.supp-wrap { overflow-x: visible; }
.supp-table { table-layout: fixed; width: 100%; }
.supp-table col.c-date { width: 138px; }
.supp-table td { white-space: normal; }
.supp-table td:first-child { white-space: nowrap; }
.supp-table col.c-amount { width: 118px; }
.supp-table col.c-kg { width: 300px; }
.supp-table col.c-price { width: 84px; }
.supp-table col.c-acts { width: 150px; }
.supp-table td { vertical-align: top; }
.supp-desc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  overflow-wrap: anywhere; cursor: pointer; }
.supp-desc.open { display: block; }
.supp-table .supp-notes { max-width: none; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical;
  overflow: hidden; cursor: pointer; overflow-wrap: anywhere; }
.supp-table .supp-notes.open { display: block; white-space: pre-line; }
.supp-table .supp-fill { flex-wrap: nowrap; }
.supp-table .supp-fill .supp-in { width: 64px; }
.supp-table .supp-fill .supp-size { width: 56px; }
.supp-total { min-width: 74px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }
.supp-guess { border-style: dashed; border-color: var(--warn); }
.supp-clear { padding: 2px 8px; }
.supp-table .supp-acts { white-space: normal; }
@media (max-width: 900px) {
  .supp-table { table-layout: auto; }
}

/* Dashboard: every warning a line of its own. */
.dash-alerts { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; }
.dash-alerts[hidden] { display: none; }
.dash-alerts .pend-bar { margin: 0; }
.supp-notify { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; white-space: nowrap; }
.supp-notify input { width: auto; }

/* Several entries changed at once: a field ticked to change stands out. */
.bulk-edit .bulk-field { border: 1px dashed var(--border, #ccc); border-radius: 8px; padding: 6px 8px; opacity: .8; }
.bulk-edit .bulk-field.on { border-style: solid; border-color: var(--accent, #2f7d4f); opacity: 1; }
.bulk-edit .bulk-on { display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 8px;
  text-align: left; font-weight: 600; cursor: pointer; margin-bottom: 6px; }
.bulk-edit .bulk-on input[type=checkbox] { width: auto; flex: none; margin: 0; }
.bulk-edit .bulk-field .picker > label { display: none; }
.bulk-edit .bulk-field .picker { grid-column: auto; }
.bulk-edit .bulk-paid { display: flex; gap: 6px; flex-wrap: wrap; }
.bulk-bar { flex-wrap: wrap; }

/* Entries made one monthly series: the payments, then the months. */
.ser-form .ser-list, .ser-form .ser-months { max-height: 34vh; overflow: auto; margin-bottom: 10px; }
.ser-form .ser-list select { min-width: 9em; }
.ser-form tr.ser-empty td { color: var(--warn, #b26a00); }

/* Utilities' histories: a part for each meter. */
.ut-form .ut-part { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.ut-form .ut-part h4 { margin: 0 0 8px; }
.ut-form .ut-part .stb-list { max-height: 30vh; overflow: auto; }

/* Receipts at a glance: matched, new or duplicate (the row's tint), revenue
   or expense (its left edge) - in the read documents and receipts to post. */
:root { --m-match: rgba(46, 125, 200, .10); --m-dup: rgba(214, 140, 20, .14); --k-rev: #2e9d5b; --k-exp: #c9473d; }
.batch-row.bm-match td, tr.pm-match td { background: var(--m-match); }
.batch-row.bm-dup td, tr.pm-already td { background: var(--m-dup); }
.batch-row.bk-receita td:first-child, tr.pk-receita td:first-child { box-shadow: inset 4px 0 0 var(--k-rev); }
.batch-row.bk-despesa td:first-child, tr.pk-despesa td:first-child { box-shadow: inset 4px 0 0 var(--k-exp); }
.match-legend { display: inline-flex; gap: 6px; align-items: center; margin-left: 10px; flex-wrap: wrap; }
.ml-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .8em; border: 1px solid var(--border); }
.ml-chip.ml-match { background: var(--m-match); border-color: rgba(46, 125, 200, .5); }
.ml-chip.ml-loan { background: var(--m-match); border-color: rgba(46, 125, 200, .5); }
.ml-chip.ml-dup { background: var(--m-dup); border-color: rgba(214, 140, 20, .6); }
.ml-kind { font-size: .8em; padding-left: 8px; }
.ml-kind.ml-rev { box-shadow: inset 4px 0 0 var(--k-rev); }
.ml-kind.ml-exp { box-shadow: inset 4px 0 0 var(--k-exp); }
.batch-table th.dt-sortable { cursor: pointer; }
/* Side by side. */
.cmp-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; height: 70vh; }
.cmp-pane { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cmp-title { padding: 6px 10px; font-weight: 600; border-bottom: 1px solid var(--border); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmp-body { flex: 1; overflow: auto; padding: 6px; }
.cmp-body .qv-page { width: 100%; height: auto; display: block; margin-bottom: 6px; }
@media (max-width: 720px) { .cmp-wrap { grid-template-columns: 1fr; height: auto; } }
/* A row opened in place. */
tr.dt-expandable { cursor: pointer; }
tr.dt-open td { border-bottom-color: transparent; }
tr.dt-expand > td { background: var(--surface-2, rgba(127, 127, 127, .06)); padding: 10px 12px; }
.pend-open { display: flex; flex-direction: column; gap: 10px; }
.pe-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 14px; }
.pe-item { display: flex; flex-direction: column; }
.pe-acts { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
/* Every table: sort, widths, columns. */
th.tc-head { position: relative; cursor: pointer; user-select: none; }
th.tc-last { padding-right: 26px; }
.tc-cols { position: absolute; right: 2px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; cursor: pointer;
  opacity: .45; font-size: 13px; padding: 2px 4px; color: inherit; }
th.tc-head:hover .tc-cols, .tc-cols:focus { opacity: 1; }
.tc-menu { position: absolute; right: 0; top: 100%; z-index: 30; background: var(--bg, #fff); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 4px; min-width: 180px; box-shadow: 0 6px 18px rgba(0,0,0,.18);
  font-weight: normal; text-align: left; cursor: default; }
table.tc-sized { table-layout: fixed; }
table.tc-sized td { overflow: hidden; text-overflow: ellipsis; }

/* A bill line with its document and, beside it, the comparison. */
.bill-line:has(.cmp-btn) { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
.bill-line .cmp-btn { justify-self: start; white-space: nowrap; }

/* A row's actions as small icons (their words on hover): more of the row fits. */
.btn.icon-act { min-width: 28px; padding: 2px 7px; font-size: 15px; line-height: 1.3; font-weight: 700; }
.batch-acts { white-space: nowrap; }
.batch-acts .btn + .btn { margin-left: 4px; }

/* The browse button: its words; in the read documents' rows an icon. */
.picker-browse .pb-icon { display: none; }
.batch-table .picker-browse .pb-icon { display: inline; }
.batch-table .picker-browse .pb-text { display: none; }
.batch-table .picker-browse { padding: 2px 8px; }
/* Open: the button closes the list - said by its ✕ and its colour. */
.picker-browse.on { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.picker-browse.on { display: inline-flex; align-items: center; gap: 4px; }
.picker-browse.on .pb-icon { display: inline; }
/* The list open under the category: its "not chosen yet" card waits. */
.pe-stack .picker.browsing + .pick-notice.mode-none { display: none; }

/* Herd: its breeds and suppliers to filter by (long names cut). */
.filters select.hf-sel { max-width: 230px; }
/* Many animals edited together. */
.hb-form .hb-sec { margin: 12px 0 4px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; opacity: .75; }
.hb-form .hb-summary { margin: 10px 0 6px; }
.hb-form .hb-preview { max-height: 34vh; overflow: auto; }

/* A lot's chart, each animal: thin lines, the lagging in red, the average on top. */
.prog-mode { display: inline-flex; gap: 0; margin-right: 6px; }
.prog-mode .btn { border-radius: 0; }
.prog-mode .btn:first-child { border-radius: 6px 0 0 6px; }
.prog-mode .btn:last-child { border-radius: 0 6px 6px 0; }
.prog-mode .btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.pa-line { fill: none; stroke: var(--muted, #8a8f98); stroke-width: 1.1; opacity: .6; }
.pa-line.pa-ahead { stroke: var(--series-2, #2e9d5b); opacity: .45; }
.pa-line.pa-behind { stroke: #d9483b; stroke-width: 1.4; opacity: .8; }
.pa-line.pa-on { stroke-width: 3; opacity: 1; }
.pa-dot { fill: var(--muted, #8a8f98); opacity: .5; }
.pa-hit { fill: none; stroke: transparent; stroke-width: 9; cursor: pointer; pointer-events: stroke; }
.pa-avg { fill: none; stroke: var(--series-1); stroke-width: 3; pointer-events: none; }
.pa-chips { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.pa-chip.on { outline: 2px solid var(--accent); }
.pa-chip-behind strong, .pa-pill-behind { color: #d9483b; }
.pa-chip-ahead strong, .pa-pill-ahead { color: #2e9d5b; }
tr.pa-row-behind td:first-child { box-shadow: inset 4px 0 0 #d9483b; }
tr.pa-row-ahead td:first-child { box-shadow: inset 4px 0 0 #2e9d5b; }

/* Pastures: lots dragged onto them; what is on each, or how long it rested. */
.pl-bar { margin: 12px 0; }
.pl-bar-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.pl-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.pl-chip { display: flex; flex-direction: column; gap: 1px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  cursor: grab; background: var(--surface-2, rgba(127,127,127,.06)); min-width: 130px; user-select: none; }
.pl-chip.placed { border-left: 4px solid var(--accent); }
.pl-chip.dragging { opacity: .4; }
.pl-off { padding: 6px 12px; border: 1px dashed var(--border); border-radius: 8px; align-self: stretch; display: flex; align-items: center; }
.pl-card.drop-on, .pl-off.drop-on { outline: 3px dashed var(--accent); outline-offset: 2px; }
.pl-state { font-size: 13px; font-weight: 600; margin-top: 4px; }
.pl-state.occupied { color: var(--accent); }
.pl-state.ready { color: #2e9d5b; }
.pl-state.resting { color: #c8902a; }
.pl-stay { margin-top: 4px; font-size: 13px; padding-left: 8px; border-left: 3px solid var(--accent); }
.pl-height.pl-h-low, .pl-height.pl-h-high { color: #d9483b; }
.pl-height.pl-h-enter, .pl-height.pl-h-ok { color: #2e9d5b; }
.pill.pq-5, .pill.pq-4 { color: #2e9d5b; }
.pill.pq-2, .pill.pq-1 { color: #d9483b; }
.pl-guide { padding: 6px 10px; border-left: 3px solid var(--accent); }

/* Readers and scales: the live strip on the handling screen, and the setup window. */
.dv-live { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 14px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; }
.dv-live.dv-stable { border-color: #2e9d5b; }
.dv-kg { font-size: 20px; }
.pill.dv-connected { color: #2e9d5b; }
.pill.dv-error { color: #d9483b; }
.dv-card { margin-bottom: 10px; }
.dv-card-head { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted, #888); }
.dv-dot.dv-connected { background: #2e9d5b; }
.dv-dot.dv-error { background: #d9483b; }
.dv-dot.dv-connecting { background: #c8902a; }
.dv-raw { max-height: 150px; overflow: auto; margin: 8px 0; padding: 6px 8px; background: var(--surface-2, rgba(127,127,127,.06)); border-radius: 6px; font-size: 12px; }
.dv-test { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.dv-test input { min-width: 260px; }
.dv-guide { margin-top: 12px; }
.dv-guide summary { cursor: pointer; font-weight: 600; }
input.dv-flash { animation: dvflash 1.2s ease-out; }
@keyframes dvflash { from { background: rgba(46, 157, 91, .45); } to { background: transparent; } }
.dv-guide table { width: 100%; table-layout: fixed; }
.dv-guide td, .dv-guide th { white-space: normal; vertical-align: top; }
.dv-guide th:first-child { width: 22%; }

/* An animal's photos: its picture on its page, in the chute, in the herd list. */
.av { display: inline-flex; align-items: center; justify-content: center; object-fit: cover; border-radius: 8px;
  background: var(--surface-2, rgba(127,127,127,.1)); border: 1px solid var(--border); }
.av-small { width: 34px; height: 34px; font-size: 18px; border-radius: 6px; }
.av-mid { width: 96px; height: 96px; font-size: 44px; }
.av-big { width: 150px; height: 150px; font-size: 70px; border-radius: 12px; }
.ph-head { display: flex; gap: 14px; align-items: flex-end; margin-bottom: 12px; }
.ph-head-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-avatar-btn { padding: 0; border: 0; background: none; cursor: pointer; }
.ph-gallery { display: flex; gap: 10px; flex-wrap: wrap; }
.ph-item { margin: 0; width: 180px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.ph-item.is-profile { border-color: var(--accent); }
.ph-item img { width: 100%; height: 130px; object-fit: cover; cursor: zoom-in; display: block; }
.ph-item figcaption { padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.ph-acts { display: flex; gap: 4px; flex-wrap: wrap; }
.pill.ph-k-treatment { color: #c8902a; }
.ph-preview { max-width: 100%; max-height: 40vh; display: block; margin: 0 auto 10px; border-radius: 8px; }
.crop-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.crop-view { position: relative; width: 320px; height: 320px; overflow: hidden; border-radius: 8px; cursor: grab; touch-action: none; background: #111; }
.crop-img { position: absolute; left: 0; top: 0; max-width: none; user-select: none; }
.crop-frame { position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none; }
.chute-photo { display: flex; flex-direction: column; align-items: center; gap: 4px; float: left; margin-right: 12px; }

/* Undo: steps made together as one group, opened to undo them one by one. */
.undo-top { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.undo-group { border: 1px solid var(--border); border-radius: 8px; margin: 6px 0; }
.undo-group-head { border-bottom: 0; }
.undo-group-acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.undo-kids { border-top: 1px dashed var(--border); }
.undo-row.undo-child { padding-left: 28px; }
.undo-row > input[type=checkbox] { align-self: center; }

/* Thumbnails: the receipt read, the document of the entry it seems to be. */
.doc-thumb { display: inline-block; padding: 0; margin: 2px 0; width: 64px; height: 84px; border: 1px solid var(--border);
  border-radius: 6px; overflow: hidden; background: var(--surface-2, rgba(127,127,127,.08)); cursor: zoom-in; flex: none; }
.doc-thumb-img { width: 100%; height: 100%; object-fit: contain; object-position: top; display: block; }
.doc-thumb.doc-thumb-none { visibility: hidden; width: 0; border: 0; }
.bill-line.has-thumb { grid-template-columns: auto minmax(0, 1fr) auto auto auto; }
.bill-line.has-thumb:has(.cmp-btn) { grid-template-columns: auto minmax(0, 1fr) auto auto auto auto; }
.bill-line .doc-thumb { width: 48px; height: 62px; }
.batch-dup .doc-thumb { width: 40px; height: 52px; vertical-align: middle; }
.pe-top { display: flex; gap: 10px; align-items: center; }
.batch-file .doc-thumb { display: block; margin: 6px 0 4px; }

/* Side by side with the entry's settings on the left. */
.cmp-wrap.with-side { grid-template-columns: minmax(260px, 340px) 1fr 1fr; height: calc(100vh - 140px); }
.cmp-side { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cmp-side-body { flex: 1; overflow: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.cmp-side-body .field, .cmp-side-body .picker { width: 100%; }
.cmp-side-status { font-size: 12px; }
.cmp-side-status button { display: none; }
@media (max-width: 900px) { .cmp-wrap.with-side { grid-template-columns: 1fr; height: auto; } }
.cmp-side-line { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0 2px 8px; border-left: 3px solid var(--border); }
.cmp-side-line span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Side by side: each document zoomed with the wheel, moved by dragging. */
.cmp-title { display: flex; align-items: center; gap: 8px; }
.cmp-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-tools { display: flex; align-items: center; gap: 4px; flex: none; font-weight: normal; }
.cmp-tools .btn { padding: 1px 8px; min-width: 26px; }
.cmp-pct { min-width: 44px; text-align: center; font-size: 12px; }
.cmp-body { cursor: zoom-in; overscroll-behavior: contain; }
.cmp-body.zoomed { cursor: grab; }
.cmp-body.dragging { cursor: grabbing; }
.cmp-zoom { width: 100%; }
.cmp-zoom .qv-page { width: 100%; user-select: none; }
.cmp-hint { padding: 3px 10px; border-top: 1px solid var(--border); }

/* Receipts to post: what waits, in small tiles on one line. */
.pend-stats { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.pend-stat { display: flex; align-items: baseline; gap: 8px; padding: 6px 14px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface, transparent); }
.pend-stat span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.pend-stat strong { font-size: 16px; }
.pend-stat.ps-exp { box-shadow: inset 3px 0 0 #c9473d; }
.pend-stat.ps-rev { box-shadow: inset 3px 0 0 #2e9d5b; }
/* Read documents, compact: the paper's picture beside its kind, name and
   what it was read as; notes kept to two lines (all of it on hover). */
.batch-file { max-width: none; }
.bf-grid { display: flex; gap: 8px; align-items: flex-start; min-width: 0; }
.bf-grid > .doc-thumb { display: block; width: 42px; height: 56px; margin: 0; flex: none; }
.bf-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.bf-info .paper-sel { margin-bottom: 1px; padding: 0 4px; font-size: 11px; height: 22px; }
.bf-info .batch-file-name { font-size: 12px; }
.bf-info .batch-file-meta { font-size: 11px; line-height: 1.25; }
.bf-info .batch-file-meta > .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.bf-info .batch-status { max-width: 100%; }
.bf-info .batch-docnote, .bf-info .batch-dup { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-size: 11px; }
/* What it is (already entered, pays...): lower, its pictures smaller. */
.batch-pays { padding: 3px 10px; gap: 4px 6px; }
.batch-pays .bill-lines { margin: 2px 0; }
.batch-pays .bill-line { padding: 1px 8px; }
.batch-pays .bill-line .doc-thumb { width: 30px; height: 40px; }
/* The choice beside what it is ("Already entered" · "Post as a new entry
   anyway"), the entries it matches on the lines beneath. */
.batch-pays > .bill-lines, .batch-pays > .pays-list { order: 10; }

/* Finance overview: the bills coming due. */
.bills-due { margin: 12px 0; }
.bd-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.bd-chip { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: inherit; cursor: pointer; font: inherit; }
.bd-chip span:first-child { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.bd-chip strong { font-size: 16px; }
.bd-chip .bd-sum { font-size: 12px; color: var(--muted); }
.bd-chip.on { outline: 2px solid var(--accent); }
.bd-chip:disabled { opacity: .45; cursor: default; }
.bd-chip.bd-overdue { box-shadow: inset 3px 0 0 #d9483b; }
.bd-chip.bd-overdue strong { color: #d9483b; }
.bd-chip.bd-today { box-shadow: inset 3px 0 0 #e0a030; }
.bd-chip.bd-week { box-shadow: inset 3px 0 0 var(--accent); }
.bd-list { display: flex; flex-direction: column; }
.bd-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) auto auto; gap: 12px; align-items: center;
  padding: 6px 8px; border-top: 1px solid var(--border); }
.bd-row.bd-overdue { box-shadow: inset 3px 0 0 #d9483b; }
.bd-row.bd-today { box-shadow: inset 3px 0 0 #e0a030; }
.bd-when { display: flex; flex-direction: column; }
.bd-row.bd-overdue .bd-when .small { color: #d9483b; }
.bd-what { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.bd-what:hover { text-decoration: underline; }
.bd-party { display: block; overflow: hidden; text-overflow: ellipsis; }
.bd-amt { font-weight: 600; }
.bd-more { padding: 6px 8px; }
@media (max-width: 700px) { .bd-row { grid-template-columns: 1fr auto; } .bd-row .bd-what { grid-column: 1 / -1; } }

/* The document viewer: wheel zoom, drag to move. */
.qv-body { cursor: zoom-in; overscroll-behavior: contain; }
.qv-body.zoomed { cursor: grab; }
.qv-body.dragging { cursor: grabbing; }
.qv-body .qv-page { user-select: none; }
.qv-pct { min-width: 44px; text-align: center; font-size: 12px; align-self: center; }
.photo-viewer img { transform-origin: 0 0; cursor: zoom-in; user-select: none; }
.photo-viewer img.zoomed { cursor: grab; }

/* An account's bank balance against the books: why they differ. */
.bal-note { margin-top: 10px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); display: flex; flex-direction: column; gap: 6px; width: 100%; }
.bal-note.bal-now { box-shadow: inset 3px 0 0 #2e9d5b; }
.bal-note.bal-off { box-shadow: inset 3px 0 0 #d9483b; }
.bal-after-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 10px; font-size: 13px; }
.bal-after-row a { color: inherit; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bal-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.bank-head { flex-wrap: wrap; }
.bank-head > .bal-note { order: 3; flex-basis: 100%; }

/* Receipts to post: a receipt opened in its row - the document, every
   field of the entry, what it matches, and the buttons. */
.pend-open { padding: 6px 4px; cursor: default; }
.pe-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 14px; align-items: start; }
.pe-doc { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.pe-doc .doc-thumb { width: 140px; height: 180px; }
/* An open receipt: its picture large enough to read beside the form -
   smaller on a narrower window, so the form keeps its room. */
.pe-body.pe-body-big { grid-template-columns: 420px minmax(0, 1fr); gap: 18px; }
.pe-body-big .pe-doc .doc-thumb { width: 420px; height: auto; min-height: 120px; max-height: 540px; }
/* The whole page, as tall as it is: a landscape one (a web page printed
   sideways) not cut to a portrait box. */
.pe-body-big .pe-doc .doc-thumb-img { height: auto; max-height: inherit; }
.pe-body-big .pe-name { max-width: 420px; }
@media (max-width: 1250px) {
  .pe-body.pe-body-big { grid-template-columns: 300px minmax(0, 1fr); }
  .pe-body-big .pe-doc .doc-thumb { width: 300px; max-height: 386px; }
  .pe-body-big .pe-name { max-width: 300px; }
}
.pe-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-form { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px 12px; align-items: end; }
.pe-form > .wide, .pe-form .pe-wide { grid-column: 1 / -1; }
/* An entry's Inventory item (what it bought, or repaired): label over the box. */
.inv-field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; color: var(--muted); }
.inv-field[hidden] { display: none; }
.inv-field select { width: 100%; max-width: 560px; }
.inv-field .muted { font-weight: 400; }
.int-row { display: flex; gap: 8px; flex-wrap: wrap; }
/* Dollars taken out and sold: the sale under the movement. */
.mv-sold { margin: 10px 0 4px; }
.mv-sale { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.mv-sale[hidden], .mv-sold[hidden] { display: none; }
/* A receipt's own bank: its account to use, or to register. */
.bank-offer { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding: 10px 12px;
  border: 1px solid var(--border); border-left: 3px solid var(--warn); border-radius: var(--radius-sm);
  background: var(--surface-2); font-size: 13px; font-weight: 400; color: var(--text); }
.bank-offer[hidden] { display: none !important; }
.bank-offer-head { display: flex; align-items: center; gap: 6px; }
.bank-offer-icon { font-size: 15px; }
.bank-offer-acc { display: flex; flex-direction: column; gap: 1px; padding-left: 21px; }
.bank-offer-acts { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 21px; }
/* The statements a page given apart may belong to: one button each, full width. */
.stack-actions { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.stack-actions .btn { justify-content: flex-start; text-align: left; white-space: normal; }
/* A receipt kept to post, opened: kind and amount; the date, due date and
   paid; then two columns - the account and under it the category, the
   supplier beside them - each box with its notice under it (the receipt's
   bank account, a name not registered, no category yet); at the bottom
   description and notes side by side. */
.pe-form.pe-receipt {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  grid-template-areas:
    "kind kind kind amount amount amount"
    "date date due due paid paid"
    "left left left right right right"
    "desc desc desc notes notes notes"
    "svc svc svc svc svc svc";
}
.pe-form.pe-receipt > .ga-kind { grid-area: kind; }
.pe-form.pe-receipt > .ga-date { grid-area: date; }
.pe-form.pe-receipt > .ga-amount { grid-area: amount; }
.pe-form.pe-receipt > .ga-due { grid-area: due; }
.pe-form.pe-receipt > .ga-paid { grid-area: paid; }
.pe-form.pe-receipt > .ga-dates { grid-row: 2; grid-column: 3 / -1; align-self: center; margin: 0; }
.pe-form.pe-receipt > .ga-left { grid-area: left; }
.pe-form.pe-receipt > .ga-right { grid-area: right; }
.pe-receipt .pe-stack { display: flex; flex-direction: column; gap: 10px; min-width: 0; align-self: start; }
.pe-receipt .pe-stack > .bank-offer { margin-top: -4px; }
/* Receipts to post: ready, or what each lacks. */
.pp-list { display: inline-flex; flex-wrap: wrap; gap: 4px; white-space: normal; }
.pp-chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); white-space: nowrap; }
.pp-chip.ok { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.pp-chip.bad { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.pp-chip.warn { border-color: var(--warn); background: var(--warn-soft); color: var(--text); }
.pp-chip.info { border-color: var(--info); background: var(--info-soft); color: var(--info); }
/* Registering the names the receipts give, all at once. */
.reg-names-list { display: flex; flex-direction: column; gap: 4px; max-height: 60vh; overflow: auto; }
.reg-names-row { display: grid; grid-template-columns: 24px minmax(0, 1fr) 150px 60px; gap: 8px; align-items: center;
  padding: 4px 6px; border-bottom: 1px solid var(--border); font-weight: normal; }
.reg-names-row.head { font-size: 12px; color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface); }
.reg-names-row.doubtful input[type=text] { color: var(--muted); }
/* Under the category: the supplier's categories to pick in one click - the
   ones its entries saying the same words had, marked. */
.cat-tips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: -4px; }
.cat-tips[hidden] { display: none; }
.cat-tips-head { color: var(--muted); font-size: 12px; }
.cat-tip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); color: var(--text); cursor: pointer; }
.cat-tip:hover { border-color: var(--accent); }
.cat-tip.hit { border-color: var(--accent); background: var(--accent-soft); }
.cat-tip-n { color: var(--muted); font-size: 11px; }
/* In a notice, the box to register the name: no frame of its own, its
   question said by the card's title - shown when the card's button is pressed. */
.pick-notice .picker-ask { border: 0; background: none; padding: 2px 0 0 21px; }
.pick-notice:not(.open) .picker-ask { display: none; }
.pick-notice.mode-add .picker-ask > .picker-q { display: none; }
.pe-form.pe-receipt > .ga-desc { grid-area: desc; }
.pe-form.pe-receipt > .ga-notes { grid-area: notes; }
/* The cards beside the boxes: compact - what each says on one line. */
.pe-receipt .bank-offer .bank-offer-acc { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.pe-receipt .bank-offer { padding: 8px 12px; gap: 4px; }
.pe-form.pe-receipt > .ga-svc { grid-area: svc; }
/* Narrow (a phone): one column - the account and category, then the supplier. */
@container (max-width: 620px) {
  .pe-form.pe-receipt {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-areas:
      "kind amount amount"
      "date due paid"
      "left left left"
      "right right right"
      "desc desc desc"
      "notes notes notes"
      "svc svc svc";
  }
  .pe-form.pe-receipt > .ga-dates { grid-column: 2 / -1; }
}
/* An account's trash: what was deleted, put back or deleted for good. */
.trash-pane { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.trash-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trash-item { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.trash-what { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1 1 320px; }
.trash-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: baseline; }
.trash-acts { display: flex; gap: 8px; }
/* An account's entries: add one, move or delete the ticked - one line. */
.bank-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0 0 8px; }
.bank-acts select { width: auto; min-width: 200px; }
.bank-row .bank-tabs { flex: 0 1 auto; }
.bank-row .bank-date { flex: 0 0 auto; width: 150px; }
.bank-row > .muted { font-size: 12.5px; }
.table-tools select.bank-move { width: auto; min-width: 190px; padding-top: 5px; padding-bottom: 5px; font-size: 13px; }
.mv-books strong { color: var(--text); font-size: 15px; padding-top: 8px; }
.int-row input { width: 120px; }
.int-row select { width: auto; }
.pe-form textarea { min-height: 38px; }
.pe-paid { display: flex; flex-direction: column; gap: 4px; }
.pe-match { padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border); }
.pe-match.pe-ok { box-shadow: inset 3px 0 0 #2e9d5b; }
.pe-match.pe-dup { box-shadow: inset 3px 0 0 #e0a030; }
.pe-rest-open { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border); }
.pe-match.pe-new { box-shadow: inset 3px 0 0 var(--accent); }
.pe-who { margin-top: 6px; }
.pe-saved { align-self: center; }
.cmp-side-body .pe-form { grid-template-columns: 1fr; }
@media (max-width: 700px) { .pe-body, .pe-body.pe-body-big { grid-template-columns: 1fr; } }
.pe-form [hidden], .alias-check[hidden] { display: none !important; }

/* Bills to pay (red) and to receive (green) coming due, on their tab. */
.tab-count.tc-pay { background: #d9483b; }
.tab-count.tc-rec { background: #2e9d5b; margin-left: 4px; }

/* A row opened in a list: kept within the width in sight, at its left. */
.dt-expand-box { position: sticky; left: 12px; box-sizing: border-box; }

/* One document in the side-by-side window: the entry, then the document. */
.cmp-wrap.cmp-one { grid-template-columns: 1fr; }
.cmp-wrap.with-side.cmp-one { grid-template-columns: minmax(260px, 340px) 1fr; }
@media (max-width: 900px) { .cmp-wrap.with-side.cmp-one { grid-template-columns: 1fr; } }
.pe-under { display: flex; flex-direction: column; gap: 10px; }
.cmp-side-body .pe-acts { margin-top: 10px; }

/* The side-by-side window's columns, with a bar between each two to drag. */
.cmp-wrap { --split-w: 12px; column-gap: 0; }
.cmp-wrap { grid-template-columns: 1fr var(--split-w) 1fr; }
.cmp-wrap.cmp-one { grid-template-columns: 1fr; }
.cmp-wrap.with-side { grid-template-columns: minmax(260px, 340px) var(--split-w) 1fr var(--split-w) 1fr; }
.cmp-wrap.with-side.cmp-one { grid-template-columns: minmax(260px, 340px) var(--split-w) 1fr; }
.cmp-split { cursor: col-resize; display: flex; justify-content: center; touch-action: none; }
.cmp-split::before { content: ''; width: 3px; height: 100%; border-radius: 2px; background: var(--border); transition: background .15s; }
.cmp-split:hover::before, .cmp-wrap.cmp-dragging .cmp-split::before { background: var(--accent); }
.cmp-wrap.cmp-dragging { user-select: none; cursor: col-resize; }
@media (max-width: 900px) {
  .cmp-wrap, .cmp-wrap.cmp-sized, .cmp-wrap.with-side, .cmp-wrap.with-side.cmp-one { grid-template-columns: 1fr !important; }
  .cmp-split { display: none; }
}

/* A list's rows that open in place: the row itself stands out (bold, a
   coloured bar on top), what opens under it sits recessed and framed by
   the same colour, closed by a thick line - where it ends and the next
   entry starts is plain. */
:root { --row-hi: rgba(0, 0, 0, .055); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --row-hi: rgba(255, 255, 255, .07); } }
:root[data-theme="dark"] { --row-hi: rgba(255, 255, 255, .07); }
tr.dt-expandable > td { background-image: linear-gradient(var(--row-hi), var(--row-hi)); font-weight: 600;
  border-top: 2px solid var(--border); }
tr.dt-expandable:hover > td { background-image: linear-gradient(var(--row-hi), var(--row-hi)), linear-gradient(var(--row-hi), var(--row-hi)); }
tr.dt-open > td { border-top-color: var(--accent); }
tr.dt-expand > td { background: transparent; padding: 14px 16px 18px; }
/* The row being worked on and its editor: one block, apart from the closed
   rows - the row tinted, the editor on its own background, a green bar down
   the left of both and a green line closing it. */
tr.dt-open > td, tr.dt-open:hover > td { background: var(--accent-soft); background-image: none; border-top: 2px solid var(--accent); }
tr.dt-open > td:first-child { box-shadow: inset 4px 0 0 var(--accent); }
tr.dt-expand > td { background: var(--surface); border-bottom: 2px solid var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
/* The editor in it wraps its text as a page does (a table's cells do not). */
tr.dt-expand > td { white-space: normal; }

/* A receipt opened in its row: six columns - the short fields on one
   line, then description and supplier, category and notes, each half. */
.pe-form { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px 14px; align-items: start; }
.pe-form > .pe-half { grid-column: span 3; }
.pe-form > .pe-inst { grid-column: span 2; align-self: center; margin: 0; }
.pe-form input, .pe-form select, .pe-form textarea { font-size: 14px; }
.pe-form textarea { min-height: 40px; height: 40px; resize: vertical; }
.pe-form-slot { container-type: inline-size; }
@container (max-width: 860px) {
  .pe-form { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .pe-form > .pe-half { grid-column: 1 / -1; }
}
.cmp-side-body .pe-form > * { grid-column: 1 / -1; }
/* The entry beside its documents: laid out for its own width (a narrow
   column), not the window's - one column, the main button across the top
   of the others. */
.cmp-side-body { container-type: inline-size; }
@container (max-width: 460px) {
  .pe-form.pe-receipt {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "kind amount"
      "date date"
      "due paid"
      "left left"
      "right right"
      "desc desc"
      "notes notes"
      "svc svc";
  }
  .pe-form.pe-receipt > .ga-dates { grid-row: auto; grid-column: 1 / -1; }
  .pe-form.pe-receipt textarea { min-height: 64px; }
}
.cmp-side-body .pe-acts > .btn:first-child { flex: 1 1 100%; }
.cmp-side-body .pe-acts > .spacer { flex: 1; }

/* An entry's attachments: each with its first page small in front. */
.att-row.has-thumb .doc-thumb { width: 52px; height: 66px; flex: none; margin: 0; }
/* What identifies a file (NF-e, Pix, boleto, GTA), under it: copied with a click. */
.att-nums { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 8px 4px 68px; }
.att-num { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: pointer;
  padding: 1px 8px; font-size: 11px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font-family: var(--mono); }
.att-num:hover { border-color: var(--accent); }
/* Under a receipt's picture in an entry's row: a column of them. */
.pe-doc .doc-nums { padding: 0; flex-direction: column; align-items: flex-start; max-width: 420px; }
.att-num-k { color: var(--muted); font-family: var(--font); }
/* Under an entry's files: its line on the bank statement. */
.st-card { grid-column: 1 / -1; margin-top: 8px; }
.st-row { display: flex; flex-direction: column; gap: 4px; padding-top: 4px; }
.st-row + .st-row { border-top: 1px solid var(--border); }

/* ---------- dashboard ---------- */
/* The top: the farm and the day on a green band. */
.dash-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px;
  padding: 22px 26px; margin-bottom: 16px; border-radius: 16px; color: #fff;
  background: radial-gradient(120% 140% at 0% 0%, #4f8f4b 0%, #2f6a35 45%, #1f4a2a 100%);
  box-shadow: var(--shadow); position: relative; overflow: hidden; }
.dash-hero::after { content: ''; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, .14), transparent 70%); pointer-events: none; }
.dash-hero h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: -.02em; color: #fff; }
.dash-hero-day { display: flex; align-items: center; gap: 8px; font-size: 13px; opacity: .85; }
.dash-hero-day .dash-ico { width: 16px; height: 16px; }
.dash-hero-chips { display: flex; flex-wrap: wrap; gap: 8px; position: relative; z-index: 1; }
.dash-hero-chips > span:not(.dw-menu-wrap) { padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, .14); font-size: 13px; backdrop-filter: blur(2px); }
.dash-hero-chips > span.warn { background: rgba(255, 196, 80, .25); }
.dash-hero-chips strong { font-size: 15px; }

.dash-ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Headline figures: an icon in its colour, the number big. */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: var(--gap); margin-bottom: 14px; }
.kpi-slot { display: grid; }
.kpi { --tone: var(--accent); display: flex; align-items: center; gap: 14px; padding: 16px 18px; text-align: left;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow);
  color: inherit; font: inherit; position: relative; overflow: hidden; min-width: 0; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone); }
button.kpi { cursor: pointer; transition: transform .12s, box-shadow .12s; }
button.kpi:hover { transform: translateY(-2px); box-shadow: 0 8px 26px rgba(0, 0, 0, .18); }
.kpi-ico { flex: none; width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  color: var(--tone); background: color-mix(in srgb, var(--tone) 16%, transparent); }
.kpi-body { min-width: 0; }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.kpi-value { font-size: 26px; font-weight: 750; letter-spacing: -.02em; line-height: 1.2; white-space: nowrap; }
.kpi-sub { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-green { --tone: #3f9a4a; } .kpi-blue { --tone: #2a78d6; } .kpi-red { --tone: #d9483b; }
.kpi-orange { --tone: #e07b2e; } .kpi-gold { --tone: #c9962a; } .kpi-grey { --tone: #8a8f94; }

/* The arroba over the years. */
.ar-card { --ar-line: #c9962a; margin-bottom: 14px; box-shadow: var(--shadow); border-radius: 14px; }
.ar-card .card-head { flex-wrap: wrap; }
.ar-title { display: flex; align-items: center; gap: 12px; }
.ar-title h2 { margin: 0; }
.ar-badge { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ar-line);
  background: color-mix(in srgb, var(--ar-line) 16%, transparent); }
.ar-controls { display: flex; flex-wrap: wrap; gap: 8px; }
.ar-head { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 22px; margin-bottom: 8px; }
.ar-price { font-size: 36px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.ar-unit { font-size: 15px; font-weight: 600; color: var(--muted); }
.ar-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ar-chip { padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 650; background: var(--surface-2); }
.ar-chip.up { color: #2e9d5b; background: color-mix(in srgb, #2e9d5b 14%, transparent); }
.ar-chip.down { color: #d9483b; background: color-mix(in srgb, #d9483b 14%, transparent); }
.ar-chip .muted { font-weight: 500; }
.ar-range { margin-left: auto; }
.ar-plot { position: relative; height: 300px; }
.ar-plot svg { display: block; overflow: visible; touch-action: none; }
.ar-line { fill: none; stroke: var(--ar-line); stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.ar-dot { fill: var(--surface); stroke: var(--ar-line); stroke-width: 2.5; }
.ar-cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.ar-tip { position: absolute; pointer-events: none; min-width: 120px; padding: 8px 10px; border-radius: 8px;
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; z-index: 2; }
.ar-tip strong { font-size: 16px; display: block; }
.ar-empty { height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  text-align: center; max-width: 560px; margin: 0 auto; }
.ar-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--border); }
.ar-foot .spacer { flex: 1; }
.ar-status { font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 4px; }
.ar-on { color: #2e9d5b; } .ar-off { color: #e0a030; }

/* The other cards on the dashboard: rounder, lifted, bars in a gradient. */
#view .evo-card, #view .grid.cols-2 > .card { border-radius: 14px; box-shadow: var(--shadow); }
.bar-row .track { height: 10px; border-radius: 6px; }
.bar-row .fill { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #fff)); border-radius: 6px; }
@media (max-width: 600px) { .dash-hero { padding: 16px 18px; } .dash-hero h1 { font-size: 24px; } .ar-price { font-size: 30px; } .ar-plot { height: 240px; } }

/* The dashboard's cards: twelve columns, each card as wide and tall as set. */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gap); align-items: stretch; grid-auto-flow: row dense; }
.dw { position: relative; min-width: 0; display: flex; flex-direction: column; }
.dw > .card { margin: 0 !important; flex: 1; min-height: 0; }
.dw-open { grid-column: 1 / -1 !important; height: auto !important; }
/* A height set: the card fills it - its chart grows or shrinks, the rest scrolls. */
.dw.dw-h > .card { display: flex; flex-direction: column; overflow: auto; }
.dw.dw-h .ar-plot, .dw.dw-h .evo-plot { flex: 1 1 auto; height: auto; min-height: 140px; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } .dw { grid-column: 1 / -1 !important; height: auto !important; } }
/* Customising: each card with a bar on top to drag it by, its insides asleep. */
.dash-tray { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 12px 16px; margin-bottom: 12px;
  border: 2px dashed var(--accent); border-radius: 14px; background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.dash-tray .spacer { flex: 1; }
.dw-hidden { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.dash-grid.editing .dw { outline: 2px dashed color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 3px; border-radius: 14px; cursor: grab; }
.dw-bar { display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin-bottom: 6px; border-radius: 10px;
  background: var(--accent); color: var(--accent-text); position: relative; z-index: 3; }
.dw-bar .btn { background: rgba(255, 255, 255, .15); color: inherit; border-color: transparent; }
.dw-grip { font-size: 18px; cursor: grab; line-height: 1; }
.dw-name { font-size: 13px; }
.dw-shield { position: absolute; inset: 44px 0 0 0; z-index: 2; cursor: grab; }
.dw-dragging { opacity: .45; }
.dash-custom { margin-left: 4px; padding: 6px 12px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .45);
  background: rgba(255, 255, 255, .1); color: #fff; font: inherit; font-size: 13px; cursor: pointer; }
.dash-custom:hover { background: rgba(255, 255, 255, .22); }
/* The cattle sold: small, opened across the width. */
.sold-card { border-radius: 14px; box-shadow: var(--shadow); }
.sold-head { display: flex; align-items: center; gap: 12px; width: 100%; padding: 0; margin-bottom: 12px; text-align: left;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.sold-head h2 { margin: 0; }
.sold-badge { --ar-line: #e07b2e; }
.sold-open { font-size: 13px; font-weight: 650; color: var(--accent); white-space: nowrap; }
.sold-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.sold-figs > div { display: flex; flex-direction: column; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); min-width: 0; }
.sold-figs strong { font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sold-spark { display: flex; align-items: flex-end; gap: 8px; height: 90px; margin-top: 14px; }
.sold-bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; min-width: 0; }
.sold-bar i { display: block; width: 100%; max-width: 38px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #e07b2e, color-mix(in srgb, #e07b2e 45%, transparent)); }
.sold-bar span { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.sold-detail { margin-top: 14px; }
.sold-detail .table-wrap { max-height: 380px; overflow: auto; }
.sold-acts { display: flex; gap: 8px; margin-top: 10px; }
.dw-plain { flex: 1; }
.dw-toolbar { display: flex; justify-content: flex-end; margin: 8px 0; }
.dw .bills-due { margin: 0; flex: 1; }
/* The herd's status: one bar of who is in and who left, then categories. */
.st-card, .fd-card { border-radius: 14px; box-shadow: var(--shadow); }
.st-badge { --ar-line: #3f9a4a; } .fd-badge { --ar-line: #2a78d6; }
.st-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; gap: 2px; }
.st-seg { border: 0; padding: 0; cursor: pointer; min-width: 4px; }
.st-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; margin: 10px 0 14px; }
.st-key { display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: inherit; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.st-key i { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.st-key strong { margin-left: auto; }
.st-cats { display: flex; flex-direction: column; gap: 5px; }
.st-cat { display: grid; grid-template-columns: minmax(90px, 32%) 1fr auto; gap: 10px; align-items: center; border: 0; padding: 2px 0;
  background: none; color: inherit; font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.st-cat-k { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st-cat-track { height: 8px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.st-cat-track i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #3f9a4a, color-mix(in srgb, #3f9a4a 50%, #fff)); }
/* The confinements going, one a row. */
.fd-row { display: block; width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 8px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-2); color: inherit; font: inherit; cursor: pointer; }
.fd-row:hover { border-color: var(--accent); }
.fd-top { display: flex; align-items: center; gap: 8px; }
.fd-top .spacer { flex: 1; }
.fd-figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.fd-figs > span { display: flex; flex-direction: column; min-width: 0; }

/* Resizing a card: the corner, and its size while dragged. */
.dw-resize { position: absolute; right: -4px; bottom: -4px; width: 26px; height: 26px; z-index: 4; cursor: nwse-resize;
  border-radius: 6px; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; touch-action: none; }
.dw-resize::before { content: '◢'; font-size: 13px; line-height: 1; }
.dw-size { position: absolute; right: 30px; bottom: 2px; white-space: nowrap; padding: 3px 8px; border-radius: 6px;
  background: var(--text); color: var(--surface); font-size: 12px; font-weight: 650; }
.dw-resizing { outline-style: solid !important; user-select: none; }
.dash-grid.editing .dw { padding-bottom: 6px; }
/* The Customise button's menu: how, what to add, back to the original. */
.dw-menu-wrap { position: relative; display: inline-flex; }
.dw-menu { position: absolute; right: 0; top: calc(100% + 8px); width: min(380px, 90vw); z-index: 60; text-align: left;
  padding: 14px 16px; border-radius: 12px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.dw-menu[hidden] { display: none; }
.dw-menu-title { font-weight: 750; font-size: 15px; }
.dw-menu-steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 5px; color: var(--muted); line-height: 1.4; }
.dw-menu-sec { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin-top: 4px; }
.dw-menu-add { display: flex; flex-wrap: wrap; gap: 6px; }
.dw-menu-foot { border-top: 1px solid var(--border); padding-top: 10px; }
.dw-menu-btn.dw-on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.dash-custom.dw-on { background: #fff; color: #1f4a2a; }
.dw-caret { opacity: .7; font-size: .85em; }
/* The green band lets the menu out over the page (its light kept inside). */
.dash-hero { overflow: visible; z-index: 5; }
.dash-hero::after { right: 0; top: 0; width: 260px; height: 100%; border-radius: 0 16px 16px 0;
  background: radial-gradient(circle at 100% 0%, rgba(255, 255, 255, .16), transparent 70%); }

/* The arroba card: what could not be read, and a period longer than the prices. */
.ar-warn { flex-basis: 100%; padding: 8px 12px; border-radius: 8px; font-size: 13px;
  background: color-mix(in srgb, #e0a030 16%, transparent); border: 1px solid color-mix(in srgb, #e0a030 45%, transparent); }
.ar-short { flex-basis: 100%; font-size: 12.5px; color: #c98a1a; }

/* Above the dashboard's tiles: the day, and Customise. */
.dash-top { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin: 2px 0 12px; }
.dash-top .spacer { flex: 1; }
.dash-day { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--muted); font-weight: 600; }
.dash-day .dash-ico { width: 18px; height: 18px; }

/* The herd's evolution: a headline, washes under smooth lines, hollow
   markers, the latest figures at the line ends, pills for a legend. */
.evo-main { border-radius: 14px; box-shadow: var(--shadow); }
.evo-main .card-head h2 { margin: 0; }
.evo-badge { --ar-line: #3f9a4a; }
.evo-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; margin: -2px 0 6px; }
.evo-big { font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; display: inline-flex; gap: 8px; flex-wrap: wrap; }
.evo-big .ar-chip { font-size: 14px; }
.evo-unit { font-size: 14px; font-weight: 600; color: var(--muted); }
.evo-main .evo-plot { height: 290px; }
.evo-main .evo-area { stroke: none; }
.evo-main .evo-line { stroke-width: 2.25; }
.evo-main .evo-mark { fill: var(--surface); stroke-width: 2; }
.evo-main .evo-dot { stroke: var(--surface); stroke-width: 2.5; }
.evo-main .evo-end { fill: var(--text); font-size: 12.5px; font-weight: 700; }
.evo-main .evo-grid { opacity: .45; }
.evo-main .evo-cross { stroke-dasharray: 3 3; }
.evo-main .evo-legend { gap: 6px; margin-top: 12px; }
.evo-main .evo-legend button { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--text); background: var(--surface); }
.evo-main .evo-legend button:hover { border-color: var(--accent); }
.evo-main .evo-legend .evo-key { width: 10px; height: 10px; border-radius: 3px; }
.evo-main .evo-leg-v { font-variant-numeric: tabular-nums; margin-left: 2px; }
.evo-main .evo-legend button.off { text-decoration: none; opacity: .5; }
.evo-main .evo-legend button.off .evo-key { background: var(--border) !important; }

/* Share charts (weight ranges, where the money went): the ring or bars
   centred when they sit above the list, and the whole centred in a card
   taller than it. */
.share-body { justify-content: center; }
.share-plot.wr-bars-plot { flex: 1 1 320px; }
.dw > .share-card { display: flex; flex-direction: column; }
.dw > .share-card .share-body { flex: 1; align-content: center; }
/* A table's column menu, closed: not drawn at all. */
.tc-menu[hidden] { display: none !important; }

/* A farm's logo: on the button itself, no tile behind it (its own
   transparency shows the button through), contained. */
.farm-badge.logo { background: transparent; border: 0; padding: 0; overflow: visible; }
.farm-badge.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.farmchip .farm-badge.logo { width: 36px; height: 36px; margin: -2px 0; }
.logo-field .logo-row { display: flex; align-items: center; gap: 14px; }
.logo-preview { width: 72px; height: 72px; flex: none; border-radius: 14px; border: 1px dashed var(--border);
  background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.logo-preview img { width: 100%; height: 100%; object-fit: contain; padding: 4px; }
.logo-preview .muted { text-align: center; padding: 4px; }
.logo-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.logo-acts .muted { flex-basis: 100%; }

/* Printing a page: the farm on top, no menus or buttons, light colours,
   cards whole, tables and charts the paper's width. */
.print-head { display: none; }
.dash-top-acts { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
@page { size: A4; margin: 12mm; }
@media print {
  :root:root:root { --bg: #fff; --surface: #fff; --surface-2: #f3f3f0; --text: #111; --muted: #555; --border: #cfcfc8;
    --accent: #2f6a35; --accent-soft: #e6efe4; --good: #2e7d32; --danger: #a5372c; color-scheme: light; }
  html, body { background: #fff !important; color: #111 !important; }
  header, nav, .subtabs, .table-tools, .filters, .seg, .dw-menu-wrap, .print-btn, .farmpicker, .toast, #toast, #modal,
  .quickview, .dt-pick-all-phone, .ar-foot button, .evo-controls, .ar-controls, .dash-top, button.btn, .card-head .btn,
  .col-grip, .tc-menu { display: none !important; }
  .print-head { display: flex !important; align-items: center; gap: 12px; padding-bottom: 8px; margin-bottom: 12px;
    border-bottom: 2px solid #2f6a35; }
  .print-head img { height: 52px; width: auto; }
  .print-head .ph-farm { display: flex; flex-direction: column; }
  .print-head .ph-farm strong { font-size: 18px; color: #2f6a35; }
  .print-head .ph-farm span, .print-head .ph-title span { font-size: 11px; color: #555; }
  .print-head .ph-title { margin-left: auto; text-align: right; display: flex; flex-direction: column; }
  .print-head .ph-title strong { font-size: 14px; }
  .view, main { padding: 0 !important; margin: 0 !important; max-width: none !important; }
  .page-head { margin-bottom: 6px; }
  .card, .kpi, .stat { box-shadow: none !important; border: 1px solid #cfcfc8 !important; break-inside: avoid; background: #fff !important; }
  .dash-grid { display: block !important; }
  .dw { height: auto !important; margin-bottom: 10px; break-inside: avoid; }
  .dw-bar, .dw-shield, .dw-resize { display: none !important; }
  .table-wrap, .stb-list, .sold-detail .table-wrap { overflow: visible !important; max-height: none !important; }
  table { width: 100% !important; }
  thead { display: table-header-group; }
  tr { break-inside: avoid; }
  svg[data-printfit] { width: 100% !important; height: auto !important; }
  a { color: inherit; text-decoration: none; }
}

/* Reviewing the entries: a question, the two sides beside each other,
   what matches, two answers. */
.rv-ask { display: flex; flex-direction: column; gap: 12px; }
.rv-q { display: flex; gap: 12px; align-items: flex-start; }
.rv-q strong { font-size: 17px; display: block; margin-bottom: 2px; }
.rv-q-mark { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  color: var(--accent-text); background: var(--accent); }
.rv-panes { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rv-panes.many { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
/* Which of the same paper twice stays, and which goes. */
.rvp.rv-stays { border-color: var(--accent); }
.rvp.rv-goes { opacity: .78; border-style: dashed; }
.rv-fate { align-self: flex-start; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; margin-bottom: 4px; display: inline-block; }
.rv-fate.stays { background: var(--accent-soft); color: var(--accent); }
.rv-fate.goes { background: var(--danger-soft); color: var(--danger); }
.rv-swap { display: flex; justify-content: center; }
.rv-nav { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 8px 10px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.rvp { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); min-width: 0; }
.rvp .doc-thumb { width: 74px; height: 96px; flex: none; margin: 0; }
.rvp-nofile { width: 74px; flex: none; display: grid; place-items: center; text-align: center; border: 1px dashed var(--border); border-radius: 8px; }
.rvp-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1; }
.rvp-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rvp-top strong { font-size: 16px; }
.rvp-desc { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rvp-nums { color: var(--muted); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.rvp-files { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.rv-cmp { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; }
.rv-checks { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.rv-checks-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
.rv-check { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.rv-ico { width: 18px; flex: none; text-align: center; font-weight: 800; }
.rv-check.rv-ok .rv-ico { color: #2e9d5b; }
.rv-check.rv-near .rv-ico, .rv-check.rv-warn .rv-ico { color: #c98a1a; }
.rv-check.rv-bad .rv-ico { color: #d9483b; }
.rv-check.rv-none .rv-ico { color: var(--muted); }
.rv-lean { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); font-weight: 650; }
.rv-answers { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rv-answer { display: flex; flex-direction: column; gap: 4px; padding: 10px; border-radius: 12px; border: 1px solid var(--border); }
.rv-answer.lean { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.rv-answer .btn { width: 100%; justify-content: center; font-weight: 700; padding: 10px; }
.rv-answer .btn.rv-no { border-color: color-mix(in srgb, #d9483b 45%, var(--border)); }
@media (max-width: 760px) { .rv-panes, .rv-answers { grid-template-columns: 1fr; } }

.rv-done { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 24px 0; }
.rv-done .rv-clean { font-size: 16px; font-weight: 650; margin: 0; }

/* An inventory item's entries (and repairs): a table - day, what, files,
   value, take off - the columns lined up, the head kept in sight. */
.inv-links-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.inv-links-total { font-size: 16px; }
.inv-link-list { gap: 0; max-height: 300px; border: 1px solid var(--border); border-radius: 10px; margin-top: 4px; }
.inv-link-list .inv-link { display: grid; grid-template-columns: 96px minmax(140px, 1fr) minmax(0, 1.1fr) 110px 64px; gap: 10px;
  align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.inv-link-list .inv-link:last-child { border-bottom: 0; }
.inv-link-list .inv-link:nth-child(even):not(.inv-link-head) { background: var(--surface-2); }
.inv-link-head { position: sticky; top: 0; z-index: 1; background: var(--surface); font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding-top: 8px; padding-bottom: 8px; }
.inv-l-date { font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-l-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-l-files { display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; }
.inv-l-files .inv-file { max-width: 100%; min-width: 0; overflow: hidden; }
.inv-l-amt { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-l-off { justify-self: end; }
.inv-link-head .num { text-align: right; }
@media (max-width: 760px) {
  .inv-link-list .inv-link { grid-template-columns: 84px minmax(0, 1fr) 96px; }
  .inv-l-files, .inv-link-head span:nth-child(3) { display: none; }
  .inv-l-off { grid-column: 3; }
}

/* Bank accounts as a bank feed: the waiting count, the matched figure,
   the tabs. */
.bank-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; color: #fff; background: #d9483b; }
.bank-cleared { font-weight: 700; }
.bf-cleared strong { color: var(--accent); }
.bf-fig-btn { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 0; border: 0; background: none;
  color: inherit; font: inherit; cursor: pointer; text-align: left; }
.bf-fig-btn:hover strong { text-decoration: underline; }
.tone-warn { color: #c98a1a; }
.bank-tabs { flex-wrap: wrap; }
.bank-tabs .seg-warn { color: #c98a1a; }
.bf-nofeed { margin: 6px 0 0; }

/* Entries the bank does not show: what to do with them, and two entries joined */
.ub-sum { display: grid; gap: 6px; margin: 4px 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.ub-sum > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.ub-join { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.ub-join-card { display: grid; gap: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.ub-join-card:last-child { opacity: .8; border-style: dashed; }
@media (max-width: 560px) { .ub-join { grid-template-columns: 1fr; } }
.ub-why { max-width: 380px; white-space: normal; }
.ub-acts { justify-content: flex-end; min-width: 330px; }
.ub-acts .btn { white-space: nowrap; }

/* A statement line opened to post; several entries typed at once; how it works */
.st-open { display: grid; gap: 10px; padding: 4px 2px; }
.st-open-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.st-open .pe-form, .many-row .pe-form { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.st-goes { display: grid; gap: 2px; justify-items: start; }
/* The window scrolls, not a box inside it (a box of its own cut the lists off). */
.many-row [hidden] { display: none !important; }
.many-intl-note { margin: 6px 0 0; }
.many-list { display: grid; gap: 10px; margin: 8px 0 10px; }
.many-row { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.many-row .pe-form > .field:nth-child(-n+3) { grid-column: span 1; }
.many-del { grid-column: 6; display: flex; justify-content: flex-end; align-self: center; }
.how-steps { display: grid; gap: 14px; }
.how-step { display: grid; grid-template-columns: 34px 1fr; gap: 12px; align-items: start; }
.how-step p { margin: 4px 0 0; }
.how-n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); }
.how-note { padding: 10px 14px; border-radius: var(--radius); background: var(--info-soft); }
.how-note p { margin: 4px 0 0; }
@media (max-width: 640px) {
  .st-open .pe-form, .many-row .pe-form { grid-template-columns: 1fr 1fr; }
  .many-del { grid-column: 2; }
}
.dup-card { display: grid; gap: 8px; margin: 0 0 12px; border-color: var(--warn); background: var(--warn-soft); }
.dup-card p { margin: 0; }
.dup-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; justify-content: space-between; }
.dup-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.dup-window .dup-row { padding: 10px 0; border-bottom: 1px solid var(--border); }
.dup-join-opt { display: flex; align-items: center; gap: 8px; }
.cust-join-list { max-height: 50vh; overflow-y: auto; margin-top: 8px; }
@media (pointer: coarse) { .dup-acts .btn { min-height: 44px; } }
.st-bulk select { width: auto; max-width: 240px; flex: 0 1 auto; }

/* Where an entry came from, and its payments beside the bank */
.trail { display: grid; gap: 6px; margin: 0 0 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.trail-row { display: grid; grid-template-columns: 90px 1fr; gap: 10px; align-items: start; }
.trail-k { color: var(--muted); font-size: 12.5px; padding-top: 3px; }
.trail-v { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.trail-v .trail-pay { flex-basis: 100%; font-size: 13px; }
.trail-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 9px; border-radius: 999px; font: inherit; font-size: 12.5px;
  background: var(--accent-soft); color: var(--text); border: 1px solid transparent; }
.inb-checks { display: grid; gap: 4px; margin: 8px 0; }
.inb-check { display: grid; grid-template-columns: auto 92px minmax(0, 1fr) auto auto; gap: 10px; align-items: center;
  padding: 5px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: pointer; }
.inb-check.on { border-color: var(--accent); background: var(--accent-soft); }
.inb-check input { margin: 0; }
.inb-check-day { color: var(--muted); font-size: 12.5px; }
.inb-check-what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 560px) { .inb-check { grid-template-columns: auto minmax(0, 1fr) auto; } .inb-check-day, .inb-check .btn { display: none; } }
.trail-file { cursor: pointer; border-color: var(--border); border-radius: 8px; padding: 3px 10px 3px 3px; gap: 8px; text-align: left; }
.trail-thumb { width: 42px; height: 54px; flex: none; object-fit: cover; object-position: top; display: block;
  border-radius: 5px; border: 1px solid var(--border); background: #fff; }
.trail-file:hover { border-color: var(--accent); }
@media (max-width: 560px) { .trail-row { grid-template-columns: 1fr; gap: 2px; } }
/* A bill line's "Open entry" on the same row as its other buttons */
.bill-line:has(.bill-open) { grid-template-columns: minmax(0, 1fr) auto auto auto auto; }
.bill-line:has(.cmp-btn):has(.bill-open) { grid-template-columns: minmax(0, 1fr) auto auto auto auto auto; }
.bill-line.has-thumb:has(.bill-open) { grid-template-columns: auto minmax(0, 1fr) auto auto auto auto; }
.bill-line.has-thumb:has(.cmp-btn):has(.bill-open) { grid-template-columns: auto minmax(0, 1fr) auto auto auto auto auto; }
.bill-open { white-space: nowrap; }
.inst-acc select { min-width: 110px; max-width: 150px; }
.inst-table input[type=number] { min-width: 112px; }
.inst-table input[data-date] { min-width: 128px; }

/* The app's own question (instead of the browser's box): centred, in the theme */
.ask-layer { position: fixed; inset: 0; z-index: 3000; display: grid; place-items: center; padding: 18px;
  grid-template-columns: minmax(0, 1fr);   /* the card never wider than the screen */
  background: rgba(0, 0, 0, .45); animation: ask-in .12s ease-out; }
.ask-card { width: min(440px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center;
  padding: 22px 22px 18px; border-radius: calc(var(--radius) + 4px); background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: 0 18px 50px rgba(0, 0, 0, .35); }
.ask-icon { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); }
.ask-icon.bad { background: var(--danger-soft); color: var(--danger); }
.ask-text { margin: 0; white-space: pre-line; line-height: 1.45; font-size: 15px; }
.ask-card input[type=text] { width: 100%; }
.ask-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; }
.ask-actions .btn { min-width: 130px; justify-content: center; }
.btn.ask-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ask-danger:hover { filter: brightness(1.08); }
@keyframes ask-in { from { opacity: 0; } to { opacity: 1; } }

/* Hover tips: the app's own, in its theme, laid out (not the browser's) */
.app-tip { position: fixed; z-index: 4000; max-width: min(380px, calc(100vw - 24px)); padding: 9px 12px;
  border-radius: 10px; background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22); font-size: 12.5px; line-height: 1.45; pointer-events: none;
  animation: tip-in .1s ease-out; }
.app-tip[hidden] { display: none; }
.app-tip-head { font-weight: 650; font-size: 13px; margin-bottom: 4px; overflow-wrap: anywhere; }
.app-tip-head:only-child { margin: 0; font-weight: 500; }
.app-tip-rows { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 14px; }
.app-tip-k { color: var(--muted); white-space: nowrap; }
.app-tip-v { font-weight: 600; overflow-wrap: anywhere; }
.app-tip-line { grid-column: 1 / -1; overflow-wrap: anywhere; }
.app-tip-head + .app-tip-rows { padding-top: 6px; border-top: 1px solid var(--border); }
@keyframes tip-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- date boxes
   The app's own date box (dd/mm/aaaa or mm/dd/yyyy, as the app's language)
   and its calendar, in the theme. */
input[data-date] { padding-right: 34px; font-variant-numeric: tabular-nums; background-image: var(--date-icon);
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; cursor: pointer; }
input[data-date]:focus { cursor: text; }
input[data-date][aria-invalid="true"] { border-color: var(--danger); }
input[data-date][aria-invalid="true"]:focus { outline-color: var(--danger); }
.date-pop { position: fixed; z-index: 3000; width: 284px; padding: 10px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22); font-size: 13px; animation: tip-in .1s ease-out; }
.date-pop[hidden] { display: none; }
.date-pop button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.date-pop button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.date-pop-head { display: flex; align-items: center; gap: 2px; margin-bottom: 6px; }
.date-pop-title { flex: 1; text-align: left; font-weight: 650; font-size: 14px; padding: 6px 8px; border-radius: 6px; }
.date-pop button.date-pop-title:hover, .date-pop .date-pop-nav:hover { background: var(--surface-2); }
.date-pop .date-pop-nav { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); }
.date-pop .date-pop-nav:hover { color: var(--text); }
.date-pop-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.date-pop-grid.months { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.date-pop-wd { text-align: center; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 0 6px; }
.date-pop-day { height: 34px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.date-pop-grid.months .date-pop-day { height: 42px; }
.date-pop .date-pop-day:hover { background: var(--surface-2); }
.date-pop .date-pop-day.other { color: var(--muted); }
.date-pop .date-pop-day.today { box-shadow: inset 0 0 0 1px var(--accent); color: var(--accent); font-weight: 650; }
.date-pop .date-pop-day.on { background: var(--accent); color: var(--accent-text); font-weight: 650; }
.date-pop .date-pop-day:disabled { opacity: .3; cursor: default; background: none; }
.date-pop-foot { display: flex; justify-content: space-between; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.date-pop .date-pop-foot button { color: var(--accent); font-weight: 600; padding: 6px 10px; border-radius: 6px; }
.date-pop .date-pop-foot button:hover { background: var(--accent-soft); }
.date-pop .date-pop-foot button:disabled { opacity: .4; cursor: default; background: none; }
@media print { .date-pop { display: none !important; } input[data-date] { background-image: none; padding-right: 10px; } }

/* An attachment's installment, and the small menu an installment's Attach opens. */
.att-row select.att-parcel { width: auto; flex: none; padding: 4px 8px; font-size: 12px; }
.pop-menu { max-width: min(440px, calc(100vw - 16px)); max-height: 60vh; overflow: auto; }
.pop-menu .nav-menu-item { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 8px 12px; }
.pop-menu-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-menu .nav-menu-item .muted { flex: none; }
.pop-menu-head { padding: 6px 12px 4px; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.pop-menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }

/* Joining a payment with the invoices it paid. */
.cmb { display: flex; flex-direction: column; gap: 10px; }
.cmb h4 { margin: 6px 0 0; }
.cmb-pick { display: flex; flex-direction: column; gap: 4px; }
.cmb-pick .pb-row { display: flex; align-items: center; gap: 10px; }
.cmb-pick input[type=radio] { width: auto; flex: none; margin: 0; }
.cmb-row { flex: 1; min-width: 0; display: flex; flex-direction: column; }
/* Resolver a diferença: one box wherever a bill and its payment (or a nota and its order) differ. */
.df-box { display: flex; flex-direction: column; align-items: stretch; gap: 8px; margin-top: 8px; text-align: left; width: 100%; box-sizing: border-box; }
.df-box .df-title { font-size: 14px; }
.df-way { grid-template-columns: auto 1fr; align-items: start; }
.df-way input[type=radio] { width: auto; flex: none; margin: 3px 0 0; }
.df-way .cmb-row { gap: 2px; }
.df-more { margin-top: 6px; }
/* More received than a loan: its parts (interest, overpaid, other) - each a way, a value, what it needs. */
.lx-parts { display: flex; flex-direction: column; gap: 10px; }
.lx-part { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: var(--radius-sm); border-left: 3px solid var(--accent); background: var(--surface-2); }
.lx-line { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 8px; align-items: center; }
.lx-line select, .lx-line input { width: 100%; min-width: 0; box-sizing: border-box; }
.lx-x { min-width: 32px; }
.lx-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
@media (max-width: 640px) {
  .lx-line { grid-template-columns: minmax(0, 1fr) auto; }
  .lx-line select { grid-column: 1 / -1; }
}
.trail-chip.trail-order { border: 1px dashed var(--warn); background: var(--warn-soft); }
.cmb-amt { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cmb-preview { display: flex; flex-direction: column; gap: 6px; }
.cmb-bill { padding: 8px 10px; border-radius: var(--radius-sm); border-left: 3px solid var(--border); background: var(--surface-2); }
.cmb-bill.full { border-left-color: var(--accent); }
.cmb-bill.part { border-left-color: var(--warn); }
.cmb-bill.none { border-left-color: var(--muted); opacity: .8; }
.cmb-sum { margin: 4px 0 0; font-weight: 600; }
.cmb .cmb-tail { display: flex; flex-direction: column; align-items: stretch; gap: 6px; text-align: left; }

/* What a found invoice has in common with the entry, on its card. */
.inv-checks { padding: 6px 10px; gap: 2px; margin: 6px 0; }
.inv-checks .rv-check { font-size: 12.5px; }
.cmb .cmb-tail .form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; width: 100%; }

/* An entry opened in its row (Entries, No statement line). */
.entry-open .eo-inst { grid-column: span 2; display: flex; align-items: flex-end; gap: 8px; flex-wrap: wrap; padding-bottom: 6px; }
.eo-sugg, .eo-extra { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.eo-sec { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.eo-cand { display: flex; flex-direction: column; gap: 4px; }
.eo-cand > .btn, .eo-sec > .btn { align-self: flex-start; }
.eo-line { display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.eo-line-find { display: flex; gap: 8px; flex-wrap: wrap; }
.eo-nodoc { padding: 34px 10px; text-align: center; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.dt-expand-wait { padding: 14px; }
.rep-ask select { width: 100%; margin: 8px 0 2px; }

/* Two documents compared: what their entries have in common, over both. */
.cmp-outer { display: flex; flex-direction: column; gap: 8px; }
.cmp-facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-height: 38px; }
.cmp-facts-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; }
.cmp-facts .rv-check { font-size: 13px; }
.cmp-wrap.with-facts { height: calc(70vh - 54px); }
/* The side-by-side window: the whole screen, the documents taking every
   bit of height left under the checks (stacked and scrolled on a phone). */
.modal-card[data-size="compare"] { width: calc(100vw - 24px); height: calc(100vh - 24px); max-height: none; }
.modal-card[data-size="compare"] > .modal-body { display: flex; flex-direction: column; overflow: hidden; padding: 10px 12px; }
.modal-card[data-size="compare"] > .modal-body > .cmp-outer,
.modal-card[data-size="compare"] > .modal-body > .cmp-wrap,
.modal-card[data-size="compare"] .cmp-outer > .cmp-wrap { flex: 1; min-height: 0; height: auto; }
@media (max-width: 900px) {
  .modal-card[data-size="compare"] > .modal-body { display: block; overflow-y: auto; }
}
.cmp-wrap.with-side.with-facts { height: calc(100vh - 196px); }
.cmp-name-box { flex: 1; display: flex; flex-direction: column; min-width: 0; }
/* An entry's papers in the side-by-side window: its name a list of them. */
.cmp-name-pick { width: 100%; min-width: 0; font-weight: 600; text-overflow: ellipsis; }
.cmp-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmp-sub:empty { display: none; }
@media (max-width: 720px) { .cmp-wrap.with-facts { height: auto; } }
@media (max-width: 900px) { .cmp-wrap.with-side.with-facts { height: auto; } }

/* An entry saved out of its list: said, and its row greyed and tagged. */
.eo-gone { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; padding: 10px 12px;
  border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--text); border-left: 3px solid var(--warn); }
.eo-gone[hidden] { display: none; }
.eo-gone-ico { color: var(--warn); font-weight: 800; }
.eo-gone-say { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
tr.dt-gone > td { opacity: .5; }
tr.dt-gone > td .eo-gone-tag { opacity: 1; }
/* Saved on a receipt: the button that posts it, shown. */
.btn.pe-next { animation: pe-next 1.2s ease-out 2; }
@keyframes pe-next { 0% { box-shadow: 0 0 0 0 var(--accent); } 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: none; } }

/* Resolve the difference: what a payment cost beyond its bill, set apart. */
.rd-box { margin-top: 8px; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.rd-box > summary { cursor: pointer; font-weight: 650; display: flex; gap: 8px; align-items: center; }
.rd-box[open] > summary { margin-bottom: 6px; }
.rd-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.rd-acts { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-top: 8px; }
.rd-box.rd-inline { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }

/* A new version: offered, its changelog, its download */
.upd { display: grid; gap: 12px; }
.upd-head { display: flex; gap: 14px; align-items: center; }
.upd-badge { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px; font-weight: 700;
  background: var(--accent-soft); color: var(--accent); flex: none; }
.upd h4 { margin: 4px 0 0; }
.upd-notes { max-height: 46vh; overflow: auto; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--bg); line-height: 1.5; }
.upd-notes p { margin: 0 0 8px; }
.upd-notes ul { margin: 0 0 8px; padding-left: 20px; }
.upd-notes li { margin: 3px 0; }
.upd-notes h4 { margin: 10px 0 4px; }
.upd-say { color: var(--muted); font-size: 13px; }
.upd-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.upd-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.upd-about { display: grid; gap: 6px; }
.upd-about-line { font-weight: 600; }
.upd-about-acts { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* The licence screen (on the login screen's frame) */
.lic-card { max-width: 460px; }
.lic-card h3 { margin: 4px 0 0; }
.lic-key { font-family: var(--mono); letter-spacing: .04em; text-transform: uppercase; }
.lic-acts { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; }

/* The entry's values: the bill, what was paid, the extra costs and where they went */
.trail-values { display: grid !important; gap: 5px; }
.trail-sum { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; }
.trail-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; text-align: left;
  font: inherit; font-size: 13px; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 10px; cursor: pointer; }
.trail-entry:hover { border-color: var(--accent); }
.trail-entry > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Every paper of an entry, side by side on its line */
.bill-thumbs { display: flex; gap: 4px; align-items: center; flex-wrap: nowrap; }
.bill-thumbs .doc-thumb { width: 44px; height: 58px; margin: 0; }
.bill-thumbs-more { font-size: 12px; color: var(--muted); padding: 0 4px; }

/* A herd file's other columns: which to keep with the animals. */
.herd-extras { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); }
.herd-extra-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px 14px; }
.herd-extra { align-items: flex-start; gap: 8px; font-weight: normal; }
.herd-extra-new { margin-left: 6px; font-size: 10px; padding: 0 6px; }

/* Papers kept with a supplier, client or employee. */
.pf-head { display: flex; align-items: center; gap: 8px; }
.pf-list { display: flex; flex-direction: column; gap: 6px; }
.pf-row { display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.pf-row .doc-thumb { width: 52px; height: 66px; margin: 0; }
.pf-name { display: flex; flex-direction: column; min-width: 0; }
.pf-name strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-files.drag-over { border-color: var(--accent); }
/* A paper with no amount: where it belongs. */
.pe-home .bank-offer { gap: 6px; }
.pe-home-pick { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pe-home-pick select { max-width: 260px; }

.pf-head .spacer { flex: 1; }
/* A plan's documentation, in its window and as a count in the list. */
.plan-files { margin-bottom: 8px; }
.plan-files-none { margin: 0; padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.plan-clip { display: inline-flex; align-items: center; gap: 3px; color: var(--muted); }
.plan-clip .clip-icon { width: 14px; height: 14px; }

/* The receipt editor: what agrees with the entry it proposes. */
.cmp-facts.pe-facts { margin-top: 8px; flex-wrap: wrap; }

/* The other columns' quick picks and filter. */
.herd-extra-picks { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.herd-extra-filter { width: 200px; padding: 4px 10px; font-size: 13px; }
.herd-extra-count { margin-left: auto; }
.herd-extra[hidden] { display: none; }

/* Merging from a backup: the preview's counts, the merges made. */
.mg-form { display: flex; flex-direction: column; gap: 12px; }
.mg-form > p, .mg-form > ul { margin: 0; }
.mg-what { display: flex; flex-direction: column; gap: 6px; }
.mg-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.mg-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--surface-2); }
.mg-box.ok { border-color: var(--accent); }
.mg-counts { margin: 6px 0 0; padding-left: 18px; }
.mg-counts li { margin: 2px 0; }
.mg-made { margin-top: 14px; }
.mg-made h3 { margin: 0 0 6px; font-size: 1rem; }

/* The page's tools - back, undo, settings - in one group by the title, next
   to Print; the title row held under the top bar on a wide screen. */
.page-tools { display: inline-flex; align-items: center; margin-left: auto; padding: 2px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
.page-head .spacer ~ .page-tools { margin-left: 0; }
/* The one Read documents button, before the tools (the wrap takes their place). */
.page-tools-wrap { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; }
.page-head .spacer ~ .page-tools-wrap { margin-left: 0; }
.page-tools-wrap > .page-tools { margin-left: 0; }
.page-read { display: inline-flex; align-items: center; gap: 6px; height: 36px; white-space: nowrap; }
.page-read .clip-icon { width: 15px; height: 15px; }
.page-read.drop-over { outline: 2px dashed var(--accent); outline-offset: 2px; }
.ptool { appearance: none; border: 0; background: none; color: var(--muted); cursor: pointer;
  width: 34px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border-radius: 7px; }
.ptool + .ptool { box-shadow: -1px 0 0 var(--border); }
.ptool:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.ptool:disabled { opacity: .35; cursor: default; }
.ptool.active { color: var(--accent); background: var(--accent-soft, var(--surface-2)); }
/* The P&L by year and by month: the line's name stays in sight while the
   months scroll sideways. */
.pl-table.pl-grid th, .pl-table.pl-grid td, .pl-table.pl-grid td:first-child { white-space: nowrap; }
.pl-grid th:first-child, .pl-grid td:first-child { position: sticky; left: 0; z-index: 1; background: var(--surface); }
.pl-grid .pl-margin-row td { color: var(--muted); border-top: 1px solid var(--border); }
.pl-math .pl-table { width: 100%; }
/* Private mode (the eye): every money figure blurred, on every page and
   window - never on paper. */
html.private .pv { filter: blur(7px); display: inline-block; user-select: none; pointer-events: none; }
html.private svg .pv { filter: blur(4px); }
/* A summary box with a big figure: gone, and its row with it when all are. */
html.private .stat.pv-box { display: none; }
html.private .grid:has(> .stat.pv-box):not(:has(> :not(.pv-box))) { display: none; }
@media print { html.private .pv { filter: none; } }
/* An invoice e-mailed from the app (invEmailCompose, invMailSetup). */
.inv-mail { display: flex; flex-direction: column; gap: 12px; }
.inv-mail .field input, .inv-mail .field textarea { width: 100%; box-sizing: border-box; }
.inv-mail-body { min-height: 150px; }
.inv-mail-keep { display: inline-flex; align-items: center; gap: 8px; margin-top: -6px; font-size: .92em; }
.inv-mail-att { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.inv-mail-guide { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); padding: 10px 12px; }
.inv-mail-guide p { margin: 0 0 8px; }
.inv-mail-guide[hidden], .inv-mail .form-grid[hidden] { display: none; }
.inv-mail-card .form-actions { justify-content: flex-start; }
/* An invoice printed (invPrint): its pages alone on the paper, nothing else. */
#inv-print { display: none; }
@media print {
  body.inv-printing > *:not(#inv-print) { display: none !important; }
  body.inv-printing #inv-print { display: block; }
  #inv-print img { display: block; width: 100%; height: auto; break-after: page; }
  #inv-print img:last-child { break-after: auto; }
}
.ptool[hidden] { display: none; }
.tool-ico { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8;
  stroke-linecap: round; stroke-linejoin: round; flex: none; }
.print-btn { display: inline-flex; align-items: center; gap: 6px; }
.print-btn .tool-ico { width: 16px; height: 16px; }
.page-head.tools-only { justify-content: flex-end; }
@media (min-width: 900px) {
  .view > .has-tools { position: sticky; top: var(--topbar-h, 54px); z-index: 20; background: var(--bg);
    margin: calc(-1 * var(--pad)) calc(-1 * var(--pad)) 16px; padding: var(--pad) var(--pad) 10px;
    transition: box-shadow .15s; }
  .view > .has-tools.stuck { box-shadow: 0 6px 10px -8px rgba(0, 0, 0, .35); }
}
@media print { .page-tools { display: none !important; } }

/* The top bar, made compact as far as it must be to fit (fitTopbar). */
.topbar.tb-nosub .tg-sub { display: none; }
.topbar.tb-noname .brand > span { display: none; }
.topbar.tb-tight { gap: 10px; }
.topbar.tb-tight .tab, .topbar.tb-tight .tabg, .topbar.tb-tight .tabflat { padding-left: 8px; padding-right: 8px; }

/* Money received and the receivable it pays. */
.trail-rows { display: contents; }
.recv-cand { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* SISBOV: the extract beside the herd. */
.sb-top .filters { align-items: center; }
.sb-drop { flex: 1 1 360px; text-align: left; }
.sb-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 18px; margin-top: 12px; }
.sb-head .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 600; }
.sb-tiles { margin: 14px 0; }
.sb-tile { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.sb-tile:disabled { cursor: default; opacity: .75; }
.sb-sec { margin-bottom: 14px; }
.sb-sec.sb-bad { border-left: 3px solid var(--danger); }
.sb-sec.sb-warn { border-left: 3px solid var(--warn); }
.sb-sec.sb-good { border-left: 3px solid var(--accent); }
.sb-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-top: 10px; }
.sb-group-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.sb-group-acts { display: flex; flex-wrap: wrap; gap: 8px; }
.sb-clash-text { color: var(--warn); font-size: 13px; margin-top: 2px; }
.sb-table td.sb-clash { color: var(--danger); font-weight: 600; }
.sb-table td.mono, .mono { font-variant-numeric: tabular-nums; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }
.sb-clean { color: var(--accent); font-weight: 600; }
.sb-counts { margin-top: 8px; }
.sb-about summary { cursor: pointer; }
.sb-anatomy { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.sb-part { display: inline-flex; flex-direction: column; align-items: center; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.sb-part strong { font-family: ui-monospace, Consolas, monospace; font-size: 16px; letter-spacing: .04em; }
.sb-part.big strong { font-size: 20px; color: var(--accent); }
.sb-part small { font-size: 11px; color: var(--muted); }
.linkish { appearance: none; border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* The logs, in the About window. */
.logs-list { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; }
.logs-row { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.logs-row.current { border-color: var(--accent); }
.logs-row .spacer { flex: 1; }

/* An animal's identification: the warnings, and their confirmation. */
.id-hint { margin-top: 4px; font-size: 12.5px; font-weight: 500; }
.id-line { line-height: 1.4; }
.id-line.id-block { color: var(--danger); font-weight: 600; }
.id-line.id-confirm { color: var(--warn); }
.id-line.id-note { color: var(--muted); }
.id-card { max-width: 540px; }
.id-card .id-list { margin: 4px 0 10px; padding-left: 18px; text-align: left; }
.id-card .id-list li { margin: 4px 0; }
.id-card .field { display: flex; flex-direction: column; justify-self: stretch; gap: 4px; text-align: left; margin: 8px 0; font-size: 12.5px; font-weight: 600; color: var(--muted); }
.id-card .field input, .id-card .field textarea { width: 100%; box-sizing: border-box; }
.id-card .check { justify-self: stretch; }
.id-card .check { text-align: left; margin: 8px 0; }
.id-held { border: 1px solid var(--warn); border-radius: 8px; padding: 8px 12px; margin: 8px 0; }

/* An address as a QR code: black on white in both themes (cameras need it). */
.qr-card { max-width: 340px; }
.qr-box { background: #fff; padding: 6px; border-radius: 10px; line-height: 0; border: 1px solid var(--border); }
.qr-box svg { display: block; width: 232px; height: 232px; max-width: 70vw; max-height: 70vw; }
.qr-url { font-family: ui-monospace, Consolas, monospace; font-size: 15px; user-select: all; }

/* SISBOV: the same difference on many animals, one choice. */
.sb-bulk { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 12px; }
.sb-bulk .sb-group-head { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.sb-bulk-all { display: flex; justify-content: flex-end; }

/* The slaughter forecast: five tiles, the month's window, how it is worked out. */
.val-fc-tiles { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.modal-card[data-size="slaughtermonth"] { width: min(1280px, 100%); }
.val-month { display: flex; flex-direction: column; gap: 12px; }
.val-how { margin-top: 12px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--surface); }
.val-how summary { cursor: pointer; font-weight: 600; }
.val-how ol { margin: 8px 0 4px; padding-left: 20px; line-height: 1.55; }
.val-how-ex { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.val-bar .track { min-width: 120px; }

/* A warning that counts animals: a click lists them. */
.pill-link { cursor: pointer; border: 0; font: inherit; font-size: inherit; text-align: left; }
.pill-link:hover { text-decoration: underline; text-underline-offset: 2px; filter: brightness(0.97); }
.pill-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.pill-link .pill-arrow { font-weight: 700; }

/* Performance: the weighing check's repairs side by side. */
.wc-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.pill-link.on { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The forecast's month: its head count reads as the link it is; print on top. */
.num-link { color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.val-month-bar { display: flex; justify-content: flex-end; margin-bottom: 10px; }

/* Performance: pasture or confinement, never side by side. */
.perf-regime { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 4px 0 2px; }
.pill.regime-feedlot { background: var(--accent-soft); color: var(--accent); }
.pill.regime-mixed { background: var(--warn-soft); color: var(--warn); }
/* A warning in a notes row is a sentence: it wraps rather than run off the card. */
.val-notes .pill { white-space: normal; border-radius: 12px; }
.perf-note { display: flex; align-items: center; gap: 10px; flex: 1 1 100%; padding: 8px 12px;
  border-radius: 10px; background: var(--surface-2); color: var(--muted); font-size: 12.5px; }
.perf-note > span { flex: 1 1 auto; }
.perf-note .btn { flex: none; }
/* On a phone a card's heading and its buttons share the width: the buttons
   drop under the heading, and a segment wider than the card scrolls in
   itself - never squashed into one word a line, never cut off. */
.seg { max-width: 100%; overflow-x: auto; }
.seg button { flex: none; white-space: nowrap; }
@media (max-width: 720px) {
  .card-head { flex-wrap: wrap; }
}

/* ---------- an account's statements, and a fund's statement ---------- */
.modal-card[data-size="stf"] { width: min(920px, 100%); }
.modal-card[data-size="fund"] { width: min(760px, 100%); }
.stf-list { display: flex; flex-direction: column; gap: 10px; }
.stf-item { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }
.stf-head { display: flex; gap: 10px; align-items: flex-start; justify-content: space-between; }
.stf-title { min-width: 0; overflow-wrap: anywhere; }
.stf-acts { display: flex; gap: 6px; flex: none; align-items: center; }
.stf-acts a.btn { text-decoration: none; }
.stf-counts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.stf-count { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; background: var(--surface-2);
  color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.stf-count:hover:not(:disabled) { border-color: var(--accent); }
.stf-count:disabled { opacity: .55; cursor: default; }
.stf-count.stf-posted strong, .pill.stf-posted { color: var(--accent); }
.stf-count.stf-todo strong, .pill.stf-todo { color: var(--warn); }
.pill.stf-posted { background: var(--accent-soft); }
.pill.stf-todo { background: var(--warn-soft); }
.pill.stf-already { background: var(--info-soft); color: var(--info); }
.stf-fund { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.stf-lines { max-height: 340px; overflow: auto; }
.stf-table td:first-child { white-space: nowrap; }
.fs h3 { margin: 14px 0 6px; font-size: 14px; }
.fs-bal, .fs-yield { max-width: 520px; }
.fs-yield .fs-total td { border-top: 2px solid var(--border); }
@media (max-width: 720px) {
  .stf-head { flex-direction: column; }
  .stf-acts { flex-wrap: wrap; }
}
.fs .table td { white-space: normal; }
.fs .table { width: 100%; }
.fs .fs-bal, .fs .fs-yield { width: auto; min-width: min(520px, 100%); }
.fs .table td.num { white-space: nowrap; }
.stf-fund a { color: var(--accent); }

/* The account's difference taken apart (gapHelp): amount | what | what to do. */
.gap-help { margin: 12px 0; display: grid; gap: 10px; }
.gap-help .gh-title { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.gap-help .gh-table { display: grid; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.gap-help .gh-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; padding: 10px 14px;
  align-items: start; border-top: 1px solid var(--border); }
.gap-help .gh-row:first-child { border-top: 0; }
.gap-help .gh-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--warn); }
.gap-help .gh-sum { background: color-mix(in srgb, var(--border) 35%, transparent); }
.gap-help .gh-sum .gh-amt { color: inherit; }
.gap-help .gh-row.also .gh-amt { color: inherit; font-weight: 600; }
.gap-help .gh-acts { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.gap-help .gh-entries { display: grid; gap: 6px; margin-top: 8px; }
.gap-help .gh-entry { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 6px 8px;
  border: 1px dashed var(--border); border-radius: 6px; }
.gap-help .gh-entry-what { display: flex; gap: 10px; flex: 1 1 260px; min-width: 0; }
.gap-help .gh-entry-day { white-space: nowrap; }
.gap-help .gh-entry-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.gap-help .gh-entry-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.gap-help .gh-also-title { margin-top: 2px; }
.gap-help-btn { margin-top: 6px; align-self: flex-start; justify-self: start; width: auto; }
@media (max-width: 720px) {
  .gap-help .gh-row { grid-template-columns: 1fr; gap: 6px; }
  .gap-help .gh-amt { text-align: left; }
  .gap-help .gh-acts { justify-content: flex-start; }
}

/* No statement line: the account's transfers on no line, apart from the entries. */
.ub-transfers { display: grid; gap: 6px; margin-bottom: 10px; }
.ub-transfers .ub-tr { display: grid; grid-template-columns: 100px 120px 1fr auto auto; gap: 10px; align-items: center; }
@media (max-width: 720px) { .ub-transfers .ub-tr { grid-template-columns: 1fr 1fr; } }

/* A transfer's papers (an entry made a transfer keeps its receipt). */
.tr-files { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }
.ub-transfers .ub-click { cursor: pointer; border-radius: 6px; padding: 2px 4px; }
.ub-transfers .ub-click:hover { background: color-mix(in srgb, var(--border) 45%, transparent); }

/* A slaughter sale's sheet: papers on the left, money on the right. */
.sale-sheet { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; width: 100%; }
.sale-sheet .ss-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sale-sheet .ss-cols, .sale-sheet .ss-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.sale-sheet .ss-row { padding: 6px 0; border-top: 1px solid var(--border); align-items: start; }
.sale-sheet .ss-row.ss-bad { background: var(--warn-soft); border-radius: 6px; padding: 6px; }
.sale-sheet .ss-sale { border-top-width: 2px; }
.sale-sheet .ss-paper, .sale-sheet .ss-money { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; min-width: 0; }
.sale-sheet .ss-checks { display: grid; gap: 4px; padding-top: 6px; border-top: 1px solid var(--border); }
.sale-sheet .ss-check { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.sale-sheet .ss-mark { width: 1.2em; text-align: center; font-weight: 700; }
.sale-sheet .ss-ok .ss-mark { color: var(--accent); }
.sale-sheet .ss-bad .ss-mark { color: var(--danger); }
.sale-sheet .ss-warn .ss-mark { color: var(--warn); }
.sale-sheet .ss-say { flex: 1 1 260px; min-width: 0; }
.sale-sheet .ss-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.sale-sheet .ss-result { font-weight: 600; padding-top: 6px; border-top: 1px solid var(--border); }
@media (max-width: 640px) { .sale-sheet .ss-cols { display: none; } .sale-sheet .ss-row { grid-template-columns: 1fr; gap: 4px; } }

/* Invoicing (the Invoicing trial's): the list and the chosen invoice beside it. */
.inv-split { display: grid; grid-template-columns: minmax(260px, 360px) 1fr; gap: var(--gap); align-items: start; }
.inv-list { padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 70vh; overflow-y: auto; }
.inv-more { align-self: center; margin: 8px 0 4px; }
@media (pointer: coarse) { .inv-more { min-height: 44px; } }
.inv-row { display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 3px solid transparent;
  border-radius: var(--radius-sm); padding: 9px 10px; color: var(--text); font: inherit; cursor: pointer; }
.inv-row:hover { background: var(--surface-2); }
.inv-row.sel { background: var(--accent-soft); border-left-color: var(--accent); }
.inv-row-top, .inv-row-sub { display: flex; align-items: center; gap: 8px; }
.inv-row-top .inv-amt { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; }
.inv-row-sub { margin-top: 3px; }
.inv-row-sub > span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-head { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 12px; }
.inv-head h2 { margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.inv-actions { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
.inv-totals { margin: 12px 0 4px auto; max-width: 420px; display: flex; flex-direction: column; gap: 4px; }
.inv-tot { display: flex; align-items: center; gap: 10px; justify-content: space-between; font-variant-numeric: tabular-nums; }
.inv-tot > span:first-child { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.inv-tot.big { font-weight: 700; font-size: 1.08em; border-top: 1px solid var(--border); padding-top: 6px; }
.inv-tot.big > span:first-child { color: var(--text); }
/* What the sale cost you and what is left: on the screen only, never printed. */
.inv-tot.inv-mine { color: var(--muted); font-size: .95em; }
.inv-tot.big + .inv-tot.inv-mine, .inv-tot.big + .inv-tot.big + .inv-tot.inv-mine { margin-top: 8px; padding-top: 6px; border-top: 1px dashed var(--border); }
.inv-prof { white-space: nowrap; }
.inv-ctl { display: inline-flex; gap: 4px; align-items: center; }
.inv-ctl select { width: auto; }
/* An invoice's line: its fields' names shown only on a phone (the table's heads say them on a computer). */
.inv-lbl, .inv-lbl-in { display: none; }
/* A line as one row, and its ✓ Save in the header: a phone's (below). */
.inv-edit td.inv-sum, .inv-head-save { display: none; }
/* The invoice's cards and folds are a phone's (below): on a computer the
   form is laid out as it always was - no card, every fold open, no heading. */
.inv-card { display: contents; }
.inv-card-h, .inv-empty, .inv-fold > summary { display: none; }
.inv-adj { display: flex; flex-direction: column; gap: 4px; }
/* A line in a window of its own (a phone): product, description, quantity,
   price and cost, its amount, taxable. */
.inv-line-form { display: flex; flex-direction: column; gap: 13px; }
.inv-line-form .picker { margin: 0; }
.inv-line-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.inv-line-form .inv-num { width: 100%; }
.inv-line-amt { color: var(--muted); }
.inv-line-amt b { color: var(--text); font-size: 17px; }
.inv-line-form .inv-taxable { display: inline-flex; align-items: center; gap: 8px; }
.inv-line-form .inv-lbl-in { display: inline; }
/* Discount, sales tax, tip: name, boxes, amount - the boxes in one column. */
.inv-tot.inv-adjrow { display: grid; grid-template-columns: 5.5em minmax(0, 1fr) auto; }
.inv-adjrow .inv-tot-v { text-align: right; }
.inv-tot.inv-taxrow[hidden], .inv-tot.inv-addtax-row:has(> [hidden]) { display: none; }
.inv-num { width: 90px; text-align: right; }
.inv-search { width: 240px; max-width: 100%; }
.inv-pays { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.inv-pays h3 { margin: 0 0 6px; font-size: 0.95em; }
.inv-pay { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.inv-pay b { margin-left: auto; font-variant-numeric: tabular-nums; }
.inv-note { white-space: pre-wrap; color: var(--muted); }
.inv-billto { margin: -4px 0 10px; min-height: 1.2em; }
.inv-edit td { vertical-align: top; }
.inv-edit td:first-child { min-width: 220px; }
/* An invoice being written: wide enough for its lines - price, cost, amount and profit side by side. */
.modal-card[data-size="invoice"] { width: min(1120px, 100%); }
.inv-edit .inv-num { width: 84px; }
.inv-desc { display: flex; flex-direction: column; gap: 4px; }
/* The Description: one line tall, growing with each line typed; printed with its lines. */
textarea.inv-desc-text { min-height: 0; resize: none; overflow: hidden; line-height: 1.35; field-sizing: content; }
.inv-line-text { white-space: pre-line; }
.inv-bar { margin-top: 14px; }
.inv-edit .center { text-align: center; }
/* Each part as wide as the screen at most - a wide table scrolls or stacks
   inside it, never the page sideways. */
.inv-split > * { min-width: 0; }
/* Several ticked: the tick beside each invoice, the bar above the list. */
.inv-pick-row { display: flex; align-items: center; gap: 6px; }
.inv-pick-row > .inv-row { flex: 1; min-width: 0; }
input.inv-pick { flex: none; width: 18px; height: 18px; margin: 0 0 0 6px; accent-color: var(--accent); }
.inv-pick-all { padding: 6px 8px 8px; gap: 8px; }
.inv-pick-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; margin: 0 0 var(--gap);
  border-color: var(--accent); }
.inv-pick-bar[hidden] { display: none; }
.inv-paid-days { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 4px 0 12px; }
.inv-paid-days input[type=date] { width: auto; }
@media (pointer: coarse) { input.inv-pick { width: 24px; height: 24px; } .inv-pick-bar .btn { min-height: 44px; } }
.inv-cust-tiles { margin: 4px 0 12px; }
/* On the profile the invoices run with the page - no box of its own to scroll, on a phone either. */
.inv-list.inv-cust-invoices { max-height: none; overflow: visible; padding: 0; }
.inv-cust-search { min-width: min(320px, 100%); }
@media (max-width: 860px) {
  .inv-split { grid-template-columns: minmax(0, 1fr); }
  .inv-list { max-height: 40vh; }
  /* An invoice opened under its row: the list is the page, not a box of its own. */
  .inv-list.inv-unfold { max-height: none; overflow: visible; }
  .inv-list .inv-pick-row { scroll-margin-top: 120px; }
  .inv-list > .inv-panel { margin: 4px 0 12px; border-left: 3px solid var(--accent); }
  .inv-num { width: 70px; }
}
/* A phone: an invoice's lines one under the other - what it is on top, then
   quantity x price and the amount; the same in the invoice being written. */
@media (max-width: 640px) {
  .inv-actions { margin-left: 0; }
  .inv-search { width: 100%; }
  .inv-lines thead, .inv-edit thead { display: none; }
  .inv-lines tr, .inv-edit tr { display: grid; align-items: center; gap: 4px 10px; padding: 8px 0;
    border-bottom: 1px solid var(--border); }
  .inv-lines tr { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .inv-lines td.num { text-align: right; }
  .inv-lines td, .inv-edit td { padding: 0; border: 0; min-width: 0; }
  .inv-lines td:first-child { grid-column: 1 / -1; font-weight: 600; }
  .inv-lines td:nth-child(2), .inv-lines td:nth-child(3) { color: var(--muted); text-align: left; }
  /* Each line a card: every field named, amount and profit spelled out, its tax tick and remove named. */
  .inv-edit tr { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-areas: "d d d" "q p c" "a a a" "t x x";
    gap: 6px 10px; padding: 10px 12px; margin: 0 0 10px; border: 1px solid var(--border); border-radius: var(--radius-sm);
    background: var(--surface-2); }
  .inv-edit, .inv-edit tbody { display: block; width: 100%; min-width: 0; }
  .inv-edit tr { box-sizing: border-box; width: 100%; }
  .inv-edit td:nth-child(1) { grid-area: d; min-width: 0; }
  .inv-edit td:nth-child(2) { grid-area: q; } .inv-edit td:nth-child(3) { grid-area: p; } .inv-edit td:nth-child(4) { grid-area: c; }
  .inv-edit td:nth-child(5) { grid-area: a; } .inv-edit td:nth-child(6) { display: none; }
  .inv-edit td:nth-child(7) { grid-area: t; text-align: left; } .inv-edit td:nth-child(8) { grid-area: x; text-align: right; }
  .inv-edit .inv-num { width: 100%; }
  .inv-edit td.num { white-space: nowrap; font-weight: 600; text-align: left; }
  .inv-lbl { display: block; font-size: 12px; color: var(--muted); margin: 2px 0; }
  .inv-lbl-in { display: inline; color: var(--muted); font-weight: 400; }
  .inv-edit .inv-del .icon-btn { width: auto; min-width: 0; padding: 4px 8px; gap: 4px; font-size: 14px; white-space: nowrap; }
  .inv-taxable { display: inline-flex; align-items: center; gap: 8px; }
  .inv-totals { max-width: none; }
  .inv-ctl { flex-wrap: wrap; justify-content: flex-end; }
  /* Discount, sales tax, tip on a phone: the name and the amount, their boxes
     under them - one under the other, from the same edge. */
  .inv-tot.inv-adjrow { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "l v" "c c"; gap: 6px 10px; }
  .inv-adjrow .inv-tot-l { grid-area: l; } .inv-adjrow .inv-tot-v { grid-area: v; }
  .inv-adjrow .inv-ctl { grid-area: c; flex-wrap: nowrap; justify-content: flex-start; }
  .inv-tot.inv-adjrow:not(:last-child) { padding-bottom: 8px; }
  /* The invoice being written: each line one row - what, quantity x price,
     the amount - tapped to edit; the list part of the form (no box of its
     own to scroll); ✓ Save in the header, asking sent or draft. */
  .inv-form .table-wrap { overflow: visible; border: 0; background: none; border-radius: 0; }
  .inv-edit tr { display: block; padding: 0; margin: 0; border: 0; border-bottom: 1px solid var(--border);
    border-radius: 0; background: none; }
  .inv-edit tr > td { display: none; }
  .inv-edit tr > td.inv-sum { display: block; }
  .inv-sum-btn { appearance: none; border: 0; background: none; font: inherit; color: var(--text); cursor: pointer;
    width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px 2px; text-align: left; }
  .inv-sum-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
  .inv-sum-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inv-sum-name.muted { font-weight: 400; }
  .inv-sum-q { font-size: 13px; color: var(--muted); }
  .inv-sum-q:empty { display: none; }
  .inv-sum-amt { font-weight: 600; white-space: nowrap; }
  .inv-sum-go { color: var(--muted); font-size: 22px; line-height: 1; }
  /* In cards, as a phone's apps are: who and when, the products (+ Add
     product beside their heading), the total with the payments, notes;
     discount, tax and tip folded under one line saying what is on. */
  .modal-body:has(> .inv-form) { background: var(--bg); }
  .inv-form { display: flex; flex-direction: column; gap: 12px; }
  .inv-form .inv-card { display: block; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; }
  .inv-card-who .form-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
  .inv-card-who .form-grid > :first-child { grid-column: 1 / -1; }
  .inv-card-who .inv-billto:not(:empty) { margin-top: 8px; }
  .inv-card-who .inv-billto:empty { display: none; }
  .inv-card-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
  .inv-card-h h3 { margin: 0; font-size: 16px; }
  .inv-card-h .inv-addprod { border-radius: 999px; padding: 8px 14px; }
  .inv-card-lines:has(tbody:empty) .inv-empty { display: block; text-align: center; padding: 18px 0 6px; margin: 0; }
  .inv-edit tbody tr:last-child { border-bottom: 0; }
  .inv-form .inv-addline { display: none; }
  .inv-bottom { display: flex; flex-direction: column; gap: 12px; margin-top: 0; }
  .inv-bottom .inv-totals { order: -1; background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px; gap: 6px; }
  .inv-bottom > .inv-paybox { background: var(--surface); border-radius: var(--radius); padding: 14px; }
  .inv-form .inv-tot.big:last-of-type { font-size: 1.25em; }
  .inv-fold > summary { display: flex; align-items: center; gap: 10px; list-style: none; cursor: pointer; padding: 8px 0; }
  .inv-fold > summary::-webkit-details-marker { display: none; }
  .inv-fold > summary::after { content: '›'; color: var(--muted); font-size: 22px; line-height: 1; width: 14px;
    text-align: center; transform: rotate(90deg); transition: transform .15s; }
  .inv-fold[open] > summary::after { transform: rotate(-90deg); }
  .inv-fold-t { font-weight: 600; flex: none; }
  .inv-fold-s { flex: 1; min-width: 0; text-align: right; color: var(--muted); font-size: 13px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .inv-adj { border-top: 1px solid var(--border); padding: 2px 0; gap: 8px; }
  .inv-adj[open] { padding-bottom: 10px; }
  .inv-notes[open] > summary { margin-bottom: 8px; }
  .inv-form .form-actions:not(.inv-desk-only) { border-top: 0; padding-top: 0; margin-top: 0; }
  .inv-head-save { display: inline-flex; }
  .inv-form .inv-desk, .inv-form .form-actions.inv-desk-only { display: none; }
  .inv-form .form-actions { position: static; margin-bottom: 0; }
}

/* Profit & loss: the statement (a line opens to its categories) and each
   month's profit - a column up from the line for a profit, down for a loss. */
.pl-table { width: 100%; }
.pl-table td:first-child { white-space: normal; }
.pl-toggle { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; }
.pl-toggle:hover strong, .pl-toggle:focus-visible strong { color: var(--accent); }
.pl-chev { width: 12px; color: var(--muted); }
tbody tr.pl-apart td { padding-top: 18px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); background: none; border-bottom: 1px solid var(--border); }
/* Each month at least 38 px wide: a long period (All: years of months)
   scrolls sideways instead of squeezing the bars to hairs. */
.pl-chart { display: flex; gap: 6px; align-items: stretch; height: 202px; padding: 8px 0 12px; overflow-x: auto; overflow-y: hidden; }
.pl-col { flex: 1; min-width: 38px; display: grid; grid-template-rows: var(--pl-up) calc(100% - var(--pl-up) - 22px) 22px;
  background: none; border: 0; padding: 0; margin: 0; font: inherit; color: inherit; cursor: pointer; border-radius: 6px; }
.pl-col:hover, .pl-col:focus-visible { background: var(--surface-2); }
.pl-col:hover .pl-m, .pl-col:focus-visible .pl-m { color: var(--text); font-weight: 600; }
.pl-back { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 12px;
  padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); }
.pl-up { display: flex; align-items: flex-end; justify-content: center; border-bottom: 1px solid var(--border); }
.pl-card { margin-top: var(--gap); }
.pl-down { display: flex; align-items: flex-start; justify-content: center; padding-bottom: 6px; }
.pl-bar { width: min(26px, 70%); min-height: 2px; }
.pl-bar.good { background: var(--good); border-radius: 4px 4px 0 0; }
.pl-bar.bad { background: var(--danger); border-radius: 0 0 4px 4px; }
.pl-m { font-size: 11px; color: var(--muted); text-align: center; align-self: end; white-space: nowrap; overflow: hidden; }
@media (max-width: 640px) { .pl-chart { gap: 2px; } .pl-col { min-width: 34px; } .pl-m { font-size: 9px; } }

/* An invoice being written: its payments beside its totals (one under the
   other on a phone) - several, each its own way: cash and a card, Venmo... */
.inv-bottom { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; margin-top: 12px; }
.inv-bottom .inv-totals { margin: 0; max-width: none; grid-column: 2; grid-row: 1; }
/* The payments beside the totals, in the room on their left: each on two
   rows there (the day, how, the amount; then the account and the reference). */
.inv-bottom > .inv-paybox { grid-column: 1; grid-row: 1; }
.inv-paybox { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.inv-paybox-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.inv-paybox-head h3 { margin: 0; font-size: .95em; }
/* An invoice's payments (invPayHead, invPaySaved, the form's new lines): a
   grid per line with the same columns, the buttons' ones fixed - so saved
   lines, a line being changed and new ones line up. Narrow (phone, side
   panel): the account and the reference go to a second row. */
.inv-paytable { container-type: inline-size; display: flex; flex-direction: column; gap: 2px; --pay-btn: 38px; }
.inv-paytable .inv-paylines { display: contents; }
.inv-payrow { display: grid; gap: 6px 10px; align-items: center; min-height: 36px;
  grid-template-columns: 9.5em minmax(5.5em, 1fr) 6.5em minmax(7em, 1.3fr) minmax(5em, 1fr) var(--pay-btn) var(--pay-btn); }
.inv-payrow > * { min-width: 0; }
.inv-payrow > input, .inv-payrow > select { width: 100%; }
.inv-payrow .ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inv-payrow .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-payrow:not(.editing):not(.inv-payhead) { border-bottom: 1px solid var(--border); }
.inv-payrow.editing { padding: 3px 0; }
.inv-payrow .icon-btn { justify-self: center; }
.inv-payrow .icon-btn.ok { color: var(--good); }
.inv-payhead { min-height: 0; font-size: .75em; text-transform: uppercase; letter-spacing: .03em; }
.inv-paytable:not(:has(.inv-payrow:not(.inv-payhead))) .inv-payhead { display: none; }
.inv-pay-bank { text-align: center; cursor: help; }
.inv-payto { margin-top: 14px; }
/* An invoice's instalments (invPlanBox in the form, invPlanList on the panel). */
.inv-plan-ro { container-type: inline-size; }
.inv-plan { container-type: inline-size; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.inv-plan-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.inv-plan-head h3 { margin: 0; font-size: .95em; }
.inv-plan:not(.on) .inv-plan-head > .btn:last-child { display: none; }
.inv-plan-maker { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.inv-plan-maker > input, .inv-plan-maker > select { width: auto; }
.inv-plan-maker > input.inv-num { width: 4.5em; }
.inv-plan-maker > input[type=date] { width: 11em; }
.inv-plan-rows { display: flex; flex-direction: column; gap: 4px; }
.inv-planrow { display: grid; gap: 6px 10px; align-items: center; min-height: 36px; --pay-btn: 38px;
  grid-template-columns: 3em 10em 8em minmax(0, 1fr) var(--pay-btn); }
.inv-planrow > * { min-width: 0; }
.inv-planrow > input { width: 100%; }
.inv-planrow .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-plan-ro .inv-planrow { border-bottom: 1px solid var(--border); }
.inv-plan-sum { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
@media (pointer: coarse) { .inv-planrow { --pay-btn: 44px; } }
@container (max-width: 440px) {
  .inv-planrow { grid-template-columns: 2.5em minmax(0, 1fr) minmax(0, 1fr) var(--pay-btn); }
  .inv-planrow > :nth-child(4) { grid-row: 2; grid-column: 2 / 5; }
}
.inv-payto td select { width: 100%; max-width: 320px; }
@media (pointer: coarse) { .inv-paytable { --pay-btn: 44px; } .inv-payrow .icon-btn { min-height: 44px; } }
@container (max-width: 600px) {
  .inv-payrow { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, 1fr) var(--pay-btn) var(--pay-btn); row-gap: 4px; }
  .inv-payrow > :nth-child(4) { grid-row: 2; grid-column: 1 / 3; }
  .inv-payrow > :nth-child(5) { grid-row: 2; grid-column: 3 / 6; }
  .inv-payhead > :nth-child(4), .inv-payhead > :nth-child(5) { display: none; }
}
/* A phone: the day, the amount and the buttons first; how and the account
   under them; the reference last (left out when there is none). */
@container (max-width: 440px) {
  .inv-payrow { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) var(--pay-btn) var(--pay-btn); }
  .inv-payrow > :nth-child(1) { grid-row: 1; grid-column: 1; }
  .inv-payrow > :nth-child(3) { grid-row: 1; grid-column: 2; }
  .inv-payrow > :nth-child(6) { grid-row: 1; grid-column: 3; }
  .inv-payrow > :nth-child(7) { grid-row: 1; grid-column: 4; }
  .inv-payrow > :nth-child(2) { grid-row: 2; grid-column: 1; }
  .inv-payrow > :nth-child(4) { grid-row: 2; grid-column: 2 / 5; }
  .inv-payrow > :nth-child(5) { grid-row: 3; grid-column: 1 / 5; }
  .inv-payrow > span:nth-child(5):empty { display: none; }
  .inv-payhead { display: none; }
  /* Boxes need more room: the day across, how beside the amount, then the account. */
  .inv-payrow.editing > :nth-child(1) { grid-column: 1 / 3; }
  .inv-payrow.editing > :nth-child(2) { grid-row: 2; grid-column: 1; }
  .inv-payrow.editing > :nth-child(3) { grid-row: 2; grid-column: 2 / 5; }
  .inv-payrow.editing > :nth-child(4) { grid-row: 3; grid-column: 1 / 5; }
  .inv-payrow.editing > :nth-child(5) { grid-row: 4; grid-column: 1 / 5; }
}
.inv-star { font-size: 1.05em; color: var(--muted); }
@media (pointer: coarse) { .inv-star { min-width: 44px; min-height: 44px; font-size: 1.3em; } }
/* The lines behind the cost of sales on a phone: each a small card, nothing off to the side. */
@media (max-width: 560px) {
  .pl-sold .table-wrap { overflow: visible; }
  .pl-sold table, .pl-sold tbody { display: block; }
  .pl-sold thead { display: none; }
  .pl-sold tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto; gap: 3px 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
  .pl-sold td { display: block; padding: 0; border: 0; min-width: 0; background: none; }
  .pl-sold td.s-item { grid-column: 1 / 4; grid-row: 1; font-weight: 600; }
  .pl-sold td.s-cost { grid-column: 4; grid-row: 1; font-weight: 600; }
  .pl-sold td.s-who { grid-column: 1 / 4; grid-row: 2; }
  .pl-sold td.s-sale { grid-column: 4; grid-row: 2; }
  .pl-sold td.s-day, .pl-sold td.s-inv, .pl-sold td.s-qty, .pl-sold td.s-unit { grid-row: 3; color: var(--muted); font-size: .9em; }
  .pl-sold td.s-inv::before { content: '# '; }
  .pl-sold td.s-qty { grid-column: 3; text-align: left; }
  .pl-sold td.s-unit { grid-column: 4; }
  .pl-sold td[data-k]::before { content: attr(data-k) ' '; color: var(--muted); font-size: .85em; }
}
.inv-star.on { color: var(--accent); }
@media (max-width: 860px) { .inv-bottom { grid-template-columns: minmax(0, 1fr); } .inv-bottom .inv-totals { grid-column: 1; } .inv-bottom > .inv-paybox { grid-row: 2; } }

/* Receive payment: a customer's unpaid invoices, oldest first, each with its share. */
.inv-recv-list { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius-sm); margin: 8px 0; max-height: 46vh; overflow-y: auto; }
.inv-recv-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto 8em; gap: 10px; align-items: center; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.inv-recv-row:last-child { border-bottom: 0; }
.inv-recv-row input[type=checkbox] { width: 18px; height: 18px; }
.inv-recv-what { min-width: 0; }
.inv-recv-owes { white-space: nowrap; text-align: right; }
.inv-recv-row .inv-num { width: 100%; text-align: right; }
.inv-recv-sum { display: flex; justify-content: space-between; gap: 10px; padding: 4px 10px 10px; }
@media (max-width: 560px) {
  .inv-recv-list { max-height: none; overflow: visible; }
  .inv-recv-row { grid-template-columns: auto minmax(0, 1fr) 7.5em; }
  .inv-recv-owes { grid-column: 2; grid-row: 2; text-align: left; }
  .inv-recv-row .inv-num { grid-column: 3; grid-row: 1 / 3; }
}

/* A product's picture: small in the list and on an invoice's lines, larger in its form. */
.inv-thumb-img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; display: block; border: 1px solid var(--border); }
.inv-thumb-none { display: block; width: 40px; height: 40px; border-radius: 6px; background: var(--surface-2); border: 1px dashed var(--border); }
.inv-line-pic { width: 28px; height: 28px; object-fit: cover; border-radius: 5px; vertical-align: middle; margin-right: 8px; border: 1px solid var(--border); }
.inv-pic-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inv-pic { width: 120px; height: 120px; border-radius: var(--radius-sm); border: 1px dashed var(--border); background: var(--surface-2);
  display: flex; align-items: center; justify-content: center; overflow: hidden; }
.inv-pic img { width: 100%; height: 100%; object-fit: cover; }
.inv-pic-acts { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }

/* Import from another app: where the file is dropped, then what it holds. */
.inv-drop { border: 2px dashed var(--border); border-radius: var(--radius); padding: 28px 16px; display: flex; flex-direction: column;
  align-items: center; gap: 10px; color: var(--muted); background: var(--surface-2); }
.inv-drop.drop-over { border-color: var(--accent); color: var(--accent); }
.inv-imp-line { margin: 6px 0; }
.inv-imp-pays { margin: 10px 0; padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inv-imp-warn { margin: 10px 0; padding: 8px 12px; border: 1px solid var(--warn); border-radius: var(--radius-sm); font-size: .92em; }
.inv-imp-warn > div { margin-top: 3px; }
/* An invoice read from a file, as it will be made. */
.inv-imp-docs { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; max-height: 50vh; overflow-y: auto; }
.inv-imp-doc { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.inv-imp-docs .inv-imp-doc { margin: 0; }
.inv-imp-doc-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.inv-imp-doc-total { margin-left: auto; }
.inv-imp-doc-lines { margin: 8px 0 6px; border-top: 1px solid var(--border); }
.inv-imp-doc-line { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 14px; padding: 5px 0; border-bottom: 1px solid var(--border); }
.inv-imp-doc-line > span:last-child { text-align: right; min-width: 70px; }
.inv-imp-doc .pill { margin-left: 6px; font-size: .78em; }
@media (max-width: 560px) {
  .inv-imp-doc-line { grid-template-columns: 1fr auto; }
  .inv-imp-doc-line > span:first-child { grid-column: 1 / -1; }
}
/* A line's product box: the table's heading names it (its label kept for readers). */
.inv-desc .picker > label, .inv-line-prod .picker > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.inv-desc .picker { margin: 0; }
/* Files dragged over the invoices: dropped there, they are imported. */
.inv-drop-zone.drop-over { outline: 3px dashed var(--accent); outline-offset: 4px; border-radius: var(--radius); }
/* Every list's tick boxes as Invoices' (input.inv-pick): 18px in the app's
   colour, 24px on a touch screen - easier to hit; the whole cell ticks too. */
table td.pick input[type=checkbox], table th.pick input[type=checkbox], input.dt-pick-all, label.check > input.dt-pick-all {
  width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
@media (pointer: coarse) {
  table td.pick input[type=checkbox], table th.pick input[type=checkbox], input.dt-pick-all, label.check > input.dt-pick-all { width: 24px; height: 24px; }
}
.idle-row { margin-top: 12px; max-width: 420px; }
/* A customer's history: searched at once - invoices or every line sold. */
.cust-hist { margin-top: 14px; }
.cust-hist-bar { align-items: center; }
.cust-hist-bar .search { flex: 1 1 260px; }
.cust-hist-inv { border-bottom: 1px solid var(--border); }
.cust-hist-line { display: block; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 2px 12px 6px 22px; font-size: 13px; cursor: pointer; }
.cust-hist-line:hover { background: var(--surface-2); }
/* A customer's invoice unfolded in place, under its row. */
.cust-hist-inv.unfolded > .inv-row { background: var(--surface-2); }
.cust-peek { margin: 0 12px 12px 22px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); }
.cust-peek-lines { width: 100%; border-collapse: collapse; font-size: 13px; }
.cust-peek-lines th { text-align: left; font-weight: 600; color: var(--muted); padding: 2px 6px 4px;
  border-bottom: 1px solid var(--border); }
.cust-peek-lines td { padding: 4px 6px; vertical-align: top; }
.cust-peek-lines .num { text-align: right; white-space: nowrap; }
.cust-peek-sums { margin: 8px 0 0 auto; max-width: 340px; font-size: 13px; }
.cust-peek-sum { display: flex; justify-content: space-between; gap: 12px; padding: 2px 6px; }
.cust-peek-sum > :last-child { white-space: nowrap; }
.cust-peek-sum.total { border-top: 1px solid var(--border); margin-top: 2px; padding-top: 4px; }
.cust-peek-notes { margin-top: 8px; font-size: 13px; white-space: pre-wrap; }
.cust-peek-foot { display: flex; justify-content: flex-end; margin-top: 10px; }
.cust-peek { overflow-x: auto; }
@media (max-width: 640px) {
  .cust-peek { margin: 0 0 12px; padding: 8px; }
  .cust-peek-lines th, .cust-peek-lines td { padding-left: 4px; padding-right: 4px; }
  .cust-peek-lines td:first-child { overflow-wrap: anywhere; }
  .cust-peek-lines th:nth-child(3), .cust-peek-lines td:nth-child(3) { display: none; }
  .cust-peek-sums { max-width: none; }
}
/* Products and services: the search beside the New button. */
.inv-item-search { flex: 1 1 260px; }
/* Look-alike products combined: a card per group - the one kept, those going into it. */
.inv-twins { display: grid; gap: 12px; }
.inv-twin { padding: 10px 12px; }
.inv-twin-head { display: grid; grid-template-columns: 44px 44px 1fr; gap: 0; padding: 0 0 4px; }
.inv-twin-head > span:last-child { grid-column: 2 / 4; }
.inv-twin-row { display: grid; grid-template-columns: 44px 44px 1fr auto; align-items: center; padding: 4px 0;
  border-top: 1px solid var(--border); }
.inv-twin-row.kept .inv-twin-name strong { color: var(--accent); }
.inv-twin-row.kept .inv-twin-tick { visibility: hidden; }
.inv-twin-keep input, .inv-twin-tick input { width: 20px; height: 20px; }
.inv-twin-acts { display: flex; justify-content: flex-end; gap: 8px; padding-top: 8px; }
.inv-combine-list { max-height: 50vh; overflow: auto; margin: 8px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.inv-combine-row { display: flex; gap: 10px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.inv-combine .search { width: 100%; }
@media (max-width: 640px) {
  .inv-twin-row { grid-template-columns: 36px 36px 1fr; }
  .inv-twin-used { grid-column: 3; }
  .inv-twin-head { grid-template-columns: 36px 36px 1fr; }
}
/* A customer's papers in Invoicing (a tax exempt form): between the tiles and the history. */
.inv-cust-files { margin-top: 14px; }
/* The statement line that paid an entry, whole, under "matched": proof of payment. */
.trail-bank { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 2px 0 0 16px; }
/* A check and the billing sheet it pays, offered on Receipts as one invoice paid. */
.cb-form { text-align: left; padding: 10px 12px; border-left: 3px solid var(--accent); background: var(--surface-2, transparent); border-radius: 8px; min-width: 0; }
.cb-head { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: flex-start; margin-bottom: 8px; }
.cb-papers { display: flex; gap: 6px; flex-wrap: wrap; }
.cb-same { margin: 0 0 8px; }
.cb-rate { margin: 6px 0 0; }
.cb-grid small { display: block; margin-top: 2px; }
/* Mark as paid / received in parts: a row a part, what is left said. */
.settle-split-btn { margin: 10px 0; }
.sp-list { display: grid; gap: 8px; }
.sp-row { display: grid; grid-template-columns: 1fr 1.2fr 1.6fr 1.2fr auto; gap: 8px; align-items: end;
  padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.sp-row .icon-btn { margin-bottom: 6px; }
.sp-foot { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 8px; }
.settle-left { margin: 0; }
@media (max-width: 640px) {
  .sp-row { grid-template-columns: 1fr 1fr; }
  .sp-row .icon-btn { grid-column: 1 / -1; justify-self: end; margin: 0; }
}

/* The phone's + (paintFab): bottom corner over the menu; a tap dims the
   page and raises the labelled actions above it. Not on a wide screen. */
.fab { display: none; }
@media (max-width: 720px) {
  .fab:not([hidden]) { display: block; }
  .fab-btn { position: fixed; right: 16px; bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 60;
    width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
    font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0, 0, 0, .3); cursor: pointer;
    display: grid; place-items: center; transition: transform .15s; }
  .fab-btn:active { transform: scale(.94); }
  .fab-shade { position: fixed; inset: 0; z-index: 58; background: rgba(0, 0, 0, .45); opacity: 0; pointer-events: none;
    transition: opacity .15s; }
  .fab-list { position: fixed; right: 16px; bottom: calc(146px + env(safe-area-inset-bottom)); z-index: 59;
    display: flex; flex-direction: column; align-items: flex-end; gap: 12px; pointer-events: none; }
  .fab-item { display: flex; align-items: center; gap: 10px; border: 0; background: none; padding: 0; cursor: pointer;
    opacity: 0; transform: translateY(12px); transition: opacity .15s, transform .15s; }
  .fab-label { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 18px;
    padding: 8px 14px; font-weight: 600; font-size: 15px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
  .fab-ico { width: 48px; height: 48px; border-radius: 50%; background: var(--surface); color: var(--text);
    border: 1px solid var(--border); display: grid; place-items: center; font-size: 22px; box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }
  .fab.open .fab-shade { opacity: 1; pointer-events: auto; }
  .fab.open .fab-list { pointer-events: auto; }
  .fab.open .fab-item { opacity: 1; transform: none; }
  /* The page's last row can scroll above it. */
  body:has(.fab:not([hidden])) { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
}
/* The entries a rule made before it changed: the bank's long words wrap,
   so the amount stays in sight on a phone. */
.rule-behind td:nth-child(3) { overflow-wrap: anywhere; }
.rule-behind td:first-child, .rule-behind th:first-child { width: 1%; }
.rule-behind th:nth-child(2) { text-align: left; }
@media (max-width: 720px) {
  .rule-behind, .rule-behind thead, .rule-behind tbody { display: block; width: 100%; }
  .rule-behind tr { display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "t d a" ". x x"; gap: 2px 10px; align-items: center; }
  .rule-behind td, .rule-behind th { border: 0; padding: 4px 0; white-space: normal; width: auto; }
  .rule-behind tr { padding: 8px 12px; border-bottom: 1px solid var(--border); }
  .rule-behind td:nth-child(1), .rule-behind th:nth-child(1) { grid-area: t; }
  .rule-behind td:nth-child(2) { grid-area: d; }
  .rule-behind td:nth-child(3) { grid-area: x; }
  .rule-behind td:nth-child(4) { grid-area: a; }
  .rule-behind th { background: transparent; }
  .rule-behind th:nth-child(2) { grid-column: 2 / 4; text-align: left; }
}
/* A text file in the quick view: a CSV as its table, an OFX as text. */
.qv-sheet { overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.qv-sheet table { margin: 0; font-size: 13px; }
.qv-sheet td { white-space: nowrap; }
.qv-sheet td.qv-sheet-note { white-space: normal; color: var(--muted); }
.qv-pre { margin: 0; padding: 12px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* Invoices: New, Receive and Import on one line; on a narrow phone Receive says less. */
.inv-acts { display: flex; gap: 8px; align-items: center; }
.inv-acts .btn { white-space: nowrap; }
.inv-acts .lbl-short { display: none; }
@media (max-width: 640px) {
  .inv-acts { flex: 1 1 100%; }
  .inv-acts .btn { flex: 1 1 auto; padding-left: 10px; padding-right: 10px; justify-content: center; }
}
@media (max-width: 420px) {
  .inv-acts .lbl-full { display: none; }
  .inv-acts .lbl-short { display: inline; }
}

/* The box: an overpaid part, its return already entered - asked. */
.lx-ret { display: flex; flex-direction: column; gap: 4px; }
.lx-ret .check { display: flex; gap: 6px; align-items: center; }

/* Import: each product not in the list, what it is. */
.inv-imp-what { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; align-items: center; }
.inv-imp-what select { width: 100%; min-width: 0; }
