/* EntraAscend OPERATOR CONSOLE — sober, commercial, same visual family as the app,
   marketing site, and admin portal. Primary #512BD4 (violet), Azure accent #0078D4.
   Light + dark.

   ★ OPERATOR SITE build. ★ A dedicated COPY — the admin site has its own
   styles.css. The two sites share NO runtime files (they deploy to different SWAs).

   Chart palette variables (--cat-*, --seq-*, --st-*) are the data-viz method's
   validated slots: categorical hues in CVD-safe fixed order, a single sequential
   blue ramp, and the reserved status palette. Light/dark swap in ONE place here. */

:root {
  /* brand */
  --primary: #512BD4;
  --primary-600: #4322b0;
  --azure: #0078D4;

  /* surfaces / ink */
  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #faf9fe;
  --border: #e6e3f0;
  --text: #1c1a26;
  --text-muted: #5a5670;
  --shadow: 0 1px 2px rgba(20, 16, 40, .06), 0 8px 24px rgba(20, 16, 40, .06);
  --radius: 14px;
  --maxw: 1160px;

  /* chart surface (for chrome coherence) */
  --chart-surface: #ffffff;

  /* categorical (fixed CVD-safe order — used for PIM phases) */
  --cat-1: #2a78d6; /* blue   — activate   */
  --cat-2: #1baf7a; /* aqua   — deactivate */
  --cat-3: #eda100; /* yellow */
  --cat-4: #008300; /* green  */
  --cat-5: #4a3aa7; /* violet — reactivate */
  --cat-6: #e34948; /* red    */

  /* sequential blue ramp (magnitude — latency, volume) */
  --seq-100: #cde2fb;
  --seq-300: #6da7ec;
  --seq-450: #2a78d6;
  --seq-500: #256abf;
  --seq-600: #184f95;

  /* status (reserved — always paired with icon+label) */
  --st-good: #0ca30c;
  --st-warning: #fab219;
  --st-serious: #ec835a;
  --st-critical: #d03b3b;

  /* chart chrome */
  --c-grid: #e1e0d9;
  --c-baseline: #c3c2b7;
  --c-track: #eceaf5;
  --c-tick: #898781;
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary: #ac99ea;
    --primary-600: #c3b4f1;
    --azure: #4aa3e8;
    --bg: #100e18;
    --surface: #1b1826;
    --surface-2: #201d2c;
    --border: #322d45;
    --text: #ece9f6;
    --text-muted: #a7a1bf;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .35);
    --chart-surface: #1b1826;

    /* categorical stepped for dark surface */
    --cat-1: #3987e5;
    --cat-2: #199e70;
    --cat-3: #c98500;
    --cat-4: #008300;
    --cat-5: #9085e9;
    --cat-6: #e66767;

    --seq-100: #184f95;
    --seq-300: #2a78d6;
    --seq-450: #3987e5;
    --seq-500: #5598e7;
    --seq-600: #86b6ef;

    --st-good: #0ca30c;
    --st-warning: #fab219;
    --st-serious: #ec835a;
    --st-critical: #e05a5a;

    --c-grid: #2c2c2a;
    --c-baseline: #383835;
    --c-track: #2a2637;
    --c-tick: #898781;
  }
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 0 0 8px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .88em;
  background: color-mix(in srgb, var(--primary) 10%, transparent); padding: 1px 5px; border-radius: 5px; }
.muted { color: var(--text-muted); }
.small { font-size: .84rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .84rem; }
.num, .c-val, .c-tick { font-variant-numeric: tabular-nums; }

/* ── Mock banner ──────────────────────────────────────────────────────────── */
.mock-banner {
  background: color-mix(in srgb, var(--azure) 14%, transparent);
  color: var(--text); border-bottom: 1px solid var(--border);
  padding: 8px 24px; font-size: .86rem; text-align: center;
}
.mock-banner .mock-flip { color: var(--text-muted); margin-left: 6px; }

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 1.02rem; letter-spacing: -0.01em; }
.brand-sub { color: var(--text-muted); font-weight: 600; }
.app-nav { display: flex; align-items: center; gap: 4px; margin-right: auto; margin-left: 8px; }
.app-nav a { font-size: .88rem; font-weight: 600; color: var(--text-muted); padding: 6px 12px; border-radius: 8px; }
.app-nav a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.app-nav a.is-active { color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, transparent); }
.header-right { display: flex; align-items: center; gap: 16px; }
.user-chip { display: inline-flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface-2); }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; flex: none; display: inline-flex;
  align-items: center; justify-content: center; font-size: .74rem; font-weight: 700; color: #fff;
  background: linear-gradient(140deg, var(--primary), var(--azure)); }
.account { display: flex; flex-direction: column; line-height: 1.2; }
.acct-name { font-weight: 600; font-size: .9rem; }
.acct-sub { font-size: .76rem; }
@media (max-width: 680px) {
  .account { display: none; }
  .user-chip { padding: 4px; border: 0; background: none; }
  .app-nav { margin-left: 0; }
  .app-nav a { padding: 6px 8px; }
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px;
  font-weight: 600; font-size: .92rem; cursor: pointer; border: 1px solid transparent;
  transition: background .15s ease, transform .05s ease, border-color .15s ease; font-family: inherit; }
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: .84rem; border-radius: 8px; }
.btn-lg { padding: 13px 26px; font-size: 1.02rem; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
main.wrap { padding-top: 24px; padding-bottom: 40px; }
.surface-head { margin: 6px 0 20px; }
.surface-head .sub { color: var(--text-muted); margin: 4px 0 0; }
.op-badge { font-size: .62em; vertical-align: middle; background: color-mix(in srgb, var(--primary) 18%, transparent);
  color: var(--primary); padding: 3px 8px; border-radius: 999px; font-weight: 700; margin-left: 8px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-loading { color: var(--text-muted); padding: 20px 0; }
.card-actions { display: flex; align-items: center; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.mini-h { margin: 20px 0 10px; font-size: .82rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }

/* ── Pills / tags ─────────────────────────────────────────────────────────── */
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: .78rem; font-weight: 600;
  padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--text-muted); }
.pill.small { font-size: .72rem; padding: 1px 8px; }
.pill-ok { color: var(--st-good); border-color: color-mix(in srgb, var(--st-good) 40%, var(--border)); background: color-mix(in srgb, var(--st-good) 8%, transparent); }
.pill-warn { color: var(--st-serious); border-color: color-mix(in srgb, var(--st-serious) 40%, var(--border)); background: color-mix(in srgb, var(--st-serious) 8%, transparent); }
.pill-crit { color: var(--st-critical); border-color: color-mix(in srgb, var(--st-critical) 40%, var(--border)); background: color-mix(in srgb, var(--st-critical) 8%, transparent); }
.pill-muted { color: var(--text-muted); }

/* ── Callouts ─────────────────────────────────────────────────────────────── */
.callout { border-radius: 10px; padding: 12px 14px; font-size: .9rem; margin-top: 14px; border: 1px solid var(--border); }
.callout-crit { background: color-mix(in srgb, var(--st-critical) 8%, transparent); border-color: color-mix(in srgb, var(--st-critical) 35%, var(--border)); }
.callout-info { background: color-mix(in srgb, var(--azure) 8%, transparent); border-color: color-mix(in srgb, var(--azure) 30%, var(--border)); }

/* ── Tables ───────────────────────────────────────────────────────────────── */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
thead th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
tbody td { padding: 9px 12px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mini-table td { white-space: nowrap; }

/* ── Selects / filters / inputs ───────────────────────────────────────────── */
.select { font: inherit; font-size: .88rem; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); }
.filter-row { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.filter-row label { font-size: .8rem; color: var(--text-muted); font-weight: 600; display: flex; flex-direction: column; gap: 4px; }
.search-input { width: 100%; padding: 11px 14px; font-size: .95rem; font-family: inherit;
  border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); color: var(--text); }
.search-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent); }
/* the operator-fallback add-admin row: wider fields, aligned baseline */
.fallback-row { align-items: flex-end; }
.fallback-row label { min-width: 220px; }
.fb-oid { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* ── Stat tiles (operator) ────────────────────────────────────────────────── */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
@media (max-width: 900px) { .stat-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 460px) { .stat-row { grid-template-columns: 1fr; } }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); font-weight: 700; }
.stat-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; margin: 4px 0 2px; letter-spacing: -0.02em; }
.stat-sub { font-size: .8rem; }
.stat-good .stat-value { color: var(--st-good); }
.stat-warning .stat-value { color: var(--st-serious); }
.stat-critical .stat-value { color: var(--st-critical); }

/* per-phase strip */
.phase-strip { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 760px) { .phase-strip { grid-template-columns: 1fr; } }
.phase-item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.phase-name { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .92rem; }
.phase-num { font-size: 1.5rem; font-weight: 700; margin: 4px 0; letter-spacing: -0.01em; }
.phase-num .unit { font-size: .8rem; color: var(--text-muted); font-weight: 500; }
.phase-rates { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }

/* ── Charts (SVG) ─────────────────────────────────────────────────────────── */
.chart { display: block; overflow: visible; }
.chart .c-track { fill: var(--c-track); }
.chart .c-grid { stroke: var(--c-grid); stroke-width: 1; }
.chart .c-tick { fill: var(--c-tick); font-size: 11px; }
.chart .c-lbl { fill: var(--text); font-size: 12px; }
.chart .c-val { fill: var(--text-muted); font-size: 12px; }
.chart .c-line { stroke: var(--seq-450); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .c-area { fill: color-mix(in srgb, var(--seq-450) 14%, transparent); stroke: none; }
.chart .c-dot { fill: var(--seq-450); stroke: var(--chart-surface); stroke-width: 2; }
.c-legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.c-legend-item, .phase-name .c-swatch { font-size: .82rem; color: var(--text-muted); display: inline-flex; align-items: center; gap: 6px; }
.c-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
/* explicit colour→percentile legend (unambiguous mapping) */
.c-legend-perc { gap: 10px; }
.c-legend-perc .c-legend-item { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 8px; background: var(--surface-2); }
.c-legend-name { font-weight: 600; color: var(--text); }
.c-legend-val { font-variant-numeric: tabular-nums; color: var(--text-muted); }
.chart .c-barval { fill: var(--text-muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.lat-note { margin: 12px 0 0; }

/* ── Sign-in / footer ─────────────────────────────────────────────────────── */
.signin-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(900px 500px at 20% -10%, color-mix(in srgb, var(--primary) 14%, transparent), transparent 60%), var(--bg); }
.signin-card { max-width: 420px; text-align: center; }
.signin-card .brand-mark.big { margin-bottom: 12px; display: inline-flex; }
.app-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding-top: 20px; padding-bottom: 28px; border-top: 1px solid var(--border); margin-top: 20px;
  font-size: .82rem; color: var(--text-muted); flex-wrap: wrap; }

/* ── API reference page (auth-gated, self-contained OpenAPI renderer) ───────── */
.api-section-head { margin-top: 28px; }
.api-list { margin: 8px 0 4px; padding-left: 18px; line-height: 1.7; }
.api-list li { margin-bottom: 4px; }
.api-sub { margin: 16px 0 6px; font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.api-op { margin-bottom: 16px; }
.api-op-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.api-op-line { display: inline-flex; align-items: center; gap: 10px; min-width: 0; }
.api-op-meta { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.api-path { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; word-break: break-all; }
.api-op-summary { margin: 10px 0 2px; font-weight: 600; }
.api-op-desc { white-space: pre-wrap; }
.api-method { font-size: .72rem; font-weight: 800; letter-spacing: .04em; color: #fff; padding: 3px 8px; border-radius: 6px; flex: none; }
.api-get { background: var(--azure); }
.api-post { background: var(--st-good); }
.api-put, .api-patch { background: var(--st-warning); color: #201a06; }
.api-delete { background: var(--st-critical); }
.api-options, .api-head { background: var(--text-muted); }
.api-tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); background: var(--surface-2); border: 1px solid var(--border); padding: 2px 7px; border-radius: 6px; }
.api-auth { font-size: .68rem; font-weight: 700; color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, transparent); padding: 2px 7px; border-radius: 6px; }
.api-auth-none { color: var(--text-muted); background: var(--surface-2); }
.api-req { font-size: .64rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--st-critical); margin-left: 4px; }
.api-table-wrap { overflow-x: auto; margin: 6px 0 4px; }
.api-table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.api-table th { text-align: left; font-weight: 600; color: var(--text-muted); padding: 6px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.api-table td { padding: 7px 10px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); vertical-align: top; }
.api-table tr:last-child td { border-bottom: 0; }
.api-pname code, .api-ptype code { white-space: nowrap; }
.api-pdesc { color: var(--text-muted); }
.api-status { display: inline-block; font-weight: 700; font-size: .8rem; padding: 1px 8px; border-radius: 6px; }
.api-ok { color: var(--st-good); background: color-mix(in srgb, var(--st-good) 10%, transparent); }
.api-err { color: var(--st-critical); background: color-mix(in srgb, var(--st-critical) 10%, transparent); }
.api-neutral { color: var(--text-muted); background: var(--surface-2); }
.api-schemas { display: flex; flex-direction: column; gap: 4px; }
.api-schema { padding: 12px 0; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.api-schema:last-child { border-bottom: 0; }
.api-schema-name { margin: 0 0 6px; font-size: 1rem; }

/* prefers-reduced-motion */
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } html { scroll-behavior: auto; } }
