/* ==========================================================================
   Zindagi — Billing (invoices, customers, billing profiles)
   Tokens only, per DESIGN_SPEC. Density matches the task rows: ~36px,
   hairline dividers, segmented controls rather than pills.
   ========================================================================== */

/* ---------- Banners ---------- */
.inv-banner {
  padding: var(--z-space-3) var(--z-space-4);
  border-radius: var(--z-radius-md);
  font-size: var(--z-fs-small);
  margin-bottom: var(--z-space-4);
  border: 1px solid var(--z-border);
  background: var(--z-surface);
}
.inv-banner--warn {
  background: var(--z-warning-soft);
  color: var(--z-warning-text);
  border-color: var(--z-warning-border);
}
.inv-banner--error {
  background: var(--z-danger-soft);
  color: var(--z-danger);
  border-color: var(--z-danger-border);
}
.pending-list { margin: var(--z-space-2) 0 0; padding-left: var(--z-space-4); }

/* ---------- Outstanding strip ----------
   Per-currency lines. Never summed across currencies: with denomination-only
   multi-currency there is no rate to sum with. */
.inv-strip {
  display: flex;
  flex-wrap: wrap;
  gap: var(--z-space-6);
  margin-bottom: var(--z-space-3);
  padding: 0 var(--z-space-3) var(--z-space-3);
  border-bottom: 1px solid var(--z-border-soft);
}
.inv-strip__cell {
  display: flex;
  flex-direction: column;
  gap: var(--z-space-1);
  min-width: 120px;
}
.inv-strip__sub {
  font-size: var(--z-fs-caption);
  color: var(--z-danger);
  font-weight: 500;
}
.inv-strip__sub--quiet { color: var(--z-text-3); font-weight: 400; }
.inv-strip__k {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
}
.inv-strip__v {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-strong);
  font-weight: 600;
  color: var(--z-text);
  font-variant-numeric: tabular-nums;
}
.inv-strip__v--warn { color: var(--z-danger); }

/* Per-entity breakdown behind the year-to-date figure. Opens on hover for the
   mouse and on focus for touch and keyboard — a hover-only disclosure would be
   unreachable on the phone, which is where this page is read most. */
.inv-strip__cell--pop { position: relative; cursor: default; }
.inv-strip__cell--pop:focus { outline: none; }
.inv-strip__cell--pop:focus-visible { box-shadow: var(--z-focus-ring); }
.inv-strip__cell--pop .inv-strip__k::after {
  content: "2";
  margin-left: var(--z-space-1);
  color: var(--z-text-muted);
}
.inv-pop {
  position: absolute;
  top: calc(100% + var(--z-space-2));
  left: 0;
  z-index: 20;
  min-width: 240px;
  padding: var(--z-space-3);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-lg);
  box-shadow: var(--z-shadow-md);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.12s ease;
}
.inv-strip__cell--pop:hover .inv-pop,
.inv-strip__cell--pop:focus-within .inv-pop,
.inv-strip__cell--pop:focus .inv-pop { opacity: 1; visibility: visible; }
.inv-pop__head {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  margin-bottom: var(--z-space-2);
}
.inv-pop__row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--z-space-3);
  align-items: baseline;
  padding: var(--z-space-1) 0;
}
.inv-pop__row + .inv-pop__row { border-top: 1px solid var(--z-border-soft); }
.inv-pop__name { font-size: var(--z-fs-small); color: var(--z-text-body); }
.inv-pop__n {
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  font-variant-numeric: tabular-nums;
}
.inv-pop__amt {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-small);
  font-variant-numeric: tabular-nums;
  color: var(--z-text);
}
.inv-pop__note {
  margin-top: var(--z-space-2);
  padding-top: var(--z-space-2);
  border-top: 1px solid var(--z-border-soft);
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  line-height: 1.45;
}

/* ---------- Monthly run ----------
   The month reviewed in one grid: tick, correct the date or amount, issue.
   Same column rhythm as the invoice list so the eye does not have to relearn
   it, but only five columns — this is a worksheet, not a record. */
.mrun {
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  margin-bottom: var(--z-space-4);
  overflow: hidden;
}
.mrun__head,
.mrun__row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 148px 168px 116px;
  column-gap: var(--z-space-3);
  align-items: center;
  padding: 0 var(--z-space-3);
}
.mrun__head {
  min-height: var(--z-control-sm);
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  background: var(--z-surface-2);
  border-bottom: 1px solid var(--z-border);
}
.mrun__row {
  min-height: 44px;   /* a touch target, not a list row: these hold inputs */
  border-bottom: 1px solid var(--z-border-soft);
}
.mrun__row:last-child { border-bottom: none; }
/* Billed already: still listed, so you can see the run did not skip anyone. */
.mrun__row--done { background: var(--z-surface-2); }
.mrun__row--done .mrun__name { color: var(--z-text-2); }
.mrun__pick { display: flex; align-items: center; }
.mrun__pick input { width: 16px; height: 16px; margin: 0; accent-color: var(--z-primary); }
.mrun__name {
  font-size: var(--z-fs-body);
  color: var(--z-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mrun__note {
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  margin-left: var(--z-space-2);
}
.mrun__date,
.mrun__amt input {
  height: var(--z-control-sm);
  padding: 0 var(--z-space-2);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  background: var(--z-surface);
  color: var(--z-text-body);
  font-family: var(--z-font);
  font-size: var(--z-fs-small);
  line-height: normal;
  width: 100%;
}
.mrun__amt {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  column-gap: var(--z-space-2);
}
.mrun__amt input {
  font-family: var(--z-font-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.mrun__cur { font-size: var(--z-fs-caption); color: var(--z-text-3); }
.mrun__fixed {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  text-align: right;
}
.mrun__from {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The contract rate and the last invoice disagree — worth seeing before
   twelve more months inherit whichever one wins. */
.mrun__drift { color: var(--z-warning-text); }
.mrun__foot {
  margin: 0 0 var(--z-space-4);
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  line-height: 1.5;
}
.mrun__busy {
  margin-right: auto;
  align-self: center;
  font-size: var(--z-fs-small);
  color: var(--z-text-3);
  opacity: 0;
}
.mrun__busy.htmx-request { opacity: 1; }
.mrun__fails { margin: var(--z-space-2) 0 0; padding-left: var(--z-space-4); }

/* Result rows: no inputs left, so the grid changes shape. */
.mrun__row--out {
  grid-template-columns: 116px minmax(0, 1fr) 96px 148px auto;
}
.mrun__num { font-family: var(--z-font-mono); font-size: var(--z-fs-small); }
.mrun__date-out { font-size: var(--z-fs-small); color: var(--z-text-2); }

@media (max-width: 767.98px) {
  /* Two columns, the tick and the name on one line and the fields under it —
     five columns of inputs on a phone is a horizontal scrollbar. */
  .mrun__head { display: none; }
  .mrun__row,
  .mrun__row--out {
    grid-template-columns: 28px minmax(0, 1fr);
    row-gap: var(--z-space-2);
    padding: var(--z-space-3);
  }
  .mrun__date, .mrun__amt, .mrun__from,
  .mrun__date-out, .mrun__num { grid-column: 2; }
  .mrun__date { height: var(--z-touch-min); }
  .mrun__amt input { height: var(--z-touch-min); }
}

/* ---------- Due to bill ----------
   Remembering to bill is the real trigger, not the billing. One tap clones
   last month's invoice, rolls the period and opens the draft. */
.due-strip {
  margin-bottom: var(--z-space-4);
  padding: var(--z-space-3) var(--z-space-4);
  background: var(--z-primary-soft);
  border: 1px solid var(--z-primary-border);
  border-radius: var(--z-radius-md);
}
.due-strip__head {
  display: flex;
  gap: var(--z-space-2);
  align-items: baseline;
  margin-bottom: var(--z-space-3);
}
.due-strip__title {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-primary-active);
}
.due-strip__hint { font-size: var(--z-fs-caption); color: var(--z-text-3); }
.due-strip__items { display: flex; gap: var(--z-space-2); flex-wrap: wrap; }
.due-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: var(--z-space-2) var(--z-space-3);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  min-width: 180px;
}
.due-card__name { font-weight: 600; color: var(--z-text); }
/* Only rendered where a customer has more than one arrangement to tell apart. */
.due-card__which { font-weight: 400; font-size: var(--z-fs-caption); color: var(--z-text-3); }
.due-card__last {
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  margin-bottom: var(--z-space-1);
}

/* ---------- Invoice list rows ----------
   Capped so the money does not end up a screen-width away from the customer
   name on a wide monitor. Date is dropped (Due is what drives action) and
   Balance folded into Amount, since they were identical on every row. */
.inv-list { max-width: 1180px; }

.inv-head,
.inv-row {
  display: grid;
  grid-template-columns:
    88px             /* date     — leads the row, and the default sort key */
    104px            /* entity   — fits "Aevum Solutions"; ellipsis past that */
    112px            /* number   — mono, fits INV-2627-0001 */
    minmax(0, 1fr)   /* customer · subject */
    92px             /* due */
    128px            /* status */
    168px            /* amount */
    92px;            /* actions — 3x28 + 2x4, reserved so hover shifts nothing */
  column-gap: var(--z-space-3);
  align-items: center;
  padding: 0 var(--z-space-3);
}
.inv-head {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  border-bottom: 1px solid var(--z-border);
}
.inv-head { padding-bottom: var(--z-space-2); }
.inv-row {
  min-height: var(--z-row-height);
  border-bottom: 1px solid var(--z-border-soft);
  transition: background 60ms ease;
}
.inv-row:hover { background: var(--z-row-hover); }

/* Overdue is a property of the row, not a status value — same treatment as
   .task-row[data-overdue]. Keeps the status column free to show whether the
   invoice is actually unsent, partly paid or settled. */
.inv-row[data-overdue="true"] { box-shadow: inset 2px 0 0 var(--z-danger); }
.inv-row[data-overdue="true"] .inv-row__due { color: var(--z-danger); font-weight: 600; }
.inv-row__due,
.inv-row__date {
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  white-space: nowrap;
}
.inv-row__date { font-variant-numeric: tabular-nums; }
.inv-row__entity {
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-row__late { font-variant-numeric: tabular-nums; margin-left: var(--z-space-1); }

.inv-head .r, .inv-row .r,
.cust-head .r, .cust-row .r,
.exp-head .r, .exp-row .r { text-align: right; }

.inv-row__num {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-small);
  font-weight: 500;
  color: var(--z-text);
  text-decoration: none;
}
.inv-row__num--draft { color: var(--z-text-muted); font-style: italic; }
.inv-row__cust {
  display: flex;
  align-items: baseline;
  gap: var(--z-space-2);
  min-width: 0;
  white-space: nowrap;      /* ellipsis does nothing without this */
  overflow: hidden;
  text-decoration: none;
}
.inv-row__name {
  font-weight: 500;
  color: var(--z-text);
  flex: 0 1 auto;
  max-width: 55%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.inv-row__subj {
  color: var(--z-text-3);
  font-size: var(--z-fs-small);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Literal characters, not CSS escapes — a mistyped escape wrote NUL
   bytes into this file and the separator rendered as junk. */
.inv-row__subj::before { content: "·"; margin-right: var(--z-space-2); color: var(--z-text-muted); }
.inv-row__meta { font-size: var(--z-fs-small); color: var(--z-text-2); }
.inv-row__sub {
  display: block;
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.money {
  font-variant-numeric: tabular-nums;
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-small);
}
.mono { font-family: var(--z-font-mono); }
.cur { color: var(--z-text-3); font-size: var(--z-fs-caption); }

/* The amount is primary data, not metadata. The currency code gets its own
   aligned track: right-aligning the whole cell put the code at a different x
   on every row, which made a mixed-currency list unscannable. */
.inv-row__total {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: baseline;
  column-gap: var(--z-space-2);
  font-size: var(--z-fs-body);
  color: var(--z-text);
}
.inv-row__total > .cur { font-family: var(--z-font); text-align: left; }
.inv-row__total > .amt { text-align: right; }
.inv-row__bal {
  grid-column: 2;
  text-align: right;
  font-size: var(--z-fs-caption);
  color: var(--z-warning-text);
}
.dim { color: var(--z-text-muted); }

.inv-row__acts { display: flex; gap: var(--z-space-1); justify-content: flex-end; opacity: 0; }
.inv-row:hover .inv-row__acts,
.inv-row:focus-within .inv-row__acts,
.cust-row:hover .inv-row__acts,
.cust-row:focus-within .inv-row__acts { opacity: 1; }

/* Hover-reveal is a desktop nicety. On touch there is no hover, so the
   actions must never be hidden — see the mobile rules at the foot of file. */
@media (hover: none) { .inv-row__acts { opacity: 1; } }

.icb {
  width: var(--z-control-sm);
  height: var(--z-control-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--z-border);
  background: var(--z-surface);
  border-radius: var(--z-radius-sm);
  cursor: pointer;
  color: var(--z-text-2);
  font-size: 12px;
  text-decoration: none;
}
.icb:hover {
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
  border-color: var(--z-primary);
}


/* ---------- Status pips ----------
   Glyph language matching the task statuses, not pills. */
.st {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
  white-space: nowrap;
}
.st::before { content: ""; width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto; }
.st--draft::before { border: 1.5px dashed var(--z-status-backlog); }
.st--issued::before { border: 1.5px solid var(--z-status-todo); }
.st--partly::before {
  border: 1.5px solid var(--z-status-in-progress);
  background: linear-gradient(90deg, var(--z-status-in-progress) 50%, transparent 50%);
}
.st--paid::before { background: var(--z-status-done); border: 1.5px solid var(--z-status-done); }
.st--void::before { background: var(--z-text-muted); border: 1.5px solid var(--z-text-muted); }
.st--issued { color: var(--z-text-2); }

/* ---------- Editor / detail shell ---------- */
.ed,
.det {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: var(--z-space-5);
  align-items: start;
}
@media (max-width: 1023px) {
  .ed, .det { grid-template-columns: 1fr; }
}

.card {
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  padding: var(--z-space-4);
  margin-bottom: var(--z-space-4);
}
.card__t {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  margin: 0 0 var(--z-space-3);
}
.card--form { max-width: 720px; }

.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--z-space-3); }
@media (max-width: 640px) { .fgrid { grid-template-columns: 1fr; } }
.field--full { grid-column: 1 / -1; }

.field textarea,
.field select,
.field input[type="text"],
.field input[type="date"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="search"],
.field input[type="file"] {
  font: inherit;
  padding: 7px 9px;
  min-height: 36px;
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  background: var(--z-surface);
  color: var(--z-text-body);
  width: 100%;
}
.field textarea { resize: vertical; }
.field__hint { font-size: var(--z-fs-caption); color: var(--z-text-3); }
.field__hint--calc { color: var(--z-primary-active); font-weight: 500; }
.field__static {
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-small);
  padding: 8px 0;
  color: var(--z-text);
}

/* ---------- Line items ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  text-align: left;
  padding: 0 var(--z-space-2) var(--z-space-2);
  border-bottom: 1px solid var(--z-border);
  white-space: nowrap;
}
.lines td {
  padding: var(--z-space-2);
  border-bottom: 1px solid var(--z-border-soft);
  vertical-align: top;
}
.lines .r { text-align: right; }
.lines input,
.lines select {
  font: inherit;
  font-size: var(--z-fs-small);
  padding: 5px 7px;
  min-height: 32px;
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-sm);
  background: var(--z-surface);
  width: 100%;
}
.lines input.mono {
  font-family: var(--z-font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lines td > input + input { margin-top: 4px; }
.lines__add { margin-top: var(--z-space-3); }

/* Under 768px a table with a right-aligned money column cannot work.
   Stack each row into a card rather than scrolling horizontally. */
@media (max-width: 767.98px) {
  .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100%; }
  .lines thead { display: none; }
  .lines tr {
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius-md);
    padding: var(--z-space-2);
    margin-bottom: var(--z-space-2);
    background: var(--z-surface);
  }
  .lines td { border: 0; padding: var(--z-space-1) 0; }
  .lines td::before {
    content: attr(data-l);
    display: block;
    font-size: var(--z-fs-caption);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
    color: var(--z-text-3);
    margin-bottom: 2px;
  }
  .lines .r { text-align: left; }
  .lines input.mono { text-align: left; }
}

/* ---------- Totals ---------- */
.tot { margin-left: auto; max-width: 340px; margin-top: var(--z-space-4); }
.tot__r {
  display: flex;
  justify-content: space-between;
  gap: var(--z-space-4);
  padding: 5px 0;
  font-size: var(--z-fs-small);
  color: var(--z-text-2);
}
.tot__r--grand {
  border-top: 1px solid var(--z-border);
  margin-top: var(--z-space-2);
  padding-top: var(--z-space-3);
  font-size: var(--z-fs-strong);
  font-weight: 700;
  color: var(--z-text);
}
.tot__r--dim { color: var(--z-text-3); }
.tot__v { font-family: var(--z-font-mono); font-variant-numeric: tabular-nums; }

/* ---------- Aside ---------- */
.aside__rows { margin-top: var(--z-space-3); }
.aside__row {
  display: flex;
  justify-content: space-between;
  gap: var(--z-space-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--z-border-soft);
  font-size: var(--z-fs-small);
}
.aside__row--strong { font-weight: 600; color: var(--z-text); }
.aside__k { color: var(--z-text-3); }
.aside__v { color: var(--z-text); font-weight: 500; text-align: right; }
.aside__words {
  font-size: var(--z-fs-small);
  font-weight: 600;
  font-style: italic;
  color: var(--z-text);
}

.callout {
  padding: var(--z-space-2) var(--z-space-3);
  border-radius: var(--z-radius-md);
  font-size: var(--z-fs-small);
  background: var(--z-info-soft);
  color: var(--z-info-text);
  border: 1px solid var(--z-info-border);
}
.callout--warn {
  background: var(--z-warning-soft);
  color: var(--z-warning-text);
  border-color: var(--z-warning-border);
}

/* ---------- Sticky action bar ---------- */
.actionbar {
  position: sticky;
  bottom: 0;
  display: flex;
  gap: var(--z-space-2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--z-space-3);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  box-shadow: var(--z-shadow-md);
  margin-top: var(--z-space-4);
  padding-bottom: calc(var(--z-space-3) + env(safe-area-inset-bottom));
}
.actionbar__spacer { flex: 1; }

/* ---------- PDF preview ----------
   The real artefact, inline. There is no second HTML renderer to drift from. */
.det__doc {
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  overflow: hidden;
}
.pdf-frame {
  width: 100%;
  height: 78vh;
  border: 0;
  display: block;
  background: var(--z-surface-2);
}
.pdf-frame__fallback {
  padding: var(--z-space-2) var(--z-space-3);
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
  border-top: 1px solid var(--z-border-soft);
}
@media (max-width: 767.98px) { .pdf-frame { height: 60vh; } }

/* ---------- Checkboxes, disclosure, roll diff ---------- */
.chk {
  display: flex;
  gap: var(--z-space-2);
  align-items: flex-start;
  padding: var(--z-space-3);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  background: var(--z-surface-2);
  margin-top: var(--z-space-3);
}
.chk--inline { background: transparent; border: 0; padding: var(--z-space-2) 0; }
.chk input { margin-top: 2px; width: 16px; height: 16px; flex: 0 0 auto; }
.chk__t { font-size: var(--z-fs-small); font-weight: 500; color: var(--z-text); display: block; }
.chk__d { font-size: var(--z-fs-caption); color: var(--z-text-3); display: block; }
.chk__d--warn { color: var(--z-warning); font-weight: 500; }

.roll-diff {
  list-style: none;
  margin: var(--z-space-2) 0 0;
  padding: 0;
  font-size: var(--z-fs-caption);
}
.roll-diff li { display: flex; gap: 6px; align-items: baseline; padding: 2px 0; flex-wrap: wrap; }
.roll-diff__field { color: var(--z-text-3); min-width: 92px; }
.roll-diff__before { color: var(--z-text-3); text-decoration: line-through; }
.roll-diff__arrow { color: var(--z-text-muted); }
.roll-diff__after { color: var(--z-primary-active); font-weight: 600; }

.disclosure {
  border-top: 1px solid var(--z-border-soft);
  margin-top: var(--z-space-3);
  padding-top: var(--z-space-3);
}
.disclosure > summary {
  cursor: pointer;
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  margin-bottom: var(--z-space-3);
}

.stack { display: flex; flex-direction: column; gap: var(--z-space-2); margin-top: var(--z-space-3); }
.stack input[type="text"] {
  font: inherit;
  padding: 0 9px;
  min-height: var(--z-control-lg);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  width: 100%;
}

.btn--danger { color: var(--z-danger); border-color: var(--z-border-strong); }
.btn--danger:hover { background: var(--z-danger-soft); border-color: var(--z-danger); }
/* .btn--sm lives with .btn in app.css — a shared variant defined in a
   screen-specific file is how the scale drifted in the first place. */

.slide-over__panel--wide { max-width: 640px; }
.thumb {
  max-width: 140px;
  max-height: 48px;
  display: block;
  margin-bottom: var(--z-space-2);
  border: 1px solid var(--z-border-soft);
  border-radius: var(--z-radius-sm);
  background: var(--z-surface-2);
}
.tag {
  font-size: var(--z-fs-caption);
  font-weight: 600;
  padding: 1px 6px;
  border-radius: var(--z-radius-sm);
  background: var(--z-primary-soft);
  color: var(--z-primary-active);
}
.tag--warn { background: var(--z-warning-soft); color: var(--z-warning-text); }

/* ---------- Customers ---------- */
.cust-head,
.cust-row {
  display: grid;
  grid-template-columns: 1fr 148px 132px 78px 140px 120px 124px 96px;
  gap: var(--z-space-2);
  align-items: center;
  padding: var(--z-space-2) var(--z-space-3);
}
.cust-head {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  border-bottom: 1px solid var(--z-border);
}
.cust-row { min-height: var(--z-row-height); border-bottom: 1px solid var(--z-border-soft); }
.cust-row:hover { background: var(--z-row-hover); }
/* Missing data, not a state of the customer — reads as something to fix. */
.cust-row__gstin--missing { color: var(--z-warning-text); }

/* ---------- Contracts ----------
   The recurring arrangements the monthly run reads from. Ended and paused
   rows stay in the list at reduced weight: a contract you cannot see is one
   you forget you paused. */
.ctr-list { max-width: 1180px; }
.ctr-head,
.ctr-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 200px 116px 156px 96px 148px 44px;
  gap: var(--z-space-2);
  align-items: center;
  padding: var(--z-space-2) var(--z-space-3);
}
.ctr-head {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  border-bottom: 1px solid var(--z-border);
}
.ctr-row {
  min-height: var(--z-row-height);
  border-bottom: 1px solid var(--z-border-soft);
}
.ctr-row:hover { background: var(--z-row-hover); }
.ctr-row[data-status="ended"] { opacity: 0.6; }
.ctr-row__cust { font-size: var(--z-fs-body); color: var(--z-text); }
.ctr-row__name { display: flex; flex-direction: column; min-width: 0; }
.ctr-row__sub { font-size: var(--z-fs-caption); color: var(--z-text-3); }
.ctr-row__dates,
.ctr-row__day { font-size: var(--z-fs-small); color: var(--z-text-2); }
.ctr-row__amt {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: baseline;
  column-gap: var(--z-space-2);
  font-size: var(--z-fs-body);
}
.ctr-row__amt > .cur { font-size: var(--z-fs-caption); color: var(--z-text-3); }
.ctr-row__amt > .amt {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.ctr-row__acts { display: flex; justify-content: flex-end; }

/* Contract states reuse the invoice chip, so the vocabulary stays one thing. */
.st--active::before {
  background: var(--z-status-done);
  border: 1.5px solid var(--z-status-done);
}
.st--paused::before {
  border: 1.5px solid var(--z-status-in-progress);
  background: linear-gradient(90deg, var(--z-status-in-progress) 50%, transparent 50%);
}
.st--ended::before {
  background: var(--z-text-muted);
  border: 1.5px solid var(--z-text-muted);
}
.st--ended { color: var(--z-text-3); }

@media (max-width: 767.98px) {
  .ctr-head { display: none; }
  .ctr-row {
    grid-template-columns: minmax(0, 1fr) auto;
    row-gap: var(--z-space-1);
    padding: var(--z-space-3);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius-md);
    background: var(--z-surface);
    margin-bottom: var(--z-space-2);
  }
  .ctr-row__amt { justify-self: end; }
  .ctr-row__acts .icb { width: 44px; height: 44px; }
}

/* ---------- Billing profiles ---------- */
.prof-grid {
  display: grid;
  gap: var(--z-space-3);
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.prof-card {
  display: block;
  padding: var(--z-space-4);
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
  color: inherit;
  text-decoration: none;
}
.prof-card:hover { border-color: var(--z-primary); background: var(--z-row-hover); }
.prof-card__head { display: flex; gap: var(--z-space-2); align-items: center; flex-wrap: wrap; }
.prof-card__name { font-weight: 600; color: var(--z-text); }
.prof-card__legal { font-size: var(--z-fs-small); color: var(--z-text-2); margin-top: 2px; }
.prof-card__facts { margin: var(--z-space-3) 0 0; display: grid; gap: 4px; }
.prof-card__facts > div {
  display: flex;
  justify-content: space-between;
  gap: var(--z-space-2);
  font-size: var(--z-fs-small);
}
.prof-card__facts dt { color: var(--z-text-3); margin: 0; }
.prof-card__facts dd { margin: 0; color: var(--z-text); }
.prof-card__warn {
  margin-top: var(--z-space-3);
  font-size: var(--z-fs-caption);
  color: var(--z-warning);
  font-weight: 500;
}
.lut-block {
  margin-top: var(--z-space-4);
  border-top: 1px solid var(--z-border-soft);
  padding-top: var(--z-space-3);
}

/* ---------- Rates and accountant export ---------- */
.rate-form { display: flex; gap: var(--z-space-3); align-items: flex-end; flex-wrap: wrap; }
.rate-form .field { flex: 1 1 140px; }
.inv-head--rates, .inv-row--rates { grid-template-columns: 90px 120px 140px 1fr; }

.exp-head,
.exp-row {
  display: grid;
  grid-template-columns: 124px 84px 1fr 150px 108px 96px 116px 116px;
  gap: var(--z-space-2);
  align-items: center;
  padding: var(--z-space-2) var(--z-space-3);
}
.exp-head {
  font-size: var(--z-fs-caption);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--z-text-3);
  border-bottom: 1px solid var(--z-border);
}
.exp-row {
  min-height: var(--z-row-height);
  border-bottom: 1px solid var(--z-border-soft);
  font-size: var(--z-fs-small);
}
.exp-row--void { color: var(--z-text-muted); text-decoration: line-through; }
.exp-total {
  display: flex;
  justify-content: space-between;
  padding: var(--z-space-3);
  font-weight: 700;
  border-top: 2px solid var(--z-border);
}

/* ---------- Timeline (payments, LUT history, activity) ---------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl li {
  display: flex;
  gap: var(--z-space-2);
  align-items: baseline;
  padding: var(--z-space-2) 0;
  border-bottom: 1px solid var(--z-border-soft);
  font-size: var(--z-fs-small);
}
.tl li:last-child { border-bottom: 0; }
.tl__d {
  flex: 0 0 auto;
  min-width: 58px;
  font-family: var(--z-font-mono);
  font-size: var(--z-fs-caption);
  color: var(--z-text-3);
}
.tl__x { flex: 1 1 auto; min-width: 0; color: var(--z-text-2); }
.tl__sub { font-size: var(--z-fs-caption); color: var(--z-text-3); }

/* The invoice editor is a full page, not a slide-over: ~28 fields is not a
   panel. Reserves room for the sticky action bar at the foot. */
.ed-form { display: block; padding-bottom: var(--z-space-4); }
.empty--card {
  background: var(--z-surface);
  border: 1px solid var(--z-border);
  border-radius: var(--z-radius-md);
}
.page-header__title--mono { font-family: var(--z-font-mono); font-size: var(--z-fs-h2); }

/* ---------- Mobile ----------
   Cards, never a horizontally scrolling table, and every action a 44px target.
   Named areas rather than source order: with a bare `1fr auto` the eight cells
   paired off arbitrarily and you got two unlabelled dates side by side. */
@media (max-width: 767.98px) {
  .inv-head, .cust-head, .exp-head { display: none; }

  /* The breakdown opens on tap here, so it has to fit the viewport rather
     than run off the right edge at its desktop min-width. */
  .inv-pop { min-width: 0; width: min(280px, calc(100vw - var(--z-space-8))); }

  .inv-row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "cust   amount"
      "num    status"
      "date   due"
      "entity entity";
    row-gap: var(--z-space-1);
    column-gap: var(--z-space-3);
    align-items: baseline;
    min-height: 0;
    padding: var(--z-space-3);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius-md);
    background: var(--z-surface);
    margin-bottom: var(--z-space-2);
  }
  .inv-row__cust  { grid-area: cust; }
  .inv-row__num   { grid-area: num; }
  .inv-row__date  { grid-area: date; }
  .inv-row__entity { grid-area: entity; }
  .inv-row__due   { grid-area: due; }
  .inv-row .st    { grid-area: status; justify-self: end; }
  .inv-row__total { grid-area: amount; justify-self: end; font-size: var(--z-fs-strong); }
  .inv-row__acts  {
    grid-area: auto / 1 / auto / -1;
    justify-content: flex-start;
    margin-top: var(--z-space-2);
  }
  .inv-row__acts .icb { width: 44px; height: 44px; }

  .cust-row, .exp-row {
    grid-template-columns: 1fr auto;
    gap: var(--z-space-1) var(--z-space-2);
    border: 1px solid var(--z-border);
    border-radius: var(--z-radius-md);
    background: var(--z-surface);
    padding: var(--z-space-3);
    margin-bottom: var(--z-space-2);
  }
  .cust-row .r, .exp-row .r { text-align: right; }

  .due-card { min-width: 100%; }
  .rate-form .field { flex: 1 1 100%; }
  .inv-strip { gap: var(--z-space-4); }
}

/* A word rather than a glyph: "Send" needs to read as an instruction, and no
   dingbat says "mark as sent" unambiguously. */
.icb--wide {
  width: auto;
  min-width: 44px;
  padding: 0 var(--z-space-2);
  font-size: var(--z-fs-caption);
  font-weight: 500;
}

/* Marks a date as the expected-payment estimate rather than the printed due
   date, so the column is never mistaken for what is on the document. */
.inv-row__est { color: var(--z-text-muted); margin-left: 2px; }
