/* ==========================================================================
   Polymath Inventory — locked design system: v4 "Heritage"
   The crest, dignified. Dignity from type and rules, not ornament.
   Source mockup: design/v4-heritage/. Sections 1–25 are the mockup port;
   section 26 adds the pieces the Django templates need.
   Display: Cormorant Garamond (headings only) · UI/body: Source Sans 3 (>=16px)
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* Brand — crest purple ramp */
  --purple-900: #3E1747;
  --purple-800: #5A2167;
  --purple-700: #722A82;
  --purple-500: #94519F;
  --purple-300: #C79ED0;
  --purple-100: #F0E4F3;
  --purple-50:  #F9F4FA;

  /* Warm neutrals — the paper of the register */
  --ink:        #1A1A1E;
  --ink-2:      #3B3A40;
  --muted:      #63666B;
  --ground:     #F7F4EE;   /* warm ivory page */
  --surface:    #FFFFFF;
  --surface-alt:#FBF9F5;   /* zebra rows, footers */
  --surface-sunk:#F1EDE6;  /* input add-ons, tracks */
  --rule:       #E6E0D6;   /* hairline */
  --rule-strong:#CBC3B6;
  --rule-ink:   #2E2733;   /* the register's header rule */
  --input-border:#8E887E;  /* 3.4:1 on white */

  /* Status — reserved for stock states and messages */
  --success: #2E7D46; --success-bg: #EAF4ED; --success-line: #B7D9C1;
  --warning: #9A5800; --warning-bg: #FDF3E3; --warning-line: #E9C992;
  --danger:  #B3261E; --danger-bg:  #FCECEA; --danger-line:  #EDB7B2;
  --info:    #2B5FA8; --info-bg:    #EAF1FB; --info-line:    #B6CBEA;
  --neutral: #55585D; --neutral-bg: #F0EEEA; --neutral-line: #D5D1CA;

  /* Chart — validated with dataviz validate_palette.js (light, white surface) */
  --chart-in:   #7B318B;
  --chart-out:  #A47C22;
  --chart-grid: #ECE7DE;
  --chart-axis: #BDB4A6;

  /* Type */
  --font-display: "Cormorant Garamond", "Cormorant", Garamond, Georgia, "Times New Roman", serif;
  --font-ui: "Source Sans 3", "Source Sans Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --fs-xs: 14px;  /* eyebrows, axis ticks only */
  --fs-sm: 15px;  /* metadata */
  --fs-base: 16px;
  --fs-md: 18px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  --fs-2xl: 30px;
  --fs-3xl: 40px;
  --fs-hero: 56px;

  /* Space (4px base) */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;
  --gutter: 24px;
  --card-pad: 24px;

  --radius-sm: 4px;
  --radius: 6px;
  --radius-lg: 10px;
  --sidebar-w: 280px;
  --tap: 44px;

  /* Elevation — "beautiful shadows", neutral and restrained */
  --shadow-sm: 0 2px 3px -1px rgba(0,0,0,.08), 0 1px 0 0 rgba(25,28,33,.02), 0 0 0 1px rgba(60,45,30,.09);
  --shadow-md: 0 0 0 1px rgba(0,0,0,.06), 0 1px 1px -.5px rgba(0,0,0,.06), 0 3px 3px -1.5px rgba(0,0,0,.06), 0 6px 6px -3px rgba(0,0,0,.06), 0 12px 12px -6px rgba(0,0,0,.06), 0 24px 24px -12px rgba(0,0,0,.06);
  --shadow-lg: 0 2.8px 2.2px rgba(0,0,0,.034), 0 6.7px 5.3px rgba(0,0,0,.048), 0 12.5px 10px rgba(0,0,0,.06), 0 22.3px 17.9px rgba(0,0,0,.072), 0 41.8px 33.4px rgba(0,0,0,.086), 0 100px 80px rgba(0,0,0,.12);

  --focus: #3E1747;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 var(--fs-base)/1.5 var(--font-ui);
  color: var(--ink);
  background: var(--ground);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img, svg { display: block; max-width: 100%; }
[hidden] { display: none !important; }
h1, h2, h3, h4, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
a { color: var(--purple-800); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--purple-900); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
strong, b { font-weight: 600; }
.num { font-variant-numeric: tabular-nums lining-nums; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }
.sidebar :focus-visible, .mobile-bar :focus-visible, .auth-brand :focus-visible { outline-color: #FFFFFF; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 200;
  background: var(--surface); color: var(--purple-900); padding: 12px 16px;
  border-radius: var(--radius); box-shadow: var(--shadow-md); font-weight: 600;
}
.skip-link:focus { top: 12px; }

.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 18px; height: 18px; }
.icon-lg { width: 28px; height: 28px; }

/* ---------- 3. Type roles ---------- */
.page-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--fs-3xl);
  line-height: 1.05;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
  color: var(--purple-900);
}
.card-title, .section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  line-height: 1.2;
  letter-spacing: .09em;
  text-transform: uppercase;
  font-variant-numeric: lining-nums;
  color: var(--purple-900);
}
.eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--purple-700);
}
.lede { font-size: var(--fs-md); color: var(--ink-2); max-width: 62ch; }
.meta { font-size: var(--fs-sm); color: var(--muted); }
.text-muted { color: var(--muted); }

/* ---------- 4. App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar — solid crest purple, deepening */
.sidebar {
  position: sticky; top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex; flex-direction: column;
  color: #FFFFFF;
  background:
    linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,0) 220px),
    linear-gradient(180deg, var(--purple-700) 0%, #672577 45%, var(--purple-800) 100%);
  box-shadow: inset -1px 0 0 rgba(255,255,255,.1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.3) transparent;
}
.sidebar-close { display: none; }

.brand {
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 12px;
  padding: 28px 24px 22px;
  color: #FFFFFF; text-decoration: none;
}
.brand:hover { color: #FFFFFF; }
.brand-chip { width: 72px; height: 72px; border-radius: 16px; box-shadow: 0 6px 16px -6px rgba(30,8,36,.55), 0 0 0 1px rgba(255,255,255,.4); }
.wordmark { display: grid; gap: 2px; font-family: var(--font-display); text-transform: uppercase; line-height: 1; }
.wordmark-1 { font-size: 27px; font-weight: 600; letter-spacing: .2em; margin-right: -.2em; }
.wordmark-2 { font-size: 15px; font-weight: 600; letter-spacing: .52em; margin-right: -.52em; }

.sidebar-rule { height: 0; margin: 0 20px; border: 0; border-top: 1px solid rgba(255,255,255,.18); }

.nav { padding: 18px 16px 8px; display: grid; gap: 18px; }
.nav-group, .nav-list { display: grid; gap: 4px; }
.nav-label {
  padding: 0 12px 4px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
  color: #E3CFE8;
}
.nav-link {
  display: flex; align-items: center; gap: 12px;
  min-height: var(--tap);
  padding: 10px 12px;
  border-radius: var(--radius);
  color: #FFFFFF; text-decoration: none;
  font-size: var(--fs-base); font-weight: 500;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.nav-link:hover { background: rgba(255,255,255,.1); color: #FFFFFF; }
.nav-link[aria-current="page"] {
  background: var(--purple-50);
  color: var(--purple-900);
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(20,4,24,.25);
}
.nav-link .nav-count {
  margin-left: auto;
  font-size: var(--fs-xs); font-weight: 600;
  font-variant-numeric: tabular-nums;
  padding: 1px 8px; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #FFFFFF;
}
.nav-link[aria-current="page"] .nav-count { background: var(--purple-100); color: var(--purple-900); }
.nav-link.is-soon { color: rgba(255,255,255,.66); cursor: default; }
.nav-link.is-soon:hover { background: transparent; }
.nav-soon {
  margin-left: auto; font-size: 13px; font-weight: 600; letter-spacing: .04em;
  padding: 1px 8px; border-radius: 999px; border: 1px solid rgba(255,255,255,.3); color: rgba(255,255,255,.8);
}

.sidebar-foot { margin-top: auto; padding: 16px 16px 20px; display: grid; gap: 14px; }
.user-card {
  display: grid; grid-template-columns: 44px minmax(0,1fr); gap: 12px; align-items: center;
  padding: 12px; border-radius: var(--radius);
  background: rgba(20,4,26,.18);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.1);
}
.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  background: #FFFFFF; color: var(--purple-800);
  font-family: var(--font-display); font-weight: 700; font-size: 19px; letter-spacing: .04em;
}
.user-name { font-weight: 600; line-height: 1.25; }
.user-role { font-size: var(--fs-sm); color: #EADAEE; line-height: 1.3; }
.signout-form { margin: 0; }
.signout {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: var(--tap);
  border: 0; border-radius: var(--radius);
  background: transparent;
  color: #FFFFFF; text-decoration: none; font: 600 var(--fs-base)/1.2 var(--font-ui);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.3);
}
.signout:hover { background: rgba(255,255,255,.1); color: #FFFFFF; }
.motto { text-align: center; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.16); }
.motto-latin { font-family: var(--font-display); font-style: italic; font-weight: 500; font-size: 21px; letter-spacing: .04em; }
.motto-en { font-size: var(--fs-xs); letter-spacing: .14em; text-transform: uppercase; color: #E3CFE8; }

/* Mobile bar (hidden on desktop) */
.mobile-bar { display: none; }
.drawer-scrim { display: none; }

/* Main column */
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px 40px;
  border-bottom: 1px solid var(--rule);
  background: rgba(255,255,255,.55);
}
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--muted); }
.crumbs a { color: var(--ink-2); text-decoration: none; padding: 4px 2px; }
.crumbs a:hover { text-decoration: underline; color: var(--purple-800); }
.crumbs .sep { color: var(--rule-strong); }
.crumbs [aria-current] { color: var(--ink); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 20px; }
.global-search { position: relative; width: 300px; }
.global-search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.global-search input {
  width: 100%; min-height: 42px; padding: 8px 12px 8px 40px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface);
  font-size: var(--fs-base);
}
.global-search input:focus { outline: 2px solid var(--purple-700); outline-offset: 1px; border-color: var(--purple-700); }
.today { display: flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); white-space: nowrap; }

.page { width: 100%; max-width: 1360px; padding: 32px 40px 72px; }

/* ---------- 5. Page head — the register title with a double rule ---------- */
.page-head {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: 20px 32px;
  padding-bottom: 22px;
  margin-bottom: 28px;
  border-bottom: 4px double var(--purple-800);
}
.page-head-text { display: grid; gap: 10px; min-width: 0; max-width: 820px; }
.page-head-text .badge { justify-self: start; }
.page-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap); margin: -12px 0 -4px -6px; padding: 0 6px;
  font-weight: 600; text-decoration: none;
}
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; }

/* ---------- 6. Framed grid ---------- */
.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: var(--gutter); }
.grid > * { min-width: 0; }
.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.stack { display: grid; gap: var(--gutter); align-content: start; }

/* L-shaped corner marks, like a mounted certificate (framed-grid-layout) */
.corners { position: relative; }
.corners::before {
  --c: var(--purple-300); --l: 16px;
  content: ""; position: absolute; inset: -7px; pointer-events: none;
  background:
    linear-gradient(var(--c), var(--c)) left top / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) left top / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) right top / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) right top / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) left bottom / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) left bottom / 1px var(--l) no-repeat,
    linear-gradient(var(--c), var(--c)) right bottom / var(--l) 1px no-repeat,
    linear-gradient(var(--c), var(--c)) right bottom / 1px var(--l) no-repeat;
}

/* ---------- 7. Card ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 18px var(--card-pad) 16px;
  border-bottom: 1px solid var(--rule);
}
.card-head .meta { margin-top: 2px; }
.card-body { padding: var(--card-pad); }
.card-foot {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px var(--card-pad);
  border-top: 1px solid var(--rule);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}
.link-arrow { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-weight: 600; text-decoration: none; }
.link-arrow:hover { text-decoration: underline; }
/* A quiet way out of a panel — the report behind it — said in text, not in another button. */
.link-quiet {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: var(--tap);
  color: var(--ink-2); font-size: var(--fs-sm); font-weight: 600; text-decoration: none;
}
.link-quiet:hover { color: var(--purple-800); text-decoration: underline; }
.link-quiet .icon { width: 17px; height: 17px; flex: none; color: var(--muted); }
.link-quiet:hover .icon { color: inherit; }
/* A single quiet link closing a section that is not a card (the dashboard's figures). */
.section-foot { display: flex; justify-content: flex-end; margin-top: 4px; }

/* ---------- 8. Buttons ---------- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--purple-800); --btn-bd: #B9B0A2;
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap);
  padding: 10px 18px;
  border: 1px solid var(--btn-bd);
  border-radius: var(--radius);
  background: var(--btn-bg); color: var(--btn-fg);
  font: 600 var(--fs-base)/1.2 var(--font-ui);
  text-decoration: none; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .1s var(--ease);
}
.btn:hover { color: var(--btn-fg); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  --btn-bg: var(--purple-700); --btn-fg: #FFFFFF; --btn-bd: var(--purple-800);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.16), 0 1px 2px rgba(62,23,71,.28);
}
.btn-primary:hover { --btn-bg: var(--purple-800); }
.btn-secondary { box-shadow: 0 1px 2px rgba(40,30,20,.06); }
.btn-secondary:hover { --btn-bg: var(--purple-50); --btn-bd: var(--purple-500); }
.btn-ghost { --btn-bg: transparent; --btn-bd: transparent; }
.btn-ghost:hover { --btn-bg: var(--purple-50); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #FFFFFF; --btn-bd: #8F1E18; box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 1px 2px rgba(120,20,15,.25); }
.btn-danger:hover { --btn-bg: #951F18; }
.btn-danger-ghost { --btn-bg: transparent; --btn-bd: transparent; --btn-fg: var(--danger); }
.btn-danger-ghost:hover { --btn-bg: var(--danger-bg); }
.btn-sm { min-height: 38px; padding: 7px 12px; font-size: var(--fs-sm); gap: 6px; }
.btn-sm .icon { width: 18px; height: 18px; }
.btn-block { width: 100%; }
.btn-icon { padding: 0; width: var(--tap); }
.btn:disabled, .btn[aria-disabled="true"] {
  --btn-bg: #ECE8E1; --btn-fg: #6E6A63; --btn-bd: #DDD7CD;
  box-shadow: none; cursor: not-allowed; transform: none;
}
.btn.is-loading { color: transparent; pointer-events: none; }
.btn.is-loading .icon { visibility: hidden; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 20px; height: 20px; inset: 0; margin: auto;
  border: 2.5px solid rgba(255,255,255,.45); border-top-color: #FFFFFF; border-radius: 50%;
  animation: spin .8s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--purple-100); border-top-color: var(--purple-700); }
@keyframes spin { to { transform: rotate(360deg); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }

/* ---------- 9. Badges (stock states) ---------- */
.badge {
  --b-fg: var(--neutral); --b-bg: var(--neutral-bg); --b-bd: var(--neutral-line);
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 7px;
  border: 1px solid var(--b-bd); border-radius: 999px;
  background: var(--b-bg); color: var(--b-fg);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; white-space: nowrap;
}
.badge .icon { width: 16px; height: 16px; stroke-width: 2.1; }
.badge-success { --b-fg: var(--success); --b-bg: var(--success-bg); --b-bd: var(--success-line); }
.badge-warning { --b-fg: var(--warning); --b-bg: var(--warning-bg); --b-bd: var(--warning-line); }
.badge-danger  { --b-fg: var(--danger);  --b-bg: var(--danger-bg);  --b-bd: var(--danger-line); }
.badge-info    { --b-fg: var(--info);    --b-bg: var(--info-bg);    --b-bd: var(--info-line); }
.badge-neutral { --b-fg: var(--neutral); --b-bg: var(--neutral-bg); --b-bd: var(--neutral-line); }
.badge-brand   { --b-fg: var(--purple-800); --b-bg: var(--purple-50); --b-bd: var(--purple-100); }

/* ---------- 10. Stats (KPI register) ---------- */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(0, 1.45fr);
  background: var(--surface);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.stat {
  position: relative;
  display: flex; flex-direction: column; gap: 4px;
  padding: 20px 22px 18px;
  color: inherit; text-decoration: none;
  border-left: 1px solid var(--rule);
  transition: background-color .15s var(--ease);
}
.stat:first-child { border-left: 0; }
.stat:hover { background: var(--purple-50); color: inherit; }
.stat:focus-visible { outline-offset: -3px; }
.stat-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); }
.stat-label .icon { width: 20px; height: 20px; }
.stat-value {
  font-family: var(--font-ui);
  font-size: 42px; font-weight: 600; line-height: 1.1; letter-spacing: -.015em;
  color: var(--ink);
  font-variant-numeric: proportional-nums lining-nums;
}
.stat-value .unit { font-size: 22px; font-weight: 600; color: var(--muted); margin-right: 6px; letter-spacing: 0; }
.stat-value .cents { font-size: 24px; color: var(--muted); }
.stat-note { font-size: var(--fs-sm); color: var(--muted); display: block; line-height: 1.4; }
.stat-note .icon { display: inline-block; vertical-align: -3px; margin-left: 4px; width: 16px; height: 16px; transition: transform .15s var(--ease); }
.stat:hover .stat-note .icon { transform: translateX(3px); }
.tone-success { color: var(--success); }
.tone-warning { color: var(--warning); }
.tone-danger { color: var(--danger); }
.tone-info { color: var(--info); }
.tone-brand { color: var(--purple-700); }

/* ---------- 11. Quick actions ---------- */
.quick-actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.action-tile {
  display: grid; grid-template-columns: 48px minmax(0,1fr); align-items: center; gap: 14px;
  min-height: 80px; padding: 14px 18px;
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s var(--ease), transform .15s var(--ease), background-color .15s var(--ease);
}
.action-tile:hover { color: var(--ink); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.action-icon { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--purple-50); color: var(--purple-700); box-shadow: inset 0 0 0 1px var(--purple-100); }
.action-icon .icon { width: 24px; height: 24px; }
.action-name { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 1.25; }
.action-hint { display: block; font-size: var(--fs-sm); color: var(--muted); line-height: 1.3; }
.action-tile.is-primary { background: var(--purple-700); color: #FFFFFF; box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 2px 6px -2px rgba(62,23,71,.45); }
.action-tile.is-primary:hover { background: var(--purple-800); color: #FFFFFF; }
.action-tile.is-primary .action-icon { background: #FFFFFF; color: var(--purple-700); box-shadow: none; }
.action-tile.is-primary .action-hint { color: #F0E4F3; }

/* ---------- 12. Needs-attention list ---------- */
.attention-list > li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px auto;
  align-items: center; gap: 16px;
  padding: 14px var(--card-pad);
  border-top: 1px solid var(--rule);
}
.attention-list > li:first-child { border-top: 0; }
.row-name { font-weight: 600; color: var(--ink); text-decoration: none; }
a.row-name:hover { color: var(--purple-800); text-decoration: underline; }
.row-meta { font-size: var(--fs-sm); color: var(--muted); }
.level { display: grid; gap: 6px; }
.level-text { font-size: var(--fs-sm); color: var(--ink-2); }
.level-text strong { color: var(--ink); font-size: var(--fs-base); }
.mini-meter { height: 6px; border-radius: 3px; background: var(--surface-sunk); overflow: hidden; }
.mini-meter > span { display: block; height: 100%; border-radius: 3px; background: var(--warning); }
.mini-meter.is-danger > span { background: var(--danger); }
.mini-meter.is-info > span { background: var(--info); }
.attention-status { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }

/* ---------- 13. Activity (ruled day book) ---------- */
.day-label {
  padding: 10px var(--card-pad) 8px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-alt);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.day-label:first-child { border-top: 0; }
.activity > li {
  display: grid; grid-template-columns: 52px minmax(0,1fr); gap: 14px;
  padding: 14px var(--card-pad);
  border-top: 1px solid var(--rule);
}
.activity > li:first-child { border-top: 0; }
.activity-time { font-weight: 600; font-variant-numeric: tabular-nums; color: var(--ink-2); padding-top: 1px; }
.activity-text { color: var(--ink); }
.activity-by { font-size: var(--fs-sm); color: var(--muted); margin-top: 2px; }

/* ---------- 14. Chart ---------- */
.chart-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; }
.chart-main { padding: 20px var(--card-pad) 12px; min-width: 0; }
.chart-aside { border-left: 1px solid var(--rule); display: grid; align-content: start; }
.chart-fig { display: grid; gap: 2px; padding: 18px 22px; border-top: 1px solid var(--rule); }
.chart-fig:first-child { border-top: 0; }
.chart-fig-label { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--ink-2); }
.chart-fig-value { font-size: 32px; font-weight: 600; line-height: 1.15; letter-spacing: -.01em; }
.chart-fig-note { font-size: var(--fs-sm); color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 8px; }
.legend-item { display: inline-flex; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.swatch { width: 12px; height: 12px; border-radius: 2px; flex: none; }
.swatch-in { background: var(--chart-in); }
.swatch-out { background: var(--chart-out); }
.chart { position: relative; width: 100%; height: 250px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.chart .tick { font: 400 14px var(--font-ui); fill: var(--muted); font-variant-numeric: tabular-nums; }
.chart .xlabel { font: 400 14px var(--font-ui); fill: var(--ink-2); }
.chart .xlabel.is-today { font-weight: 700; fill: var(--ink); }
.chart .val { font: 600 14px var(--font-ui); fill: var(--ink); font-variant-numeric: tabular-nums; }
.chart .band { fill: transparent; }
.chart .hit { fill: transparent; cursor: default; outline: none; }
.chart .hit:focus-visible + .band-hl, .chart .band-hl.is-on { opacity: 1; }
.chart .band-hl { fill: var(--purple-50); opacity: 0; transition: opacity .12s; }
.chart .hit:focus-visible { stroke: var(--focus); stroke-width: 2; }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none;
  min-width: 170px; padding: 10px 12px;
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  transform: translate(-50%, -100%);
  opacity: 0; transition: opacity .12s;
}
.chart-tip.is-on { opacity: 1; }
.chart-tip-title { font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.chart-tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; }
.chart-tip-row b { font-size: var(--fs-base); text-align: right; font-variant-numeric: tabular-nums; }
.line-key { width: 14px; height: 3px; border-radius: 2px; }
.table-toggle { margin-top: 8px; }
.table-toggle summary {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap);
  font-weight: 600; color: var(--purple-800); cursor: pointer; list-style: none;
}
.table-toggle summary::-webkit-details-marker { display: none; }
.table-toggle summary .icon { transition: transform .15s; }
.table-toggle[open] summary .icon { transform: rotate(180deg); }
.no-js .chart { display: none; }

/* ---------- 15. Tables — the school register ---------- */
.table-wrap { width: 100%; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
}
.table caption { text-align: left; }
.table th, .table td { padding: 13px 14px; text-align: left; vertical-align: middle; }
.table th:first-child, .table td:first-child { padding-left: var(--card-pad); }
.table th:last-child, .table td:last-child { padding-right: var(--card-pad); }
.table thead th {
  font-size: var(--fs-sm); font-weight: 700; color: var(--ink-2);
  letter-spacing: .02em;
  background: var(--surface);
  border-bottom: 1.5px solid var(--rule-ink);
  white-space: nowrap;
}
.table tbody td { border-bottom: 1px solid var(--rule); }
.table tbody tr:nth-child(even) td { background: var(--surface-alt); }
.table tbody tr:hover td { background: var(--purple-50); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .is-num { text-align: right; font-variant-numeric: tabular-nums lining-nums; white-space: nowrap; }
.table th.is-num { text-align: right; }
.table .unit { color: var(--muted); font-size: var(--fs-sm); margin-left: 3px; }
.table .cell-item a { font-weight: 600; color: var(--ink); text-decoration: none; }
.table .cell-item a:hover { color: var(--purple-800); text-decoration: underline; }
.table .cell-item { min-width: 230px; }
.table .cell-item .code { display: block; font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.table .cell-actions { white-space: nowrap; text-align: right; }
.table .cell-actions .btn + .btn { margin-left: 10px; }
.table tr.is-archived td { color: var(--muted); }
.table tr.is-archived .cell-item a { color: var(--ink-2); font-weight: 500; }
.table .status-note { display: block; font-size: var(--fs-sm); color: var(--muted); margin-top: 3px; white-space: nowrap; }
.change-in { color: var(--success); font-weight: 600; }
.change-out { color: var(--ink-2); font-weight: 600; }
.movement-type { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.movement-type .icon { color: var(--purple-700); }
.table-compact th, .table-compact td { padding-top: 10px; padding-bottom: 10px; }

/* ---------- 16. Filters ---------- */
/* Any number of filters: the search box takes the most room, selects share the rest. */
.filters {
  display: flex; flex-wrap: wrap;
  align-items: flex-end; gap: 14px 16px;
  padding: 20px var(--card-pad);
  border-bottom: 1px solid var(--rule);
}
.filters .field { margin: 0; flex: 1 1 160px; max-width: 260px; }
.filters .field-search { flex: 2 1 260px; max-width: 420px; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.filter-actions .btn { min-height: 48px; }
.results-bar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px;
  padding: 12px var(--card-pad);
  font-size: var(--fs-sm); color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
  background: var(--surface-alt);
}
.results-bar strong { color: var(--ink); }

/* ---------- 17. Forms ---------- */
.field { display: grid; gap: 6px; margin-bottom: 22px; align-content: start; }
.field:last-child { margin-bottom: 0; }
.field-label { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; font-weight: 600; color: var(--ink); }
.req {
  font-size: 13px; font-weight: 600; letter-spacing: .02em;
  color: var(--purple-800); background: var(--purple-50);
  padding: 0 7px; border-radius: 3px; box-shadow: inset 0 0 0 1px var(--purple-100);
}
.opt { font-size: var(--fs-sm); font-weight: 400; color: var(--muted); }
.field-help { font-size: var(--fs-sm); color: var(--muted); line-height: 1.45; margin-top: -2px; }
.input, .select, .textarea {
  display: block; width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  font-size: var(--fs-base); line-height: 1.4;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--input-border);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 2px rgba(40,30,20,.05);
  transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: #807B73; }
.input:hover, .select:hover, .textarea:hover { border-color: #6D675E; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--purple-700);
  box-shadow: 0 0 0 3px rgba(114,42,130,.22), inset 0 0 0 1px var(--purple-700);
}
.textarea { min-height: 104px; resize: vertical; }
.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 42px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%235A2167' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.input-group { display: flex; }
.input-addon {
  display: grid; place-items: center; padding: 0 14px;
  border: 1px solid var(--input-border); border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  background: var(--surface-sunk); color: var(--ink-2); font-weight: 600;
}
.input-group .input { border-radius: 0 var(--radius) var(--radius) 0; }
.input-narrow { max-width: 220px; }
.input-mid { max-width: 340px; }
.field-error {
  display: flex; align-items: flex-start; gap: 6px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--danger);
}
.field-error .icon { width: 18px; height: 18px; margin-top: 1px; }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea {
  border-color: var(--danger); box-shadow: inset 0 0 0 1px var(--danger);
}
.field.has-error { padding-left: 14px; border-left: 3px solid var(--danger); }
.check { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; font-weight: 500; }
.check input { width: 22px; height: 22px; accent-color: var(--purple-700); margin: 0; }
.radio-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.radio-card {
  position: relative; display: flex; align-items: center; gap: 10px;
  min-height: 52px; padding: 10px 14px;
  border: 1px solid var(--input-border); border-radius: var(--radius);
  background: var(--surface); cursor: pointer; font-weight: 600;
}
.radio-card input { width: 20px; height: 20px; accent-color: var(--purple-700); margin: 0; }
.radio-card:has(input:checked) { border-color: var(--purple-700); background: var(--purple-50); box-shadow: inset 0 0 0 1px var(--purple-700); }
.radio-card:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.form-section { padding: 0; border: 0; margin: 0; min-width: 0; }
.form-section legend { padding: 0; float: left; width: 100%; }
.form-section legend + * { clear: both; }
.section-num {
  display: inline-grid; place-items: center; width: 30px; height: 30px; margin-right: 10px;
  border-radius: 50%; border: 1px solid var(--purple-300); color: var(--purple-800);
  font-family: var(--font-display); font-weight: 700; font-size: 18px; letter-spacing: 0;
  vertical-align: 2px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 18px var(--card-pad);
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
}
.form-actions .btn-row { margin-left: auto; }

/* Stepper */
.stepper { display: inline-grid; grid-template-columns: 52px 96px 52px; align-items: stretch; }
.stepper .btn { min-height: 52px; border-radius: 0; padding: 0; }
.stepper .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.stepper .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.stepper .input {
  min-height: 52px; border-radius: 0; border-left: 0; border-right: 0;
  text-align: center; font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.stepper .input::-webkit-outer-spin-button, .stepper .input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.preview-line {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: var(--radius);
  background: var(--purple-50); box-shadow: inset 0 0 0 1px var(--purple-100);
  font-weight: 600;
}
.preview-line .arrow { color: var(--purple-700); }
.preview-line .to { font-size: var(--fs-lg); color: var(--purple-900); }

/* Password toggle */
.password-wrap { position: relative; }
.password-wrap .input { padding-right: 132px; }
.password-toggle {
  position: absolute; right: 4px; top: 4px; bottom: 4px;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; border: 0; border-radius: 4px;
  background: transparent; color: var(--purple-800); font-weight: 600; font-size: var(--fs-sm);
}
.password-toggle:hover { background: var(--purple-50); }

/* ---------- 18. Alerts ---------- */
.alert {
  --a-fg: var(--info); --a-bg: var(--info-bg); --a-bd: var(--info-line);
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--a-bd); border-left: 4px solid var(--a-fg);
  border-radius: var(--radius-sm);
  background: var(--a-bg); color: var(--ink);
}
.alert > .icon { color: var(--a-fg); width: 22px; height: 22px; margin-top: 1px; }
.alert-title { font-weight: 700; color: var(--ink); }
.alert-body { display: grid; gap: 4px; }
.alert-body ul { list-style: disc; padding-left: 20px; display: grid; gap: 4px; }
.alert-body a { color: var(--danger); font-weight: 600; }
.alert-success { --a-fg: var(--success); --a-bg: var(--success-bg); --a-bd: var(--success-line); }
.alert-warning { --a-fg: var(--warning); --a-bg: var(--warning-bg); --a-bd: var(--warning-line); }
.alert-danger  { --a-fg: var(--danger);  --a-bg: var(--danger-bg);  --a-bd: var(--danger-line); }
.alert-info    { --a-fg: var(--info);    --a-bg: var(--info-bg);    --a-bd: var(--info-line); }
.alert .btn-icon { width: 36px; min-height: 36px; margin: -6px -6px 0 0; }
.alert-stack { display: grid; gap: 12px; }
.error-summary:focus { outline: 3px solid var(--danger); outline-offset: 2px; }

/* ---------- 19. Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
  padding: 24px;
}
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(34, 18, 40, .55); animation: fade-in .18s var(--ease); }
.modal-panel {
  position: relative;
  width: min(560px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in .22s var(--ease);
}
.modal-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--rule);
}
.modal-title {
  font-family: var(--font-display); font-weight: 700; font-size: 25px; line-height: 1.15;
  letter-spacing: .05em; text-transform: uppercase; color: var(--purple-900);
}
.modal-sub { margin-top: 4px; color: var(--muted); font-size: var(--fs-sm); }
.modal-head .btn-icon { margin: -6px -8px 0 0; }
.modal-body { padding: 22px 24px; display: grid; gap: 18px; }
.modal-body .field { margin: 0; }
.modal-foot {
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--rule);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.modal-danger .modal-panel { box-shadow: var(--shadow-lg), inset 0 4px 0 var(--danger); }
.modal-danger .modal-title { color: var(--danger); }
.consequences { display: grid; gap: 8px; }
.consequences li { display: grid; grid-template-columns: 20px 1fr; gap: 10px; }
.consequences .icon { width: 20px; height: 20px; color: var(--purple-700); margin-top: 2px; }
.modal-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border-radius: var(--radius); background: var(--surface-alt); box-shadow: inset 0 0 0 1px var(--rule);
}
.modal-item strong { display: block; }
body.modal-open { overflow: hidden; }
@keyframes fade-in { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.985); } }

/* ---------- 20. Toasts ---------- */
.toast-region {
  position: fixed; right: 24px; bottom: 24px; z-index: 150;
  width: min(420px, calc(100vw - 32px));
  display: flex; flex-direction: column; gap: 12px;
  pointer-events: none;
}
.toast {
  --t-fg: var(--info);
  pointer-events: auto;
  display: grid; grid-template-columns: 24px minmax(0,1fr) auto; gap: 12px; align-items: start;
  padding: 14px 10px 14px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md), inset 4px 0 0 var(--t-fg);
  animation: toast-in .25s var(--ease);
}
.toast > .icon { color: var(--t-fg); width: 22px; height: 22px; margin-top: 1px; }
.toast-title { font-weight: 700; }
.toast-msg { color: var(--ink-2); font-size: var(--fs-sm); margin-top: 2px; }
.toast-actions { display: flex; align-items: center; gap: 2px; margin-top: -6px; }
.toast-actions .btn-icon { width: 40px; min-height: 40px; }
.toast-actions .btn-sm { min-height: 40px; }
.toast-success { --t-fg: var(--success); }
.toast-warning { --t-fg: var(--warning); }
.toast-danger  { --t-fg: var(--danger); }
.toast-info    { --t-fg: var(--info); }
.toast.is-leaving { animation: toast-out .2s var(--ease) forwards; }
.toast-static { animation: none; box-shadow: var(--shadow-sm), inset 4px 0 0 var(--t-fg); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ---------- 21. Empty states & skeletons ---------- */
.empty {
  display: grid; justify-items: center; gap: 12px;
  padding: 56px 24px 60px;
  text-align: center;
}
.empty-mark {
  width: 72px; height: 72px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--purple-50); color: var(--purple-700);
  box-shadow: inset 0 0 0 1px var(--purple-100), 0 0 0 8px var(--surface-alt);
}
.empty-mark .icon { width: 32px; height: 32px; stroke-width: 1.6; }
.empty-title { font-family: var(--font-display); font-weight: 700; font-size: 28px; line-height: 1.15; color: var(--purple-900); }
.empty p { max-width: 46ch; color: var(--ink-2); }
.empty .btn-row { justify-content: center; margin-top: 8px; }
.skeleton {
  display: block; border-radius: 4px;
  background: linear-gradient(90deg, #EFEBE4 25%, #F8F5F0 45%, #EFEBE4 65%);
  background-size: 300% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
}
.sk-line { height: 14px; }
.sk-row { display: grid; grid-template-columns: 40px 1fr 90px; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--rule); }
.sk-row:last-child { border-bottom: 0; }
.sk-circle { width: 40px; height: 40px; border-radius: 50%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- 22. Pager ---------- */
.pager {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px;
  padding: 14px var(--card-pad);
  border-top: 1px solid var(--rule);
}
.pager-list { display: flex; align-items: center; gap: 6px; }
.pager-link {
  display: inline-grid; place-items: center;
  min-width: var(--tap); height: var(--tap); padding: 0 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--ink-2); font-weight: 600; text-decoration: none; font-variant-numeric: tabular-nums;
}
a.pager-link:hover { background: var(--purple-50); color: var(--purple-900); border-color: var(--purple-100); }
.pager-link[aria-current="page"] { background: var(--purple-700); color: #FFFFFF; border-color: var(--purple-800); }
.pager-gap { color: var(--muted); padding: 0 4px; }
.pager .btn { gap: 4px; }

/* ---------- 23. Detail page ---------- */
.detail-layout { display: grid; grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); gap: var(--gutter); align-items: start; }
.level-card { display: grid; grid-template-columns: minmax(0, 1fr); }
.level-top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.hero-figure {
  font-size: var(--fs-hero); font-weight: 600; line-height: 1; letter-spacing: -.02em;
  color: var(--ink);
  font-variant-numeric: proportional-nums lining-nums;
}
.hero-figure .unit { font-size: 24px; font-weight: 600; color: var(--muted); letter-spacing: 0; margin-left: 6px; }
.hero-label { font-weight: 600; color: var(--ink-2); margin-bottom: 8px; }
.meter { margin-top: 26px; }
.meter-track {
  position: relative; height: 14px; border-radius: 7px;
  background: var(--purple-100);
}
.meter-fill {
  position: absolute; left: 0; top: 0; bottom: 0;
  border-radius: 7px; background: var(--purple-700);
  transition: width .5s var(--ease);
}
.meter-fill.is-warning { background: var(--warning); }
.meter-fill.is-danger { background: var(--danger); }
.meter-mark { position: absolute; top: -6px; bottom: -6px; width: 2px; background: var(--ink); border-radius: 1px; }
.meter-mark::after {
  content: ""; position: absolute; left: 50%; top: -3px; width: 8px; height: 8px;
  background: var(--ink); transform: translateX(-50%) rotate(45deg);
}
.meter-scale { position: relative; height: 22px; margin-top: 8px; font-size: var(--fs-xs); color: var(--muted); font-variant-numeric: tabular-nums; }
.meter-scale span { position: absolute; transform: translateX(-50%); white-space: nowrap; }
.meter-scale span:first-child { transform: none; }
.meter-scale span:last-child { transform: translateX(-100%); }
.meter-scale .is-mark { color: var(--ink); font-weight: 600; }
.meter-caption { margin-top: 10px; color: var(--ink-2); }
.facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--rule); }
.fact { padding: 16px var(--card-pad); border-left: 1px solid var(--rule); }
.fact:first-child { border-left: 0; }
.fact dt { font-size: var(--fs-sm); color: var(--muted); }
.fact dd { font-size: var(--fs-md); font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.dl-list { display: grid; }
.dl-list > div { display: grid; grid-template-columns: 128px minmax(0,1fr); gap: 12px; padding: 12px var(--card-pad); border-top: 1px solid var(--rule); }
.dl-list > div:first-child { border-top: 0; }
.dl-list dt { color: var(--muted); font-size: var(--fs-sm); padding-top: 1px; }
.dl-list dd { font-weight: 500; }
.loc-list > li { padding: 12px var(--card-pad); border-top: 1px solid var(--rule); display: grid; gap: 8px; }
.loc-list > li:first-child { border-top: 0; }
.loc-row { display: flex; justify-content: space-between; gap: 12px; }
.loc-row strong { font-variant-numeric: tabular-nums; }
.loc-bar { height: 8px; border-radius: 0 4px 4px 0; background: var(--chart-in); min-width: 2px; }
.loc-track { background: transparent; box-shadow: inset 0 -1px 0 var(--chart-grid); }

/* Form page aside */
.help-card .card-body { display: grid; gap: 16px; }
.help-item { display: grid; grid-template-columns: 24px 1fr; gap: 12px; }
.help-item .icon { color: var(--purple-700); margin-top: 2px; }
.help-item h3 { font-size: var(--fs-base); font-weight: 700; margin-bottom: 2px; }
.help-item p { font-size: var(--fs-sm); color: var(--ink-2); }
.sticky-aside { position: sticky; top: 24px; }

/* UI kit */
.kit-note { font-size: var(--fs-sm); color: var(--muted); margin-bottom: 14px; }
.kit-sub { font-size: var(--fs-base); font-weight: 700; color: var(--ink); margin: 20px 0 10px; }
.kit-sub:first-child { margin-top: 0; }
.badge-row { display: flex; flex-wrap: wrap; gap: 10px; }
.toast-preview { display: grid; gap: 10px; margin-top: 18px; }

/* ---------- 24. Auth (login) ---------- */
.auth { display: grid; grid-template-columns: minmax(360px, 5fr) minmax(0, 7fr); min-height: 100vh; }
.auth-brand {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: 56px 48px 40px; text-align: center; color: #FFFFFF;
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255,255,255,.1), rgba(255,255,255,0) 60%),
    linear-gradient(180deg, var(--purple-700) 0%, var(--purple-800) 70%, #4C1B58 100%);
}
.auth-brand::after {
  content: ""; position: absolute; inset: 20px; pointer-events: none;
  border: 1px solid rgba(255,255,255,.2);
}
.auth-lockup { position: relative; z-index: 1; display: grid; justify-items: center; gap: 22px; margin-top: 7vh; }
.auth-chip { width: 132px; height: 132px; border-radius: 28px; box-shadow: 0 18px 40px -16px rgba(20,4,26,.7), 0 0 0 1px rgba(255,255,255,.5); }
.auth-lockup .wordmark-1 { font-size: 46px; }
.auth-lockup .wordmark-2 { font-size: 22px; }
.auth-motto { position: relative; z-index: 1; display: grid; gap: 4px; }
.auth-motto .motto-latin { font-size: 30px; }
.auth-motto .motto-en { font-size: var(--fs-sm); }
.auth-place { font-size: var(--fs-sm); color: #E3CFE8; letter-spacing: .06em; margin-top: 8px; }
.auth-main {
  position: relative;
  display: grid; place-items: center; padding: 48px 32px;
  background:
    repeating-linear-gradient(135deg, transparent 0 11px, rgba(62,23,71,.022) 11px 12px),
    var(--ground);
}
.auth-card { width: min(460px, 100%); padding: 40px 40px 32px; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); }
.auth-card .page-title { font-size: 34px; }
.auth-crest { width: 64px; height: auto; margin-bottom: 18px; }
.auth-intro { margin: 10px 0 26px; color: var(--ink-2); }
.auth-card form { display: grid; gap: 20px; }
.auth-card .field { margin: 0; }
.auth-help { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--rule); font-size: var(--fs-sm); color: var(--ink-2); display: grid; grid-template-columns: 20px 1fr; gap: 10px; }
.auth-help .icon { color: var(--purple-700); width: 20px; height: 20px; margin-top: 1px; }
.auth-foot { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; font-size: var(--fs-sm); color: var(--muted); }

/* ---------- 25. Responsive ---------- */
@media (max-width: 1280px) {
  .page { padding: 28px 28px 64px; }
  .topbar { padding: 12px 28px; }
  .global-search { width: 240px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { border-left: 0; border-top: 1px solid var(--rule); }
  .stat:nth-child(even) { border-left: 1px solid var(--rule); }
  .stat:nth-child(-n+2) { border-top: 0; }
  .stat:last-child { grid-column: 1 / -1; border-left: 0; }
  .quick-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters .field-search { flex-basis: 100%; max-width: none; }
}
@media (max-width: 1100px) {
  .span-7, .span-5, .span-8, .span-4 { grid-column: span 12; }
  .detail-layout { grid-template-columns: minmax(0,1fr); }
  .chart-layout { grid-template-columns: minmax(0,1fr); }
  .chart-aside { border-left: 0; border-top: 1px solid var(--rule); grid-template-columns: repeat(3, minmax(0,1fr)); }
  .chart-fig { border-top: 0; border-left: 1px solid var(--rule); }
  .chart-fig:first-child { border-left: 0; }
}

/* Drawer navigation takes over */
@media (max-width: 960px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .topbar { display: none; }
  .mobile-bar {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    min-height: 64px; padding: 10px 12px 10px 12px;
    color: #FFFFFF;
    background: linear-gradient(90deg, var(--purple-700), var(--purple-800));
    box-shadow: 0 1px 0 rgba(0,0,0,.06), 0 4px 12px -6px rgba(40,10,50,.5);
  }
  .mobile-brand { display: flex; align-items: center; gap: 10px; color: #FFFFFF; text-decoration: none; min-width: 0; }
  .mobile-brand img { width: 42px; height: 42px; border-radius: 10px; }
  .mobile-brand .wordmark-1 { font-size: 20px; letter-spacing: .16em; margin-right: 0; }
  .mobile-brand .wordmark-2 { font-size: 13px; letter-spacing: .3em; margin-right: 0; color: #EEDFF1; }
  .mobile-brand .wordmark { gap: 3px; }
  .menu-btn {
    display: inline-flex; align-items: center; gap: 8px;
    min-height: var(--tap); padding: 0 14px 0 12px; margin-left: auto;
    border: 1px solid rgba(255,255,255,.45); border-radius: var(--radius);
    background: rgba(255,255,255,.08); color: #FFFFFF; font-weight: 600;
  }
  .menu-btn:hover { background: rgba(255,255,255,.16); }

  .js .sidebar {
    position: fixed; z-index: 90; top: 0; left: 0; bottom: 0;
    width: min(320px, 86vw); height: auto;
    transform: translateX(-102%); visibility: hidden;
    transition: transform .28s var(--ease), visibility 0s linear .28s;
    box-shadow: var(--shadow-lg);
  }
  .js .sidebar.is-open { transform: none; visibility: visible; transition: transform .28s var(--ease), visibility 0s; }
  .js .drawer-scrim {
    display: block; position: fixed; inset: 0; z-index: 80;
    background: rgba(34,18,40,.5);
    opacity: 0; pointer-events: none; transition: opacity .25s var(--ease);
  }
  .js .drawer-scrim.is-open { opacity: 1; pointer-events: auto; }
  .js .sidebar-close {
    display: inline-flex; position: absolute; top: 12px; right: 12px;
    align-items: center; gap: 6px; min-height: var(--tap); padding: 0 12px;
    border: 1px solid rgba(255,255,255,.35); border-radius: var(--radius);
    background: transparent; color: #FFFFFF; font-weight: 600;
  }
  .js .brand { padding-top: 64px; }
  .no-js .sidebar { position: static; height: auto; }
  .no-js .app { display: block; }

  .page { padding: 20px 16px 56px; }
  .page-title { font-size: 30px; letter-spacing: .05em; }
  .page-head { padding-bottom: 18px; margin-bottom: 20px; }
}

@media (max-width: 760px) {
  :root { --gutter: 16px; --card-pad: 16px; }
  .span-6 { grid-column: span 12; }
  .page-actions { width: 100%; }
  .page-actions .btn { flex: 1 1 auto; }
  .lede { font-size: var(--fs-base); }
  .card-title { font-size: 19px; }
  .btn-sm { min-height: var(--tap); }
  .stat { padding: 16px; }
  .stat-value { font-size: 34px; }
  .stat-value .unit { font-size: 18px; }
  .stat-value .cents { font-size: 20px; }
  .quick-actions { gap: 10px; }
  .action-tile { grid-template-columns: 1fr; gap: 8px; padding: 14px; min-height: 0; align-content: start; }
  .action-icon { width: 40px; height: 40px; }
  .action-icon .icon { width: 22px; height: 22px; }
  .action-name { font-size: var(--fs-base); }

  .attention-list > li { grid-template-columns: minmax(0, 1fr) auto; gap: 10px 12px; align-items: start; }
  .attention-list .level { grid-column: 1 / -1; grid-row: 2; grid-template-columns: auto minmax(0,1fr); align-items: center; gap: 6px 12px; }
  .attention-list .level .mini-meter { grid-column: 1 / -1; }
  .attention-list .attention-action { grid-column: 2; grid-row: 1; }

  .chart-aside { grid-template-columns: minmax(0,1fr); }
  .chart-fig { border-left: 0; border-top: 1px solid var(--rule); padding: 14px 16px; }
  .chart-fig:first-child { border-top: 0; }
  .chart { height: 230px; }

  .filters { padding: 16px; }
  .filters .field { flex-basis: calc(50% - 8px); max-width: none; }
  .filters .field-search { flex-basis: 100%; }
  .filter-actions { flex-basis: 100%; }
  .filter-actions .btn { flex: 1; }

  /* Tables become labelled cards */
  .table-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tbody { padding: 12px; display: grid; gap: 12px; background: var(--surface-alt); }
  .table-stack tr { background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 4px 0; }
  .table-stack tbody tr:nth-child(even) td, .table-stack tbody tr:hover td { background: transparent; }
  .table-stack td, .table-stack td:first-child, .table-stack td:last-child {
    display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: baseline;
    padding: 9px 16px; border-bottom: 1px solid var(--rule); text-align: left;
  }
  .table-stack td::before { content: attr(data-label); font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
  .table-stack td.is-num { text-align: left; }
  .table-stack tbody tr:last-child td { border-bottom: 1px solid var(--rule); }
  .table-stack tr td:last-child { border-bottom: 0; }
  .table-stack td.cell-item { display: block; padding-top: 12px; padding-bottom: 12px; font-size: var(--fs-md); }
  .table-stack td.cell-item::before { display: none; }
  .table-stack tbody { grid-template-columns: minmax(0, 1fr); }   /* one row with many actions can't widen every card */
  .table-stack td.cell-actions { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 12px; padding-bottom: 12px; white-space: normal; }
  .table-stack td.cell-actions::before { display: none; }
  .table-stack td.cell-actions .btn { flex: 1 1 40%; min-height: var(--tap); border: 1px solid var(--rule-strong); }
  .table-stack td.cell-actions .btn + .btn { margin-left: 0; }
  .table-stack td.cell-actions .action-form { flex: 1 1 40%; margin: 0; }
  .table-stack td.cell-actions .action-form .btn { width: 100%; }
  .table-stack .status-note { white-space: normal; }

  .pager { justify-content: center; }
  .pager .pager-summary { width: 100%; text-align: center; }
  .pager-list .pager-hide-sm { display: none; }
  .pager-list { flex-wrap: wrap; justify-content: center; gap: 4px; }
  .table-stack td .cell-val { min-width: 0; }
  .table-stack td .badge { vertical-align: middle; }

  .facts { grid-template-columns: 1fr; }
  .fact { border-left: 0; border-top: 1px solid var(--rule); padding: 12px 16px; }
  .fact:first-child { border-top: 0; }
  .hero-figure { font-size: 48px; }
  .dl-list > div { grid-template-columns: 112px minmax(0,1fr); }

  .form-grid { grid-template-columns: 1fr; }
  .input-narrow, .input-mid { max-width: none; }
  .form-actions {
    position: sticky; bottom: 0; z-index: 30;
    margin: 0 -16px -56px; border-radius: 0;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    box-shadow: 0 -1px 0 var(--rule), 0 -8px 20px -12px rgba(40,30,20,.35);
  }
  .form-actions .form-note { display: none; }
  .form-actions .btn-row { width: 100%; flex-wrap: nowrap; }
  .form-actions .btn-row .btn { flex: 1; }
  .sticky-aside { position: static; }
  .has-sticky-bar .toast-region { bottom: 88px; }

  .radio-cards { grid-template-columns: 1fr; }
  .toast-region { left: 16px; right: 16px; bottom: 16px; width: auto; }

  .modal { padding: 0; place-items: end stretch; }
  .modal-panel { width: 100%; max-height: 92vh; border-radius: 14px 14px 0 0; animation: sheet-in .25s var(--ease); }
  .modal-foot { position: sticky; bottom: 0; z-index: 2; border-radius: 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); box-shadow: 0 -6px 16px -10px rgba(40,30,20,.3); }
  .modal-foot .btn { flex: 1 1 100%; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-title { font-size: 22px; }
  .modal-head, .modal-body { padding-left: 18px; padding-right: 18px; }

  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 28px 20px 24px; }
  .auth-brand::after { inset: 10px; }
  .auth-lockup { margin-top: 0; gap: 14px; }
  .auth-chip { width: 84px; height: 84px; border-radius: 18px; }
  .auth-lockup .wordmark-1 { font-size: 32px; }
  .auth-lockup .wordmark-2 { font-size: 17px; }
  .auth-brand { gap: 14px; }
  .auth-motto { gap: 0; }
  .auth-motto .motto-latin { font-size: 22px; }
  .auth-motto .motto-en { font-size: 13px; }
  .auth-place { display: none; }
  .auth-main { padding: 24px 16px 40px; place-items: start center; }
  .auth-card { padding: 28px 20px 24px; }
  .auth-crest { display: none; }
  .auth-card .page-title { font-size: 28px; }
}
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
  .skeleton { animation: none; }
}

@media (forced-colors: active) {
  .badge, .btn, .card, .stat, .alert, .toast { border: 1px solid CanvasText; }
  .nav-link[aria-current="page"] { outline: 2px solid Highlight; }
}

@media print {
  .sidebar, .mobile-bar, .topbar, .page-actions, .toast-region { display: none !important; }
  .app { display: block; }
  body { background: #FFFFFF; }
}

/* ---------- 26. App integration (Django templates) ---------- */
/* Page-head blocks that a page leaves empty collapse away. */
.eyebrow:empty, .lede:empty, .page-actions:empty { display: none; }
.section-gap { margin-bottom: var(--sp-5); }
.section-gap-lg { margin-bottom: 28px; }
.btn-lg { min-height: 52px; font-size: 17px; }
.auth-card .eyebrow + .page-title { margin-top: var(--sp-2); }
.error-actions { margin-top: var(--sp-1); }
.auth-help-plain { grid-template-columns: minmax(0, 1fr); }
.card-head + .pager { border-top: 0; }

/* Nav + quick actions for routes that aren't built yet */
.action-tile.is-soon {
  background: var(--surface-alt); color: var(--muted); cursor: default;
  box-shadow: inset 0 0 0 1px var(--rule);
}
.action-tile.is-soon:hover { transform: none; color: var(--muted); box-shadow: inset 0 0 0 1px var(--rule); }
.action-tile.is-soon .action-icon { background: var(--surface-sunk); color: var(--muted); box-shadow: none; }
.action-tile.is-soon .action-name { color: var(--ink-2); }

/* KPI tile without data yet: a muted dash, not a fake number */
.stat-value.is-empty { color: var(--rule-strong); }
div.stat:hover { background: transparent; }

/* Django messages: static alerts without JS; main.js turns them into toasts */
.flash-list { display: grid; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.js .flash-list { display: none; }

/* Controls that only work with JS */
.no-js .menu-btn, .no-js .password-toggle { display: none; }
.no-js .password-wrap .input { padding-right: 14px; }

/* {% field %} variants */
.field-check .check { font-weight: 600; }
.field-choices > div { display: grid; gap: var(--sp-1); }
.field-choices label { display: inline-flex; align-items: center; gap: 10px; min-height: var(--tap); cursor: pointer; }
.field-choices input { width: 20px; height: 20px; accent-color: var(--purple-700); margin: 0; }

.empty-compact { padding: 36px var(--sp-5) 40px; }

/* Small utilities (instead of inline styles) */
.section-gap-top { margin-top: var(--sp-3); }
.sk-w-55 { width: 55%; }
.sk-w-70 { width: 70%; }
.sk-w-80 { width: 80%; }

/* UI kit */
.kit-form { max-width: 820px; }
.kit-form .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kit-form .btn-row { margin-top: var(--sp-5); }

@media (max-width: 760px) {
  .kit-form .form-grid { grid-template-columns: minmax(0, 1fr); }
  .auth-foot { position: static; margin-top: var(--sp-5); }
}

/* ---------- 27. CRUD pages (setup hub, lists, forms, detail, confirm) ---------- */
/* Form sections ({% formsection %}) */
.form-card .form-section > legend { margin-bottom: 20px; }
.form-card .section-hint { clear: both; margin: -10px 0 20px; font-size: var(--fs-sm); color: var(--muted); max-width: 62ch; }
.form-card .field:last-child { margin-bottom: 0; }
.form-card .form-grid > .field:nth-last-child(2) { margin-bottom: 22px; }
.form-card .field-hint-live { font-size: var(--fs-sm); color: var(--ink-2); margin: -12px 0 22px; }
.field-inline-note { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--ink-2); }

/* Wide tables scroll inside their card instead of spilling over it */
.table-wrap { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.contact-lines { display: grid; gap: 2px; }
.contact-lines a { overflow-wrap: anywhere; }

/* Page-head and panel actions may be small POST forms */
.action-form { margin: 0; display: inline-flex; }
.page-actions .action-form .btn { width: 100%; }
.cell-actions .action-form { margin-left: 10px; }
/* Rows with three or more actions: on desktop let them wrap instead of widening the table
   (on phones the card layout already stacks them) */
@media (min-width: 761px) {
  .table .cell-actions-wrap { white-space: normal; }
  .table .cell-actions-wrap > * { display: inline-flex; margin: 2px 0 2px 6px; }
  .table .cell-actions-wrap .btn + .btn, .table .cell-actions-wrap .action-form { margin-left: 6px; }
}

/* Setup hub */
.setup-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gutter); }
.setup-card {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; gap: 16px; align-items: start;
  padding: 20px 22px;
  background: var(--surface); color: var(--ink); text-decoration: none;
  border-radius: var(--radius-sm); box-shadow: var(--shadow-sm);
  transition: box-shadow .15s var(--ease), transform .15s var(--ease);
}
.setup-card:hover { color: var(--ink); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.setup-card .action-icon { width: 52px; height: 52px; }
.setup-card-name { display: block; font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .06em; text-transform: uppercase; color: var(--purple-900); line-height: 1.15; }
.setup-card-text { display: block; margin-top: 4px; font-size: var(--fs-sm); color: var(--ink-2); }
.setup-card-count { font-size: 30px; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; color: var(--ink); text-align: right; }
.setup-card-count small { display: block; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-top: 4px; }

/* History panel (audit entries) */
.history > li { display: grid; gap: 4px; padding: 14px var(--card-pad); border-top: 1px solid var(--rule); }
.history > li:first-child { border-top: 0; }
.history-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.history-text { color: var(--ink-2); }
.history-note { font-size: var(--fs-sm); color: var(--muted); }

/* Detail extras */
.loc-name { margin-right: auto; min-width: 0; }
.loc-name a { font-weight: 600; text-decoration: none; color: var(--ink); }
.loc-name a:hover { color: var(--purple-800); text-decoration: underline; }
.dl-list > div { grid-template-columns: 150px minmax(0, 1fr); }
.dl-list dd { overflow-wrap: anywhere; }
.facts-note { padding: 12px var(--card-pad); font-size: var(--fs-sm); color: var(--muted); border-top: 1px solid var(--rule); }
.facts-note .icon { display: inline-block; vertical-align: -4px; margin-right: 4px; }
.facts-note-inline { display: flex; align-items: flex-start; gap: 8px; margin-top: 18px; }
.facts-note-inline .icon { flex: none; margin-top: 2px; color: var(--purple-700); }
.facts-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.level-top .meter-caption { margin: 0; }
.flag-list { display: grid; }
.flag-list > li { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; padding: 12px var(--card-pad); border-top: 1px solid var(--rule); }
.flag-list > li:first-child { border-top: 0; }
.flag-list .icon { margin-top: 2px; }
.flag-list strong { display: block; }
.flag-list p { font-size: var(--fs-sm); color: var(--ink-2); }
.flag-list .is-off { color: var(--muted); }
.flag-list .is-off strong { color: var(--ink-2); font-weight: 500; }
.panel-form { padding: var(--card-pad); border-top: 1px solid var(--rule); }
.panel-form .form-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.panel-form .field { margin-bottom: 0; }
.panel-form .btn-row { margin-top: 18px; }
.changes-table td.is-old { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--rule-strong); }
.changes-table code { font: inherit; }

/* Confirm page (the no-JS fallback for a dialog) */
.confirm-card { max-width: 640px; }
.confirm-card .card-body { display: grid; gap: 16px; }
.confirm-danger { box-shadow: var(--shadow-sm), inset 0 4px 0 var(--danger); }
.confirm-foot { justify-content: flex-end; }
.empty-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; padding: 0 24px 48px; margin-top: -32px; }

@media (max-width: 1100px) {
  .setup-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-form .form-grid { grid-template-columns: 1fr; gap: 22px 0; }
}
@media (max-width: 760px) {
  .table-wrap { overflow: visible; }   /* rows are cards here; nothing to scroll sideways */
  .setup-grid { grid-template-columns: minmax(0, 1fr); }
  .setup-card { padding: 16px; gap: 12px; grid-template-columns: 44px minmax(0, 1fr) auto; }
  .setup-card .action-icon { width: 44px; height: 44px; }
  .setup-card-name { font-size: 19px; }
  .dl-list > div { grid-template-columns: 120px minmax(0, 1fr); }
  .confirm-foot { flex-direction: column-reverse; }
  .confirm-foot .btn { width: 100%; }
  .panel-form .btn-row .btn { flex: 1; }
}

/* ---------- 28. Stock ledger (phase 2): counts, ledger, reorder alerts, popup, print ---------- */
/* Item detail: the level card's live figures and the "history is behind" note after a JS save */
.level-card .card-head .meta { font-variant-numeric: tabular-nums; }
.stale-note { padding: 12px var(--card-pad); border-top: 1px solid var(--rule); background: var(--info-bg); font-size: var(--fs-sm); color: var(--ink-2); display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.stale-note .icon { color: var(--info); flex: none; }

/* Adjust dialog: three ways to say what happened. Side by side on a wide form, stacked in the
   dialog and on phones so no label has to wrap onto three lines. */
.radio-cards-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.modal .radio-cards-3 { grid-template-columns: 1fr; gap: 8px; }
.modal .radio-cards-3 .radio-card { min-height: 52px; padding: 10px 14px; }
.field-choices.form-section { margin-bottom: 22px; }
.modal-body .field-choices.form-section { margin-bottom: 0; }
.chart-fig-day { font-size: 24px; }
.fact .status-note { display: block; font-size: var(--fs-sm); font-weight: 400; color: var(--muted); margin-top: 2px; }

/* Movement detail: the headline change */
.move-hero { display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 24px; }
.move-hero .hero-figure { font-size: 48px; }
.move-hero .hero-figure.is-out { color: var(--ink-2); }
.move-hero .hero-figure.is-in { color: var(--success); }
.move-flow { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; font-variant-numeric: tabular-nums; }
.move-flow .arrow { color: var(--purple-700); }
.move-flow .to { font-weight: 700; font-size: var(--fs-lg); color: var(--purple-900); }

/* Reorder popup (dashboard) */
.popup-list > li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 16px; padding: 12px 0; border-top: 1px solid var(--rule); align-items: center; }
.popup-list > li:first-child { border-top: 0; padding-top: 0; }
.popup-figure { text-align: right; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); color: var(--muted); }
.popup-figure strong { display: block; font-size: var(--fs-lg); color: var(--ink); }
.popup-more { padding-top: 12px; border-top: 1px solid var(--rule); }
.modal-foot .btn[disabled] { cursor: not-allowed; }

/* Dropdown menu that works without JS: <details class="menu"> */
.menu { position: relative; display: inline-block; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .icon:last-child { width: 16px; height: 16px; margin-left: -2px; }
.menu[open] > summary .icon:last-child { transform: rotate(180deg); }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px;
  display: grid; gap: 2px; padding: 6px;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.menu-panel .action-form { display: block; margin: 0; }
.menu-panel .btn { width: 100%; justify-content: flex-start; }

/* The counting sheet: big targets, used on a phone in the store room */
.count-bar {
  position: sticky; top: 0; z-index: 30;
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px;
  padding: 14px var(--card-pad);
  background: var(--surface); border-bottom: 1px solid var(--rule);
}
.count-progress { display: grid; gap: 6px; flex: 1 1 240px; }
.count-progress-text { font-weight: 600; font-variant-numeric: tabular-nums; }
.count-progress-track { height: 8px; border-radius: 4px; background: var(--surface-sunk); overflow: hidden; }
.count-progress-track > span { display: block; height: 100%; border-radius: 4px; background: var(--purple-700); transition: width .2s var(--ease); }
.count-list { display: grid; }
.count-row {
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, .9fr) 190px minmax(0, 1.1fr);
  gap: 10px 20px; align-items: start;
  padding: 16px var(--card-pad); border-top: 1px solid var(--rule);
}
.count-row:first-child { border-top: 0; }
.count-row.is-counted { background: var(--surface-alt); }
.count-row.is-variance { box-shadow: inset 4px 0 0 var(--warning); }
.count-row.has-error { box-shadow: inset 4px 0 0 var(--danger); }
.count-item strong { display: block; font-size: var(--fs-md); line-height: 1.3; }
.count-item .code { display: block; font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.count-expected { font-size: var(--fs-sm); color: var(--muted); display: grid; gap: 2px; }
.count-expected strong { font-size: var(--fs-md); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.count-field { margin: 0; }
.count-field .field-label { font-size: var(--fs-sm); }
.count-input { min-height: 56px; font-size: 24px; font-weight: 600; text-align: center; font-variant-numeric: tabular-nums; }
.count-input::-webkit-outer-spin-button, .count-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.count-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.count-extra { display: grid; gap: 10px; }
.count-extra .field { margin: 0; }
.count-extra .select, .count-extra .input { min-height: 48px; }
.count-state { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; font-size: var(--fs-sm); color: var(--muted); }
.count-state .icon { width: 18px; height: 18px; }
.count-state.is-saved { color: var(--success); }
.count-state.is-error { color: var(--danger); }
.count-state.is-variance { color: var(--warning); }
.count-note { padding: 12px var(--card-pad); border-top: 1px solid var(--rule); font-size: var(--fs-sm); color: var(--muted); }
.count-foot .form-note { font-size: var(--fs-sm); color: var(--muted); }

/* Item picker (new partial count): a search box over inventory:item_search, results as big
   buttons, and the picked items as chips. The real <select multiple> stays in the form, hidden. */
.picker { display: grid; gap: 10px; }
.picker-search { position: relative; }
.picker-search > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.picker-search .input { padding-left: 46px; }
.picker-results {
  display: grid; gap: 2px; padding: 6px; max-height: 320px; overflow: auto;
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: var(--radius); box-shadow: var(--shadow-md);
}
.picker-result {
  display: grid; grid-template-columns: minmax(0, 1fr) 24px; grid-template-rows: auto auto; column-gap: 12px;
  width: 100%; min-height: var(--tap); padding: 8px 12px; text-align: left;
  background: none; border: 0; border-radius: var(--radius-sm); font: inherit; color: var(--ink); cursor: pointer;
}
.picker-result:hover { background: var(--purple-50); }
.picker-result:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.picker-result[disabled] { color: var(--muted); cursor: default; }
.picker-result .icon { grid-column: 2; grid-row: 1 / 3; align-self: center; color: var(--purple-700); }
.picker-result[disabled] .icon { color: var(--success); }
.picker-result-name { font-weight: 600; }
.picker-result-meta { font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.picker-empty { padding: 10px 12px; color: var(--muted); }
.picker-count { font-variant-numeric: tabular-nums; }
.picker-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.picker-chips:empty { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 4px 4px 4px 12px;
  background: var(--purple-50); border: 1px solid var(--purple-300); border-radius: 999px; color: var(--purple-900);
}
.chip-text { font-weight: 600; }
.chip-remove {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  background: none; border: 0; border-radius: 50%; color: var(--purple-800); cursor: pointer;
}
.chip-remove:hover { background: var(--purple-100); }
.chip-remove:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.chip-remove .icon { width: 18px; height: 18px; }

/* Submit-confirm page: the figures strip sits inside the card body */
.facts-plain { border: 1px solid var(--rule); border-radius: var(--radius-sm); }

/* Opening balances: inputs inside the register table */
.table .cell-input { width: 170px; }
.table .cell-input .input, .table .cell-input .input-group { width: 100%; }
.table .cell-input .input { min-height: 48px; text-align: right; font-variant-numeric: tabular-nums; }
.table .cell-input .input-group .input { text-align: right; }
.table .cell-input .field-error { margin-top: 6px; }
.table td.cell-input .field { margin: 0; }
.opening-total {
  display: flex; flex-wrap: wrap; gap: 8px 32px; padding: 14px var(--card-pad);
  border-top: 1px solid var(--rule); background: var(--surface-alt); font-variant-numeric: tabular-nums;
}
.opening-total strong { font-size: var(--fs-md); }

/* The A4 count sheet (standalone page, black on white) */
.print-page { background: #FFFFFF; color: #111; font-size: 14px; line-height: 1.4; }
.print-sheet { max-width: 190mm; margin: 0 auto; padding: 24px 16px 48px; }
.print-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; padding: 12px 16px; background: var(--surface-alt); border-radius: var(--radius); }
.print-head { display: grid; grid-template-columns: 56px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding-bottom: 12px; border-bottom: 2px solid #111; }
.print-head img { width: 56px; height: 56px; border-radius: 10px; }
.print-app { font-family: var(--font-display); font-weight: 700; font-size: 22px; letter-spacing: .08em; text-transform: uppercase; line-height: 1.1; }
.print-title { font-size: 16px; font-weight: 700; margin-top: 2px; }
.print-number { text-align: right; font-variant-numeric: tabular-nums; }
.print-number strong { display: block; font-size: 20px; }
.print-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px 16px; padding: 12px 0; border-bottom: 1px solid #999; font-size: 13px; }
.print-meta dt { color: #555; }
.print-meta dd { font-weight: 600; }
.print-table-wrap { overflow-x: auto; margin-top: 16px; }   /* on a phone the A4 table scrolls sideways */
.print-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.print-table th, .print-table td { border: 1px solid #444; padding: 7px 8px; text-align: left; vertical-align: top; }
.print-table th { background: #EDEDED; font-size: 13px; font-weight: 700; }
.print-table .is-num { text-align: right; font-variant-numeric: tabular-nums; }
.print-table .blank { min-width: 90px; height: 36px; }
.print-table .blank-wide { min-width: 150px; }
.print-table .code { color: #555; font-size: 12px; }
.print-sign { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; margin-top: 40px; }
.print-sign div { border-top: 1px solid #111; padding-top: 6px; font-size: 13px; color: #333; }
.print-foot { margin-top: 24px; font-size: 12px; color: #555; }
@page { size: A4; margin: 14mm; }

@media (max-width: 1100px) {
  .count-row { grid-template-columns: minmax(0, 1fr) 190px; }
  .count-row .count-expected { grid-column: 1; }
  .count-row .count-extra { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .count-bar { top: 64px; padding: 12px 16px; }   /* below the sticky purple top bar */
  .count-row { grid-template-columns: minmax(0, 1fr) 150px; gap: 8px 12px; padding: 14px 16px; }
  .count-input { min-height: 60px; font-size: 26px; }
  .count-foot { flex-direction: column; align-items: stretch; }
  .count-foot .btn-row { width: 100%; flex-wrap: nowrap; }
  .count-foot .btn-row .btn { flex: 1; }
  .table .cell-input { width: auto; }
  .table-stack td.cell-input { grid-template-columns: 112px minmax(0, 1fr); }
  .print-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .print-head { grid-template-columns: 56px minmax(0, 1fr); }
  .print-head .print-number { grid-column: 1 / -1; text-align: left; }
  .print-head .print-number strong { display: inline; margin-right: 8px; }
  .print-sign { grid-template-columns: 1fr; gap: 28px; }
  .move-hero .hero-figure { font-size: 40px; }
  .menu-panel { right: auto; left: 0; }
  .radio-cards-3 { grid-template-columns: 1fr; }
}
@media print {
  .print-tools, .no-print { display: none !important; }
  .print-page { font-size: 12.5px; }
  .print-sheet { max-width: none; padding: 0; }
  .print-table tr { break-inside: avoid; page-break-inside: avoid; }
  .print-table th { background: #EDEDED !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .print-table thead { display: table-header-group; }
}

/* ---------- 29. Approvals (phase 3): rules form, inbox, timeline, nav badge ---------- */
/* A plain-language explanation at the top of a form: quieter than an alert, not a card */
.explain { padding: 14px 18px; border-left: 3px solid var(--purple-300); border-radius: var(--radius-sm); background: var(--purple-50); color: var(--ink-2); max-width: 70ch; }
.explain p + p { margin-top: 6px; }

/* Approval steps on the rules form: one bordered block per step */
.step-list { display: grid; gap: 14px; }
.step-row { border: 1px solid var(--rule-strong); border-radius: var(--radius); background: var(--surface); }
.step-row.is-removed { display: none; }
.step-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px 10px 16px;
  border-bottom: 1px solid var(--rule); background: var(--surface-alt);
  border-radius: var(--radius) var(--radius) 0 0;
}
.step-num {
  display: inline-grid; place-items: center; width: 34px; height: 34px; flex: none;
  border-radius: 50%; background: var(--purple-700); color: #FFFFFF;
  font-family: var(--font-display); font-weight: 700; font-size: 19px; line-height: 1;
}
.step-num-sm { width: 28px; height: 28px; font-size: 16px; }
.step-title { font-size: var(--fs-md); font-weight: 700; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.step-tools { margin-left: auto; display: flex; gap: 2px; }
.step-body { padding: 18px 16px 16px; }
.step-body .alert { margin-bottom: 18px; }
.step-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.step-grid .field-step-name { grid-column: 1 / -1; }
.step-grid > .field:last-child, .step-grid > div > .field { margin-bottom: 22px; }
.step-checks { display: flex; flex-wrap: wrap; gap: 0 32px; padding-top: 4px; border-top: 1px solid var(--rule); }
.step-checks .field { margin-bottom: 0; }
.js .step-row .field-seq, .js .step-row .field-delete { display: none; }
.step-empty { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border: 1px dashed var(--rule-strong); border-radius: var(--radius); }
.step-empty .icon { color: var(--purple-700); }
.step-nojs { margin-top: 12px; }
.step-add-row { margin-top: 14px; }

/* Inbox: tick cells, the bulk bar, selected rows */
.inbox-table .cell-check { width: 56px; padding-right: 0; }
.inbox-table th.cell-check { padding-top: 6px; padding-bottom: 6px; }
.check-plain { display: inline-flex; align-items: center; gap: 10px; min-width: var(--tap); min-height: var(--tap); margin: -10px 0; cursor: pointer; }
.check-plain input { width: 22px; height: 22px; accent-color: var(--purple-700); margin: 0; flex: none; }
.check-plain .check-text { display: none; font-weight: 600; }
.inbox-table tbody tr.is-selected td { background: var(--purple-50); }
.bulk-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.bulk-count { font-variant-numeric: tabular-nums; }
.inbox-table th, .inbox-table td { padding-left: 10px; padding-right: 10px; }
.inbox-table .cell-item { min-width: 190px; }
.inbox-table .btn-sm .icon { width: 16px; height: 16px; }
.inbox-entity-inline { display: none; }
@media (min-width: 761px) {
  /* Approve over Reject in one narrow column, so seven columns fit a 1440 screen without scrolling */
  .inbox-table .cell-actions { white-space: normal; width: 1%; }
  .inbox-table .cell-actions .btn { display: flex; width: 100%; }
  .inbox-table .cell-actions .btn + .btn { margin: 6px 0 0; }
}
@media (min-width: 761px) and (max-width: 1280px) {
  /* On a laptop the entity moves into the document's second line instead of its own column */
  .inbox-table .cell-entity { display: none; }
  .inbox-entity-inline { display: inline; }
  .inbox-table th, .inbox-table td { padding-left: 8px; padding-right: 8px; }
  .inbox-table .cell-item { min-width: 150px; }
}

/* Task confirm page: the facts list inside the card body */
.task-facts { margin: 0; }
.task-facts > div { padding-left: 16px; padding-right: 16px; }
.approval-comment-card { display: grid; gap: 6px; }

/* Approval timeline on a document page */
.approval-timeline { display: grid; padding: 4px 0 6px; }
.approval-round {
  padding: 8px var(--card-pad) 6px; margin-top: 4px;
  font-size: var(--fs-xs); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
  background: var(--surface-alt); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
}
.approval-round:first-child { margin-top: 0; border-top: 0; }
.approval-step { position: relative; display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 12px var(--card-pad); }
.approval-step::before { content: ""; position: absolute; left: calc(var(--card-pad) + 17px); top: 0; bottom: 0; width: 2px; background: var(--rule); }
.approval-step:first-child::before { top: 30px; }
.approval-step:last-child::before { bottom: calc(100% - 30px); }
.approval-step:first-child:last-child::before { display: none; }
.approval-mark {
  position: relative; z-index: 1; width: 36px; height: 36px; margin-top: -1px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--rule-strong); color: var(--muted);
}
.approval-mark .icon { width: 18px; height: 18px; stroke-width: 2.2; }
.approval-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--rule-strong); }
.approval-step.is-approved .approval-mark { border-color: var(--success); background: var(--success-bg); color: var(--success); }
.approval-step.is-rejected .approval-mark { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }
.approval-step.is-skipped .approval-mark { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); }
.approval-step.is-pending .approval-mark { border-color: var(--warning); background: var(--warning-bg); color: var(--warning); box-shadow: 0 0 0 4px var(--warning-bg); }
.approval-step.is-waiting .approval-mark { border-style: dashed; }
.approval-step.is-superseded { color: var(--muted); }
.approval-step.is-superseded strong { color: var(--ink-2); font-weight: 500; }
.approval-body { min-width: 0; }
.approval-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; }
.approval-meta { font-size: var(--fs-sm); color: var(--muted); margin-top: 3px; }
.approval-comment {
  margin: 8px 0 0; padding: 8px 12px;
  border-left: 3px solid var(--rule-strong); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--surface-alt); color: var(--ink-2); font-size: var(--fs-sm); white-space: pre-line; overflow-wrap: anywhere;
}
.approval-step.is-rejected .approval-comment { border-color: var(--danger-line); background: var(--danger-bg); color: var(--ink); }
.approval-plan-wrap { display: grid; gap: 12px; }
.approval-plan { display: grid; gap: 10px; }
.approval-plan > li { display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 10px; align-items: start; }
.approval-plan .meta { display: block; }
.approval-none { display: flex; align-items: flex-start; gap: 8px; color: var(--ink-2); }
.approval-none .icon { flex: none; margin-top: 2px; }
.approval-actions { display: grid; gap: 10px; }
.approval-actions .btn-row .btn { flex: 1 1 auto; }
.approval-problem { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); color: var(--ink-2); }
.approval-problem .icon { flex: none; color: var(--info); margin-top: 1px; }

/* Item page: adjustments waiting for approval */
.pending-note { color: var(--ink-2); }
.pending-note .icon { color: var(--warning); }
.pending-note a { margin-left: 4px; font-weight: 600; }

/* Dashboard: a sixth KPI tile fits on one row; "Waiting for you" is a compact register */
.stats:has(> .stat:nth-child(6)) { grid-template-columns: repeat(5, minmax(0, 1fr)) minmax(0, 1.45fr); }
/* Seven or more (phase 4 adds two): two rows of four, so no label is squeezed to three lines */
.stats:has(> .stat:nth-child(7)) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.inbox-preview .cell-item { min-width: 150px; }

@media (max-width: 1280px) {
  .stats:has(> .stat:nth-child(6)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats:has(> .stat:nth-child(6)) .stat:last-child { grid-column: auto; border-left: 1px solid var(--rule); }
  .stats:has(> .stat:nth-child(7)) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .step-grid { grid-template-columns: minmax(0, 1fr); }
  .step-head { padding: 10px 12px; }
  .step-tools { width: 100%; margin-left: 0; justify-content: flex-end; }
  .step-tools .btn-sm { min-height: 40px; }
  .step-body { padding: 16px 12px 12px; }
  .table-stack td.cell-check { display: block; padding: 12px 16px 4px; border-bottom: 0; }
  .table-stack td.cell-check::before { display: none; }
  .check-plain { margin: 0; }
  .check-plain .check-text { display: inline; }
  .bulk-bar { width: 100%; justify-content: space-between; }
  .approval-actions .btn-row { width: 100%; }
  .approval-actions .btn-row .btn { flex: 1 1 100%; }
}

/* ---------- 30. Requests, issues and returns (phase 4) ---------- */
/* A two-up row followed by more fields kept no gap under it (.field:last-child zeroes it) */
.form-grid:not(:last-child) > .field:last-child { margin-bottom: 22px; }
/* A unit after a number box ("5 EA"), the mirror of the "Rs" add-on before a money box */
.input-group.has-suffix .input { border-radius: var(--radius) 0 0 var(--radius); }
.input-group.has-suffix .input-addon {
  border: 1px solid var(--input-border); border-left: 0;
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* A total beside a card's title (value at cost, items handed over) */
.doc-figure {
  margin-left: auto; text-align: right;
  font-size: var(--fs-lg); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap;
}
.doc-figure .meta { display: block; font-size: var(--fs-sm); font-weight: 400; }
/* A note under a figure that may run long (a damaged line's write-off) wraps instead of
   forcing its column wider than the card. */
.table .status-note.is-wrap { white-space: normal; }

/* The request line editor: one bordered row per item, wrapped by the page's form card */
.doc-lines { display: grid; gap: 0; }
.doc-line-list { display: grid; }
.doc-line {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 170px auto;
  gap: 4px 16px; align-items: start;
  padding: 16px 0; border-top: 1px solid var(--rule);
}
.doc-line:first-child { border-top: 0; }
.doc-line.has-error { padding-left: 12px; border-left: 3px solid var(--danger); }
.doc-line .field { margin: 0; }
.doc-line .field-label { font-size: var(--fs-sm); }
.doc-line-num {
  margin-top: 32px;
  font-size: var(--fs-sm); font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted);
  text-align: right;
}
.doc-line-note { grid-column: 2 / 4; }
.doc-line-hint { margin-top: 4px; font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }
.doc-line-remove { grid-column: 4; grid-row: 1; margin-top: 26px; }
.doc-line-remove .check { min-height: var(--tap); }
.doc-line-drop { color: var(--danger); }
.doc-line-foot {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding-top: 16px; border-top: 1px solid var(--rule);
}
.doc-line-foot .meta { margin-left: auto; }
/* The per-row picker sits inside the row, so its result list floats over what follows */
.picker-inline { position: relative; gap: 0; }
.picker-inline .picker-results {
  position: absolute; z-index: 20; top: 100%; left: 0; right: 0; margin-top: 4px;
  max-height: 280px; overflow-y: auto; background: var(--surface); box-shadow: var(--shadow-md);
}

/* Picking list: the issue and return pages, used standing at the shelves */
.doc-picks { display: grid; }
.doc-pick {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) 200px 112px;
  gap: 12px 20px; align-items: start;
  padding: 18px var(--card-pad); border-top: 1px solid var(--rule);
}
.doc-pick:first-child { border-top: 0; }
.doc-pick.is-picked { background: var(--surface-alt); box-shadow: inset 4px 0 0 var(--purple-500); }
.doc-pick.is-damaged { box-shadow: inset 4px 0 0 var(--warning); }
.doc-pick.has-error { box-shadow: inset 4px 0 0 var(--danger); }
.doc-pick-item strong { display: block; font-size: var(--fs-md); line-height: 1.3; }
.doc-pick-item .code { display: block; font-size: var(--fs-sm); color: var(--muted); font-variant-numeric: tabular-nums; }
.doc-pick-figures { display: grid; gap: 4px; font-size: var(--fs-sm); }
.doc-pick-figures div { display: flex; gap: 8px; justify-content: space-between; }
.doc-pick-figures dt { color: var(--muted); }
.doc-pick-figures dd { font-size: var(--fs-md); font-weight: 600; font-variant-numeric: tabular-nums; }
.doc-pick-figures dd.is-short { color: var(--warning); }
.doc-pick .field { margin: 0; }
.doc-pick-qty .field-label { font-size: var(--fs-sm); }
.doc-pick-input { min-height: 56px; font-size: 22px; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.doc-pick-input::-webkit-outer-spin-button, .doc-pick-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.doc-pick-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.doc-pick-action { margin-top: 26px; }
.doc-pick-action .btn { min-height: 56px; }
/* The return page adds condition, reason and note, so its rows run two lines deep */
.doc-pick-wide { grid-template-columns: minmax(0, 1.3fr) minmax(0, .9fr) 180px minmax(0, 1.1fr); }
.doc-pick-wide .doc-pick-condition { grid-column: 4; grid-row: 1; }
.doc-pick-wide .doc-pick-reason { grid-column: 3 / -1; }
.doc-pick-wide .doc-pick-note { grid-column: 1 / 3; }
.doc-pick-condition .radio-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
.doc-pick-condition .radio-card { min-height: var(--tap); padding: 8px 12px; font-size: var(--fs-base); }

/* ---------- 27. Buying: purchase orders, deliveries, the reorder picker ---------- */

/* A purchase-order line is a request line plus a price box */
.doc-line-priced { grid-template-columns: 26px minmax(0, 1fr) 150px 150px auto; }
.doc-line-priced .doc-line-note { grid-column: 2 / 5; }
.doc-line-priced .doc-line-remove { grid-column: 5; grid-row: 1; }

/* Receiving a delivery: the four numbers and the one box that can be typed, then the
   cost, the use-by date and a note on the row below. */
.doc-pick-grn { grid-template-columns: minmax(0, 1.2fr) minmax(0, .9fr) 190px auto; }
.doc-pick-grn .doc-pick-cost { grid-column: 1; }
.doc-pick-grn .doc-pick-expiry { grid-column: 2; }
.doc-pick-grn .doc-pick-note { grid-column: 3 / -1; }
.doc-pick-grn .field-help { margin-bottom: 6px; }
.doc-pick-grn .doc-pick-expiry .input { min-height: var(--tap); }

/* The reorder picker: one card per supplier, tick boxes and boxes inside the register table */
.pick-group.is-unassigned { border-left: 4px solid var(--warning); }
.pick-group.is-covered { border-left: 4px solid var(--info); }
.pick-group .card-title .icon { vertical-align: -4px; margin-right: 6px; }
.pick-table .cell-tick { width: 56px; padding-right: 0; }
.pick-table .cell-tick .check-plain { justify-content: center; }
.pick-table .cell-supplier { min-width: 240px; }
.pick-table .cell-supplier .select { width: 100%; min-height: var(--tap); }
.pick-table tr.is-picked td { background: var(--purple-50); }
.pick-table tr.is-picked td:first-child { box-shadow: inset 4px 0 0 var(--purple-500); }
.pick-table tr.has-error td:first-child { box-shadow: inset 4px 0 0 var(--danger); }
.pick-preferred { margin-top: 10px; font-size: var(--fs-sm); font-weight: 500; }
.pick-table .cell-input .status-note { text-align: right; }

/* The approver's "approve less" boxes on a request's lines: one small form per line */
.reduce-form { display: grid; gap: 6px; margin: 0; }
.reduce-row { display: flex; gap: 8px; align-items: stretch; justify-content: flex-end; }
.reduce-row .input { flex: 1 1 72px; min-width: 64px; }
.reduce-row .btn { white-space: nowrap; }
.reduce-input { max-width: 110px; }
.reduce-state {
  display: block; margin-top: 6px; min-height: 20px;
  font-size: var(--fs-sm); font-weight: 600; color: var(--muted); text-align: right;
}
.reduce-state .icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.reduce-state.is-saved { color: var(--success); }
.reduce-state.is-error { color: var(--danger); }
.reduce-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 16px; }
.reduce-foot .meta { flex: 1 1 260px; }

/* A print sheet for a document that hasn't been posted yet */
.print-draft {
  margin-top: 12px; padding: 8px 12px;
  border: 1px solid #A33; border-radius: 4px; color: #A33; font-weight: 700;
}

@media (max-width: 1100px) {
  .doc-line { grid-template-columns: 26px minmax(0, 1fr) 170px; }
  .doc-line .doc-line-note { grid-column: 2; grid-row: 2; }
  .doc-line .doc-line-remove { grid-column: 3; grid-row: 2; margin-top: 26px; justify-self: end; }
  .doc-pick { grid-template-columns: minmax(0, 1fr) 190px; }
  .doc-pick .doc-pick-figures { grid-column: 1; }
  .doc-pick .doc-pick-action { grid-column: 2; margin-top: 0; }
  .doc-pick-wide { grid-template-columns: minmax(0, 1fr) 190px; }
  .doc-pick-wide .doc-pick-condition,
  .doc-pick-wide .doc-pick-reason,
  .doc-pick-wide .doc-pick-note { grid-column: 1 / -1; grid-row: auto; }
  .doc-pick-grn { grid-template-columns: minmax(0, 1fr) 190px; }
  .doc-pick-grn .doc-pick-cost,
  .doc-pick-grn .doc-pick-expiry,
  .doc-pick-grn .doc-pick-note { grid-column: 1 / -1; grid-row: auto; }
  .doc-line-priced { grid-template-columns: 26px minmax(0, 1fr) 150px 150px; }
  .doc-line-priced .doc-line-note { grid-column: 2 / 5; grid-row: 2; }
  .doc-line-priced .doc-line-remove { grid-column: 2 / 5; grid-row: 3; justify-self: end; margin-top: 0; }
}
@media (max-width: 760px) {
  /* One field per row, in the order they're filled in: item, how many, note, remove. */
  .doc-line { grid-template-columns: minmax(0, 1fr); gap: 10px; padding: 16px 0; }
  .doc-line-num { display: none; }
  .doc-line .doc-line-item { grid-column: 1; grid-row: 1; }
  .doc-line .doc-line-qty { grid-column: 1; grid-row: 2; }
  .doc-line .doc-line-note { grid-column: 1; grid-row: 3; }
  .doc-line .doc-line-remove { grid-column: 1; grid-row: 4; margin-top: 0; justify-self: end; }
  .doc-line-priced { grid-template-columns: minmax(0, 1fr); }
  .doc-line-priced .doc-line-price { grid-column: 1; grid-row: 3; }
  .doc-line-priced .doc-line-note { grid-column: 1; grid-row: 4; }
  .doc-line-priced .doc-line-remove { grid-column: 1; grid-row: 5; }
  .pick-table .cell-tick { width: auto; }
  .pick-table .cell-tick .check-plain { justify-content: flex-start; }
  /* Two forms on one page (a document's details, then its lines): only the last bar sticks. */
  .span-8 > form:not(:last-of-type) .form-actions { position: static; }
  .doc-line-foot { flex-direction: column; align-items: stretch; }
  .doc-line-foot .btn { width: 100%; }
  .doc-line-foot .meta { margin-left: 0; }
  .doc-pick, .doc-pick-wide, .doc-pick-grn { grid-template-columns: minmax(0, 1fr) 150px; gap: 10px 12px; padding: 16px; }
  .doc-pick-input { min-height: 60px; font-size: 24px; }
  .doc-pick-action { grid-column: 1 / -1; margin-top: 0; }
  .doc-pick-action .btn { width: 100%; }
  .doc-pick-condition .radio-cards { grid-template-columns: 1fr 1fr; }
  .doc-figure { margin-left: 0; text-align: left; }
  .reduce-input { max-width: none; }
  .reduce-state { text-align: left; }
  .reduce-foot .btn { width: 100%; }
}

/* ---------- 31. Assets (phase 6): register, depreciation, tag picker, labels ---------- */
/* The "life used" meter on an asset page: the stock meter's track, no reorder mark */
.life-meter .meter { margin-top: 14px; }
.life-meter .meter-fill { max-width: 100%; }
.life-meter .meter-fill.is-done { background: var(--neutral); }
/* An asset's history: "Central store -> Science lab", custodian change, the document */
.route { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.route .icon { width: 16px; height: 16px; color: var(--muted); flex: none; }
.route .is-from { color: var(--ink-2); }
.route .is-to { font-weight: 600; }

/* Tag picker on the issue page: one tick box per asset in the store, under the row */
.doc-pick-tags { grid-column: 1 / -1; }
.tag-picker { margin: 4px 0 0; padding: 10px 14px 14px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--surface); }
.tag-picker legend { padding: 0 6px; margin-left: -6px; }
.tag-picker .field-error { margin-bottom: 10px; }
.tag-state { margin: 2px 0 10px; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); font-variant-numeric: tabular-nums; }
.tag-state .icon { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
/* The tags that went out on an issue line, as small linked pills under the item */
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px;
  border: 1px solid var(--purple-300); border-radius: 999px; background: var(--purple-50);
  color: var(--purple-900); font-size: var(--fs-sm); font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none;
}
.tag-chip:hover { background: var(--purple-100); }
.tag-chip.is-released { border-color: var(--neutral-line); background: var(--neutral-bg); color: var(--neutral); }
/* Dashboard: assets by entity — the bar list beside the status counts */
.assets-tile { display: grid; grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
.assets-tile .loc-list > li { padding-left: var(--card-pad); padding-right: var(--card-pad); }
.assets-tile-facts { grid-template-columns: 1fr; border: 0; border-left: 1px solid var(--rule); border-radius: 0; }
.assets-tile-facts .fact { border-left: 0; border-top: 1px solid var(--rule); padding: 12px var(--card-pad); }
.assets-tile-facts .fact:first-child { border-top: 0; }
.tag-state.is-ok { color: var(--success); }
.tag-state.is-short { color: var(--warning); }
.tag-state.is-over { color: var(--danger); }
.tag-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; list-style: none; margin: 0; padding: 0; }
.tag-option {
  display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 4px 12px; align-items: center;
  min-height: 48px; padding: 8px 12px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer;
}
.tag-option:hover { border-color: var(--purple-300); }
.tag-option:focus-within { outline: 3px solid var(--focus); outline-offset: 1px; }
.tag-option.is-picked { background: var(--purple-50); border-color: var(--purple-500); }
.tag-option input { width: 22px; height: 22px; margin: 0; accent-color: var(--purple-700); grid-row: 1 / 3; }
.tag-option .tag-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.tag-option .code { font-size: var(--fs-sm); color: var(--muted); }
.tag-picker.has-error { border-color: var(--danger); box-shadow: inset 4px 0 0 var(--danger); }

/* A visible table caption (one table per category in a depreciation run) */
.table caption.table-caption {
  padding: 12px var(--card-pad) 6px; font-weight: 700; color: var(--ink-2); font-size: var(--fs-sm);
  letter-spacing: .04em; text-transform: uppercase;
}
.table tfoot th, .table tfoot td { padding: 11px 14px; background: var(--surface-alt); border-top: 1.5px solid var(--rule-strong); font-weight: 600; }
.table tfoot th:first-child, .table tfoot td:first-child { padding-left: var(--card-pad); }
.table tfoot th:last-child, .table tfoot td:last-child { padding-right: var(--card-pad); }
.run-group + .run-group { border-top: 1px solid var(--rule-strong); }
.run-group-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; padding: 16px var(--card-pad) 4px; }
.run-group-head h3 { font-size: var(--fs-md); font-weight: 700; }
.run-group-head .num { font-weight: 600; font-variant-numeric: tabular-nums; }
.money-gain { color: var(--success); font-weight: 600; }
.money-loss { color: var(--danger); font-weight: 600; }

/* Asset tag labels: a standalone sheet of stickers, two across on A4 */
.label-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6mm; margin-top: 16px; }
.asset-label {
  display: grid; grid-template-columns: 14mm minmax(0, 1fr); gap: 2mm 4mm; align-items: center;
  min-height: 42mm; padding: 4mm 5mm;
  border: 1px solid #111; border-radius: 3mm; background: #FFFFFF; color: #111;
  break-inside: avoid; page-break-inside: avoid;
}
.asset-label img { width: 14mm; height: 14mm; border-radius: 2mm; }
.label-app { font-family: var(--font-display); font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; line-height: 1.1; }
.label-tag { font-size: 26px; font-weight: 700; letter-spacing: .02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.label-item { font-size: 14px; font-weight: 600; line-height: 1.25; }
.label-meta { font-size: 12px; color: #333; }
.label-foot { grid-column: 1 / -1; padding-top: 2mm; border-top: 1px solid #999; font-size: 11px; color: #555; }
@media print {
  .label-sheet { gap: 4mm; }
  .asset-label { border-color: #000; }
}
@media (max-width: 1100px) {
  .assets-tile { grid-template-columns: minmax(0, 1fr); }
  .assets-tile-facts { border-left: 0; border-top: 1px solid var(--rule-strong); }
}
@media (max-width: 760px) {
  /* Stacked tables: a visible caption spans the card and a tfoot becomes its own card with labelled rows */
  .table-stack caption.table-caption { display: block; width: 100%; padding: 12px 16px 4px; }
  .table-stack tfoot { display: block; padding: 0 12px 12px; background: var(--surface-alt); }
  .table-stack tfoot tr { display: block; background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); padding: 4px 0; }
  .table-stack tfoot th, .table-stack tfoot td {
    display: block; width: 100%; padding: 9px 16px; text-align: left;
    background: transparent; border-top: 0; border-bottom: 1px solid var(--rule);
  }
  .table-stack tfoot td[data-label] { display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 12px; align-items: baseline; }
  .table-stack tfoot td[data-label]::before { content: attr(data-label); font-size: var(--fs-sm); font-weight: 600; color: var(--muted); }
  .table-stack tfoot td:empty { display: none; }
  .table-stack tfoot tr > :last-child { border-bottom: 0; }
  .label-sheet { grid-template-columns: minmax(0, 1fr); }
  .tag-list { grid-template-columns: minmax(0, 1fr); }
  .run-group-head { padding: 14px 16px 4px; }
}

/* ---------- 32. Reports (phase 7): the index cards and the one report page ---------- */
/* The index reuses the setup-hub cards; a report card has no count, so two columns. */
.report-grid .report-card { grid-template-columns: 52px minmax(0, 1fr); }

/* How to read these figures: sits directly under the page title (reuses .explain) */
.report-basis { display: flex; gap: 10px; align-items: flex-start; max-width: none; padding: 12px 16px; margin-bottom: var(--sp-4); }
.report-basis .icon { width: 19px; height: 19px; flex: none; margin-top: 2px; color: var(--purple-700); }
.report-basis strong { color: var(--ink); }

/* The filter card: the form is the last thing in it, so it keeps the card's corners */
.filters-foot { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
/* A report has up to five filters, each with a line of guidance, so they sit on a grid
   rather than in a row: every one keeps its full width and its help text. */
.report-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 0 20px; align-items: start; }
.report-filters .field { max-width: none; margin-bottom: 18px; }
.report-filters .field-help { max-width: 42ch; }
/* A tick box has no label line above it, so it sits level with the boxes beside it */
.report-filters .field-check { margin-top: 28px; }
.report-filters .filter-actions { grid-column: 1 / -1; }

/* Totals that have no column of their own ("of which fixed assets awaiting issue") */
.report-figures {
  display: flex; flex-wrap: wrap; gap: 8px 32px;
  padding: 14px var(--card-pad); border-top: 1px solid var(--rule);
  background: var(--surface-alt); font-variant-numeric: tabular-nums;
}
.report-figures > div { display: flex; gap: 10px; align-items: baseline; }
.report-figures dt { color: var(--ink-2); font-size: var(--fs-sm); }
.report-figures dd { font-weight: 700; color: var(--ink); }

/* The caveats the report carries (Report.notes): quiet, but under the totals they qualify */
.report-notes {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px var(--card-pad); border-top: 1px solid var(--rule);
  background: var(--surface-alt); color: var(--ink-2); font-size: var(--fs-sm);
  border-radius: 0 0 var(--radius) var(--radius);
}
.report-notes .icon { width: 19px; height: 19px; flex: none; margin-top: 2px; color: var(--muted); }
.report-notes p + p { margin-top: 8px; }
.report-notes-title { font-weight: 700; color: var(--ink); }

/* A report table carries up to eleven columns, so its cells are narrower than a list's */
.report-table th, .report-table td { padding: 10px; }
.report-table th:first-child, .report-table td:first-child { padding-left: var(--card-pad); }
.report-table th:last-child, .report-table td:last-child { padding-right: var(--card-pad); }

/* A figure below zero: the minus sign says it, the colour only helps it stand out */
.table .is-less { color: var(--danger); }
.table tbody th.row-head { font-weight: 600; white-space: nowrap; }
/* A row header names the row; a .code under it (a prefix, a serial) is a quieter second line,
   so it drops the header's weight instead of reading as a second heading. */
.table tbody th.row-head .code { font-weight: 400; }

/* The printed sheet: a report carries more columns than a count sheet, so its table is tighter,
   and a wide one prints landscape (a named page, so only this sheet turns). */
.print-report .print-table { font-size: 12.5px; }
.print-report .print-table th, .print-report .print-table td { padding: 5px 6px; }
.print-report .print-table tbody th.row-head { white-space: nowrap; font-weight: 700; }
.print-report-wide .print-sheet { max-width: 272mm; }
.print-report-wide { page: wide; }
@page wide { size: A4 landscape; margin: 10mm; }
.print-lede { margin-top: 12px; font-size: 13px; color: #333; max-width: 95ch; }
.print-figures { display: flex; flex-wrap: wrap; gap: 6px 28px; margin-top: 12px; padding: 8px 0; border-top: 1px solid #999; font-size: 13px; }
.print-figures > div { display: flex; gap: 8px; }
.print-figures dt { color: #555; }
.print-figures dd { font-weight: 700; }
.print-table tfoot th, .print-table tfoot td { background: #F3F3F3; font-weight: 700; }
/* The totals row's own summary ("2 group(s)") sits under the word Total, not welded to it:
   .status-note is styled for the screen table, and the printed table needs it too. */
.print-table .status-note { display: block; font-size: 11.5px; font-weight: 400; color: #444; }
.print-table .is-less { color: #000; }
@media print {
  .print-table tfoot { display: table-footer-group; }
  .print-table tfoot th, .print-table tfoot td { background: #F3F3F3 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

@media (max-width: 760px) {
  /* The first column names the row, so on a phone it becomes the card's heading */
  .table-stack tbody th.row-head {
    display: block; width: 100%; text-align: left;
    padding: 12px 16px 8px; border-bottom: 1px solid var(--rule);
    font-size: var(--fs-md); font-weight: 700; background: transparent;
  }
  /* A report label can be long ("Value at selling price (Rs)"), so it wraps above the figure
     instead of running into it — numeric cells are nowrap, their labels are not. */
  .report-table.table-stack td[data-label] { grid-template-columns: 132px minmax(0, 1fr); }
  .report-table.table-stack td[data-label]::before { white-space: normal; }
  .report-filters .field-check { margin-top: 0; }
  /* The totals card has to look like a conclusion, not one more row */
  .report-table.table-stack tfoot th[scope="row"] { font-size: var(--fs-md); font-weight: 700; color: var(--purple-900); }
  .report-figures { flex-direction: column; gap: 8px; padding: 12px 16px; }
  .report-notes { padding: 12px 16px; }
  .report-basis { padding: 12px 14px; }
}
