/* ==========================================================================
   DIST-17 — Components
   ========================================================================== */

/* --------------------------------------------------------------------------
   Panel: the universal container. Flat, bordered, square-ish. Panels stack
   into a dashboard grid; each owns exactly one job.
   -------------------------------------------------------------------------- */
.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel--flush { padding: 0; }
.panel--pad { padding: var(--s-6); }

.panel__hd {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--c-line);
  min-height: 40px;
  flex: none;
}
.panel__hd--plain { border-bottom: 0; padding-bottom: 0; }
.panel__title {
  font-size: var(--t-md);
  font-weight: 600;
  color: var(--c-ink);
  letter-spacing: var(--tr-tight);
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.panel__sub { font-size: var(--t-xs); color: var(--c-ink-3); }
.panel__actions { margin-left: auto; display: flex; align-items: center; gap: var(--s-3); }
.panel__bd { padding: var(--s-5); min-width: 0; }
.panel__bd--flush { padding: 0; }
/* A flush body that still needs a horizontal inset for a full-bleed table.
 * The gutter has to live on the CONTAINER: CSS table layout overrides padding
 * declared on the <table> box, so padding there is silently ignored and the
 * row groups end up flush against the panel edge.
 * overflow-x:auto costs nothing when the table fits and becomes a horizontal
 * scroll on a narrow window, which is preferable to silently dropping columns
 * or letting the table escape the panel. */
.panel__bd--gutter { padding: 0 var(--s-5) var(--s-3); overflow-x: auto; }
.panel__ft {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--c-line);
  background: var(--c-surface-2);
  font-size: var(--t-xs);
  color: var(--c-ink-3);
  flex: none;
}

/* --------------------------------------------------------------------------
   KPI card. Value is the hero; the comparison sits underneath as a caption so
   the number is never competing with its own delta.
   -------------------------------------------------------------------------- */
.kpi {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  position: relative;
  min-width: 0;
  text-align: left;
  transition: border-color .12s ease, box-shadow .12s ease;
}
button.kpi { cursor: pointer; }
button.kpi:hover { border-color: var(--c-line-3); box-shadow: var(--sh-2); }
.kpi__hd { display: flex; align-items: center; gap: var(--s-3); }
.kpi__label { font-size: var(--t-xs); color: var(--c-ink-3); font-weight: 500; }
/* 3px spine on the left edge — the only place a KPI is allowed colour. */
.kpi__spine {
  position: absolute; left: 0; top: 10px; bottom: 10px;
  width: 3px; border-radius: 0 var(--r-pill) var(--r-pill) 0;
  background: var(--c-line-3);
}
.kpi__val {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-kpi);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.05;
  color: var(--c-ink);
  display: flex;
  align-items: baseline;
  gap: 3px;
}
.kpi__unit { font-size: var(--t-md); color: var(--c-ink-3); font-weight: 500; }
.kpi__ft { display: flex; align-items: center; gap: var(--s-3); font-size: var(--t-xs); }

.delta { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }
.delta--up   { color: var(--s-ok-text); }
.delta--down { color: var(--s-bad-text); }
.delta--flat { color: var(--c-ink-3); }

/* --------------------------------------------------------------------------
   Status chip. Systematic mapping of the 12 account_status enum values onto
   5 semantic families + neutral terminal states, so a chip's colour always
   tells you the *kind* of problem before you read the word.
   -------------------------------------------------------------------------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 18px;
  padding: 0 6px;
  border-radius: var(--r-xs);
  font-size: var(--t-xs);
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 1px solid transparent;
  background: var(--s-mute-bg);
  color: var(--s-mute-text);
  border-color: var(--s-mute-line);
}
.chip::before {
  content: "";
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
  opacity: .85;
}
.chip--plain::before { display: none; }

.chip--ok      { background: var(--s-ok-bg);      color: var(--s-ok-text);      border-color: var(--s-ok-line); }
.chip--warn    { background: var(--s-warn-bg);    color: var(--s-warn-text);    border-color: var(--s-warn-line); }
.chip--bad     { background: var(--s-bad-bg);     color: var(--s-bad-text);     border-color: var(--s-bad-line); }
.chip--info    { background: var(--s-info-bg);    color: var(--s-info-text);    border-color: var(--s-info-line); }
.chip--promise { background: var(--s-promise-bg); color: var(--s-promise-text); border-color: var(--s-promise-line); }
.chip--mute    { background: var(--s-mute-bg);    color: var(--s-mute-text);    border-color: var(--s-mute-line); }
.chip--accent  { background: var(--c-accent-soft);color: var(--c-accent-3);     border-color: var(--c-accent-line); }

/* --------------------------------------------------------------------------
   DataGrid — the centre of the product. A real financial grid: frozen leading
   columns, sticky header + sticky filter row, sticky totals footer, zebra-free
   (row rules read cleaner at 25px than zebra), tabular numerals, right-aligned
   money, and a hover-revealed row action slot that never shifts the layout.
   -------------------------------------------------------------------------- */
.grid-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  background: var(--c-surface);
}
.grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: var(--grid-fs);
  table-layout: fixed;
}

/* --- Header */
.grid thead th {
  position: sticky;
  z-index: 3;
  background: var(--c-surface-2);
  border-bottom: 1px solid var(--c-line-2);
  border-right: 1px solid var(--c-line);
  padding: 0;
  text-align: left;
  font-weight: 600;
  color: var(--c-ink-2);
  white-space: nowrap;
}
.grid thead tr:first-child th {
  height: 30px;
  font-size: var(--t-xs);
  letter-spacing: 0.01em;
}
.grid thead tr.colfilter th {
  z-index: 3;
  height: 28px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line-2);
}
.grid th.colgroup {
  background: var(--c-surface-3);
  height: 22px;
  font-size: var(--t-micro);
  font-weight: 600;
  letter-spacing: var(--tr-wide);
  text-transform: uppercase;
  color: var(--c-ink-3);
  text-align: center;
  border-bottom: 1px solid var(--c-line);
}
.grid th.colgroup-start { text-align: left; padding-left: var(--s-5); }

.th-btn {
  width: 100%;
  height: 100%;
  min-height: 24px;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: 0 var(--s-4);
  color: inherit;
  font: inherit;
  transition: background .1s ease;
}
.th-btn:hover { background: var(--c-surface-3); }
.th-btn--r { justify-content: flex-end; }
.th-btn__sort { opacity: 0; color: var(--c-ink-4); flex: none; transition: opacity .1s ease, transform .15s ease; }
.th-btn:hover .th-btn__sort { opacity: .5; }
.th-btn[aria-sort="ascending"] .th-btn__sort,
.th-btn[aria-sort="descending"] .th-btn__sort { opacity: 1; color: var(--c-accent); }
.th-btn[aria-sort="descending"] .th-btn__sort { transform: rotate(180deg); }

/* --- Column filter inputs, inline under the header (prototype pattern, kept) */
.colfilter__in {
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
  padding: 0 var(--s-4);
  font-size: var(--t-xs);
  color: var(--c-ink);
}
.colfilter__in::placeholder { color: var(--c-ink-4); }
.colfilter__in:focus-visible { box-shadow: inset 0 0 0 2px var(--c-accent-ring); }
.colfilter__in.is-active { color: var(--c-accent-3); font-weight: 600; background: var(--c-accent-soft); }
.th--num .colfilter__in { text-align: right; }

/* --- Body */
.grid tbody td {
  height: var(--row-h);
  padding: 0 var(--s-4);
  border-bottom: 1px solid var(--c-line);
  border-right: 1px solid transparent;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--c-ink);
  vertical-align: middle;
}
.grid tbody tr { transition: background .08s ease; }
.grid tbody tr:hover td { background: var(--c-surface-2); }
.grid tbody tr.is-selected td { background: var(--c-accent-soft); }
.grid tbody tr.is-selected:hover td { background: #dbe7f7; }
.grid tbody tr.is-flagged td:first-child { box-shadow: inset 3px 0 0 var(--s-bad-bar); }
.grid tbody tr.is-warnflag td:first-child { box-shadow: inset 3px 0 0 var(--s-warn-bar); }

/* --- Frozen leading columns (account no + customer). Kept to 2 so the money
       columns never get pushed off a 1440px screen. */
.grid .col-freeze {
  position: sticky;
  z-index: 2;
  background: var(--c-surface);
}
.grid thead .col-freeze { z-index: 4; background: var(--c-surface-2); }
.grid .col-freeze-1 { left: 0; }
.grid .col-freeze-2 { left: var(--w-acct, 108px); }
.grid tbody tr:hover .col-freeze { background: var(--c-surface-2); }
.grid tbody tr.is-selected .col-freeze { background: var(--c-accent-soft); }
.grid tbody tr.is-selected:hover .col-freeze { background: #dbe7f7; }
/* Hairline that appears only once content scrolls under the frozen block. */
.grid .col-freeze-2 { box-shadow: 1px 0 0 var(--c-line-2), 4px 0 6px -4px rgba(15,21,28,.16); }
.grid .col-freeze--first { z-index: 5; }

/* --- Row hover action slot: absolutely positioned so nothing reflows */
.grid td.col-actions { text-align: right; padding-right: var(--s-3); }
.rowacts { display: inline-flex; gap: 2px; opacity: 0; transition: opacity .1s ease; }
tr:hover .rowacts, tr:focus-within .rowacts { opacity: 1; }
/* Selection checkbox cell. The checkbox itself is a 14px square, so the label
   is padded out to the 24px hit floor and gives the whole cell a click target. */
.rowact { display: flex; align-items: center; justify-content: center; width: 100%; min-height: 24px; min-width: 24px; cursor: pointer; }
.rowacts__b {
  width: 24px; height: 24px;
  display: grid; place-content: center;
  border-radius: var(--r-xs);
  color: var(--c-ink-3);
}
.rowacts__b:hover { background: var(--c-surface-4); color: var(--c-ink); }

/* --- Totals footer: the reconciliation strip. Mono, bold, pinned. */
.grid tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  height: 34px;
  padding: 0 var(--s-4);
  background: var(--c-surface-2);
  border-top: 1px solid var(--c-line-3);
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: var(--t-sm);
  color: var(--c-ink);
  white-space: nowrap;
}
.grid tfoot .col-freeze { z-index: 4; }
.grid tfoot td.is-ok  { color: var(--s-ok-text); }
.grid tfoot td.is-bad { color: var(--s-bad-text); }
.grid tfoot tr.pager td { height: 34px; font-family: var(--f-sans); font-weight: 500; }

/* --- Column resize handle */
.col-resize {
  position: absolute;
  top: 0; right: -3px;
  width: 6px; height: 100%;
  cursor: col-resize;
  z-index: 6;
}
.col-resize:hover::after, .col-resize.is-dragging::after {
  content: ""; position: absolute; inset: 0 2px;
  background: var(--c-accent);
}

/* --- Amount colouring. Only *material* numbers get a tint, and only via a
       2px left border — a coloured background on money reads as an error. */
.amt { text-align: right; }
.amt--bad  { color: var(--s-bad-text);  font-weight: 600; }
.amt--ok   { color: var(--s-ink, var(--c-ink)); }
.amt--zero { color: var(--c-ink-4); }

/* --------------------------------------------------------------------------
   Branch card (P04 branch strip / P16). Compact horizontal card: identity, a
   single progress meter, and the three numbers a manager actually compares.
   -------------------------------------------------------------------------- */
.branchstrip {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  overflow-x: auto;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  flex: none;
  scrollbar-width: none;
}
.branchstrip::-webkit-scrollbar { display: none; }

.branchcard {
  flex: none;
  width: 168px;
  padding: var(--s-4);
  border: 1px solid var(--c-line);
  border-radius: var(--r-md);
  background: var(--c-surface);
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  transition: border-color .12s ease, background .12s ease;
}
.branchcard:hover { border-color: var(--c-line-3); background: var(--c-surface-2); }
.branchcard[aria-pressed="true"] {
  border-color: var(--c-accent);
  background: var(--c-accent-soft);
  box-shadow: inset 0 0 0 1px var(--c-accent);
}
.branchcard__top { display: flex; align-items: baseline; gap: var(--s-3); }
.branchcard__code {
  font-family: var(--f-mono);
  font-size: var(--t-sm);
  font-weight: 600;
  letter-spacing: var(--tr-tight);
}
.branchcard__n { margin-left: auto; font-size: var(--t-xs); color: var(--c-ink-3); }
.branchcard__pct {
  display: flex;
  align-items: baseline;
  gap: 3px;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-lg);
  font-weight: 600;
  letter-spacing: -0.02em;
}
.branchcard__pct small { font-size: var(--t-xs); color: var(--c-ink-3); font-weight: 500; }
.branchcard__nums {
  display: flex;
  gap: var(--s-4);
  font-size: var(--t-micro);
  color: var(--c-ink-3);
}
.branchcard__nums b {
  display: block;
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--c-ink-2);
}

/* --- Meter: the one bar primitive used everywhere (target attainment, aging,
       allocation coverage). Track is a flat neutral so the fill carries all
       the meaning. */
.meter {
  height: 5px;
  background: var(--c-surface-3);
  border-radius: var(--r-pill);
  overflow: hidden;
  display: flex;
}
.meter__fill { height: 100%; background: var(--c-accent); }
.meter__fill--ok   { background: var(--s-ok-bar); }
.meter__fill--warn { background: var(--s-warn-bar); }
.meter__fill--bad  { background: var(--s-bad-bar); }
.meter--thin { height: 3px; }
.meter--tall { height: 7px; }

/* --------------------------------------------------------------------------
   Filter bar. Search grows, filters don't. Wraps to a second row of
   "active filter pills" so it's always obvious what the current view is.
   -------------------------------------------------------------------------- */
.filterbar {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  flex: none;
}
.filterbar__row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.filterbar__search { position: relative; width: 260px; flex: none; }
.filterbar__search .ctl { width: 100%; padding-left: 28px; }
.filterbar__search svg { position: absolute; left: var(--s-4); top: 50%; transform: translateY(-50%); color: var(--c-ink-4); pointer-events: none; }
.filterbar__search kbd {
  position: absolute; right: var(--s-3); top: 50%; transform: translateY(-50%);
  font-family: var(--f-mono); font-size: var(--t-micro);
  color: var(--c-ink-4); background: var(--c-surface-3);
  padding: 1px 4px; border-radius: var(--r-xs); border: 1px solid var(--c-line);
}
.filterbar__spacer { flex: 1 1 auto; }

.fchip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  height: 22px;
  padding: 0 var(--s-2) 0 var(--s-3);
  border-radius: var(--r-pill);
  background: var(--c-accent-soft);
  border: 1px solid var(--c-accent-line);
  color: var(--c-accent-3);
  font-size: var(--t-xs);
  font-weight: 500;
}
.fchip__k { color: var(--c-ink-3); font-weight: 400; }
.fchip__x {
  width: 14px; height: 14px; display: grid; place-content: center;
  border-radius: 50%; color: var(--c-accent-3); opacity: .6;
}
.fchip__x:hover { background: var(--c-accent-line); opacity: 1; }

.badge-count {
  display: inline-grid; place-content: center;
  min-width: 15px; height: 15px; padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--c-accent); color: #fff;
  font-size: var(--t-micro); font-weight: 700;
  font-family: var(--f-mono);
}

/* --------------------------------------------------------------------------
   Bulk-action bar: replaces the toolbar in place when rows are selected, so
   the table never moves vertically when you start selecting.
   -------------------------------------------------------------------------- */
.bulkbar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: 40px;
  padding: 0 var(--s-5);
  background: var(--c-accent-3);
  color: #fff;
  flex: none;
  font-size: var(--t-sm);
}
.bulkbar strong { font-weight: 600; }
.bulkbar__sep { width: 1px; height: 18px; background: rgba(255,255,255,.24); }
.bulkbar .btn {
  background: rgba(255,255,255,.12);
  border-color: rgba(255,255,255,.26);
  color: #fff;
}
.bulkbar .btn:hover { background: rgba(255,255,255,.2); }
.bulkbar__x { margin-left: auto; color: rgba(255,255,255,.8); display: grid; place-content: center; width: 24px; height: 24px; border-radius: var(--r-sm); }
.bulkbar__x:hover { background: rgba(255,255,255,.18); color: #fff; }

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-bottom: 1px solid var(--c-line);
  background: var(--c-surface);
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  height: 36px;
  padding: 0 var(--s-5);
  display: inline-flex;
  align-items: center;
  gap: var(--s-3);
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--c-ink-3);
  white-space: nowrap;
  transition: color .12s ease;
}
.tab:hover { color: var(--c-ink); }
.tab[aria-selected="true"] { color: var(--c-ink); font-weight: 600; }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
  height: 2px; background: var(--c-accent);
}
.tab__n {
  font-family: var(--f-mono);
  font-size: var(--t-micro);
  padding: 0 4px; height: 15px;
  display: inline-grid; place-content: center;
  border-radius: var(--r-xs);
  background: var(--c-surface-3);
  color: var(--c-ink-3);
}
.tab[aria-selected="true"] .tab__n { background: var(--c-accent-soft); color: var(--c-accent-3); }
.tab__n--alert { background: var(--s-bad-bg); color: var(--s-bad-text); }

/* --------------------------------------------------------------------------
   Drawer
   -------------------------------------------------------------------------- */
.scrim {
  position: fixed; inset: 0;
  background: rgba(15, 21, 28, 0.32);
  z-index: var(--z-drawer);
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: min(var(--drawer-w), 100vw);
  background: var(--c-surface);
  border-left: 1px solid var(--c-line-2);
  box-shadow: var(--sh-3);
  z-index: calc(var(--z-drawer) + 1);
  display: flex;
  flex-direction: column;
  animation: slidein .2s cubic-bezier(.32, .72, 0, 1);
}
.drawer--wide { width: min(720px, 100vw); }
@keyframes slidein { from { transform: translateX(24px); opacity: .4 } to { transform: none; opacity: 1 } }
@media (prefers-reduced-motion: reduce) {
  .drawer, .scrim, .toast { animation: none !important; }
  * { transition-duration: .01ms !important; }
}

.drawer__hd {
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
  padding: var(--s-5);
  border-bottom: 1px solid var(--c-line);
  flex: none;
}
.drawer__bd { flex: 1 1 auto; overflow-y: auto; }
/* Sheet body holds a form, not a record summary: it must not scroll
   independently of its own footer actions. */
.sheet__bd { padding: var(--s-6) var(--s-6) var(--s-7); overflow-y: auto; }
.sheet__ft { gap: var(--s-4); }
.drawer__ft {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--c-line);
  background: var(--c-surface-2);
  flex: none;
}

/* --------------------------------------------------------------------------
   Field list — the read-only "label / value" stack used in drawers and 360
   panels. Dotted-label pattern avoided; a hairline grid is calmer at density.
   -------------------------------------------------------------------------- */
.fields { display: grid; grid-template-columns: minmax(84px, 34%) 1fr; gap: 0; }
.fields > dt {
  font-size: var(--t-xs);
  color: var(--c-ink-3);
  padding: 5px var(--s-4) 5px 0;
  border-bottom: 1px solid var(--c-line);
}
.fields > dd {
  font-size: var(--t-sm);
  color: var(--c-ink);
  padding: 5px 0;
  border-bottom: 1px solid var(--c-line);
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.fields > dt:last-of-type, .fields > dd:last-of-type { border-bottom: 0; }

/* --------------------------------------------------------------------------
   Timeline — activities, audit, follow-ups
   -------------------------------------------------------------------------- */
.tl { position: relative; padding-left: var(--s-7); }
.tl::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--c-line);
}
.tl__i { position: relative; padding-bottom: var(--s-6); }
.tl__i:last-child { padding-bottom: 0; }
.tl__dot {
  position: absolute; left: calc(-1 * var(--s-7) + 3px); top: 4px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--c-surface);
  border: 2px solid var(--c-line-3);
}
.tl__dot--ok   { border-color: var(--s-ok-bar); }
.tl__dot--bad  { border-color: var(--s-bad-bar); }
.tl__dot--warn { border-color: var(--s-warn-bar); }
.tl__dot--info { border-color: var(--s-info-bar); }
.tl__hd { display: flex; align-items: baseline; gap: var(--s-3); flex-wrap: wrap; }
.tl__title { font-size: var(--t-sm); font-weight: 600; }
.tl__when { font-size: var(--t-xs); color: var(--c-ink-3); font-family: var(--f-mono); margin-left: auto; }
.tl__body { font-size: var(--t-xs); color: var(--c-ink-2); margin-top: 2px; }

/* --------------------------------------------------------------------------
   Installment schedule table (Account 360) — a heat grid. Each due month is a
   cell whose fill encodes paid / partial / due / overdue.
   -------------------------------------------------------------------------- */
.sched { display: flex; flex-wrap: wrap; gap: 3px; }
.sched__c {
  width: 34px; height: 26px;
  border-radius: var(--r-xs);
  border: 1px solid var(--c-line);
  background: var(--c-surface-2);
  display: grid; place-content: center;
  font-family: var(--f-mono);
  font-size: var(--t-micro);
  font-weight: 600;
  color: var(--c-ink-4);
  position: relative;
  cursor: default;
}
.sched__c[data-tip] { cursor: help; }
.sched__c--paid    { background: var(--s-ok-bg);   border-color: var(--s-ok-line);   color: var(--s-ok-text); }
.sched__c--partial { background: var(--s-warn-bg); border-color: var(--s-warn-line); color: var(--s-warn-text); }
.sched__c--due     { background: var(--c-surface); border-color: var(--c-accent-line); color: var(--c-accent-3); border-style: dashed; }
.sched__c--overdue { background: var(--s-bad-bg);  border-color: var(--s-bad-line);  color: var(--s-bad-text); }
.sched__c--future  { opacity: .5; }
.sched__c--current { box-shadow: 0 0 0 2px var(--c-accent-ring); }
.sched__legend { display: flex; gap: var(--s-5); flex-wrap: wrap; margin-top: var(--s-4); }

/* --------------------------------------------------------------------------
   Misc atoms
   -------------------------------------------------------------------------- */
.avatar {
  width: 22px; height: 22px;
  border-radius: var(--r-pill);
  display: grid; place-content: center;
  background: var(--c-surface-4);
  color: var(--c-ink-2);
  font-size: var(--t-micro);
  font-weight: 700;
  letter-spacing: .01em;
  flex: none;
  text-transform: uppercase;
}
.avatar--sm { width: 18px; height: 18px; font-size: 9px; }
.avatar--lg { width: 36px; height: 36px; font-size: var(--t-sm); }
.avatar--ok   { background: var(--s-ok-bg);   color: var(--s-ok-text); }
.avatar--info { background: var(--s-info-bg); color: var(--s-info-text); }
.avatar--bad  { background: var(--s-bad-bg);  color: var(--s-bad-text); }

.stack   { display: flex; flex-direction: column; }
.row     { display: flex; align-items: center; }
.row--wrap { flex-wrap: wrap; }
.g2 { gap: var(--s-2); } .g3 { gap: var(--s-3); } .g4 { gap: var(--s-4); }
.g5 { gap: var(--s-5); } .g6 { gap: var(--s-6); } .g8 { gap: var(--s-8); }
.mt2{margin-top:var(--s-2)} .mt3{margin-top:var(--s-3)} .mt4{margin-top:var(--s-4)}
.mt5{margin-top:var(--s-5)} .mt6{margin-top:var(--s-6)} .mt8{margin-top:var(--s-8)}
.mb2{margin-bottom:var(--s-2)} .mb3{margin-bottom:var(--s-3)} .mb4{margin-bottom:var(--s-4)}
.mb5{margin-bottom:var(--s-5)} .mb6{margin-bottom:var(--s-6)}
.ml-auto { margin-left: auto; }

.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-4);
  padding: var(--s-11) var(--s-6);
  text-align: center;
  color: var(--c-ink-3);
}
.empty__ico {
  width: 40px; height: 40px;
  display: grid; place-content: center;
  border-radius: var(--r-lg);
  background: var(--c-surface-2);
  border: 1px solid var(--c-line);
  color: var(--c-ink-4);
}
.empty__t { font-size: var(--t-md); font-weight: 600; color: var(--c-ink-2); }
.empty__d { font-size: var(--t-xs); max-width: 42ch; line-height: 1.5; }

.skel {
  background: linear-gradient(90deg, var(--c-surface-3) 25%, var(--c-surface-2) 37%, var(--c-surface-3) 63%);
  background-size: 400% 100%;
  animation: shim 1.3s ease infinite;
  border-radius: var(--r-xs);
}
@keyframes shim { 0% { background-position: 100% 0 } 100% { background-position: -100% 0 } }

.toast {
  position: fixed;
  bottom: var(--s-6); left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-4) var(--s-5);
  background: #1b2430;
  color: #fff;
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  font-size: var(--t-sm);
  z-index: var(--z-toast);
  animation: toastin .2s cubic-bezier(.32,.72,0,1);
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px) } to { opacity: 1; transform: translate(-50%, 0) } }
.toast__ico { color: #6ee7a8; display: grid; place-content: center; }

/* Popover menu */
.menu {
  position: fixed;
  min-width: 190px;
  background: var(--c-surface);
  border: 1px solid var(--c-line-2);
  border-radius: var(--r-md);
  box-shadow: var(--sh-3);
  padding: var(--s-2);
  z-index: var(--z-modal);
  animation: fade .12s ease;
}
.menu__i {
  width: 100%;
  display: flex; align-items: center; gap: var(--s-4);
  height: 26px;
  padding: 0 var(--s-3);
  border-radius: var(--r-sm);
  font-size: var(--t-sm);
  color: var(--c-ink);
  text-align: left;
}
.menu__i:hover { background: var(--c-surface-3); }
.menu__i[aria-checked="true"] { color: var(--c-accent-3); font-weight: 600; }
.menu__i svg { color: var(--c-ink-4); flex: none; }
.menu__i:hover svg { color: var(--c-ink-2); }
.menu__i--danger { color: var(--s-bad-text); }
.menu__i--danger svg { color: var(--s-bad-text); }
.menu__sep { height: 1px; background: var(--c-line); margin: var(--s-2) 0; }
.menu__hd {
  padding: var(--s-2) var(--s-3) var(--s-3);
  font-size: var(--t-micro); font-weight: 600; letter-spacing: var(--tr-wide);
  text-transform: uppercase; color: var(--c-ink-3);
}
.menu__k { margin-left: auto; font-family: var(--f-mono); font-size: var(--t-xs); color: var(--c-ink-4); }
