/* The Replenishment Middleware's pages on Pola, AII's design system (DESIGN.md at the repo root). This app takes
   Pola's tokens only: pola/pola-tokens-<version>.css is the Release's dist/tokens.css, copied verbatim and loaded
   first. Every colour, type size, space, radius, shadow and duration here is a Pola token; a test holds the colours.
   The --mw- tokens below are this app's own sizes, which Pola leaves to the app. Pola's Library is React, so the
   components are drawn here from the same tokens and rules: one blue for action, two text greys, soft badges, flat
   cards on hairlines, a hover a person can see, motion on Astryx's curve. Then this service's own part: the strip. */

/* ---------- Base ---------- */
:root {
  --mw-topbar-height: 56px; --mw-rail-width: 220px; --mw-touch: 44px;
  --mw-control-sm: 28px; --mw-control-md: 32px; --mw-control-lg: 36px;
  --mw-focus-width: 2px; --mw-press-scale: 0.98;
  /* Pola's hover: an 8% overlay of the ink over whatever the control rests on (The Visible Hover Rule, ΔE ≥ 3), laid
     as a background image so it works on any fill. The ink flips in dark, so the overlay does too. */
  --mw-hover: color-mix(in srgb, var(--text-primary) 8%, transparent);
  --mw-hover-layer: linear-gradient(var(--mw-hover), var(--mw-hover));
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body { margin: 0; font-family: var(--font-sans); font-size: var(--font-size-body-sm); line-height: var(--line-height-body);
  color: var(--text-primary); background: var(--surface-page); }
code, kbd, samp, pre { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
a { color: var(--text-link); text-decoration: none; }
a:hover { color: var(--text-link-hover); text-decoration: underline; }
:where(a, button, input, select, textarea, [tabindex]):focus-visible { outline: var(--mw-focus-width) solid var(--focus-ring); outline-offset: 2px;
  border-radius: var(--radius-xs); }
h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; margin: 0; }
form { display: inline; }
::selection { background: var(--surface-tint); color: var(--text-primary); }
:where(summary):focus-visible { outline: var(--mw-focus-width) solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-xs); }
code { font-size: 0.92em; padding: 0 var(--space-xs); border-radius: var(--radius-xs); background: var(--field-rest); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--text-secondary); }
.small { font-size: var(--font-size-caption); line-height: var(--line-height-body); }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

a.skip { position: absolute; left: var(--space-lg); top: -100px; z-index: 60; padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm); background: var(--surface-inverse); color: var(--text-on-inverse); }
a.skip:focus, a.skip:hover { top: var(--space-sm); color: var(--text-on-inverse); text-decoration: none; }

/* ---------- AppShell + TopNav ---------- */
.shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 40; background: var(--surface-card); border-bottom: 1px solid var(--border-hairline); }
.topbar__row { display: flex; align-items: center; gap: var(--space-md); height: var(--mw-topbar-height); padding: 0 var(--space-xl) 0 var(--space-lg); }
a.topbar__brand, .topbar__brand { display: flex; align-items: center; gap: var(--space-sm); min-width: 0; color: var(--text-primary); }
a.topbar__brand:hover { color: var(--text-primary); text-decoration: none; }
.topbar__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--font-size-h4); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-heading); }
.topbar__end { margin-left: auto; display: flex; flex: none; align-items: center; gap: var(--space-md); }
.topbar__user { font-size: var(--font-size-caption); color: var(--text-secondary); }
.topbar__writes { font-size: var(--font-size-caption); color: var(--text-secondary); white-space: nowrap; }
.topbar__writes-short { display: none; }
.fact__part { white-space: nowrap; }
.body { display: flex; min-height: calc(100vh - var(--mw-topbar-height) - 1px); }
.main { flex: 1; min-width: 0; padding: var(--space-xl) var(--space-lg) var(--space-4xl); }
/* The pages fill the window: tables and the strip use the width (Pola's 1200px container suits reading pages, not
   data). Prose keeps its own measure: the status reason and a banner's words stop at 72ch. */
.page { display: flex; flex-direction: column; gap: var(--space-lg); }
/* Status, Config and the Pause page are reading pages, not data: they stop at Pola's 1200px container (#30). */
.page--narrow { max-width: 1200px; }
@media (min-width: 768px) { .main { padding-left: var(--space-xl); padding-right: var(--space-xl); } }

/* ---------- SideNav ---------- */
.rail { position: sticky; top: calc(var(--mw-topbar-height) + 1px); align-self: flex-start; flex: none; width: var(--mw-rail-width);
  height: calc(100vh - var(--mw-topbar-height) - 1px); display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface-card); border-right: 1px solid var(--border-hairline); }
.rail__inner { display: flex; flex-direction: column; flex: 1; gap: var(--space-xs); padding: var(--space-sm); overflow-y: auto; }
.rail__section { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--space-sm); }
.rail__title { padding: var(--space-md) var(--space-md) var(--space-xs); font-size: var(--font-size-micro); font-weight: var(--pola-font-weight-medium);
  line-height: var(--line-height-body); letter-spacing: var(--letter-spacing-kicker); text-transform: uppercase; color: var(--text-secondary); }
a.rail__link { display: flex; align-items: center; gap: var(--space-sm); min-height: var(--mw-control-lg); padding: 0 var(--space-md);
  border-radius: var(--radius-sm); color: var(--text-primary); transition: var(--transition-control); }
a.rail__link:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); text-decoration: none; }
a.rail__link[aria-current="page"] { background: var(--surface-tint); color: var(--text-brand); font-weight: var(--pola-font-weight-medium); }
.rail__icon { flex: none; color: var(--icon-secondary); }
a.rail__link[aria-current="page"] .rail__icon { color: var(--text-brand); }
.rail__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Folded (desktop): 64px of icons, as the Planner's SideNav. The label stays for screen readers; the Tooltip names
   each item on hover and focus (middleware.js). The width animates only on a toggle: the head script sets the state
   before the first paint. */
.iconbtn.navtoggle { display: none; width: var(--mw-control-md); height: var(--mw-control-md); margin: 0; padding: 0; border: 0; background: transparent; }
@media (min-width: 768px) { .js .iconbtn.navtoggle { display: inline-flex; } }
.body > .rail { transition: width var(--pola-duration-medium) var(--easing-standard); }
[data-nav="collapsed"] .body > .rail { width: 64px; }
[data-nav="collapsed"] .body > .rail .rail__title { display: none; }
[data-nav="collapsed"] .body > .rail a.rail__link { justify-content: center; padding: 0; }
[data-nav="collapsed"] .body > .rail .rail__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Phone (<768px): the SideNav as a drawer, a <details> that middleware.js also closes on Esc and on the scrim. */
.drawer { display: none; }
.iconbtn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: var(--mw-touch); height: var(--mw-touch);
  margin-left: calc(-1 * var(--space-sm)); border-radius: var(--radius-sm); color: var(--text-secondary); cursor: pointer; list-style: none; }
.iconbtn:hover { background-image: var(--mw-hover-layer); }
.iconbtn::-webkit-details-marker { display: none; }
@media (max-width: 767px) {
  .body > .rail { display: none; }
  .drawer { display: block; }
  .drawer .rail { position: fixed; top: calc(var(--mw-topbar-height) + 1px); left: 0; z-index: 40; box-shadow: var(--shadow-card); }
  .drawer[open]::before { content: ""; position: fixed; inset: calc(var(--mw-topbar-height) + 1px) 0 0 0; z-index: 30;
    background: color-mix(in srgb, var(--color-deep-navy) 24%, transparent); }
  .drawer .rail a.rail__link { min-height: var(--mw-touch); }
  .topbar__row { gap: var(--space-sm); padding: 0 var(--space-md); }
  .topbar__user { display: none; }
  .topbar__writes-long { display: none; }
  .topbar__writes-short { display: inline; }
}

/* ---------- Text ---------- */
h1 { font-size: var(--font-size-h2); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-heading); letter-spacing: var(--letter-spacing-h2); }
.page__head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-xs) var(--space-lg); }
.page__titles { display: flex; flex-direction: column; gap: var(--space-xs); }
.page__sub { font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }

/* ---------- Card ---------- */
.card { border: 1px solid var(--border-hairline); border-radius: var(--radius-md); background: var(--surface-card); }
.card--pad { padding: var(--space-lg) var(--space-20); }
/* The card itself does not clip, so the rows-per-page menu can open upward past a short table. The scrolling table
   area clips instead: its corners follow the card's, inside the 1px border, so the sticky header and the rows
   never paint over the rounded edge. */
.card--table { position: relative; }
.card--table > .tablewrap { border-radius: calc(var(--radius-md) - 1px) calc(var(--radius-md) - 1px) 0 0; }
.card--table > .tablewrap:last-child { border-radius: calc(var(--radius-md) - 1px); }
.card--table > :first-child:not(.tablewrap) { border-radius: calc(var(--radius-md) - 1px); }

/* ---------- Button (Pola: 8px radius; one primary per view; 44px touch on a phone) ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-sm); height: var(--mw-control-md); padding: 0 var(--space-md);
  border: 1px solid transparent; border-radius: var(--radius-sm); font-size: var(--font-size-body-sm); font-weight: var(--pola-font-weight-medium); line-height: 1;
  white-space: nowrap; cursor: pointer; transition: var(--transition-control); background: var(--color-anugrah-blue); color: var(--color-on-brand); }
/* The base colours every anchor; a link styled as a Button takes its colours back. */
a.btn, a.btn:hover { color: var(--color-on-brand); text-decoration: none; }
.btn:not(:disabled):active { transform: scale(var(--mw-press-scale)); }
.btn--primary:not(:disabled):hover, a.btn--primary:hover { background-color: var(--color-anugrah-blue-hover); color: var(--color-on-brand); }
.btn--secondary, a.btn--secondary { background: var(--field-rest); color: var(--text-primary); }
.btn--secondary:not(:disabled):hover, a.btn--secondary:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); }
.btn--ghost, a.btn--ghost { background: transparent; color: var(--text-primary); }
.btn--ghost:not(:disabled):hover, a.btn--ghost:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); }
.btn--sm { height: var(--mw-control-sm); padding: 0 var(--space-sm); font-size: var(--font-size-caption); }
.btn--block { width: 100%; height: var(--mw-control-lg); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: var(--disabled-opacity); cursor: not-allowed; }
.btn[aria-disabled="true"]:hover { background-image: none; }
@media (max-width: 767px) {
  .btn, .btn--sm, .btn--block { height: var(--mw-touch); padding: 0 var(--space-lg); }
}

/* ---------- Badge: soft only, tint + 1px line + ink (Pola's Soft Badge Rule, ADR-0013 there) ---------- */
.badge { display: inline-flex; align-items: center; gap: var(--space-xs); height: 20px; padding: 0 var(--space-sm); border: 1px solid; border-radius: var(--radius-pill);
  font-size: var(--font-size-caption); font-weight: var(--pola-font-weight-medium); line-height: 1; white-space: nowrap; }
.badge { text-transform: capitalize; }
/* An outcome badge is capitalised in the template: "Answered, not written" keeps its later words lower case (#35). */
.badge[class*="out--"] { text-transform: none; }
.badge--neutral { background: var(--badge-neutral-tint); border-color: var(--badge-neutral-line); color: var(--badge-neutral-ink); }
.badge--info    { background: var(--badge-info-tint);    border-color: var(--badge-info-line);    color: var(--badge-info-ink); }
.badge--success { background: var(--badge-success-tint); border-color: var(--badge-success-line); color: var(--badge-success-ink); }
.badge--warning { background: var(--badge-warning-tint); border-color: var(--badge-warning-line); color: var(--badge-warning-ink); }
.badge--error   { background: var(--badge-error-tint);   border-color: var(--badge-error-line);   color: var(--badge-error-ink); }

/* ---------- Banner ---------- */
.banner { display: flex; align-items: flex-start; gap: var(--space-md); padding: var(--space-md) var(--space-lg); border: 1px solid; border-radius: var(--radius-md);
  color: var(--text-primary); }
.banner__icon { flex: none; width: 20px; height: 20px; margin-top: 0; }
/* A banner's words keep the prose measure (#71): across a wide page a line ran to about 170 characters. */
.banner__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; max-width: 72ch; text-wrap: pretty; }
.banner__title { font-weight: var(--pola-font-weight-bold); }
.banner a { color: var(--text-link); text-decoration: underline; text-underline-offset: 2px; font-weight: var(--pola-font-weight-medium); }
/* Pola's status tints with their hairline; the glyph and the title take the status text colour, the body stays ink. */
.banner--info    { background: var(--surface-tint);     border-color: var(--color-sky-line); }
.banner--success { background: var(--color-success-bg); border-color: var(--color-success-line); }
.banner--warning { background: var(--color-warning-bg); border-color: var(--color-warning-line); }
.banner--error   { background: var(--color-danger-bg);  border-color: var(--color-danger-line); }
.banner--info .banner__icon, .banner--info .banner__title { color: var(--text-brand); }
.banner--success .banner__icon, .banner--success .banner__title { color: var(--text-success); }
.banner--warning .banner__icon, .banner--warning .banner__title { color: var(--text-warning); }
.banner--error .banner__icon, .banner--error .banner__title { color: var(--text-danger); }

/* ---------- Field ---------- */
.field { display: block; }
.field__label { display: block; margin-bottom: var(--space-sm); font-weight: var(--pola-font-weight-medium); }
.field__box { display: flex; align-items: center; height: var(--mw-control-lg); padding: 0 var(--space-md); background: var(--surface-card);
  border: 1px solid var(--icon-secondary); border-radius: var(--radius-sm); transition: var(--transition-control); }
.field__box:focus-within { border-color: var(--focus-ring); box-shadow: var(--shadow-focus); }
.field__input { flex: 1; min-width: 0; padding: 0; border: 0; background: transparent; outline: none; }
.field__input:focus-visible { outline: none; }
@media (max-width: 767px) { .field__box { height: var(--mw-touch); } }

/* ---------- Status ---------- */
.status { display: flex; flex-direction: column; gap: var(--space-lg); }
.status__top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--space-md) var(--space-xl); }
.status__verdict { display: flex; flex-direction: column; gap: var(--space-xs); min-width: 0; max-width: 72ch; }
.status-word { font-size: var(--font-size-display-sm); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-display);
  letter-spacing: var(--letter-spacing-display); text-transform: capitalize; color: var(--text-secondary); }
.status--ok .status-word { color: var(--text-success); }
/* "ok" is an abbreviation: OK, not Ok. */
.status--ok .status-word, #live-badge[data-status="ok"] { text-transform: uppercase; }
.status--retrying .status-word, .status--paused .status-word { color: var(--text-warning); }
.status--alerting .status-word, .status--stalled .status-word { color: var(--text-danger); }
.status-reason { overflow-wrap: anywhere; }
/* The first thing to check while a reason keeps failing (#27). */
.status-hint { color: var(--text-secondary); overflow-wrap: anywhere; }
/* Where it broke (#36), Parts of a run and Alongside each run (#40): one row per part, name then state; only a failing
   part is coloured. Both lists share the block's columns, so their states line up. */
.chain-block { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: var(--space-xs) var(--space-xl);
  margin-block: var(--space-sm); }
.chain-block__label { grid-column: 1 / -1; font-size: var(--font-size-caption); font-weight: var(--font-weight-regular);
  line-height: var(--line-height-body); letter-spacing: 0; color: var(--text-secondary); }
.chain-block__label--beside { margin-top: var(--space-sm); }
.chain { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; row-gap: var(--space-xs);
  margin: 0; padding: 0; list-style: none; font-size: var(--font-size-body-sm); line-height: var(--line-height-body); }
/* Rows align at their top line box: the name's mark is centred in it, and the badge sits inside the state's line. */
.chain__link { display: grid; grid-column: 1 / -1; grid-template-columns: subgrid; align-items: start; min-width: 0; }
.chain__name { display: flex; align-items: center; gap: var(--space-sm); min-height: calc(1em * var(--line-height-body)); }
.chain__mark { flex: none; color: var(--icon-secondary); }
.chain__state { min-width: 0; color: var(--text-secondary); overflow-wrap: anywhere; text-wrap: pretty; }
/* "last answer 17:00 WIB" wraps as one phrase, never between the words and their time. */
.chain__when { white-space: nowrap; }
/* A part that is not doing its part (`Link.quiet`: not reached, not yet, off, paused, held) reads quieter. */
.chain__link--quiet .chain__name { color: var(--text-secondary); }
.chain__link--failing .chain__name { font-weight: var(--pola-font-weight-medium); }
.chain__link--failing .chain__mark { color: var(--text-danger); }
/* Who to ask is the answer the list exists for: primary ink, medium weight. */
.chain__owner { color: var(--text-primary); font-weight: var(--pola-font-weight-medium); }
/* A phone puts each state under its name, lined up with the name's text: most states carry a time, too long to sit
   beside it, and rows that wrap only sometimes read ragged. */
@media (max-width: 767px) {
  .chain-block { display: flex; flex-direction: column; }
  .chain { display: flex; flex-direction: column; gap: var(--space-sm); }
  .chain__link { display: flex; flex-direction: column; gap: 2px; }
  .chain__state { padding-left: calc(16px + var(--space-sm)); }
}
.status-history { font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }
.controls { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.controls__note { flex-basis: 100%; }
/* Beside the verdict (desktop) the buttons hold the card's right edge, so a note appearing under them, or Pause turning
   into Resume, never moves Run now. */
@media (min-width: 768px) {
  /* The parts lists (#40) make the verdict wide enough to push the buttons under it: the verdict gives way instead. */
  .status__top { flex-wrap: nowrap; }
  .controls { flex: none; justify-content: flex-end; }
  .controls__note { text-align: right; }
}
.running { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-sm); }
.over { color: var(--text-danger); }

.refresh { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); font-size: var(--font-size-caption);
  line-height: var(--line-height-body); color: var(--text-secondary); }
.refresh__toggle, .refresh__mode { display: none; }
.js .refresh__toggle { display: inline-flex; }
.js .refresh__mode { display: inline; }
.refresh--held { color: var(--text-secondary); font-style: italic; }
.refresh--stale { color: var(--text-warning); }

/* MetadataList: label above value, the Lag first and largest. */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 20rem)); gap: var(--space-lg) var(--space-xl); }
.facts > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.facts dt { font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }
.facts dd { min-width: 0; overflow-wrap: anywhere; text-wrap: pretty; }
/* What the facts' words mean (#27): closed by default, one line under the facts. */
.defs summary { display: inline-flex; align-items: center; gap: var(--space-xs); height: var(--mw-control-sm); padding: 0 var(--space-sm);
  margin-left: calc(-1 * var(--space-sm)); border-radius: var(--radius-sm); color: var(--text-link); font-size: var(--font-size-caption);
  font-weight: var(--pola-font-weight-medium); cursor: pointer; list-style: none; }
.defs summary::-webkit-details-marker { display: none; }
.defs summary:hover { background-image: var(--mw-hover-layer); }
.defs summary svg { width: 16px; height: 16px; transition: transform var(--pola-duration-fast) var(--easing-standard); }
.defs[open] summary svg { transform: rotate(90deg); }
.defs__list { display: grid; gap: var(--space-sm); max-width: 72ch; margin-top: var(--space-sm); }
.defs__list dt { font-weight: var(--pola-font-weight-medium); }
.defs__list dd { color: var(--text-secondary); }
.facts .fact--lead dd strong, .facts .fact--lead dd .fact__value { font-family: var(--font-mono); font-variant-numeric: tabular-nums;
  font-size: var(--font-size-h3); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-heading); }
.facts .fact__limit { display: block; font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }

/* ---------- Slot strip: 4 runs of 6 h, side by side on desktop, stacked on a phone ---------- */
.strip { display: flex; flex-direction: column; gap: var(--space-md); }
.strip__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-xs) var(--space-lg); }
.strip__title { font-size: var(--font-size-h4); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-heading); letter-spacing: 0; }
.strip__summary { font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }
/* The verdict's number (#38): medium weight in the line's own colour, never a coloured number (status in words). */
.strip__figure { font-weight: var(--pola-font-weight-medium); }
.cells { display: flex; gap: 2px; }
.cells__run { display: flex; flex: 1; flex-direction: column; gap: var(--space-xs); min-width: 0; }
.cells__row { display: flex; gap: 1px; height: 28px; }
.cells__times { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: var(--font-size-caption); color: var(--text-secondary); }
.cell { flex: 1; min-width: 0; }
.cells__row .cell:first-child { border-top-left-radius: var(--radius-xs); border-bottom-left-radius: var(--radius-xs); }
.cells__row .cell:last-child { border-top-right-radius: var(--radius-xs); border-bottom-right-radius: var(--radius-xs); }
@media (max-width: 767px) {
  .cells { flex-direction: column; gap: var(--space-md); }
  .cells__row { gap: 2px; height: 32px; }
}
/* Fills (#22, the pola chart review): the strip's point is where a slot did not write, so failure is the focus and
   the rest is context. Written, the usual case, recedes to the hairline grey; failed is the solid danger fill, about
   3:1 from written in lightness as well as hue, so it stands out without colour; paused is a grey hatch; a slot with
   no run is a danger ring on the card. Pola ships no data greys to a tokens-only app, so the greys are its own. */
/* Answered but not written is the healthy state while WRITE_FORECASTS is off (#35): drawn as written. */
.cell--written, .swatch--written, .cell--answered_not_written, .swatch--answered_not_written { background: var(--color-line); }
.cell--failed, .swatch--failed { background: var(--color-danger); }
.cell--paused, .swatch--paused { background: repeating-linear-gradient(135deg, var(--icon-secondary) 0 2px, var(--color-line) 2px 5px); }
.cell--answered, .swatch--answered { background: linear-gradient(to top, var(--icon-secondary) 50%, var(--surface-card) 50%);
  box-shadow: inset 0 0 0 1px var(--icon-secondary); }
.cell--seeded, .swatch--seeded { background: var(--surface-card); box-shadow: inset 0 0 0 2px var(--text-primary); }
.cell--idle, .swatch--idle { background: var(--field-rest); box-shadow: inset 0 0 0 1px var(--color-line); }
.cell--gap, .swatch--gap { background: var(--surface-card); box-shadow: inset 0 0 0 2px var(--color-danger); }
.cell--before { background: var(--skeleton-base); }
/* The current slot before its run records a call: not a gap yet, so no danger ring. */
.cell--now { background: var(--surface-card); box-shadow: inset 0 0 0 1px var(--icon-secondary); }
a.cell { display: block; }
/* The cells carry patterns and rings in their background and shadow, so their hover darkens the whole cell instead. */
a.cell:hover { filter: brightness(0.85); }
/* The slot a tap opened keeps the focus ring, so it is clear which slot the tip describes (#39 critique). */
a.cell:focus-visible, a.cell[aria-expanded="true"] { outline: var(--mw-focus-width) solid var(--focus-ring); outline-offset: 2px; border-radius: var(--radius-xs); position: relative; z-index: 1; }
.legend { display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-lg); font-size: var(--font-size-caption); color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: var(--space-xs); }
.legend .legend__note { flex-basis: 100%; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: var(--radius-xs); }
.legend b { font-weight: var(--pola-font-weight-medium); color: var(--text-primary); }

/* Tooltip: the inverse surface, placed by middleware.js. */
.tip { position: fixed; z-index: 70; max-width: 20rem; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-sm); pointer-events: none;
  background: var(--surface-inverse); color: var(--text-on-inverse); font-size: var(--font-size-caption); line-height: var(--line-height-body);
  box-shadow: var(--shadow-card); }
/* A slot's tip is stacked lines (#39): its time in medium weight, then the outcome word, then the details. */
.tip__line { display: block; }
.tip__time { font-weight: var(--pola-font-weight-medium); }
/* On a phone the first tap opens it with a real link, so it takes taps; the link is underlined (The Underlined Link Rule). */
.tip--open { pointer-events: auto; }
.tip__open { display: inline-block; margin-top: var(--space-xs); padding-block: var(--space-xs); color: var(--text-on-inverse);
  font-weight: var(--pola-font-weight-medium); text-decoration: underline; text-underline-offset: 2px; }
.tip__open:hover, .tip__open:focus { color: var(--text-on-inverse); }

/* ---------- Past incidents (#41) ----------
   Text first, on one left edge: day headings, then each incident's lines. Two text greys only: lines 1 to 3 primary
   (the time medium weight), the lag and the retry fixes secondary. Only Ongoing is coloured. */
.incidents__title { font-size: var(--font-size-h4); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-heading); letter-spacing: 0; }
.incidents__day { margin-top: var(--space-lg); }
.incidents__day + .incidents__day { margin-top: var(--space-xl); }
.incidents__date { font-size: var(--font-size-body-sm); font-weight: var(--pola-font-weight-medium); line-height: var(--line-height-body);
  letter-spacing: 0; padding-bottom: var(--space-xs); border-bottom: 1px solid var(--border-hairline); }
.incidents__list { list-style: none; margin: 0; padding: 0; }
.incident { padding-block: var(--space-sm); overflow-wrap: anywhere; text-wrap: pretty; }
.incident + .incident { border-top: 1px solid var(--border-hairline); }
.incident p { margin: 0; max-width: 72ch; }
.incident__when { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); font-weight: var(--pola-font-weight-medium); }
.incident__aside { color: var(--text-secondary); }
/* One-slot failures, folded: each row links to its calls, in the secondary grey so the least urgent block is the
   quietest; the underlined time tells it is a link without colour, and the row turns link blue on hover and focus. */
.incident__blips { list-style: none; margin: var(--space-xs) 0 0; padding: 0; }
/* Each row at least 24px tall, so neighbouring targets and focus rings never touch (WCAG 2.5.8). */
.incident__blip { display: grid; grid-template-columns: 5ch minmax(0, 1fr); align-items: baseline; gap: var(--space-sm);
  max-width: 72ch; padding-block: 2px; color: var(--text-secondary); }
.incident__blip-time { font-variant-numeric: tabular-nums; text-decoration: underline; text-underline-offset: 2px; }
.incident__blip:hover, .incident__blip:focus-visible { color: var(--text-link-hover); }
/* "Show N more" and its rows sit on the fold's left edge, in the same disclosure as "What these mean". */
.incident__more { margin-top: var(--space-xs); }
.incident__more > .incident__blips { margin-top: var(--space-xs); }
.incident__more-open, .incident__more[open] .incident__more-closed { display: none; }
.incident__more[open] .incident__more-open { display: inline; }
.incidents__defs { margin-top: var(--space-lg); }
.incidents__fixes { margin: var(--space-sm) 0 0; max-width: 72ch; overflow-wrap: anywhere; }
.incident__calls, .incidents__more { text-decoration: underline; text-underline-offset: 2px; }
.incidents__empty { margin: var(--space-sm) 0 0; color: var(--text-secondary); text-wrap: pretty; }
.incidents__all { margin: var(--space-lg) 0 0; }
.incidents__rest { margin: var(--space-lg) 0 0; }
.incidents__rest + .incidents__all { margin-top: var(--space-xs); }
.incidents__pages { display: flex; gap: var(--space-lg); margin-top: var(--space-lg); }
/* On a phone each link is a 44px touch target: padding grows the tap area around the line without opening a gap
   between wrapped lines. The badge wraps above the time when they do not fit. */
@media (max-width: 767px) {
  .incident__calls, .incidents__more { padding-block: calc((var(--mw-touch) - 1em) / 2); }
  /* Each folded row is a 44px target, 8px from the next (The Touch Target Rule). */
  .incident__blips { display: grid; gap: var(--space-sm); margin-top: 0; }
  .incident__blip { padding-block: calc((var(--mw-touch) - 1lh) / 2); }
  .incident__more { margin-top: var(--space-sm); }
  .incident__more summary { height: var(--mw-touch); }
  .incident__more > .incident__blips { margin-top: var(--space-sm); }
}

/* ---------- SegmentedControl ----------
   Recessed rounded-square track (12px radius, 4px inset), raised selected segment (8px radius). On a phone the
   track grows to the 44px touch target and the segments keep the same 8px inset. */
.segmented { display: inline-flex; align-items: center; gap: 2px; height: var(--mw-control-lg); padding: var(--space-xs);
  border-radius: var(--radius-md); background: var(--field-rest); }
a.segmented__item { display: inline-flex; flex: 0 0 auto; align-items: center; height: 100%; padding: 0 var(--space-md); border-radius: var(--radius-sm);
  white-space: nowrap; font-size: var(--font-size-body-sm); font-weight: var(--pola-font-weight-medium); line-height: 1; color: var(--text-secondary);
  transition: var(--transition-control); }
a.segmented__item:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); text-decoration: none; }
a.segmented__item[aria-current="page"] { background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-soft); }
@media (max-width: 767px) {
  .segmented { height: auto; }
  a.segmented__item { height: var(--mw-touch); }
}

/* ---------- EmptyState ---------- */
/* EmptyState: a 56px tinted circle, the fact, the guidance, an action. */
.empty { display: flex; flex-direction: column; align-items: center; gap: var(--space-sm); padding: var(--space-2xl) var(--space-xl); text-align: center; }
.empty__glyph { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; margin-bottom: var(--space-xs);
  border-radius: var(--radius-pill); background: var(--surface-tint); color: var(--text-brand); }
.empty__title { font-size: var(--font-size-h4); font-weight: var(--pola-font-weight-medium); color: var(--text-primary); }
.empty__text { max-width: 260px; font-size: var(--font-size-body-sm); line-height: var(--line-height-body); color: var(--text-secondary); }
.empty__action { margin-top: var(--space-sm); }
.empty__text code { white-space: nowrap; }

/* ---------- Table ---------- */
/* The page scrolls, not the table (see the wide-screen rule after the table's own). */
/* Positioned, so the screen-reader notes in its cells (visually hidden, absolute) are clipped by its scroller too
   instead of widening the page. */
.tablewrap { position: relative; overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; white-space: nowrap; }
.table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface-card); }
/* The card does not clip, so the header and the last row round their own outer corners. */
.card--table .table thead th:first-child { border-top-left-radius: calc(var(--radius-md) - 1px); }
.card--table .table thead th:last-child { border-top-right-radius: calc(var(--radius-md) - 1px); }
.card--table > .tablewrap:last-child .table tbody tr:last-child td:first-child { border-bottom-left-radius: calc(var(--radius-md) - 1px); }
.card--table > .tablewrap:last-child .table tbody tr:last-child td:last-child { border-bottom-right-radius: calc(var(--radius-md) - 1px); }
.table th { height: 44px; padding: var(--space-xs) var(--space-md); white-space: normal; text-align: left; vertical-align: middle;
  font-weight: var(--pola-font-weight-medium); color: var(--text-secondary); border-bottom: 1px solid var(--border-hairline); }
.table td { height: 44px; padding: var(--space-sm) var(--space-md); vertical-align: middle; border-bottom: 1px solid var(--border-hairline); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background-image: var(--mw-hover-layer); }
.table .num, .table th.num { text-align: right; }
.table td.num, .table td.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table tr.quiet td { color: var(--text-secondary); }
/* A note under a badge: since when a folded run of idle or paused slots began, or that a retry wrote a failed call. */
.line__note { display: block; margin-top: var(--space-xs); font-size: var(--font-size-caption); line-height: var(--line-height-body);
  color: var(--text-secondary); }
/* A failed master copy (#89): the one coloured note, since the call's own badge does not change. It wraps to the
   column's width instead of setting it (contain: inline-size), so the table still fits its card on a laptop (#87). */
.line__note--failed { contain: inline-size; white-space: normal; text-wrap: pretty; color: var(--text-danger); }
.table td.reason { min-width: 11rem; max-width: 26rem; white-space: normal; overflow-wrap: anywhere; }
.table td.wrap { white-space: normal; overflow-wrap: anywhere; }
/* The date above the time: the Run time column stays narrow enough for Reason to fit on a laptop screen. */
.table .date { display: block; font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }
.table tbody tr.row--slot { background: var(--surface-tint); }
.table tbody tr.row--slot td { border-bottom-color: var(--color-sky-line); }
/* The slot a strip cell opened lands below the top bar and the sticky header, not under them. */
#slot { scroll-margin-top: calc(var(--mw-topbar-height) + 112px); }
.reason__code { margin-left: var(--space-xs); font-size: var(--font-size-caption); color: var(--text-secondary); white-space: nowrap; }
/* A card wide enough for every column: no sideways scroller, so the header sticks under the top bar as the page scrolls.
   Narrower, the table scrolls sideways inside its card and the header stays at its top. It is the card's width, not
   the window's, because the rail folds: Calls needs about 1140px since its three duration columns (#72), which a
   1280px window has with the rail folded but not with it open. */
.card--table { container-type: inline-size; }
@container (min-width: 1160px) {
  .card--table > .tablewrap { overflow: visible; }
  .table thead th { top: calc(var(--mw-topbar-height) + 1px); }
}

/* Collapsible: the call's detail. */
.more summary { display: inline-flex; align-items: center; gap: var(--space-xs); height: var(--mw-control-sm); padding: 0 var(--space-sm);
  border-radius: var(--radius-sm); color: var(--text-link); font-size: var(--font-size-caption); font-weight: var(--pola-font-weight-medium); cursor: pointer; list-style: none; }
.more summary::-webkit-details-marker { display: none; }
.more summary:hover { background-image: var(--mw-hover-layer); }
.more summary svg { transition: transform var(--pola-duration-fast) var(--easing-standard); }
.more[open] summary svg { transform: rotate(90deg); }
/* The detail of a call opens as its own full-width row under the call (no JavaScript: :has), never inside the narrow
   last cell, so the table never widens. The call and its detail share one quiet background and read as one unit. */
.table tbody tr.more-row { display: none; }
.table tbody tr:has(details.more[open]) + tr.more-row { display: table-row; }
.table tbody tr:has(details.more[open]), .table tbody tr:has(details.more[open]) + tr.more-row { background: var(--surface-page); }
.table tbody tr:has(details.more[open]) td { border-bottom-color: transparent; }
/* The hairline between a call and its detail runs edge to edge, as the rows' own lines do. */
.table tbody tr.more-row td { height: auto; padding: 0 var(--space-md) var(--space-sm); border-top: 1px solid var(--border-hairline); }
/* The facts of a call in one line under it: each label above its value (a caption label, a body-small value), kept
   together on the left, one hairline across. */
.more__body { display: flex; flex-wrap: wrap; gap: var(--space-sm) var(--space-40); margin: 0; padding: var(--space-sm) 0 var(--space-xs);
  white-space: normal; }
.more__item { display: flex; flex-direction: column; gap: 2px; min-width: 8rem; }
.more__item dt { font-size: var(--font-size-caption); line-height: var(--line-height-body); color: var(--text-secondary); }
.more__item dd { color: var(--text-primary); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
/* The Readings without a tenant row (#72): last and on a line of its own, one tenant a line; "none" said quietly. */
.more__item--wide { flex-basis: 100%; }
/* Wider, the Planner's row panel: one fact a line, the labels in a column of their own and the values aligned beside
   them, kept to a readable width instead of spread under the table's columns. The row's own durations are left out,
   since its columns show them. */
@media (min-width: 768px) {
  .more__body { display: grid; grid-template-columns: max-content minmax(0, 40rem); align-items: baseline;
    gap: var(--space-xs) var(--space-lg); padding: var(--space-md) 0 var(--space-sm); }
  .more__item { display: contents; }
  .more__item--row { display: none; }
}
.more__tenants { margin: 0; padding: 0; list-style: none; }
/* A master table sent and its row count stay on one line (#89). */
.more__pair { white-space: nowrap; }
.more__item dd.more__none { color: var(--text-secondary); }

/* Table footer: rows per page and the total on the left, the pagination on the right. */
.tablefoot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-md);
  padding: var(--space-md) var(--space-20); border-top: 1px solid var(--border-hairline); font-size: var(--font-size-caption); color: var(--text-secondary); }
.tablefoot__size { display: inline-flex; align-items: center; gap: var(--space-sm); }
.tablefoot__total { white-space: nowrap; }
.pagination { display: inline-flex; align-items: center; gap: var(--space-xs); }
.pagination__item, a.pagination__item, .pagination__gap { display: inline-flex; align-items: center; justify-content: center; min-width: 32px;
  height: var(--mw-control-md); padding: 0 var(--space-sm); border: 1px solid transparent; border-radius: var(--radius-sm);
  font-size: var(--font-size-body-sm); font-weight: var(--pola-font-weight-medium); font-variant-numeric: tabular-nums; color: var(--text-primary);
  transition: var(--transition-control); }
a.pagination__item:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); text-decoration: none; }
a.pagination__item[aria-current="page"] { border-color: var(--text-brand); background: var(--surface-tint); color: var(--text-brand);
  font-weight: var(--pola-font-weight-medium); }
.pagination__item[aria-disabled="true"] { color: var(--text-disabled); cursor: not-allowed; }
.pagination__item svg { width: 16px; height: 16px; }
.pagination__gap { color: var(--text-secondary); }

/* Dropdown: a <details> whose list opens upward from the footer; middleware.js closes it on
   Esc and on a click outside. */
.menu { position: relative; }
.pagesize { display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-xs); min-width: 88px; height: var(--mw-control-md);
  padding: 0 var(--space-sm) 0 var(--space-md); border: 1px solid var(--icon-secondary); border-radius: var(--radius-sm); background: var(--surface-card);
  font-family: var(--font-mono); font-size: var(--font-size-body-sm); font-variant-numeric: tabular-nums; color: var(--text-primary);
  cursor: pointer; list-style: none; transition: var(--transition-control); }
.pagesize::-webkit-details-marker { display: none; }
.pagesize svg { color: var(--icon-secondary); }
.menu[open] .pagesize { border-color: var(--focus-ring); }
.menu__list { position: absolute; bottom: 100%; left: 0; z-index: 30; display: flex; flex-direction: column; min-width: 88px; max-height: 20rem;
  margin-bottom: var(--space-xs); padding: var(--space-xs); overflow-y: auto; border: 1px solid var(--color-line); border-radius: var(--radius-md);
  background: var(--surface-card); box-shadow: var(--shadow-card); }
a.menu__option { display: flex; align-items: center; justify-content: space-between; gap: var(--space-sm); height: var(--mw-control-md);
  padding: 0 var(--space-sm); border-radius: var(--radius-sm); font-family: var(--font-mono); font-size: var(--font-size-body-sm);
  font-variant-numeric: tabular-nums; color: var(--text-primary); }
a.menu__option:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); text-decoration: none; }
.menu__option svg { color: var(--text-brand); }


/* The failed and no-run slots as links: reachable by keyboard and by thumb (the strip's cells are small on a phone). */
.slotlinks { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-xs) var(--space-sm); font-size: var(--font-size-caption); }
a.slotlinks__item { gap: var(--space-xs); }
.slotlinks__count, .slotlinks__why { font-family: var(--font-sans); color: var(--text-secondary); }
.slotlinks__label { min-width: 3.5rem; color: var(--text-secondary); }
a.slotlinks__item { display: inline-flex; align-items: center; height: var(--mw-control-sm); padding: 0 var(--space-sm); border-radius: var(--radius-sm);
  background: var(--field-rest); font-family: var(--font-mono); font-variant-numeric: tabular-nums; color: var(--text-primary); }
a.slotlinks__item:hover { background-image: var(--mw-hover-layer); color: var(--text-primary); text-decoration: none; }
.slotlinks__more { color: var(--text-secondary); }
@media (max-width: 767px) { a.slotlinks__item { height: var(--mw-touch); padding: 0 var(--space-md); } }

/* ---------- Toast: one-off feedback after an action ---------- */
.toast { position: fixed; right: var(--space-xl); bottom: var(--space-xl); z-index: 60; display: inline-flex; align-items: center; gap: var(--space-md);
  max-width: min(460px, calc(100vw - 2 * var(--space-lg))); padding: var(--space-md) var(--space-lg); border: 1px solid var(--toast-border); border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-raised); }
.toast__icon { flex: none; }
.toast--info .toast__icon { color: var(--toast-icon-info); }
.toast--success .toast__icon { color: var(--toast-icon-success); }
.toast--error .toast__icon { color: var(--toast-icon-error); }
.toast__body { flex: 1; }
.toast__close { display: none; flex: none; padding: 0; border: 0; background: transparent; color: var(--icon-secondary); cursor: pointer; }
.js .toast__close { display: inline-flex; }
.toast[hidden] { display: none; }
@media (max-width: 767px) { .toast { left: var(--space-lg); right: var(--space-lg); bottom: var(--space-lg); } .toast__close { min-width: var(--mw-touch); min-height: var(--mw-touch); justify-content: center; } }

/* ---------- Config ---------- */
.config .table td:first-child { font-weight: var(--pola-font-weight-medium); }
.config .group-row th { height: auto; padding: var(--space-md) var(--space-md) var(--space-xs); background: var(--surface-page);
  font-size: var(--font-size-micro); letter-spacing: var(--letter-spacing-kicker); text-transform: uppercase; }
.config .table tbody tr.group-row:hover { background-image: none; }

/* ---------- Calls: Go to a time, and a since filter (#29) ---------- */
.goto { display: inline-flex; align-items: center; gap: var(--space-sm); font-size: var(--font-size-caption); }
.goto__label { color: var(--text-secondary); }
.goto__input { height: var(--mw-control-sm); padding: 0 var(--space-sm); border: 1px solid var(--icon-secondary); border-radius: var(--radius-sm);
  background: var(--surface-card); font-family: var(--font-mono); font-size: var(--font-size-caption); }
.goto__input:focus-visible { border-color: var(--focus-ring); }
.filter-note { font-size: var(--font-size-caption); color: var(--text-secondary); }
/* The table's controls right above it: the filter on the left, Go to on the right (the Planner's listings). */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-sm) var(--space-lg);
  margin-bottom: calc(var(--space-md) - var(--space-lg)); }
.tablefoot__label { white-space: nowrap; }

/* ---------- Date picker (Go to, on Calls) ----------
   Pola's DatePicker, date-and-time mode (Pola 0.7.2), drawn by middleware.js on Pola's tokens: the label above, the format
   hint under it, the date field with its calendar button and the time field side by side, then the error. The calendar
   is a popover under the fields; on a phone a bottom sheet over a scrim with 44 px days 8 px apart. Fields keep this
   app's input border (--icon-secondary), as .field__box does. */
.goto--picker { align-items: flex-end; }
.datepick__row > .btn { height: var(--mw-control-lg); padding: 0 var(--space-md); font-size: var(--font-size-body-sm); }
.datepick { position: relative; display: flex; flex-direction: column; gap: var(--space-xs); font-size: var(--font-size-body-sm); }
/* In the Calls toolbar: the label before the fields and the error under them, no hint line (the format shows in the empty
   fields and stays the fields' description). A phone stacks the label above. */
.toolbar .datepick { display: grid; grid-template-areas: "label" "row" "error"; grid-template-columns: minmax(0, 1fr);
  gap: var(--space-xs) var(--space-sm); }
@media (min-width: 768px) {
  .toolbar .datepick { grid-template-areas: "label row" ". error"; grid-template-columns: auto auto; align-items: center; }
}
.toolbar .datepick__label { grid-area: label; }
.toolbar .datepick__row { grid-area: row; }
.toolbar .datepick__error { grid-area: error; min-height: 0; }
.toolbar .datepick__error:empty { display: none; }
.toolbar .datepick__hint { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.datepick__input::placeholder { color: var(--text-secondary); opacity: 1; }
.datepick__label { font-weight: var(--pola-font-weight-medium); color: var(--text-secondary); }
.datepick__hint { color: var(--text-secondary); }
.datepick__row { display: flex; gap: var(--space-sm); }
.datepick__box { display: flex; align-items: center; height: var(--mw-control-lg); background: var(--surface-card); transition: var(--transition-control);
  border: 1px solid var(--icon-secondary); border-radius: var(--radius-sm); }
.datepick__box:focus-within { border-color: var(--focus-ring); box-shadow: var(--shadow-focus); }
.datepick__date { width: 11rem; padding-left: var(--space-sm); }
.datepick__time { width: 7.5rem; gap: var(--space-sm); padding: 0 var(--space-sm); color: var(--icon-secondary); }
.datepick__input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: transparent; color: var(--text-primary);
  font-variant-numeric: tabular-nums; }
.datepick__input:focus-visible { outline: none; }
.datepick__open { display: inline-flex; align-items: center; justify-content: center; flex: none; align-self: stretch;
  width: var(--mw-control-lg); margin-left: var(--space-sm); padding: 0; border: 0; border-left: 1px solid var(--icon-secondary);
  border-radius: 0 calc(var(--radius-sm) - 1px) calc(var(--radius-sm) - 1px) 0; background: var(--field-rest); color: var(--text-primary); cursor: pointer; }
.datepick__open:hover { background-image: var(--mw-hover-layer); }
.datepick__open:focus-visible { outline-offset: -2px; }
.datepick__hint, .datepick__error { font-size: var(--font-size-caption); line-height: var(--line-height-body); }
.datepick__error { min-height: calc(var(--font-size-caption) * var(--line-height-body)); color: var(--text-danger); }
.datepick--error .datepick__box:has([aria-invalid]) { border-color: var(--text-danger); }

.datepick__panel { position: absolute; top: calc(100% + var(--space-xs)); left: var(--mw-datepick-left, 0); right: auto; z-index: 60; margin: 0;
  width: clamp(16rem, var(--mw-datepick-anchor, 18rem), 24rem); padding: var(--space-md); border: 0; border-radius: var(--radius-md);
  background: var(--surface-card); color: var(--text-primary); box-shadow: var(--shadow-card); }
.datepick__panel[open] { display: flex; flex-direction: column; gap: var(--space-sm); }
.datepick__handle, .datepick__close:not(:focus-visible) { position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.datepick__close:focus-visible { align-self: center; padding: var(--space-xs) var(--space-sm); border: 0; border-radius: var(--radius-sm);
  background: var(--field-rest); color: var(--text-primary); }
.datepick__selects { display: flex; gap: var(--space-sm); }
.datepick__select { position: relative; display: flex; align-items: center; flex: 2; min-width: 0; color: var(--icon-secondary); }
.datepick__select--year { flex: 1; }
.datepick__select select { width: 100%; height: var(--mw-control-md); padding: 0 var(--space-32) 0 var(--space-md); appearance: none;
  border: 1px solid var(--icon-secondary); border-radius: var(--radius-sm); background: var(--surface-card); color: var(--text-primary); cursor: pointer; }
.datepick__select svg { position: absolute; right: var(--space-md); pointer-events: none; }
.datepick__head { display: flex; align-items: center; justify-content: space-between; }
.datepick__title { font-weight: var(--pola-font-weight-medium); }
.datepick__nav { display: inline-flex; align-items: center; justify-content: center; width: var(--mw-control-md); height: var(--mw-control-md);
  padding: 0; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--text-primary); cursor: pointer; }
.datepick__nav:not(:disabled):hover { background-image: var(--mw-hover-layer); }
.datepick__nav:disabled { opacity: var(--disabled-opacity); cursor: not-allowed; }
.datepick__grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.datepick__grid th { height: 36px; padding: 0 0 var(--space-xs); font-size: var(--font-size-caption); font-weight: inherit; color: var(--text-secondary); }
.datepick__grid td { height: var(--mw-control-md); padding: 0; text-align: center; }
.datepick__day { width: var(--mw-control-sm); height: var(--mw-control-sm); padding: 0; border: 0; border-radius: var(--radius-pill);
  background: transparent; color: var(--text-primary); font-variant-numeric: tabular-nums; cursor: pointer; }
.datepick__day:hover { background-image: var(--mw-hover-layer); }
.datepick__day--outside { color: var(--text-secondary); }
.datepick__day[aria-current="date"] { box-shadow: inset 0 0 0 1px var(--icon-secondary); }
[aria-selected="true"] > .datepick__day { background: var(--color-anugrah-blue); color: var(--color-on-brand); }
.datepick__day[aria-disabled="true"] { color: var(--text-disabled); background: transparent; cursor: not-allowed; }

@media (max-width: 767px) {
  .goto--picker { width: 100%; }
  .datepick { flex: 1; min-width: 0; }
  .datepick__date { flex: 1; width: auto; min-width: 0; }
  /* The calendar button stretches inside the box, so the box's border runs under it. */
  .datepick__box, .datepick__row > .btn { height: var(--mw-touch); }
  .datepick__open { width: var(--mw-touch); }
  .datepick__time { width: 7rem; }
  /* The sheet: the whole width, from the bottom, over the drawer's scrim. */
  .datepick__panel { position: fixed; inset: auto 0 0 0; width: 100%; max-width: none; max-height: calc(100dvh - var(--space-2xl));
    overflow-y: auto; padding: var(--space-sm) var(--space-xs) var(--space-2xl); border-radius: var(--radius-md) var(--radius-md) 0 0;
    box-shadow: var(--shadow-raised); }
  .datepick__panel::backdrop { background: color-mix(in srgb, var(--color-deep-navy) 24%, transparent); }
  .datepick__handle { position: static; align-self: center; width: 32px; height: 4px; margin: 0 0 var(--space-xs); clip: auto;
    border-radius: var(--radius-pill); background: var(--icon-secondary); }
  .datepick__select select, .datepick__nav { height: var(--mw-touch); }
  .datepick__nav { width: var(--mw-touch); }
  /* 7 days of 44 px with 8 px between need 356 px; the sheet gives each column its share, so only rows are spaced. */
  .datepick__grid { border-collapse: separate; border-spacing: 0 var(--space-sm); margin: calc(-1 * var(--space-sm)) 0; }
  .datepick__grid td { height: var(--mw-touch); }
  .datepick__day { width: var(--mw-touch); height: var(--mw-touch); }
}
@media (prefers-reduced-motion: no-preference) {
  .datepick__panel[open] { animation: datepick-in var(--pola-duration-fast) var(--easing-standard); }
}
@keyframes datepick-in { from { opacity: 0; transform: translateY(-4px); } }

/* ---------- Pause page (#24) ---------- */
.pause-form { display: flex; flex-direction: column; gap: var(--space-lg); }
.pause-form .field { display: flex; flex-direction: column; gap: var(--space-xs); }
.pause-form .field__label { margin-bottom: 0; }
.controls--form { justify-content: flex-start; }

/* ---------- Login and error pages ---------- */
.solo { max-width: 400px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: var(--space-lg); padding: var(--space-xl); }
.solo form { display: flex; flex-direction: column; gap: var(--space-md); }
.solo--wide { max-width: 520px; }
.solo--in-app { margin: 0; }

/* ---------- Phone ---------- */
@media (max-width: 767px) {
  .opt { display: none; }
  .table { font-size: var(--font-size-caption); }
  .table th, .table td { padding: var(--space-sm); height: auto; }
  .table td.reason { min-width: 8rem; }
  .solo { margin: var(--space-xl) var(--space-md); padding: var(--space-lg); }
  /* Thumb-sized links where a phone needs them (#25). */
  .status-history a, .filter-note a { display: inline-flex; align-items: center; min-height: var(--mw-touch); }
  a.segmented__item { min-width: var(--mw-touch); justify-content: center; }
  .goto { margin-left: 0; flex-wrap: wrap; }
  .goto__input, .goto .btn { height: var(--mw-touch); }
  /* Config: each row stacks, the setting over its env var and value, so the value gets the width (#25). */
  .config .table thead { display: none; }
  .config .table, .config .table tbody, .config .table tr, .config .table td, .config .table th { display: block; width: 100%; }
  .config .table td { height: auto; padding: 0 var(--space-md); border: 0; }
  .config .table td.config__setting { padding-top: var(--space-md); }
  .config .table td.config__value { padding-bottom: var(--space-md); border-bottom: 1px solid var(--border-hairline); white-space: normal; }
  .config .table td.config__env { color: var(--text-secondary); }
  /* Calls: Details shrinks to its chevron, a 44px target, so the row fits the phone and the detail opens under it. */
  .more__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .more summary { width: var(--mw-touch); height: var(--mw-touch); justify-content: center; padding: 0; }
  .table td.details { padding-left: 0; padding-right: 0; }
  /* The visible columns share the width: notes under a badge and reasons wrap, cells pad less. */
  .table th, .table td { padding-left: var(--space-xs); padding-right: var(--space-xs); }
  .table td { white-space: normal; }
  .table td.reason { min-width: 0; }
  .table td time > span { white-space: nowrap; }
  .card--pad { padding: var(--space-lg); }
  .tablefoot { padding: var(--space-md) var(--space-lg); }
  .pagesize, a.menu__option { height: var(--mw-touch); }
  .pagination__item, a.pagination__item, .pagination__gap { min-width: var(--mw-touch); height: var(--mw-touch); padding: 0; }
}

/* A narrow phone keeps the first, current and last page; the neighbours go. */
@media (max-width: 479px) { a.pagination__item--sibling { display: none; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; }
  .btn:not(:disabled):active { transform: none; }
}
