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

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

/* ── 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; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-bottom: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

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

/* ── Usage headline ───────────────────────────────────────────────────────── */
.usage-headline { display: flex; align-items: baseline; gap: 20px; margin: 6px 0 14px; flex-wrap: wrap; }
.big-num { font-size: 2.6rem; font-weight: 700; line-height: 1; letter-spacing: -0.02em; }
.big-num .of { font-size: 1.1rem; color: var(--text-muted); font-weight: 600; margin-left: 6px; }
.usage-meta { font-size: .9rem; }

/* ── Key-value list ───────────────────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 0; }
.kv dt { color: var(--text-muted); font-size: .88rem; }
.kv dd { margin: 0; font-weight: 500; }

/* ── 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; }
.activity-table td, .mini-table td { white-space: nowrap; }

/* ── Search-by-name (RBAC) ────────────────────────────────────────────────── */
.search-wrap { position: relative; margin: 8px 0 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); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 15;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.search-empty { padding: 14px; color: var(--text-muted); font-size: .9rem; }
.person-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent); }
.person-row:last-child { border-bottom: 0; }
.admin-list .person-row { border: 1px solid var(--border); border-radius: 11px; margin-bottom: 8px; background: var(--surface-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  font-size: .78rem; font-weight: 700; color: #fff; background: linear-gradient(140deg, var(--primary), var(--azure)); }
.person-meta { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.person-name { font-weight: 600; }
.person-sub { font-size: .8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── 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; }
.c-legend { display: flex; gap: 16px; margin-top: 10px; flex-wrap: wrap; }
.c-legend-item { 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; }

/* stacked-results chart columns (clickable → requestId drill) */
.chart-stack .c-col { cursor: pointer; }
.chart-stack .c-col:focus { outline: none; }
.chart-stack .c-col:focus .c-col-hit,
.chart-stack .c-col.is-selected .c-col-hit { fill: color-mix(in srgb, var(--primary) 10%, transparent); }
.chart-stack .c-col.is-selected .c-stack-seg { stroke: var(--text); stroke-width: 1; }
.chart-stack .c-col:hover .c-col-hit { fill: color-mix(in srgb, var(--primary) 6%, transparent); }

/* activity aggregate (tenant surface) */
.activity-intro { margin: 0 0 10px; }
.activity-totals { display: flex; gap: 18px; flex-wrap: wrap; margin: 6px 0 10px; }
.act-total { display: inline-flex; align-items: center; gap: 7px; font-size: .88rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.act-chart { margin-top: 4px; }
.act-drill { margin-top: 16px; border-top: 1px solid var(--border); padding-top: 14px; }
.drill-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.drill-counts { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.reqid-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.reqid-row { display: flex; align-items: center; gap: 10px; }
.reqid { flex: 1; min-width: 0; overflow-x: auto; white-space: nowrap; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 10px; }
.reqid-copy { flex: none; }
.lat-note { margin: 12px 0 0; }

/* ── Sign-in / denied / 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; }
.denied { max-width: 560px; margin: 40px auto; }
.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; }

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