/* Live Oak outbound — the operator's console.
 *
 * Design language: a sibling of Live Oak's inventory manager (../inventory_manager/
 * frontend/src/index.css), so the two tools feel like one company's software. A dark
 * navy sidebar (#0b1120) carries the brand and the five views; the working surface is a
 * cool light grey (#f4f5f7) with white cards, soft shadows and radii of 6/10/14px.
 * Plus Jakarta Sans for everything, JetBrains Mono for figures (arm keys, counts,
 * rates). Tables follow the inventory manager's DataTable: sticky header, small
 * uppercase column labels, quiet row hover. Status words are pill badges; buttons are
 * primary (blue, the default `<button>`), `.secondary` (white) and `.danger` (red).
 *
 * The one loud element is still the state bar at the top of the working area. Its
 * colour answers "is anything going out?": green SENDING, amber NOT LIVE, solid red
 * when the kill switch is on (with hazard stripes) or a protective action has failed.
 * It is safety-relevant — do not make it quieter than the rest of the page.
 *
 * There is no inline CSS anywhere in the templates, because the Content-Security
 * Policy is `style-src 'self'`. Adding a `style="…"` attribute will silently do
 * nothing; add a class here instead. Fonts are self-hosted in /static/fonts
 * (`font-src 'self'`) and icons are CSS masks over /static/icons/*.svg — see
 * dashboard/static/README.md for why they are not inline <svg>.
 */

/* --- fonts (self-hosted, SIL OFL 1.1; see fonts/OFL-*.txt) -------------------------- */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/plus-jakarta-sans-latin-wght-normal.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: "Plus Jakarta Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("/static/fonts/plus-jakarta-sans-latin-ext-wght-normal.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB,
    U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url("/static/fonts/jetbrains-mono-latin-wght-normal.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 (the inventory manager's, name for name where they overlap) ------------- */

:root {
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --color-bg: #f4f5f7;
  --color-surface: #ffffff;
  --color-surface-sunk: #f8f9fb;
  --color-sidebar: #0b1120;
  --color-sidebar-hover: rgba(255, 255, 255, 0.06);
  --color-sidebar-active: rgba(99, 149, 255, 0.15);
  --color-sidebar-accent: #6395ff;
  --color-sidebar-rule: rgba(255, 255, 255, 0.08);

  --color-text: #1a1d26;
  --color-text-secondary: #5e6578;
  --color-text-muted: #8a91a3;
  --color-text-inverse: #ffffff;

  --color-accent: #3b6cf5;
  --color-accent-hover: #2d5ce0;
  --color-accent-light: #eef2ff;
  --color-success: #0d9668;
  --color-success-light: #ecfdf5;
  --color-danger: #dc2626;
  --color-danger-hover: #c81e1e;
  --color-danger-light: #fef2f2;
  --color-warning: #b86e0b;
  --color-warning-light: #fffbeb;
  --color-purple: #7c3aed;
  --color-purple-light: #f5f3ff;

  --color-border: #e2e5ea;
  --color-border-strong: #ccd0d8;
  --color-border-light: #eff0f3;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);

  --transition-fast: 120ms ease;

  --sidebar-width: 240px;
  --page-pad-x: 40px;
}

/* --- base ---------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

a:hover {
  color: var(--color-accent-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-surface-sunk);
  border: 1px solid var(--color-border-light);
  border-radius: 4px;
  padding: 0.05em 0.35em;
}

::selection {
  background: rgba(59, 108, 245, 0.15);
}

.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;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

.muted {
  color: var(--color-text-muted);
}

.strong {
  font-weight: 700;
}

/* --- icons: CSS masks, so they take the colour of the text around them ---------------- */

.icon {
  display: inline-block;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.icon-experiments { -webkit-mask-image: url("/static/icons/experiments.svg"); mask-image: url("/static/icons/experiments.svg"); }
.icon-pipeline { -webkit-mask-image: url("/static/icons/pipeline.svg"); mask-image: url("/static/icons/pipeline.svg"); }
.icon-discovery { -webkit-mask-image: url("/static/icons/discovery.svg"); mask-image: url("/static/icons/discovery.svg"); }
.icon-approve { -webkit-mask-image: url("/static/icons/approve.svg"); mask-image: url("/static/icons/approve.svg"); }
.icon-controls { -webkit-mask-image: url("/static/icons/controls.svg"); mask-image: url("/static/icons/controls.svg"); }
.icon-settings { -webkit-mask-image: url("/static/icons/settings.svg"); mask-image: url("/static/icons/settings.svg"); }
.icon-account { -webkit-mask-image: url("/static/icons/account.svg"); mask-image: url("/static/icons/account.svg"); }
.icon-signout { -webkit-mask-image: url("/static/icons/signout.svg"); mask-image: url("/static/icons/signout.svg"); }
.icon-menu { -webkit-mask-image: url("/static/icons/menu.svg"); mask-image: url("/static/icons/menu.svg"); }
.icon-dot { -webkit-mask-image: url("/static/icons/dot.svg"); mask-image: url("/static/icons/dot.svg"); }
.icon-stop { -webkit-mask-image: url("/static/icons/stop.svg"); mask-image: url("/static/icons/stop.svg"); }
.icon-pause { -webkit-mask-image: url("/static/icons/pause.svg"); mask-image: url("/static/icons/pause.svg"); }
.icon-send { -webkit-mask-image: url("/static/icons/send.svg"); mask-image: url("/static/icons/send.svg"); }

/* --- shell: fixed sidebar + working area ---------------------------------------------- */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: 100vh;
  /* The sidebar is sticky and one viewport tall; paint its column all the way down so
   * a long page (or a full-page screenshot) never shows grey under it. */
  background: linear-gradient(
    to right,
    var(--color-sidebar) var(--sidebar-width),
    transparent var(--sidebar-width)
  );
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 24px 12px 16px;
  background: var(--color-sidebar);
  color: var(--color-text-inverse);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  margin-bottom: 32px;
}

.brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-eyebrow {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-sidebar-accent);
  margin-bottom: 0.2rem;
}

.brand-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.sidebar-toggle {
  display: none;
}

.sidebar-panel {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav a,
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.75rem;
  border-left: 2px solid transparent;
  border-radius: var(--radius-sm);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.nav a .icon,
.sidebar-link .icon {
  opacity: 0.85;
}

.nav a:hover,
.sidebar-link:hover {
  background: var(--color-sidebar-hover);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.nav a.current,
.sidebar-link.current {
  background: var(--color-sidebar-active);
  border-left-color: var(--color-sidebar-accent);
  color: #fff;
  font-weight: 600;
}

.sidebar :focus-visible {
  outline-color: var(--color-sidebar-accent);
}

.sidebar-foot {
  margin-top: auto;
  padding: 16px 12px 0;
  border-top: 1px solid var(--color-sidebar-rule);
}

.sidebar-foot .sidebar-link {
  margin: 0 -12px 8px;
}

.whoami {
  margin: 0 0 0.5rem;
}

.whoami-label {
  display: block;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.15rem;
}

.whoami-email {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  color: #fff;
  word-break: break-all;
}

.sidebar-foot form {
  margin: 0;
}

button.signout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.65);
  font-size: 0.75rem;
  font-weight: 600;
}

button.signout .icon {
  width: 14px;
  height: 14px;
}

button.signout:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  border-color: transparent;
  color: #fff;
}

.main-col {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

main {
  width: 100%;
  max-width: 1440px;
  padding: 28px var(--page-pad-x) 64px;
}

/* --- the state bar: the one loud thing on the page ------------------------------------ */

.state {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 10px var(--page-pad-x);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: 13px;
}

.state-headline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem 0.3rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  white-space: nowrap;
}

.state-headline .icon {
  width: 15px;
  height: 15px;
}

.state-lead {
  font-weight: 600;
}

.state-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.6rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.06);
  font-size: 0.75rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.chip-bad {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
  font-weight: 700;
}

.chip-warn {
  background: var(--color-warning-light);
  border-color: rgba(184, 110, 11, 0.35);
  color: var(--color-warning);
  font-weight: 600;
}

/* SENDING — outbound is live. */
.state.is-live {
  background: var(--color-success-light);
  border-bottom-color: rgba(13, 150, 104, 0.3);
  color: #065f46;
}

.state.is-live .state-headline {
  background: var(--color-success);
}

/* NOT LIVE — nothing is sent. */
.state.is-dark {
  background: var(--color-warning-light);
  border-bottom-color: rgba(184, 110, 11, 0.35);
  color: #7a4a09;
}

.state.is-dark .state-headline {
  background: var(--color-warning);
}

/* KILL SWITCH ON, or a protective action failed: solid red, white type. */
.state.is-alarm {
  background: var(--color-danger);
  border-bottom-color: #b91c1c;
  color: #fff;
}

.state.is-alarm .state-headline {
  background: #fff;
  color: var(--color-danger);
}

.state.is-alarm .chip {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.28);
  color: #fff;
}

.state.is-alarm .chip-bad {
  background: #fff;
  color: var(--color-danger);
}

.state.is-kill {
  background-image: repeating-linear-gradient(
    -45deg,
    rgba(0, 0, 0, 0.1) 0,
    rgba(0, 0, 0, 0.1) 10px,
    transparent 10px,
    transparent 20px
  );
}

.state.is-alarm a {
  color: #fff;
}

/* --- alerts: toast-style cards under the state bar ------------------------------------ */

.alerts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px var(--page-pad-x) 0;
}

.alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border-light);
  border-left: 4px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.alert-level {
  display: inline-flex;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--color-surface-sunk);
  color: var(--color-text-secondary);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.alert-critical {
  border-left-color: var(--color-danger);
  background: var(--color-danger-light);
}

.alert-critical .alert-level {
  background: var(--color-danger);
  color: #fff;
}

.alert-warning {
  border-left-color: var(--color-warning);
  background: var(--color-warning-light);
}

.alert-warning .alert-level {
  background: var(--color-warning);
  color: #fff;
}

.alert-info {
  border-left-color: var(--color-accent);
}

.alert-info .alert-level {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

.alert-message {
  flex: 1 1 20rem;
  font-weight: 500;
}

.alert-kind {
  color: var(--color-text-secondary);
  font-size: 12.5px;
  font-weight: 400;
}

.alert form {
  margin: 0;
}

.alerts-more {
  margin: 0;
}

/* --- page ------------------------------------------------------------------------------ */

.page-header {
  margin-bottom: 20px;
}

h1 {
  font-size: 1.4rem;
  margin: 0;
}

.page-header .lede {
  margin-top: 0.3rem;
}

h2 {
  font-size: 1rem;
  margin: 0;
}

h2::first-letter {
  text-transform: uppercase;
}

h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  margin: 22px 0 8px;
}

p {
  margin: 0 0 0.75rem;
}

.lede {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  max-width: 76ch;
  margin: 0;
}

.note {
  color: var(--color-text-secondary);
  font-size: 13px;
  max-width: 80ch;
  margin: 6px 0 0;
}

.note.muted {
  color: var(--color-text-muted);
}

.notice,
.error {
  padding: 0.6rem 0.85rem;
  border-left: 4px solid;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  margin: 0 0 16px;
}

.notice {
  background: var(--color-success-light);
  border-left-color: var(--color-success);
  color: #065f46;
}

.error {
  background: var(--color-danger-light);
  border-left-color: var(--color-danger);
  color: #991b1b;
}

td .error,
th .error {
  margin: 6px 0 0;
}

.callout {
  padding: 0.7rem 0.95rem;
  margin: 10px 0 0;
  border-radius: var(--radius-sm);
  background: var(--color-accent-light);
  border-left: 4px solid var(--color-accent);
  max-width: none;
}

.callout .note {
  color: #2a3d78;
  margin: 0;
}

.callout .note + .note {
  margin-top: 4px;
}

.callout-warning {
  background: var(--color-warning-light);
  border-left-color: var(--color-warning);
  color: #7a4a09;
  margin-top: 16px;
}

.empty {
  padding: 2.25rem 1.5rem;
  margin: 0 0 20px;
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-secondary);
  text-align: center;
}

.empty p {
  max-width: 62ch;
  margin: 0 auto 0.5rem;
}

.empty p:last-child {
  margin-bottom: 0;
}

.empty strong {
  color: var(--color-text);
  font-size: 0.95rem;
}

/* A section is a card. */
.section {
  margin-top: 20px;
  padding: 18px 20px 20px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.section.empty {
  box-shadow: none;
  border-style: dashed;
  border-color: var(--color-border-strong);
}

.section-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.count-pill {
  display: inline-flex;
  min-width: 1.6rem;
  justify-content: center;
  padding: 0.05rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
}

.section > .note + form,
.section > .note + .inline-form {
  margin-top: 12px;
}

/* htmx's own indicator rules (it would otherwise inject a <style>, which the CSP
 * blocks; `includeIndicatorStyles` is off in base.html's htmx-config meta). */
.htmx-indicator {
  opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  opacity: 1;
  transition: opacity 200ms ease-in;
}

/* --- stat tiles ---------------------------------------------------------------------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 14px 0 4px;
}

.stat {
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
}

.stat dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
}

.stat dd {
  margin: 0.15rem 0 0;
  font-family: var(--font-mono);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--color-text);
}

.stat-good dd {
  color: var(--color-success);
}

/* --- tables: the DataTable look ------------------------------------------------------- */

.table-scroll {
  max-width: 100%;
  max-height: 72vh;
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

caption {
  caption-side: top;
  text-align: left;
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border-light);
  color: var(--color-text-secondary);
  font-size: 12.5px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0.6rem 0.85rem;
  background: var(--color-surface-sunk);
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody th,
tbody td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--color-border-light);
  text-align: left;
  vertical-align: top;
}

tbody th {
  font-weight: 500;
}

tbody tr {
  transition: background var(--transition-fast);
}

tbody tr:hover {
  background: var(--color-surface-sunk);
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: 0;
}

td.num,
th.num {
  text-align: right;
}

td.num {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  white-space: nowrap;
}

td.num.strong {
  font-weight: 700;
}

tr.is-inactive td,
tr.is-inactive th {
  color: var(--color-text-muted);
}

.row-title {
  font-weight: 600;
  color: var(--color-text);
}

tr.is-inactive .row-title {
  color: var(--color-text-muted);
}

th .muted,
td .muted {
  font-size: 12.5px;
}

.wrapcell {
  min-width: 14ch;
  max-width: 34ch;
}

td.actions {
  min-width: 11rem;
}

td.actions button,
td.actions a {
  margin: 0 4px 4px 0;
}

/* Discovery: a brand row and its expander row read as one unit. */
tr.brand-row th,
tr.brand-row td {
  border-bottom: 0;
}

tr.detail-row td {
  padding-top: 0;
}

tr.detail-row:hover,
tr.brand-row:hover {
  background: transparent;
}

tr.detail-row summary {
  color: var(--color-text-secondary);
  font-size: 12.5px;
  cursor: pointer;
}

tr.detail-row details[open] {
  padding: 10px 12px;
  margin-top: 4px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
  border: 1px solid var(--color-border-light);
}

tr.detail-row dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 6px 16px;
  margin: 10px 0 0;
  font-size: 13px;
}

tr.detail-row dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--color-text-secondary);
  padding-top: 2px;
}

tr.detail-row dd {
  margin: 0;
}

.demand-chip {
  display: inline-block;
  margin-top: 4px;
  padding: 0.1rem 0.5rem;
  border-radius: var(--radius-full);
  background: var(--color-purple-light);
  color: var(--color-purple);
  font-size: 0.72rem;
}

.demand-chip[data-demand="failed"] {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.demand-chip[data-demand="pending"] {
  background: var(--color-surface-sunk);
  color: var(--color-text-secondary);
}

/* --- badges ---------------------------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-neutral,
.badge-status-merged,
.badge-status-suppressed,
.badge-run-limit_reached,
.badge-run-not_configured {
  background: #f0f1f4;
  color: var(--color-text-secondary);
}

.badge-success,
.badge-status-promoted,
.badge-run-completed {
  background: var(--color-success-light);
  color: var(--color-success);
}

.badge-warning,
.badge-status-review,
.badge-run-rate_limited,
.badge-run-quota_exhausted {
  background: var(--color-warning-light);
  color: var(--color-warning);
}

.badge-danger,
.badge-status-disqualified,
.badge-status-rejected,
.badge-run-session_expired,
.badge-run-auth_failed,
.badge-run-blocked,
.badge-run-parse_failed,
.badge-run-error {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge-status-new,
.badge-event {
  background: var(--color-purple-light);
  color: var(--color-purple);
}

.badge-accent,
.badge-status-qualified {
  background: var(--color-accent-light);
  color: var(--color-accent);
}

/* --- the weekly series --------------------------------------------------------------- */

.spark {
  display: block;
}

.spark-line {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.75;
}

.spark-dot {
  fill: var(--color-accent);
}

.spark-axis {
  stroke: var(--color-border-strong);
  stroke-width: 1;
}

.spark-empty {
  fill: var(--color-text-muted);
  font-size: 11px;
  font-family: var(--font-sans);
}

/* --- forms ------------------------------------------------------------------------------ */

label {
  display: block;
  margin-bottom: 0.3rem;
  color: var(--color-text-secondary);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

th label {
  display: inline;
  margin: 0;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: normal;
  text-transform: none;
  color: inherit;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  max-width: 100%;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  font: inherit;
  font-size: 13px;
  line-height: 1.4;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(59, 108, 245, 0.12);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
}

textarea {
  min-height: 62px;
  resize: vertical;
}

input[type="checkbox"] {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--color-accent);
  vertical-align: middle;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 12px;
  margin: 0;
}

.field {
  flex: 0 1 auto;
  min-width: 0;
}

.field-narrow input,
.field-narrow select {
  width: 8.5rem;
}

.field-wide {
  flex: 1 1 16rem;
}

.field-status {
  align-self: center;
  padding-bottom: 2px;
}

.stack-form {
  display: grid;
  gap: 4px;
  min-width: 16rem;
}

.stack-form label {
  margin-top: 4px;
}

.stack-form button {
  justify-self: start;
  margin-top: 6px;
}

.filter-bar {
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.result-count {
  margin-bottom: 0;
}

/* --- buttons: `<button>` is primary; `.secondary`, `.danger`, `.small` ------------------ */

button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

button:hover:not(:disabled) {
  background: var(--color-accent-hover);
  border-color: var(--color-accent-hover);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button.secondary,
.button-link {
  background: var(--color-surface);
  border-color: var(--color-border);
  color: var(--color-text);
}

button.secondary:hover:not(:disabled),
.button-link:hover {
  background: var(--color-bg);
  border-color: var(--color-border-strong);
  color: var(--color-text);
  text-decoration: none;
}

button.danger {
  background: var(--color-danger);
  border-color: var(--color-danger);
  color: #fff;
}

button.danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
  border-color: var(--color-danger-hover);
}

button.small {
  padding: 0.28rem 0.6rem;
  font-size: 12px;
}

/* Per-row decision forms on the Approve and Discovery views. Hidden, but still
 * submittable: a button inside the table reaches them with the HTML `form` attribute. */
.rowforms {
  display: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin: 12px 0;
}

.toolbar form {
  margin: 0;
}

.toolbar-forms {
  gap: 14px 20px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
  border: 1px solid var(--color-border-light);
}

.toolbar-bulk {
  margin-bottom: 0;
}

.toolbar-view {
  margin-top: 0;
}

/* Segmented control: the experiments view switch and the Discovery pager. */
.toggle {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-sm);
  background: #e8eaef;
}

.toggle a {
  padding: 0.3rem 0.85rem;
  border-radius: 4px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.toggle a:hover {
  color: var(--color-text);
  text-decoration: none;
}

.toggle a.current {
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
  color: var(--color-accent);
}

.pager {
  margin-top: 14px;
}

/* --- the brake ------------------------------------------------------------------------ */

.brake {
  padding: 22px 24px;
  margin: 0 0 8px;
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-success);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  box-shadow: var(--shadow-sm);
}

.brake.is-on {
  border-color: rgba(220, 38, 38, 0.35);
  border-left-color: var(--color-danger);
  background: var(--color-danger-light);
}

.brake p {
  max-width: 70ch;
}

.brake-state {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 8px;
  color: var(--color-success);
}

.brake-state .icon {
  width: 22px;
  height: 22px;
}

.brake.is-on .brake-state {
  color: var(--color-danger);
}

.brake form {
  margin-top: 14px;
}

/* --- login ------------------------------------------------------------------------------ */

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2.5rem;
  border: 1px solid var(--color-border-light);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
}

.login-head {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-eyebrow {
  margin: 0 0 0.4rem;
  color: var(--color-accent);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.login h1 {
  font-size: 1.3rem;
}

.login-sub {
  margin: 0.35rem 0 0;
  color: var(--color-text-secondary);
  font-size: 13px;
}

.login-form {
  margin: 0;
}

.login-field {
  margin-bottom: 0.9rem;
}

.login-field input {
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
}

.login-submit {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem;
  font-size: 0.9rem;
}

/* --- narrow screens: the sidebar becomes a top bar with a menu ------------------------ */

@media (max-width: 900px) {
  :root {
    --page-pad-x: 16px;
  }

  .shell {
    display: block;
    background: none;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    max-height: 100vh;
    padding: 10px 16px;
  }

  .sidebar-head {
    padding: 0;
    margin: 0;
  }

  .brand {
    flex-direction: row;
    align-items: baseline;
    gap: 0.5rem;
  }

  .brand-eyebrow {
    margin: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    padding: 0.4rem;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: transparent;
    color: #fff;
  }

  .sidebar-toggle:hover:not(:disabled) {
    background: var(--color-sidebar-hover);
    border-color: rgba(255, 255, 255, 0.3);
  }

  .sidebar-panel {
    padding-top: 12px;
  }

  /* With the script loaded the panel starts closed; without it, it simply shows. */
  .js-nav .sidebar-panel {
    display: none;
  }

  .js-nav .sidebar.is-open .sidebar-panel {
    display: flex;
  }

  .sidebar-foot {
    margin-top: 12px;
  }

  .state {
    position: static;
  }

  .state-facts {
    margin-left: 0;
  }

  main {
    padding-top: 20px;
  }

  .section {
    padding: 14px;
  }

  .table-scroll {
    max-height: none;
  }

  .field-narrow input,
  .field-narrow select {
    width: 7rem;
  }

  .brake {
    padding: 18px;
  }

  .stack-form {
    min-width: 13rem;
  }
}

@media (max-width: 480px) {
  .login-card {
    padding: 1.75rem 1.25rem;
  }

  .inline-form .field-wide {
    flex-basis: 100%;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
