/* Hallmark · theme: cobalt (dark drop) · genre: modern-minimal
 * macrostructure: console — rail head → tab band → dense panel stack
 * pre-emit critique: P4 H5 E4 S5 R4 V4
 * contrast: pass · states: default·hover·focus·active·disabled·empty
 *
 * An operations console, not a landing page. Density is the point: the people
 * using this read it for hours, so the design work goes into hierarchy and
 * legibility rather than ornament. One signal ink, hairline rules, numbers in
 * mono. No card sits inside another card; no panel carries a shadow.
 */

@import url("tokens.css");

*, *::before, *::after { box-sizing: border-box; }

/* Checkboxes and radios take the signal ink in both themes. */
input[type="checkbox"], input[type="radio"] { accent-color: var(--color-accent); }

html, body {
  /* clip, never hidden — `hidden` on the root breaks position: sticky. */
  overflow-x: clip;
  margin: 0;
}

body {
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Numbers are mono everywhere, and lined up on the digit. */
.num, .mono { font-variant-numeric: tabular-nums; }

:focus-visible {
  /* No transition: a focus ring that fades in is useless to a keyboard user. */
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* ---------------------------------------------------------------- head bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-md); flex-wrap: wrap;
  padding: var(--space-sm) var(--space-md);
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
}

.brand { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }

/* The mark is drawn from type metrics, not an image: a signal square where a
   full stop would fall. One geometric move, no asset to maintain. */
.brand .mark {
  width: 0.75rem; height: 0.75rem; flex: 0 0 auto;
  background: var(--color-accent);
}

.brand h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  font-style: normal;
  letter-spacing: var(--tracking-display);
  overflow-wrap: anywhere; min-width: 0;
}

.sub {
  margin: 2px 0 0;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
}

.controls { display: flex; gap: var(--space-2xs); flex-wrap: wrap; }

/* -------------------------------------------------------------- form fields */
select, input[type="search"] {
  background: var(--color-paper-3);
  color: var(--color-ink);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  padding: var(--space-2xs) var(--space-xs);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  transition: border-color var(--dur-fast) var(--ease-out),
              background-color var(--dur-fast) var(--ease-out);
}
select { cursor: pointer; min-width: 9.5rem; }
input[type="search"] { min-width: 11rem; }

select:hover, input[type="search"]:hover { border-color: var(--color-ink-3); }
select:active { background: var(--color-paper-4); }
select:disabled, input:disabled {
  opacity: 0.45; cursor: not-allowed; background: var(--color-paper-2);
}

select.inline {
  min-width: 0; padding: 2px var(--space-3xs);
  font-family: var(--font-mono); font-size: var(--text-xs);
}

/* --------------------------------------------------------------- tab strip */
.tabs {
  display: flex; gap: var(--space-md);
  padding: 0 var(--space-md);
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  position: relative;
  background: none; border: none;
  color: var(--color-ink-3);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  padding: var(--space-xs) 0;
  cursor: pointer;
  /* Never wraps: a two-line tab label is a mobile tell. */
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab::after {
  content: ""; position: absolute; inset-inline: 0; bottom: -1px;
  height: 2px; background: var(--color-accent);
  transform: scaleX(0); transform-origin: left;
  transition: transform var(--dur-base) var(--ease-out);
}
.tab:hover, .tab:active { color: var(--color-ink); }
.tab.active { color: var(--color-ink); }
.tab.active::after { transform: scaleX(1); }
.tab:disabled { opacity: 0.4; cursor: not-allowed; }

/* ----------------------------------------------------------------- banner */
.banner {
  margin: var(--space-sm) var(--space-md) 0;
  padding: var(--space-2xs) var(--space-xs);
  /* A hairline left rule rather than a filled panel: the warning is a margin
     note on the data, not a surface competing with it. */
  border-left: 2px solid var(--color-warn);
  color: var(--color-ink-2);
  font-size: var(--text-sm);
}
.hidden { display: none; }

main {
  padding: var(--space-md);
  max-width: var(--shell);
  margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; }

/* ------------------------------------------------------------------- kpis */
.kpis {
  display: grid;
  gap: 1px;                       /* the gap IS the rule — a hairline grid */
  background: var(--color-rule-2);
  border: 1px solid var(--color-rule-2);
  grid-template-columns: repeat(auto-fit, minmax(min(11rem, 100%), 1fr));
  margin-bottom: var(--space-md);
}
/* The overview's queue focus. Off: a quiet way in. On: a filter that is
   applied must be seen, so it gets a bar and a way out. */
.focus-bar {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--space-xs);
  margin: 0 0 var(--space-2xs); min-height: 1.6rem;
}
.focus-bar.on {
  justify-content: space-between; flex-wrap: wrap;
  margin-bottom: var(--space-sm); padding: .45rem .7rem;
  background: var(--color-paper-3); border-left: 2px solid var(--color-accent);
  border-radius: var(--radius-sm); font-size: .85rem; color: var(--color-ink-2);
}
.focus-bar.on strong { color: var(--color-ink); }
/* What a row of tiles counts, said once above it rather than in every foot. */
.kpis-title {
  margin: 0 0 var(--space-3xs);
  font-family: var(--font-mono); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--color-ink-2);
}
.kpis-title span { text-transform: none; letter-spacing: 0; color: var(--color-ink-3); font-family: var(--font-body); }
.kpi {
  background: var(--color-paper);
  padding: var(--space-xs) var(--space-sm) var(--space-sm);
}
.kpi .label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-label);
  color: var(--color-ink-3);
  margin-bottom: var(--space-2xs);
}
.kpi .value {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.kpi .value.good { color: var(--color-good); }
.kpi .value.warn { color: var(--color-warn); }
.kpi .value.bad  { color: var(--color-bad); }
.kpi .value.none { color: var(--color-ink-3); font-size: var(--text-xl); }
.kpi .foot {
  font-size: var(--text-xs); color: var(--color-ink-3);
  margin-top: var(--space-3xs); line-height: 1.4;
}

/* ----------------------------------------------------------------- panels */
.panel {
  border: 1px solid var(--color-rule-2);
  padding: var(--space-sm);
  margin-bottom: var(--space-md);
}
.panel-head {
  display: flex; align-items: baseline; gap: var(--space-2xs);
  flex-wrap: wrap;
  padding-bottom: var(--space-2xs);
  margin-bottom: var(--space-sm);
  border-bottom: 1px solid var(--color-rule-2);
}
.panel-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  font-style: normal;
  letter-spacing: var(--tracking-display);
}
.hint {
  font-size: var(--text-xs); color: var(--color-ink-3);
  max-width: 68ch; line-height: 1.45;
}
.spacer { flex: 1 1 var(--space-sm); }
.count {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--color-ink-3); white-space: nowrap;
}

.chart-wrap { height: 19rem; position: relative; }
.chart-wrap.short { height: 14rem; }

.grid { display: grid; gap: var(--space-md); grid-template-columns: minmax(0,1fr) minmax(0,1fr); }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }

th {
  text-align: left;
  font-family: var(--font-mono);
  font-weight: 500; font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--color-ink-3);
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--color-rule);
  white-space: nowrap;
}
td {
  padding: var(--space-2xs) var(--space-xs);
  border-bottom: 1px solid var(--color-rule-2);
}
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--font-mono); }

tbody tr { transition: background-color var(--dur-fast) var(--ease-out); }
tbody tr:hover { background: var(--color-paper-2); }

tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--color-paper-3); }
tr.clickable:focus-visible { outline: 2px solid var(--color-focus); outline-offset: -2px; }
tr.clickable:active { background: var(--color-paper-4); }

.tag {
  display: inline-block;
  padding: 1px var(--space-2xs);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  white-space: nowrap;
}
.warn-tag { color: var(--color-warn); border-color: var(--color-warn); margin-left: var(--space-3xs); }

.rate-good { color: var(--color-good); }
.rate-warn { color: var(--color-warn); }
.rate-bad  { color: var(--color-bad); }

.empty {
  padding: var(--space-lg) var(--space-xs);
  text-align: center; color: var(--color-ink-3); font-size: var(--text-sm);
}

/* --------------------------------------------------------- service level */
.sla-headline {
  display: flex; align-items: baseline; gap: var(--space-xs);
  flex-wrap: wrap;
  margin-bottom: var(--space-sm);
}
.sla-headline .big {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: var(--tracking-display);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.sla-headline .meta {
  font-size: var(--text-xs); color: var(--color-ink-3); line-height: 1.5;
}

.bar-row {
  display: grid; grid-template-columns: minmax(0,1fr) 3.25rem;
  gap: var(--space-2xs); align-items: center;
  margin-bottom: var(--space-2xs);
}
.bar-label { display: flex; justify-content: space-between; gap: var(--space-2xs); font-size: var(--text-sm); }
.bar-label .nm { color: var(--color-ink); min-width: 0; overflow-wrap: anywhere; }
.bar-label .sub2 { color: var(--color-ink-3); font-size: var(--text-xs); white-space: nowrap; }
.bar-track {
  height: 3px; background: var(--color-paper-3);
  margin-top: var(--space-3xs); overflow: hidden;
}
.bar-fill { height: 100%; transition: width var(--dur-base) var(--ease-out); }
/* Status colour is owned by the stylesheet, not assembled in JS. */
.bar-fill.good { background: var(--color-good); }
.bar-fill.warn { background: var(--color-warn); }
.bar-fill.bad  { background: var(--color-bad); }
.bar-fill.none { background: var(--color-ink-3); }
.bar-pct {
  text-align: right; font-family: var(--font-mono);
  font-size: var(--text-sm); font-variant-numeric: tabular-nums;
}
.bar-pct.good, .sla-headline .big.good { color: var(--color-good); }
.bar-pct.warn, .sla-headline .big.warn { color: var(--color-warn); }
.bar-pct.bad,  .sla-headline .big.bad  { color: var(--color-bad); }
.bar-pct.none, .sla-headline .big.none { color: var(--color-ink-3); }

/* ------------------------------------------------------------------ modal */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: var(--color-scrim);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--space-lg) var(--space-sm);
  overflow-y: auto;
}
/* Compound selector: `.hidden` is declared earlier and ties on specificity,
   so a bare .hidden loses to .modal and the overlay never hides. */
.modal.hidden { display: none; }

.modal-card {
  background: var(--color-paper);
  border: 1px solid var(--color-rule);
  padding: var(--space-sm) var(--space-md) var(--space-md);
  width: 100%; max-width: 44rem;
}
/* A table in a modal (an account's sessions) needs the room. */
.modal-card.wide { max-width: 64rem; }
.cell-nowrap { white-space: nowrap; }
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-sm); }
.modal-head h3 {
  margin: 0;
  font-family: var(--font-display); font-size: var(--text-lg);
  font-weight: 600; font-style: normal; letter-spacing: var(--tracking-display);
  overflow-wrap: anywhere; min-width: 0;
}
.close {
  background: none; border: 1px solid transparent;
  color: var(--color-ink-3);
  font-size: var(--text-xl); line-height: 1;
  padding: 0 var(--space-3xs); cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out);
}
.close:hover { color: var(--color-ink); }
.close:active { color: var(--color-accent); }

.kpis.small { grid-template-columns: repeat(3, minmax(0,1fr)); margin: var(--space-sm) 0 0; }
.kpis.small .value { font-size: var(--text-xl); }

.modal-card h4 {
  margin: var(--space-md) 0 var(--space-2xs);
  font-family: var(--font-mono);
  font-size: var(--text-xs); font-weight: 500;
  text-transform: uppercase; letter-spacing: var(--tracking-label);
  color: var(--color-ink-3);
}
table.mini th { font-size: var(--text-xs); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  main, .topbar, .tabs { padding-inline: var(--space-sm); }
  .banner { margin-inline: var(--space-sm); }
  .kpis { grid-template-columns: repeat(auto-fit, minmax(min(9rem, 100%), 1fr)); }
  .kpis.small { grid-template-columns: minmax(0, 1fr); }
  .chart-wrap { height: 15rem; }
  .chart-wrap.short { height: 12rem; }
  .controls { width: 100%; }
  .controls select { flex: 1 1 8rem; min-width: 0; }
  input[type="search"] { width: 100%; }
  .panel-head { gap: var(--space-3xs); }
}

@media (max-width: 420px) {
  .kpis { grid-template-columns: minmax(0, 1fr); }
  .kpi .value { font-size: var(--text-xl); }
  main, .topbar, .tabs { padding-inline: var(--space-xs); }
  .banner { margin-inline: var(--space-xs); }
}

/* Every transition above names its properties and has a still fallback. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .tab::after { transition: none; }
}


/* ---------------------------------------------------------------- login */
/* Full-bleed gate: nothing of the dashboard shows through, so an unauthorised
   viewer never sees the shape of the data they cannot read. */
.login-screen {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-paper);
}
.login-screen.hidden { display: none; }
.login-card {
  width: min(22rem, 90vw);
  display: flex; flex-direction: column; gap: var(--space-2xs);
  padding: var(--space-md);
  background: var(--color-paper-2);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
}
.login-card h1 { margin: 0; font-size: 1.35rem; }
.login-card .sub { margin: 0 0 var(--space-xs); color: var(--color-ink-3); font-size: .85rem; }
.login-card label {
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--color-ink-3);
}
.login-card input {
  padding: .55rem .7rem;
  background: var(--color-paper-3);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
  color: var(--color-ink); font: inherit;
}
.login-card input:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 1px; }
.login-card button {
  margin-top: var(--space-xs); padding: .6rem;
  background: var(--color-accent); color: var(--color-paper);
  border: 0; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: .6; cursor: default; }
.login-form { display: flex; flex-direction: column; gap: var(--space-2xs); }
.login-form.hidden, .login-sso.hidden { display: none; }
.login-sso {
  display: block; margin-top: var(--space-xs); padding: .6rem;
  background: var(--color-accent); color: var(--color-paper);
  border-radius: var(--radius-sm); text-align: center; text-decoration: none;
  font-weight: 600;
}
.login-sso:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 2px; }
.login-error { margin: var(--space-2xs) 0 0; color: var(--color-bad); font-size: .82rem; }
.login-error.hidden { display: none; }
#app.hidden { display: none; }

/* -------------------------------------------------- provenance markers */
/* An inferred value must never look like a measured one. */
.tag-est, .tag-warn {
  font-size: .68rem; padding: .05rem .3rem; border-radius: var(--radius-sm);
  vertical-align: middle; white-space: nowrap;
}
.tag-est  { background: var(--color-paper-4); color: var(--color-ink-3); }
.tag-warn { background: var(--color-paper-4); color: var(--color-warn, var(--color-ink-2)); }
.name-cell { display: flex; flex-direction: column; gap: .1rem; }
.sub-cell { font-size: .74rem; color: var(--color-ink-3); }
tr.row-muted td { opacity: .72; }
.notice {
  margin: 0 0 var(--space-xs); padding: .5rem .7rem;
  background: var(--color-paper-3); border-left: 2px solid var(--color-warn, var(--color-accent));
  border-radius: var(--radius-sm); color: var(--color-ink-2); font-size: .82rem;
}
.who { color: var(--color-ink-3); font-size: .8rem; margin-left: auto; padding: 0 var(--space-2xs); }
.linkish {
  background: none; border: 0; color: var(--color-ink-3);
  font: inherit; font-size: .8rem; cursor: pointer; text-decoration: underline;
}
.linkish:hover { color: var(--color-ink); }
.kpis.compact .kpi { padding: var(--space-2xs) var(--space-xs); }


/* ------------------------------------------------- detail modal extras */
.modal-actions { display: flex; align-items: center; gap: var(--space-xs); }
.modal-actions select {
  background: var(--color-paper-3); border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm); color: var(--color-ink);
  font: inherit; font-size: .8rem; padding: .25rem .4rem;
}
/* A measurement and a caveat should not look alike, but the caveat must still
   be read -- quieter than body text, never hidden. */
.footnote {
  margin: var(--space-xs) 0 0; padding: 0;
  color: var(--color-ink-3); font-size: .78rem; line-height: 1.5;
}
.footnote strong { color: var(--color-ink-2); }
.callout {
  margin: var(--space-xs) 0 0; padding: .6rem .8rem;
  background: var(--color-paper-3); border-left: 2px solid var(--color-accent);
  border-radius: var(--radius-sm); color: var(--color-ink-2);
  font-size: .82rem; line-height: 1.5;
}
.callout strong { color: var(--color-ink); }
.scroll-y { max-height: 17rem; overflow-y: auto; }
.modal-card h3 {
  margin: var(--space-sm) 0 var(--space-2xs);
  font-size: .78rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--color-ink-3);
}


/* Staleness is not a nuance: a dashboard describing last week while looking
   current is worse than one that is plainly down. Loudest element on the page. */
.banner-alert {
  background: var(--color-paper-3);
  border-left: 3px solid var(--color-bad);
  color: var(--color-ink);
}
.banner-alert strong { color: var(--color-bad); }

/* ---------------------------------------------------------- administration */
/* Accounts and scopes. Departments offered here are 3CX's own. */
.admin-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-sm);
  align-items: end;
}
.admin-form label {
  display: flex; flex-direction: column; gap: var(--space-3xs);
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--color-ink-3);
}
.admin-form input, .admin-form select {
  padding: .5rem .6rem;
  background: var(--color-paper-3);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-md);
  color: var(--color-ink); font: inherit; text-transform: none; letter-spacing: 0;
}
.admin-form fieldset {
  grid-column: 1 / -1;
  margin: 0; padding: var(--space-xs);
  border: 1px solid var(--color-rule); border-radius: var(--radius-md);
}
.admin-form legend {
  padding: 0 var(--space-3xs);
  font-size: .72rem; letter-spacing: .04em; text-transform: uppercase;
  color: var(--color-ink-3);
}
.admin-form button {
  grid-column: 1 / -1; justify-self: start;
  padding: .55rem 1.1rem;
  background: var(--color-accent); color: var(--color-paper);
  border: 0; border-radius: var(--radius-md);
  font: inherit; font-weight: 600; cursor: pointer;
}
.admin-form button:disabled { opacity: .6; cursor: default; }
.admin-form button.danger { background: var(--color-bad); }
/* "Toute l'entreprise": a checkbox, not a field. Its own .hidden rule, since
   `.admin-form label` outranks the global one. */
.admin-form label.check {
  flex-direction: row; align-items: center; gap: var(--space-3xs);
  font-size: var(--text-sm); text-transform: none; letter-spacing: 0; color: var(--color-ink);
}
.admin-form label.check.hidden { display: none; }

.dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr));
  gap: var(--space-3xs) var(--space-xs);
}
.dept-grid label {
  flex-direction: row; align-items: center; gap: var(--space-3xs);
  text-transform: none; letter-spacing: 0;
  font-size: var(--text-sm); color: var(--color-ink-2);
}
.dept-grid input { width: auto; padding: 0; }

/* Destructive and neutral row actions must not look alike. */
.row-action {
  background: none; border: 1px solid var(--color-rule);
  border-radius: var(--radius-sm);
  padding: 1px var(--space-2xs); margin-right: var(--space-3xs);
  color: var(--color-ink-2); font-family: var(--font-mono);
  font-size: var(--text-xs); cursor: pointer;
}
.row-action:hover { border-color: var(--color-ink-3); color: var(--color-ink); }
.row-action.danger:hover { border-color: var(--color-bad); color: var(--color-bad); }
.row-action:disabled { opacity: .35; cursor: not-allowed; }

.admin-error { margin: var(--space-xs) 0 0; color: var(--color-bad); font-size: .82rem; }
.admin-error.hidden { display: none; }


/* ======================================================================
 * 2026-09-24 — 3CX-only rebuild: live screen, drill-down drawer, journal,
 * settings. Same rules as above: hairlines, one signal ink, numbers in mono,
 * status colour only where the colour means good/bad.
 * ==================================================================== */

/* ---------------------------------------------------------- period control */
.seg {
  display: inline-flex; border: 1px solid var(--color-rule);
  border-radius: var(--radius-md); overflow: hidden;
}
.seg button {
  background: var(--color-paper-3); color: var(--color-ink-3);
  border: 0; border-right: 1px solid var(--color-rule);
  padding: var(--space-2xs) var(--space-xs);
  font-family: var(--font-mono); font-size: var(--text-xs);
  cursor: pointer; white-space: nowrap;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--color-ink); background: var(--color-paper-4); }
.seg button.active { color: var(--color-paper); background: var(--color-accent); }
.custom-range { display: inline-flex; gap: var(--space-3xs); align-items: center; }
.custom-range.hidden { display: none; }
input[type="date"], input[type="number"], input[type="text"].field {
  background: var(--color-paper-3); color: var(--color-ink);
  border: 1px solid var(--color-rule); border-radius: var(--radius-md);
  padding: var(--space-3xs) var(--space-2xs);
  font-family: var(--font-mono); font-size: var(--text-xs);
}

/* ------------------------------------------------------------ live pieces */
.live-dot {
  display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 50%;
  background: var(--color-good); margin-right: var(--space-3xs);
  vertical-align: middle;
}
.live-dot.stale { background: var(--color-bad); }
.age { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }

/* Presence: a dot plus a word. Never colour alone. */
.presence { display: inline-flex; align-items: center; gap: var(--space-3xs); white-space: nowrap; font-size: var(--text-xs); color: var(--color-ink-2); }
.presence::before {
  content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%;
  border: 1px solid var(--color-ink-3); flex: 0 0 auto;
}
.presence.available::before { background: var(--color-good); border-color: var(--color-good); }
.presence.oncall::before    { background: var(--color-accent); border-color: var(--color-accent); }
.presence.away::before      { background: var(--color-warn); border-color: var(--color-warn); }
.presence.off::before       { background: transparent; }
.presence.oncall { color: var(--color-ink); }

.board { display: grid; gap: 1px; background: var(--color-rule-2); border: 1px solid var(--color-rule-2);
         grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); }
.board .cell { background: var(--color-paper); padding: var(--space-xs) var(--space-sm); min-width: 0; }
.board .cell.clickable { cursor: pointer; }
.board .cell.clickable:hover { background: var(--color-paper-2); }
.board .cell .nm { font-size: var(--text-sm); overflow-wrap: anywhere; }
.board .cell .dept { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.board .cell .figs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--space-2xs); margin-top: var(--space-2xs); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.board .cell .figs span { min-width: 0; overflow-wrap: anywhere; }
.board .cell .figs b { font-family: var(--font-display); font-size: var(--text-lg); color: var(--color-ink); font-weight: 600; display: block; }
.board .cell.alert { box-shadow: inset 3px 0 0 var(--color-bad); }
.board .cell.alert .figs b.w { color: var(--color-bad); }

.people-group { margin-bottom: var(--space-sm); }
.people-group h4 {
  margin: 0 0 var(--space-3xs); font-family: var(--font-mono); font-size: var(--text-xs);
  font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--color-ink-3);
}
.chips { display: flex; flex-wrap: wrap; gap: var(--space-3xs) var(--space-sm); }
.chips .chip { cursor: pointer; background: none; border: 0; padding: 0; font: inherit; color: inherit; text-align: left; }
.chips .chip:hover .presence { color: var(--color-ink); }

tr.alert td:first-child { box-shadow: inset 3px 0 0 var(--color-bad); }
td.bad, .bad-text { color: var(--color-bad); }
td.warn { color: var(--color-warn); }
.muted { color: var(--color-ink-3); }
.strong { font-weight: 600; }

/* ---------------------------------------------------------- sortable table */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--color-ink); }
th.sortable[aria-sort="ascending"]::after  { content: " ↑"; }
th.sortable[aria-sort="descending"]::after { content: " ↓"; }
.pager { display: flex; gap: var(--space-xs); align-items: center; justify-content: flex-end;
         padding-top: var(--space-xs); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.pager button, .btn {
  background: var(--color-paper-3); color: var(--color-ink-2);
  border: 1px solid var(--color-rule); border-radius: var(--radius-sm);
  padding: var(--space-3xs) var(--space-xs); font-family: var(--font-mono); font-size: var(--text-xs); cursor: pointer;
}
.pager button:hover, .btn:hover { color: var(--color-ink); border-color: var(--color-ink-3); }
.pager button:disabled { opacity: .35; cursor: not-allowed; }
.btn.primary { background: var(--color-accent); color: var(--color-paper); border-color: var(--color-accent); font-weight: 600; }
.toolbar { display: flex; gap: var(--space-2xs); flex-wrap: wrap; align-items: center; margin-bottom: var(--space-xs); }

/* ---------------------------------------------------------------- drawer */
/* Drill-down panel. Full height on the right, so the list it was opened from
   stays in view on a wide screen. */
.drawer {
  position: fixed; inset: 0; z-index: 40; display: flex; justify-content: flex-end;
  background: var(--color-scrim);
}
.drawer.hidden { display: none; }
.drawer-card {
  width: var(--drawer); height: 100%; overflow-y: auto;
  background: var(--color-paper); border-left: 1px solid var(--color-rule);
  padding: var(--space-sm) var(--space-md) var(--space-xl);
}
.drawer-head { display: flex; gap: var(--space-sm); align-items: flex-start; justify-content: space-between;
               padding-bottom: var(--space-xs); border-bottom: 1px solid var(--color-rule-2); margin-bottom: var(--space-sm); }
.drawer-head h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-xl); font-weight: 600;
                  letter-spacing: var(--tracking-display); overflow-wrap: anywhere; }
.drawer-head .sub { margin-top: var(--space-3xs); }
.drawer-actions { display: flex; gap: var(--space-2xs); align-items: center; flex-wrap: wrap; }
.drawer .tabs { padding: 0; margin-bottom: var(--space-sm); }
.drawer h3 {
  margin: var(--space-md) 0 var(--space-2xs); font-family: var(--font-mono); font-size: var(--text-xs);
  font-weight: 500; text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--color-ink-3);
}
.back { margin-bottom: var(--space-2xs); }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: var(--space-2xs) var(--space-md); }
.kv div { display: flex; flex-direction: column; font-size: var(--text-sm); }
.kv > div > span:first-child { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); text-transform: uppercase; letter-spacing: var(--tracking-label); }

.kpi .delta { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); margin-left: var(--space-3xs); font-weight: 400; letter-spacing: 0; }

/* -------------------------------------------------------- call timeline */
.timeline { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--color-rule); }
.timeline li { position: relative; padding: 0 0 var(--space-sm) var(--space-sm); }
.timeline li::before {
  content: ""; position: absolute; left: -5px; top: 0.35rem; width: 9px; height: 9px; border-radius: 50%;
  background: var(--color-paper); border: 2px solid var(--color-ink-3);
}
.timeline li.ok::before { border-color: var(--color-good); }
.timeline li.queue::before { border-color: var(--color-series-3); }
.timeline li.miss::before { border-color: var(--color-bad); }
.timeline .when { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.timeline .what { font-size: var(--text-sm); }
.timeline .why { font-size: var(--text-xs); color: var(--color-ink-3); overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- heatmap */
.heat { display: grid; grid-template-columns: 3rem repeat(24, minmax(0, 1fr)); gap: 2px; font-family: var(--font-mono); font-size: var(--text-xs); }
.heat .lbl { color: var(--color-ink-3); display: flex; align-items: center; }
.heat .hh { color: var(--color-ink-3); text-align: center; }
.heat .c { height: 1.6rem; border-radius: 2px; position: relative; }
.heat .c:hover { outline: 1px solid var(--color-ink); outline-offset: 0; z-index: 1; }
.heat-legend { display: flex; align-items: center; gap: var(--space-2xs); margin-top: var(--space-xs); font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.heat-legend .ramp { width: 10rem; height: 0.5rem; border-radius: 2px; }
.tip {
  position: fixed; z-index: 60; pointer-events: none;
  background: var(--color-paper-2); border: 1px solid var(--color-rule);
  padding: var(--space-3xs) var(--space-2xs); font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--color-ink);
}
.tip.hidden { display: none; }

/* ------------------------------------------------------------- settings */
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr)); gap: var(--space-sm) var(--space-md); }
.setting { display: flex; flex-direction: column; gap: var(--space-3xs); }
.setting label { font-size: var(--text-sm); color: var(--color-ink); }
.setting .hint { max-width: none; }
.setting .row { display: flex; gap: var(--space-2xs); align-items: center; }
.setting.changed label::after { content: " • modifié"; color: var(--color-ink-3); font-family: var(--font-mono); font-size: var(--text-xs); }
.subtabs { display: flex; gap: var(--space-2xs); flex-wrap: wrap; margin-bottom: var(--space-sm); }
.ok-text { color: var(--color-good); }
.switch { cursor: pointer; }

.sparkline { height: 5rem; position: relative; }
/* An empty "nobody waiting" is good news and should not take a third of the screen. */
.panel.tight .empty { padding: var(--space-2xs) var(--space-xs); text-align: left; }

/* ----------------------------------------------------------- multi-select */
.ms { position: relative; display: inline-block; }
.ms.hidden { display: none; }   /* .ms comes after .hidden and would win */
.ms-btn {
  display: inline-flex; align-items: center; justify-content: space-between; gap: var(--space-2xs);
  min-width: 11rem; max-width: 16rem;
  background: var(--color-paper-3); color: var(--color-ink);
  border: 1px solid var(--color-rule); border-radius: var(--radius-md);
  padding: var(--space-2xs) var(--space-xs); font-family: var(--font-body); font-size: var(--text-sm);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.ms-btn:hover { border-color: var(--color-ink-3); }
.ms-btn.active { border-color: var(--color-accent); }
.ms-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ms-caret { color: var(--color-ink-3); font-size: var(--text-xs); }
.ms-pop {
  position: absolute; z-index: 45; top: calc(100% + 4px); left: 0;
  min-width: 17rem; max-width: 22rem;
  background: var(--color-paper-2); border: 1px solid var(--color-rule); border-radius: var(--radius-md);
  padding: var(--space-2xs);
}
.ms-pop.hidden { display: none; }
.ms-q { width: 100%; margin-bottom: var(--space-2xs); min-width: 0; }
.ms-list { max-height: 18rem; overflow-y: auto; display: flex; flex-direction: column; }
.ms-opt {
  display: flex; align-items: center; gap: var(--space-2xs);
  padding: var(--space-3xs) var(--space-2xs); border-radius: var(--radius-sm);
  font-size: var(--text-sm); color: var(--color-ink); cursor: pointer;
}
.ms-opt:hover, .ms-opt:focus-within { background: var(--color-paper-3); }
.ms-opt[hidden] { display: none; }
.ms-hint { margin-left: auto; font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.ms-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2xs);
           border-top: 1px solid var(--color-rule-2); margin-top: var(--space-2xs); padding-top: var(--space-2xs); }

/* ------------------------------------------------------ user bar + theme */
/* Two rows by design: title and user bar, then the filters. Three blocks on
   one line only fit on very wide screens, and a line that wraps at some
   widths and not others makes the bar jump when the filters change. */
.topbar {
  display: grid; grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "brand user" "filters filters";
  align-items: center; row-gap: var(--space-xs);
}
.topbar .brand    { grid-area: brand; }
.topbar .userbar  { grid-area: user; }
.topbar .controls { grid-area: filters; }
.userbar { display: flex; align-items: center; gap: var(--space-xs); min-width: 0; }
@media (max-width: 720px) {
  .topbar { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "user" "filters"; }
  .topbar .userbar { justify-self: start; }
}

/* Three icons in a pill, not three words: it is a preference, and it should
   weigh less on the bar than the filters do. */
.theme-seg {
  display: inline-flex; gap: 2px; padding: 2px;
  background: var(--color-paper-3); border: 1px solid var(--color-rule); border-radius: 999px;
}
.theme-seg button {
  width: 26px; height: 26px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; color: var(--color-ink-3); cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.theme-seg button:hover { color: var(--color-ink); }
.theme-seg button.active { background: var(--color-paper); color: var(--color-accent);
                           box-shadow: inset 0 0 0 1px var(--color-rule); }
.theme-seg svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5;
                 stroke-linecap: round; stroke-linejoin: round; }
.theme-seg svg .fill { fill: currentColor; stroke: none; }

.userbar .who {
  margin: 0; padding: 0; font-size: var(--text-sm); color: var(--color-ink-2);
  max-width: 18rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.logout {
  background: none; border: 1px solid var(--color-rule); border-radius: var(--radius-sm);
  padding: var(--space-3xs) var(--space-2xs); color: var(--color-ink-3);
  font-family: var(--font-body); font-size: var(--text-xs); cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.logout:hover { color: var(--color-ink); border-color: var(--color-ink-3); }

/* ------------------------------------------------------------------ tour */
.tour { position: fixed; inset: 0; z-index: 70; }
.tour.hidden { display: none; }
.tour-block { position: absolute; inset: 0; }      /* the page is not clickable mid-tour */
.tour-spot {
  position: fixed; border-radius: var(--radius-md);
  /* The scrim is the spot's own shadow: one element dims everything except
     the hole, so the highlighted control stays at full contrast. */
  box-shadow: 0 0 0 9999px var(--color-scrim);
  outline: 2px solid var(--color-focus); outline-offset: 0;
  transition: left var(--dur-base) var(--ease-out), top var(--dur-base) var(--ease-out),
              width var(--dur-base) var(--ease-out), height var(--dur-base) var(--ease-out);
  pointer-events: none;
}
.tour-card {
  position: fixed; width: min(24rem, calc(100vw - 24px));
  background: var(--color-paper); color: var(--color-ink);
  border: 1px solid var(--color-rule); border-radius: var(--radius-lg);
  padding: var(--space-sm) var(--space-md) var(--space-sm);
}
.tour-card h3 { margin: var(--space-3xs) 0 var(--space-2xs); font-family: var(--font-display);
                font-size: var(--text-lg); font-weight: 600; letter-spacing: var(--tracking-display); }
.tour-card p { margin: 0 0 var(--space-sm); font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.55; }
.tour-count { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3); }
.tour-dots { display: flex; gap: 4px; margin-bottom: var(--space-sm); }
.tour-dots span { width: 6px; height: 6px; border-radius: 50%; background: var(--color-rule); }
.tour-dots span.on { background: var(--color-accent); }
.tour-actions { display: flex; align-items: center; gap: var(--space-2xs); }

/* ------------------------------------------------------------------ help */
.help { display: grid; grid-template-columns: 13rem minmax(0, 1fr); gap: var(--space-md); align-items: start; }
.help-toc { position: sticky; top: var(--space-sm); display: flex; flex-direction: column; gap: 2px; }
.help-toc a {
  color: var(--color-ink-3); text-decoration: none; font-size: var(--text-sm);
  padding: var(--space-3xs) var(--space-2xs); border-left: 2px solid transparent;
}
.help-toc a:hover { color: var(--color-ink); border-left-color: var(--color-accent); }
.help-body p, .help-list { font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.6; max-width: 80ch; }
.help-body a { color: var(--color-accent); }
.help-list { padding-left: var(--space-md); margin: 0; }
.help-list li { margin-bottom: var(--space-2xs); }
.glossary { display: grid; grid-template-columns: minmax(10rem, 16rem) minmax(0, 1fr); gap: var(--space-2xs) var(--space-md); margin: 0; }
.glossary dt { font-weight: 600; font-size: var(--text-sm); }
.glossary dd { margin: 0; font-size: var(--text-sm); color: var(--color-ink-2); line-height: 1.55; }
dl.kv { margin: 0 0 var(--space-sm); }
dl.kv dt { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--color-ink-3);
           text-transform: uppercase; letter-spacing: var(--tracking-label); }
dl.kv dd { margin: 0; font-size: var(--text-sm); }
details { border-top: 1px solid var(--color-rule-2); padding: var(--space-2xs) 0; }
details summary { cursor: pointer; font-size: var(--text-sm); font-weight: 500; }
details summary:hover { color: var(--color-accent); }
details p { margin: var(--space-2xs) 0 0; }
@media (max-width: 900px) {
  .help { grid-template-columns: minmax(0, 1fr); }
  .help-toc { position: static; flex-direction: row; flex-wrap: wrap; }
  .glossary { grid-template-columns: minmax(0, 1fr); }
}
/* On a phone, a segmented control scrolls sideways rather than being cut
   off at the edge ("Dates…" was unreachable at 390 px). */
@media (max-width: 720px) {
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .seg button { flex: 0 0 auto; }
  .ms-btn { min-width: 0; }
}

/* ------------------------------------------------------------------ logo */
/* Each logo exists in a version per theme (scripts/make_brand.py): the
   sources are greyscale on transparency, and half of the drawing vanished on
   either background. Only the one that reads on the current theme shows. */
:root[data-theme="light"] .only-dark,
:root:not([data-theme="light"]) .only-light { display: none !important; }

.brand-mark { height: 36px; width: auto; flex: 0 0 auto; }
.login-logo { margin: 0 0 var(--space-3xs); line-height: 0; }
.login-logo img { display: block; width: 100%; max-width: 17rem; height: auto; margin: 0 auto; }
.login-card .sub { text-align: center; margin-bottom: var(--space-sm); }

/* ------------------------------------------------------------------ export */
/* The button sits with the filters it exports; it is a filter row's action,
   so it keeps the row's height and the segmented control's type. */
.export-btn {
  display: inline-flex; align-items: center; gap: var(--space-3xs);
  padding: var(--space-2xs) var(--space-xs); border-radius: var(--radius-md);
}
.export-btn.hidden { display: none; }
.export-btn svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: currentColor;
                  stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* Where the data starts: information, not a warning -- the accent's rule,
   not the warn or bad one, and quieter than the staleness banner. */
.banner-info { border-left-color: var(--color-accent); color: var(--color-ink-2); }
.banner-info strong { color: var(--color-ink); font-weight: 500; }
.banner-info .linkish { margin-left: var(--space-2xs); }

.xp-lede { margin: var(--space-3xs) 0 var(--space-sm); }
.xp-section { padding: var(--space-sm) 0; border-top: 1px solid var(--color-rule-2); }
.xp-label {
  margin-bottom: var(--space-2xs);
  font-family: var(--font-mono); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: var(--tracking-label); color: var(--color-ink-3);
}
.xp-row { display: flex; flex-wrap: wrap; gap: var(--space-2xs); align-items: center; }
.xp-row + .xp-row { margin-top: var(--space-2xs); }
.xp-row.hidden { display: none; }
.xp-chip {
  display: inline-flex; align-items: center; gap: var(--space-3xs);
  padding: var(--space-3xs) var(--space-2xs); border-radius: var(--radius-sm);
  background: var(--color-paper-3); border-left: 2px solid var(--color-accent);
  font-size: var(--text-xs); color: var(--color-ink-2);
}
.xp-chip.hidden { display: none; }
.xp-chip .linkish { text-decoration: none; font-size: var(--text-sm); line-height: 1; }
.xp-data {
  margin: var(--space-2xs) 0 0; padding: var(--space-3xs) var(--space-xs);
  border-left: 2px solid var(--color-accent); color: var(--color-ink-2); font-size: var(--text-xs);
}
.xp-data.hidden { display: none; }

/* What goes in the file: cards, so the choice reads at a glance. */
.xp-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2xs); }
.xp-card {
  display: flex; gap: var(--space-2xs); align-items: flex-start; cursor: pointer;
  padding: var(--space-xs); border: 1px solid var(--color-rule); border-radius: var(--radius-md);
  background: var(--color-paper-2);
  transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out);
}
.xp-card:hover { border-color: var(--color-ink-3); }
.xp-card.on { border-color: var(--color-accent); background: var(--color-paper-3); }
.xp-card input { margin-top: 0.15rem; accent-color: var(--color-accent); }
.xp-card-body { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.xp-card-body strong { font-size: var(--text-sm); font-weight: 500; color: var(--color-ink); }
.xp-card-body span { font-size: var(--text-xs); color: var(--color-ink-3); }
.xp-sub {
  display: flex; flex-wrap: wrap; gap: var(--space-2xs) var(--space-xs); align-items: center;
  margin-top: var(--space-xs); padding-left: var(--space-xs); border-left: 1px solid var(--color-rule);
}
.xp-sub.hidden { display: none; }
.xp-sublabel { font-size: var(--text-xs); color: var(--color-ink-3); }
.xp-check { display: inline-flex; gap: var(--space-3xs); align-items: center; font-size: var(--text-xs);
            color: var(--color-ink-2); cursor: pointer; }
.xp-check.hidden { display: none; }
.xp-check input { accent-color: var(--color-accent); }
.xp-hint { font-size: var(--text-xs); color: var(--color-ink-3); margin: var(--space-2xs) 0 0; }
.xp-sub .xp-hint, .xp-foot .xp-hint { margin: 0; }
.xp-foot {
  display: flex; flex-wrap: wrap; gap: var(--space-2xs); align-items: center;
  padding-top: var(--space-sm); border-top: 1px solid var(--color-rule-2);
}
.xp-foot .btn { padding: var(--space-2xs) var(--space-sm); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
@media (max-width: 560px) {
  .xp-cards { grid-template-columns: minmax(0, 1fr); }
}
