/* Workforce Intelligence account site.

   This stylesheet re-implements the Workforce Intelligence app's design system for the central
   service, which is a separate deployable and never imports web/. Source of truth, in priority order:
     docs/design-system/README.md        the rules (colour roles, type, spacing, buttons, tables, dialogs)
     web/src/tokens.css                  the token values copied into :root below
     web/src/wi-bundle.css               .wi-btn, .wi-input, .wi-pill, .wi-table (mirrored here, same names)
     web/src/styles.css                  card header, dialog, top bar, phone menu
     web/src/components/{TopBar,Card,PageHeader,Dialog,ConfirmDialog,CopyField,StatusLine,EmptyState}.tsx
   Drift guard: central/tests/test_portal_design_tokens.py compares the token block below with
   web/src/tokens.css. Change a token in the web app first, then here.

   CSP: no external resources, no inline style. The two fonts are self-hosted in ./fonts (SIL OFL). */

/* Fonts: the same families the app loads from Google Fonts (Newsreader headings, Work Sans body). */
@font-face {
  font-family: "Newsreader";
  font-style: normal;
  font-weight: 500 600;
  font-display: swap;
  src: url("/portal/static/fonts/newsreader-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Work Sans";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("/portal/static/fonts/work-sans-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ---- Tokens (copied from web/src/tokens.css; the drift test reads this block) ---- */
:root {
  --brand-yellow:     #f3b840;
  --ink:              #3d3836;
  --paper:            #ffffff;
  --black:            #000000;
  --gear-mid:         #f9d59f;
  --figure-coral:     #e15d6f;
  --figure-mint:      #63b698;
  --lavender:         #7c607b;
  --chair:            #ada28c;
  --link-blue:        #006e99;
  --site-blue:        #39bddf;
  --cool-600:         #5f6673;
  --od-teal:          #00344f;

  --primary:          var(--brand-yellow);
  --primary-content:  var(--black);
  --secondary:        var(--ink);
  --secondary-content:var(--paper);
  --accent:           var(--figure-coral);
  --accent-content:   var(--black);
  --neutral:          var(--ink);
  --neutral-content:  var(--paper);
  --base-100:         var(--paper);
  --base-200:         #fafafa;
  --base-300:         #d5d9df;
  --base-content:     var(--ink);
  --info:             var(--site-blue);
  --info-content:     var(--black);
  --success:          var(--figure-mint);
  --success-content:  var(--black);
  --warning:          #e37f40;
  --warning-content:  var(--black);
  --error:            #c83737;
  --error-content:    var(--paper);
  --success-text:     #36735d;
  --warning-text:     #b85a16;
  --scrim:            rgba(61,56,54,0.4);
  --hover-layer:      rgba(61,56,54,0.08);
  --press-layer:      rgba(61,56,54,0.12);
  --focus-ring:       color-mix(in srgb, var(--od-teal) 80%, transparent);

  --font-display: "Newsreader", Georgia, serif;
  --font-body:    "Work Sans", system-ui, sans-serif;
  --font-ui:      "Work Sans", system-ui, sans-serif;

  --space-half: 4px;
  --space-1: 8px; --space-1h: 12px; --space-2: 16px; --space-3: 24px; --space-4: 32px;
  --space-6: 48px; --space-8: 64px;

  --topbar-height: 58px;
  --z-topbar: 40;
  --z-dialog: 100;

  --radius: 4px;
  --radius-sm: 4px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --maxw: 1280px;

  --shadow-xl:   0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
}

/* ---- Base ---- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-font-smoothing: antialiased; }
body {
  margin: 0; background: var(--base-200); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.5; font-weight: 400;
}
h1, h2, h3, p, dl, dd, ul, ol, figure, pre { margin: 0; }
h1, h2, h3, p, dt, dd, li, label, td, th, a, pre, .mono { overflow-wrap: anywhere; }
::selection { background: color-mix(in srgb, var(--ink) 15%, transparent); }
button, input, textarea, select { font: inherit; color: inherit; }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }

/* One global focus ring (same as the app): 3px teal outline with a 3px gap. Text fields keep the 2px ink border. */
:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 3px; box-shadow: none; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
@media (forced-colors: active) { :focus-visible { outline: 2px solid CanvasText; } }

main a:not(.wi-btn), .foot a, .callout a {
  color: var(--success-text); text-decoration: underline; text-underline-offset: 3px;
  transition: text-decoration-color 150ms ease-out;
}
main a:not(.wi-btn):hover, .foot a:hover, .callout a:hover {
  text-decoration-color: var(--brand-yellow); text-decoration-thickness: 2px;
}

.skip {
  position: absolute; left: -999px; top: 0; z-index: 200; padding: var(--space-1) var(--space-2);
  background: var(--paper); color: var(--ink); border-radius: var(--radius-sm);
}
.skip:focus { left: var(--space-1); top: var(--space-1); }

/* ---- Top bar (web/src/styles.css .topbar, .nav-link, .menu-button, .phone-menu-*) ---- */
.topbar {
  background: var(--od-teal); color: var(--paper);
  position: sticky; top: 0; z-index: var(--z-topbar);
  --hover-layer: rgba(255,255,255,0.08);
  --press-layer: rgba(255,255,255,0.12);
}
.topbar-inner {
  max-width: var(--maxw); margin: 0 auto; padding: 0 var(--space-4);
  display: flex; flex-wrap: wrap; align-items: center; gap: 0 var(--space-3);
  min-height: var(--topbar-height);
}
.wordmark {
  display: flex; align-items: center; gap: var(--space-1);
  font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -.01em;
  line-height: 1.1; color: var(--paper); text-decoration: none; min-height: 44px;
}
.reddot {
  position: relative; display: inline-block; flex: none;
  width: 10px; height: 10px; border-radius: 50%; background: var(--brand-yellow);
}
.reddot::after {
  content: ""; position: absolute; inset: -4px;
  border: 1.5px solid var(--brand-yellow); border-radius: 50%;
  opacity: 0; animation: radiate 2.6s ease-out infinite;
}
@keyframes radiate {
  0%   { transform: scale(.4); opacity: .8; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}
.menu-button {
  display: none; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; margin-left: -8px; padding: 0;
  background: none; border: 0; border-radius: var(--radius); color: var(--paper); cursor: pointer;
}
.menu-button:hover, .nav-link:hover { background-image: linear-gradient(var(--hover-layer), var(--hover-layer)); }
.menu-button:active, .nav-link:active { background-image: linear-gradient(var(--press-layer), var(--press-layer)); }
.nav { margin-left: auto; flex: 1 1 0; min-width: 0; }
.nav-list { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-1); list-style: none; margin: 0; padding: 0; }
.nav-link {
  display: flex; align-items: center; min-height: 44px; padding: 0 12px;
  border: 0; border-bottom: 3px solid transparent; border-radius: var(--radius);
  background: none; color: rgba(255,255,255,0.85);
  font-family: var(--font-ui); font-size: 14px; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  transition: background-image 150ms ease-out;
}
.nav-link:hover { color: var(--paper); }
.nav-link[aria-current="page"] { color: var(--paper); border-bottom-color: var(--brand-yellow); }
.nav-link[aria-current="page"]:not(:focus-visible) { box-shadow: none; }
.nav-form { margin: 0; }

/* ---- Page ---- */
.page { max-width: var(--maxw); margin: 0 auto; padding: var(--space-3) var(--space-4) var(--space-8); }
.page:focus { outline: none; }
.page.narrow { max-width: calc(560px + 2 * var(--space-4)); }
.page-body { display: flex; flex-direction: column; gap: var(--space-2); }
.page-header { margin-bottom: var(--space-3); }
.kicker {
  display: flex; align-items: center; gap: var(--space-half);
  font-size: 12px; font-weight: 500; line-height: 18px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink);
}
.kicker::before { content: ""; width: 24px; height: 4px; flex-shrink: 0; background: var(--link-blue); }
.display { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; }
h1 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.01em; line-height: 1.1; font-size: 30px; }
.kicker + h1, .back-link + .kicker { margin-top: var(--space-1); }
.page-header h1:first-child { margin-top: 0; }
.page-header .intro, .page-header > p { margin-top: var(--space-1); font-size: 16px; }
.back-link {
  display: inline-flex; align-items: center; gap: var(--space-1); min-height: 32px; margin-bottom: var(--space-1);
  font-size: 14px; font-weight: 600; text-decoration: none;
}
.back-link svg { width: 16px; height: 16px; }
main a.back-link { text-decoration: none; }
main a.back-link:hover { text-decoration: underline; text-decoration-color: var(--brand-yellow); text-decoration-thickness: 2px; }
.icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---- Cards ---- */
.card {
  min-width: 0; background: var(--paper); border: 1px solid var(--base-300);
  border-radius: var(--radius-lg); padding: var(--space-2); box-shadow: var(--shadow-xl);
  scrollbar-color: var(--base-300) transparent; scrollbar-width: thin;
}
.card > * + * { margin-top: var(--space-2); }
.card > .card-header + * { margin-top: var(--space-3); }
.card-header { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0 var(--space-2); }
.card-title {
  order: 0; flex: 1 1 auto; display: flex; align-items: center; gap: var(--space-1);
  font-family: var(--font-display); font-size: 20px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.1;
}
.card-title-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; background: var(--gear-mid); color: var(--ink);
}
.card-header-action { order: 1; max-width: 100%; min-width: 0; }
.card-header-action .wi-btn { white-space: normal; text-align: left; max-width: 100%; }
.card-desc { order: 2; flex-basis: 100%; margin-top: var(--space-1); font-size: 14px; }
.card h3, .card-heading { font-size: 16px; font-weight: 600; font-family: var(--font-body); letter-spacing: 0; }
.card .small, .wi-help, .card p.wi-help { font-size: 14px; }
.cols { display: grid; gap: var(--space-2); grid-template-columns: minmax(0, 1fr); align-items: start; }
.card.accent-warning { border-color: var(--warning-text); }

/* Callouts and status lines */
.callout {
  background: var(--paper); border: 1px solid var(--base-300); border-radius: var(--radius-sm);
  padding: var(--space-2); color: var(--ink); font-size: 14px; line-height: 20px;
}
.status-line { display: flex; align-items: flex-start; gap: var(--space-1); font-size: 14px; line-height: 20px; }
.status-line .icon { margin-top: 2px; }
.status-line.is-error { color: var(--error); }
.status-line.is-warning { color: var(--warning-text); }
.status-line.is-success { color: var(--success-text); }
.card .status-line, .callout .status-line { font-size: 14px; }
.callout-error, .callout-warning { background: var(--paper); }

/* Number cards and details rows */
.stats { display: grid; gap: var(--space-2); grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr)); }
.stat { min-width: 0; background: var(--paper); border: 1px solid var(--base-300); border-radius: var(--radius-lg); padding: var(--space-2); box-shadow: var(--shadow-xl); }
.stat dt { font-size: 12px; font-weight: 500; line-height: 18px; letter-spacing: .1em; text-transform: uppercase; }
.stat dd { margin-top: var(--space-1); font-size: 16px; font-weight: 600; }
.stat dd.stat-value { font-family: var(--font-display); font-size: 30px; line-height: 1.1; letter-spacing: -0.01em; }
.stat dd .stat-sub { display: block; margin-top: var(--space-half); font-family: var(--font-body); font-size: 14px; font-weight: 400; letter-spacing: 0; }
.stat.spotlight { background: var(--od-teal); border-color: var(--od-teal); color: var(--paper); }
.details { display: flex; flex-direction: column; }
.details > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-2); padding: var(--space-1) 0; font-size: 14px; }
.details > div + div { border-top: 1px solid var(--base-300); }
.details dt { font-weight: 400; }
.details dd { font-weight: 600; text-align: right; }
.card .details > div { font-size: 14px; }

/* ---- Buttons (web/src/wi-bundle.css) ---- */
.wi-btn {
  position: relative; white-space: nowrap; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1);
  min-height: 32px; padding: 0 12px; border: 2px solid transparent; border-radius: var(--radius-sm);
  font-family: var(--font-ui); font-weight: 600; font-size: 14px; line-height: 1; text-decoration: none; cursor: pointer;
  transition: background-color 150ms ease-out, background-image 150ms ease-out, color 150ms ease-out, border-color 150ms ease-out;
}
.wi-btn .icon { width: 16px; height: 16px; }
.wi-btn-primary { background: var(--primary); color: var(--primary-content); }
.wi-btn-ghost { background: transparent; color: var(--secondary); border-color: var(--secondary); }
.wi-btn-text { background: transparent; color: var(--success-text); border-color: transparent; }
.wi-btn-destructive { background: var(--error); color: var(--paper); border-color: var(--error); }
.wi-btn.wi-btn-sm { min-height: 24px; padding: 0 var(--space-1); }
.wi-btn:hover { background-image: linear-gradient(var(--hover-layer), var(--hover-layer)); }
.wi-btn:active { background-image: linear-gradient(var(--press-layer), var(--press-layer)); }
.wi-btn-primary:hover, .wi-btn-primary:active { color: var(--primary-content); }
.wi-btn-destructive:hover { color: var(--paper); }
/* A truly disabled button (design system Button README; docs/design-system/components/bundle.css):
   a flat base-300 block with cool-600 words, no outline, the not-allowed cursor. */
.wi-btn:disabled, .wi-btn:disabled:hover, .wi-btn:disabled:active { background: var(--base-300); background-image: none; border-color: transparent; color: var(--cool-600); cursor: not-allowed; box-shadow: none; }
/* An invisible 44px tap area behind every button (the button itself keeps the app's size). */
.wi-btn::after { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 44px; transform: translateY(-50%); }
.btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
/* Copy icons come from CSS masks (img-src allows data:), so the button text stays plain. */
.wi-btn[data-copy-key]::before {
  content: ""; width: 16px; height: 16px; flex-shrink: 0; background: currentColor;
  -webkit-mask: var(--icon-copy) center / contain no-repeat; mask: var(--icon-copy) center / contain no-repeat;
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='14' height='14' x='8' y='8' rx='2'/%3E%3Cpath d='M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2'/%3E%3C/svg%3E");
}
.wi-btn[data-copy-key].is-copied::before {
  --icon-copy: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}

/* ---- Fields (web/src/wi-bundle.css .wi-field, .wi-input, .wi-check) ---- */
.wi-form { display: flex; flex-direction: column; gap: var(--space-2); }
.wi-field { display: flex; flex-direction: column; gap: var(--space-half); min-width: 0; }
.wi-field label { font-family: var(--font-ui); font-weight: 500; font-size: 14px; line-height: 20px; color: var(--base-content); }
.wi-input {
  display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 32px; padding: 4px 12px;
  border: 1px solid var(--base-content); border-radius: var(--radius-sm);
  background: var(--base-100); color: var(--base-content);
  font-family: var(--font-body); font-size: 14px; line-height: 20px; appearance: none; -webkit-appearance: none;
}
.wi-input::placeholder { color: var(--base-content); opacity: .75; }
.wi-input:focus { border-width: 2px; padding: 3px 11px; outline: none; }
.wi-input:-webkit-autofill, .wi-input:-webkit-autofill:hover, .wi-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--paper) inset; box-shadow: 0 0 0 1000px var(--paper) inset;
  -webkit-text-fill-color: var(--base-content);
}
.wi-help { font-size: 14px; line-height: 20px; color: var(--base-content); }
.wi-check { display: flex; gap: var(--space-1h); align-items: flex-start; font-size: 14px; line-height: 20px; }
.wi-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--base-content); flex-shrink: 0; }
.wi-check label { font-weight: 400; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin-top: var(--space-1); }

/* One-time key field: read-only, wraps the whole key, never clipped (CopyField pattern). */
.key-box { display: flex; flex-direction: column; gap: var(--space-1); }
.key-field { display: flex; align-items: flex-start; gap: var(--space-1); }
.key-field .secret {
  flex: 1 1 auto; resize: none; overflow: auto; padding: var(--space-1) var(--space-1h);
  font-variant-numeric: tabular-nums; letter-spacing: .02em; overflow-wrap: anywhere; word-break: break-all;
  field-sizing: content; cursor: text;
}
.key-field .secret:focus { padding: 7px 11px; }
.copy-status { min-height: 20px; }

/* ---- Pills ---- */
.wi-pill {
  display: inline-flex; align-items: center; min-height: 24px; padding: 0 12px; border-radius: var(--radius-full);
  font-family: var(--font-ui); font-weight: 500; font-size: 12px; line-height: 18px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--paper); white-space: nowrap;
}
.wi-pill-success { background: var(--success); color: var(--success-content); }
.wi-pill-warning { background: var(--warning); color: var(--warning-content); }
.wi-pill-neutral { background: var(--base-300); color: var(--black); }
.wi-pill-info { background: var(--info); color: var(--info-content); }

/* ---- Tables (web/src/wi-bundle.css .wi-table; wrapped in a card, scrolling inside it) ---- */
.table-scroll { overflow-x: auto; scrollbar-color: var(--ink) var(--base-300); scrollbar-width: thin; }
.wi-table { width: 100%; border-collapse: collapse; font-family: var(--font-body); font-size: 14px; line-height: 20px; color: var(--base-content); }
.wi-table th {
  text-align: left; padding: var(--space-1h) var(--space-2); border-bottom: 1px solid var(--base-content);
  font-family: var(--font-ui); font-weight: 500; font-size: 12px; line-height: 18px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink);
}
.wi-table td, .wi-table tbody th { padding: var(--space-2); border-bottom: 1px solid var(--base-300); vertical-align: top; }
.wi-table tbody th { font-family: var(--font-body); font-weight: 600; font-size: 14px; letter-spacing: 0; text-transform: none; text-align: left; border-bottom-color: var(--base-300); }
.wi-table tbody tr:last-child > * { border-bottom: 0; }
.wi-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.wi-table .nowrap { white-space: nowrap; }
.wi-table .wi-sub { display: block; color: var(--ink); }
.wi-table.data { min-width: 640px; }
.wi-table.data thead th, .wi-table.data tbody th { white-space: nowrap; }
.wi-table.data tbody th:first-child, .wi-table.data thead th:first-child { position: sticky; left: 0; background: var(--paper); }
.wi-table .mono { font-variant-numeric: tabular-nums; }
.wi-table.data tbody th.who, .wi-table .who { white-space: normal; min-width: 12rem; max-width: 22rem; overflow-wrap: anywhere; }
.wi-table .wi-muted { font-size: 12px; opacity: .75; }
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.row-actions form { margin: 0; }
.callout .op-inline { margin-top: var(--space-1); }
.op-mode { margin-bottom: var(--space-2); }
.op-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-1); }
.op-inline .wi-field { flex: 1 1 180px; }

/* ---- Empty state (full size, centered inside its card) ---- */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-1); padding: var(--space-6) var(--space-3); }
.empty .icon { width: 24px; height: 24px; }
.empty .empty-title { font-size: 16px; font-weight: 600; }
.empty .empty-body { font-size: 14px; }
.empty .wi-btn { margin-top: var(--space-2); }

/* ---- Pop-up (web/src/styles.css .wi-dialog; native <dialog>, opened by portal.js) ---- */
.wi-dialog {
  width: calc(100% - 2 * var(--space-2)); max-width: 480px; padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow-xl);
}
.wi-dialog::backdrop { background: var(--scrim); }
.wi-dialog[open] { animation: wi-dialog-in 200ms ease-out; }
@keyframes wi-dialog-in { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.wi-dialog-body { padding: var(--space-2); }
.wi-dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-1h); margin-bottom: var(--space-1); }
.wi-dialog-header h2 { font-family: var(--font-display); font-size: 20px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; }
.wi-dialog p { font-size: 14px; }
.wi-dialog-footer { display: flex; gap: var(--space-1); justify-content: flex-end; margin-top: var(--space-3); }
.wi-btn-icon {
  position: relative; width: 32px; height: 32px; padding: 0; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: var(--radius-full); background: transparent; color: var(--ink); cursor: pointer;
  transition: background-color 150ms ease-out;
}
.wi-btn-icon:hover { background: var(--hover-layer); }
.wi-btn-icon:active { background: var(--press-layer); }
.wi-btn-icon::after { content: ""; position: absolute; inset: -6px; }

/* ---- Footer ---- */
.foot { background: var(--base-200); color: var(--ink); border-top: 1px solid var(--base-300); }
.foot-inner { max-width: var(--maxw); margin: 0 auto; padding: var(--space-2) var(--space-4); }
.legal-links { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); list-style: none; margin: 0; padding: 0; font-size: 14px; }
.legal-links a { display: inline-flex; align-items: center; min-height: 44px; }
.consent { font-size: 14px; }

/* ---- Wider screens: pair a form card with its supporting card ---- */
@media (min-width: 840px) {
  .cols.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols.two-wide { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
  .page-body { gap: var(--space-2); }
}

/* ---- Phones and tablets under 840px ---- */
@media (max-width: 839px) {
  :root { --topbar-height: 56px; }
  .topbar-inner { padding: 0 var(--space-2); gap: 0 var(--space-1); }
  .page { padding: var(--space-3) var(--space-2) var(--space-6); }
  .foot-inner { padding: var(--space-2); }
  /* Without script the links wrap onto their own row under the wordmark. */
  .nav { flex: 1 0 100%; margin-left: 0; padding-bottom: var(--space-1); }
  .nav-list { justify-content: flex-start; }
  /* With script (class set by portal.js) the links collapse into a menu button and panel. */
  .js .menu-button { display: flex; }
  .js .topbar-inner { flex-wrap: nowrap; }
  .js .nav {
    display: none; position: absolute; top: 100%; left: 0; right: 0; flex: none; padding: var(--space-1) var(--space-2) var(--space-2);
    background: var(--paper); color: var(--ink); border-bottom: 1px solid var(--base-300); box-shadow: var(--shadow-xl);
    max-height: calc(100vh - var(--topbar-height)); max-height: calc(100dvh - var(--topbar-height)); overflow-y: auto;
  }
  .js .nav.is-open { display: block; }
  .js .nav-list { flex-direction: column; align-items: stretch; gap: 0; }
  .js .nav-link {
    width: 100%; padding: 12px 0; border: 0; border-bottom: 1px solid var(--base-300); border-radius: 0;
    color: var(--ink); font-size: 16px; text-align: left; justify-content: flex-start;
    --hover-layer: rgba(61,56,54,0.08); --press-layer: rgba(61,56,54,0.12);
  }
  .js .nav-link:hover { color: var(--ink); }
  .js .nav-link[aria-current="page"] { background: color-mix(in srgb, var(--ink) 8%, transparent); border-left: 3px solid var(--brand-yellow); padding-left: 12px; }
  .js .nav-list li:last-child .nav-link { border-bottom: 0; }
  .js .menu-button + .wordmark { flex: 1 1 auto; }

  h1 { overflow-wrap: anywhere; }
  .wi-input { font-size: 16px; min-height: 44px; padding: 10px 12px; }
  .wi-input:focus { padding: 9px 11px; }
  .key-field .secret { padding: 10px 12px; }
  .key-field .secret:focus { padding: 9px 11px; }
  .wi-btn.wi-btn-sm { min-height: 32px; }
  .key-field { flex-direction: column; align-items: stretch; }
  .form-actions { flex-direction: column; align-items: stretch; }
  .form-actions .wi-btn, .key-field .wi-btn { width: 100%; }
  .details > div { flex-direction: column; gap: var(--space-half); }
  .details > div { padding: 0; }
  .details > div + div { margin-top: var(--space-1); padding-top: var(--space-1); }
  .details dd { text-align: left; }
  .wi-dialog { max-width: calc(100vw - 32px); }
  .wi-dialog-footer { flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
  .wi-dialog-footer .wi-btn { width: 100%; }

  /* Record tables become stacked blocks: name first, then each column as a caps label and value. */
  .wi-table.record, .wi-table.record tbody, .wi-table.record tr, .wi-table.record td, .wi-table.record th { display: block; }
  .wi-table.record thead { display: none; }
  .wi-table.record tr { padding: var(--space-2) 0; border-bottom: 1px solid var(--base-300); }
  .wi-table.record tbody tr:first-child { padding-top: 0; }
  .wi-table.record tr:last-child { border-bottom: 0; padding-bottom: 0; }
  .wi-table.record td, .wi-table.record tbody th { padding: var(--space-half) 0; border-bottom: 0; }
  .wi-table.record td[data-label]::before {
    content: attr(data-label); display: inline-block; margin-right: var(--space-1);
    font-weight: 500; font-size: 12px; line-height: 18px; letter-spacing: 0.1em; text-transform: uppercase;
  }
  .wi-table.record td[data-actions] { padding-top: var(--space-1); }
  .wi-table.record td[data-actions] .wi-btn-text { color: var(--ink); border-color: var(--ink); }
  .wi-table.record td:empty { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .reddot::after { animation: none; }
  .wi-btn, .nav-link, .wi-btn-icon, main a { transition: none !important; }
  .wi-dialog[open] { animation: none; }
}

/* ---- Small helpers ---- */
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.page-notice { margin-bottom: var(--space-2); }
.wi-form { max-width: 560px; }
.card ul { padding-left: var(--space-3); }
.card pre { font-family: var(--font-body); font-size: 14px; white-space: pre-wrap; }

/* ---- Operator section: grouped left nav + content (web/src/styles.css .settings-layout, .settings-nav*) ---- */
.op-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.op-content { min-width: 0; }
.op-nav { position: sticky; top: calc(var(--topbar-height) + var(--space-3)); }
.op-nav ul { list-style: none; margin: 0; padding: 0; }
.op-group-label {
  font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink); padding: 32px 0 8px;
}
.op-item {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm); border-left: 3px solid transparent;
  font-size: 16px; color: var(--ink); text-decoration: none;
  transition: background-image 150ms ease-out;
}
main a.op-item { color: var(--ink); text-decoration: none; }
.op-item:hover { background-image: linear-gradient(var(--hover-layer), var(--hover-layer)); }
.op-item-active {
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  border-left-color: var(--brand-yellow); font-weight: 600;
}
.op-item-active:hover { background-image: none; }
@media (max-width: 839px) {
  .op-layout { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .op-nav { position: static; display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-half) var(--space-2); padding-bottom: var(--space-2); border-bottom: 1px solid var(--base-300); }
  .op-nav ul { display: flex; flex-wrap: wrap; gap: var(--space-half); }
  .op-group-label { padding: 0; font-size: 11px; }
  .op-item { padding: 8px 12px; border-left-width: 0; border-bottom: 3px solid transparent; min-height: 40px; }
  .op-item-active { border-bottom-color: var(--brand-yellow); }
}
@media (prefers-reduced-motion: reduce) { .op-item { transition: none; } }
.stat-link { display: block; margin-top: var(--space-1); font-size: 14px; font-weight: 600; }
.filter-row { display: flex; flex-wrap: wrap; gap: var(--space-1); }
/* Bug reports: the filter row (From, To, Status, Apply) wraps; fields never force a page scroll. */
.op-filter { margin-bottom: var(--space-2); }
.op-filter .wi-field { flex: 1 1 160px; min-width: 0; }
.op-filter .form-actions { margin-top: 0; }
select.wi-input { padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px, 6px 6px; background-repeat: no-repeat; }
.op-ticket { overflow-wrap: anywhere; }
/* The reports table keeps whole words in its headers and scrolls inside its card instead of
   squeezing columns (above 840px; below it each row is a stacked block with labelled values). */
.op-reports thead th { white-space: nowrap; }
.op-reports td, .op-reports tbody th { overflow-wrap: anywhere; }
.page-body, .card { min-width: 0; }

.op-description { white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word; margin: 0; }

/* Bug reports marking: the status form and the bulk bar wrap, fields never force a page scroll. */
.op-bulk .wi-field { flex: 1 1 180px; min-width: 0; }
.op-bulk .form-actions { margin-top: 0; }
/* The detail page's Status form is a plain .wi-form (vertical stack, like Revoke/Restore). */
.wi-form .wi-help { margin: 0; }
#bulk-form { margin-bottom: var(--space-2); }
.op-select-all { display: none; }
.js .op-select-all { display: inline; }
.op-reports input[type=checkbox] { width: 20px; height: 20px; }

/* Bug reports list: the whole row opens the report. The Received timestamp is a real link; its ::after
   stretches over the row (position: relative + a no-op transform keeps the row the containing block
   in every browser). The row checkbox and the Deployment link sit above it and stay clickable. */
.op-reports tr.op-row { position: relative; transform: translate(0); cursor: pointer; }
.op-reports tr.op-row:hover { background-image: linear-gradient(var(--hover-layer), var(--hover-layer)); }
.op-reports .op-row-link { color: inherit; }
.op-reports .op-row-link::after { content: ""; position: absolute; inset: 0; }
.op-reports .op-row-link:focus-visible { outline: none; }
.op-reports .op-row-link:focus-visible::after { outline: 3px solid var(--focus-ring); outline-offset: -3px; }
@media (forced-colors: active) { .op-reports .op-row-link:focus-visible::after { outline: 2px solid CanvasText; } }
.op-reports tr.op-row input[type=checkbox], .op-reports tr.op-row td a { position: relative; z-index: 1; }
