/* MeuPosOp — Premium Dark Clinical UI
   Aesthetic: deep emerald + emerald glow, editorial confidence
   Type: Manrope (display) + JetBrains Mono (data) */

:root {
  /* Surfaces — deep emerald */
  --bg-0: oklch(14% 0.018 165);
  --bg-1: oklch(17% 0.022 165);
  --bg-2: oklch(20% 0.028 165);
  --bg-3: oklch(24% 0.032 165);
  --line: oklch(28% 0.028 165);
  --line-soft: oklch(24% 0.020 165);

  /* Brand — emerald with glow */
  --emerald: oklch(72% 0.16 162);
  --emerald-bright: oklch(82% 0.18 160);
  --emerald-deep: oklch(45% 0.12 162);
  --emerald-glow: oklch(75% 0.18 162 / 0.35);

  /* Text */
  --ink: oklch(96% 0.01 160);
  --ink-2: oklch(82% 0.012 160);
  --ink-3: oklch(64% 0.015 160);
  --ink-4: oklch(48% 0.018 160);

  /* Status */
  --crit: oklch(68% 0.21 25);
  --crit-soft: oklch(28% 0.10 25);
  --warn: oklch(78% 0.16 75);
  --warn-soft: oklch(30% 0.09 75);
  --ok: oklch(72% 0.16 162);
  --ok-soft: oklch(28% 0.08 162);
  --info: oklch(74% 0.13 220);
  --info-soft: oklch(30% 0.08 220);

  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-xl: 22px;

  --pad: clamp(20px, 2vw, 32px);

  --display: "Manrope", -apple-system, "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--bg-0);
  color: var(--ink);
  font-family: var(--display);
  font-feature-settings: "ss01", "ss02", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 700px at 12% -10%, oklch(40% 0.10 162 / 0.20), transparent 60%),
    radial-gradient(900px 600px at 100% 110%, oklch(38% 0.10 162 / 0.16), transparent 55%),
    var(--bg-0);
  overflow-x: hidden;
}

::selection { background: var(--emerald-glow); color: var(--ink); }

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; background: none; border: 0; outline: 0; }
a { color: inherit; text-decoration: none; }
svg { display: block; }

/* Scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: oklch(30% 0.02 165 / 0.6);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background: oklch(40% 0.04 165 / 0.7); background-clip: padding-box; border: 2px solid transparent; }

/* === Glass card === */
.glass {
  background: linear-gradient(180deg, oklch(22% 0.025 165 / 0.65), oklch(18% 0.020 165 / 0.55));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  backdrop-filter: blur(14px) saturate(110%);
  -webkit-backdrop-filter: blur(14px) saturate(110%);
}

.glass-strong {
  background: linear-gradient(180deg, oklch(24% 0.028 165 / 0.85), oklch(19% 0.022 165 / 0.85));
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}

/* === Mono numerals === */
.mono { font-family: var(--mono); font-feature-settings: "tnum", "ss01"; letter-spacing: -0.02em; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.005em;
  transition: transform 120ms ease, background 200ms ease, box-shadow 200ms ease, border-color 200ms ease;
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }

.btn-primary {
  background: linear-gradient(180deg, oklch(60% 0.16 162), oklch(48% 0.14 162));
  color: oklch(12% 0.02 165);
  box-shadow: 0 0 0 1px oklch(70% 0.16 162 / 0.4) inset, 0 8px 28px -8px var(--emerald-glow);
}
.btn-primary:hover {
  background: linear-gradient(180deg, oklch(64% 0.17 162), oklch(52% 0.15 162));
  box-shadow: 0 0 0 1px oklch(78% 0.18 162 / 0.5) inset, 0 12px 36px -8px var(--emerald-glow);
}

.btn-ghost {
  background: oklch(22% 0.020 165 / 0.5);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-ghost:hover { background: oklch(26% 0.025 165 / 0.7); color: var(--ink); border-color: var(--line); }

.btn-danger {
  background: linear-gradient(180deg, oklch(58% 0.20 25), oklch(46% 0.18 25));
  color: oklch(98% 0.01 0);
  box-shadow: 0 0 0 1px oklch(68% 0.21 25 / 0.45) inset;
}

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: oklch(22% 0.020 165 / 0.5);
  border: 1px solid var(--line);
  color: var(--ink-2);
}
.btn-icon { transition: background 160ms, color 160ms, border-color 160ms; }
.btn-icon:hover { color: var(--ink); background: oklch(26% 0.025 165 / 0.7); }

.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { padding: 4px 9px; font-size: 11.5px; border-radius: 7px; gap: 5px; }

.btn-secondary {
  background: oklch(22% 0.020 165 / 0.5);
  border-color: var(--line);
  color: var(--ink-3);
}
.btn-secondary:hover { background: oklch(26% 0.025 165 / 0.7); color: var(--ink); border-color: var(--line); }

.btn-danger:hover {
  background: linear-gradient(180deg, oklch(64% 0.21 25), oklch(52% 0.19 25));
  box-shadow: 0 0 0 1px oklch(74% 0.22 25 / 0.5) inset, 0 8px 24px -8px oklch(60% 0.20 25 / 0.4);
}

.btn-block { width: 100%; justify-content: center; }

/* === Badges === */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border: 1px solid;
}
.badge-crit { background: oklch(28% 0.10 25 / 0.5); color: oklch(85% 0.10 25); border-color: oklch(50% 0.18 25 / 0.5); }
.badge-warn { background: oklch(30% 0.09 75 / 0.5); color: oklch(85% 0.10 75); border-color: oklch(55% 0.16 75 / 0.5); }
.badge-ok   { background: oklch(28% 0.08 162 / 0.5); color: oklch(86% 0.10 162); border-color: oklch(55% 0.14 162 / 0.5); }
.badge-info { background: oklch(28% 0.08 220 / 0.5); color: oklch(86% 0.09 220); border-color: oklch(55% 0.13 220 / 0.5); }
.badge-neutral { background: oklch(24% 0.018 165 / 0.6); color: var(--ink-2); border-color: var(--line); }
.badge-danger  { background: oklch(28% 0.10 25 / 0.5); color: oklch(85% 0.10 25); border-color: oklch(50% 0.18 25 / 0.5); }
.badge-success { background: oklch(28% 0.08 162 / 0.5); color: oklch(86% 0.10 162); border-color: oklch(55% 0.14 162 / 0.5); }
.badge-muted   { background: oklch(22% 0.015 165 / 0.5); color: var(--ink-4); border-color: var(--line-soft); }

.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.dot-crit { background: var(--crit); box-shadow: 0 0 0 3px oklch(60% 0.20 25 / 0.18); }
.dot-warn { background: var(--warn); box-shadow: 0 0 0 3px oklch(75% 0.15 75 / 0.18); }
.dot-ok   { background: var(--emerald-bright); box-shadow: 0 0 0 3px var(--emerald-glow); }

/* Pulsing dot for live data */
.dot-live { position: relative; }
.dot-live::after {
  content: "";
  position: absolute; inset: -4px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  opacity: 0.5;
  animation: ping 1.6s cubic-bezier(0,0,0.2,1) infinite;
}
@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.7; }
  80%, 100% { transform: scale(1.6); opacity: 0; }
}

/* === Input === */
.input, .form-control, .form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 12px 14px;
  background: oklch(15% 0.018 165 / 0.7);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px;
  transition: border-color 160ms, box-shadow 160ms;
  outline: 0;
}
.input::placeholder, .form-group input::placeholder, .form-group textarea::placeholder { color: var(--ink-4); }
.input:focus, .form-control:focus, .form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  border-color: oklch(50% 0.14 162 / 0.7);
  box-shadow: 0 0 0 4px oklch(60% 0.16 162 / 0.12);
}

.form-group { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-group label, .field-label {
    font-size: 11.5px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    font-weight: 600;
}

.auth-error {
    background: oklch(28% 0.10 25 / 0.4);
    border: 1px solid oklch(50% 0.18 25 / 0.5);
    color: oklch(85% 0.10 25);
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 12.5px;
    margin-bottom: 12px;
}

/* === Layout: app shell === */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}
.shell--collapsed { grid-template-columns: 76px 1fr; }

/* === Sidebar === */
.side {
  position: sticky; top: 0;
  height: 100vh;
  padding: 22px 16px;
  display: flex; flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line-soft);
  background: linear-gradient(180deg, oklch(15% 0.018 165 / 0.7), oklch(13% 0.014 165 / 0.95));
  backdrop-filter: blur(18px);
}

.brand {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px 16px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 11px;
  background:
    radial-gradient(circle at 30% 30%, oklch(82% 0.18 162) 0%, transparent 55%),
    linear-gradient(135deg, oklch(50% 0.14 162), oklch(28% 0.06 162));
  display: grid; place-items: center;
  box-shadow: 0 0 0 1px oklch(60% 0.16 162 / 0.4) inset, 0 8px 22px -6px var(--emerald-glow);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.brand-mark::after {
  content: "";
  position: absolute; inset: 1px;
  border-radius: 10px;
  background: radial-gradient(circle at 70% 80%, oklch(20% 0.04 162 / 0.7), transparent 50%);
}
.brand-mark svg { position: relative; z-index: 1; }
.brand-name { font-weight: 800; font-size: 16px; letter-spacing: -0.02em; line-height: 1; }
.brand-sub { color: var(--ink-3); font-size: 11.5px; margin-top: 4px; letter-spacing: 0.02em; }

.nav {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 8px;
}
.nav-label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  padding: 14px 10px 6px;
  font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-3);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 160ms, color 160ms;
  position: relative;
}
.nav-item:hover { background: oklch(22% 0.022 165 / 0.6); color: var(--ink); }
.nav-item.active {
  color: var(--ink);
  background: linear-gradient(90deg, oklch(35% 0.10 162 / 0.5), oklch(25% 0.05 162 / 0.2));
  box-shadow: inset 2px 0 0 var(--emerald-bright);
}
.nav-item .nav-count {
  margin-left: auto;
  font-size: 11px;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 6px;
  background: oklch(28% 0.05 165 / 0.5);
  color: var(--ink-2);
}
.nav-item.active .nav-count { background: oklch(40% 0.10 162 / 0.5); color: var(--ink); }
.nav-item.crit .nav-count { background: oklch(40% 0.16 25 / 0.4); color: oklch(86% 0.12 25); }

.side-foot {
  margin-top: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: oklch(20% 0.022 165 / 0.5);
  border: 1px solid var(--line-soft);
}
.avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(60% 0.14 162), oklch(35% 0.08 162));
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 12.5px;
  color: oklch(15% 0.02 165);
  flex-shrink: 0;
}
.side-foot-name { font-size: 13px; font-weight: 600; line-height: 1.2; }
.side-foot-role { font-size: 11px; color: var(--ink-4); }

/* === Main === */
.main {
  display: flex; flex-direction: column;
  min-width: 0;
}

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 18px var(--pad);
  border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 30;
  background: oklch(14% 0.016 165 / 0.85);
  backdrop-filter: blur(20px);
}
.topbar-search {
  flex: 1; max-width: 480px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: oklch(18% 0.018 165 / 0.6);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  font-size: 13.5px;
  color: var(--ink);
}
.topbar-search input::placeholder { color: var(--ink-4); }
.topbar-search input:focus { border-color: oklch(50% 0.14 162 / 0.6); box-shadow: 0 0 0 4px oklch(60% 0.16 162 / 0.1); }
.topbar-search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ink-4); }
.topbar-search kbd {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font-family: var(--mono); font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 5px;
  background: oklch(22% 0.018 165 / 0.7);
  color: var(--ink-3);
  border: 1px solid var(--line-soft);
}
.topbar-spacer { flex: 1; }
.topbar-clock {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--line-soft);
  background: oklch(18% 0.018 165 / 0.5);
}
.topbar-clock b { color: var(--emerald-bright); font-weight: 600; }

/* Page wrapper */
.page {
  padding: var(--pad);
  display: flex; flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.page-head {
  display: flex; align-items: end; justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-4);
  font-weight: 600;
  margin-bottom: 8px;
}
.page-title {
  font-size: clamp(28px, 3vw, 40px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.page-sub { color: var(--ink-3); margin-top: 8px; font-size: 14.5px; max-width: 60ch; }

/* === KPI — large hero stat === */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}
@media (max-width: 1100px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  padding: 20px 22px;
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, oklch(22% 0.025 165 / 0.7), oklch(17% 0.018 165 / 0.7));
  position: relative;
  overflow: hidden;
}
.kpi-glow::before {
  content: "";
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--emerald-glow), transparent 65%);
  pointer-events: none;
}
.kpi-glow.crit::before { background: radial-gradient(circle, oklch(60% 0.20 25 / 0.35), transparent 65%); }
.kpi-glow.warn::before { background: radial-gradient(circle, oklch(75% 0.15 75 / 0.30), transparent 65%); }
.kpi-glow.info::before { background: radial-gradient(circle, oklch(72% 0.13 220 / 0.30), transparent 65%); }

.kpi-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.kpi-value {
  font-family: var(--mono);
  font-size: clamp(32px, 4vw, 44px);
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 14px;
  display: flex; align-items: baseline; gap: 8px;
}
.kpi-unit { font-size: 14px; color: var(--ink-3); font-weight: 500; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 4px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--ink-3);
}
.kpi-delta b { font-weight: 600; font-family: var(--mono); }
.kpi-delta.up b { color: var(--crit); }
.kpi-delta.down b { color: var(--emerald-bright); }
.kpi { transition: transform 200ms ease, box-shadow 200ms ease, border-color 200ms ease; cursor: default; }
.kpi:hover { transform: translateY(-2px); border-color: oklch(38% 0.04 165); box-shadow: 0 10px 32px -8px oklch(4% 0.01 165 / 0.5); }

/* Sparkline */
.spark {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 40px;
  opacity: 0.7;
}

/* === Section heading === */
.section-h {
  display: flex; align-items: end; justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-h h3 {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.015em;
}
.section-h .meta {
  font-size: 12px;
  color: var(--ink-4);
  display: flex; align-items: center; gap: 10px;
}

/* === Patient row card === */
.p-list {
  display: flex; flex-direction: column;
  gap: 8px;
}
.p-row {
  display: grid;
  grid-template-columns: 44px 1.6fr 1fr 1fr 1fr 90px;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-soft);
  background: oklch(20% 0.020 165 / 0.45);
  transition: background 160ms, border-color 160ms, transform 160ms;
  cursor: pointer;
}
.p-row:hover { background: oklch(24% 0.025 165 / 0.6); border-color: var(--line); }
.p-row.crit { border-left: 3px solid var(--crit); }
.p-row.warn { border-left: 3px solid var(--warn); }
.p-row.ok { border-left: 3px solid var(--emerald-bright); }

.p-avatar {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, oklch(36% 0.06 162), oklch(22% 0.04 162));
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px;
  color: var(--ink);
  border: 1px solid var(--line);
}
.p-name { font-weight: 600; font-size: 14.5px; line-height: 1.2; }
.p-meta { font-size: 12px; color: var(--ink-4); margin-top: 4px; font-family: var(--mono); }

.p-cell-label { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 4px; font-weight: 600; }
.p-cell-val { font-family: var(--mono); font-size: 16px; font-weight: 500; color: var(--ink); letter-spacing: -0.02em; }
.p-cell-val .u { font-size: 11px; color: var(--ink-4); margin-left: 2px; font-weight: 400; }

/* === Score gauge === */
.gauge {
  position: relative;
  width: 100%;
  display: grid;
  place-items: center;
}
.gauge-ring { transform: rotate(-90deg); }
.gauge-num {
  position: absolute;
  text-align: center;
}
.gauge-num .v { font-family: var(--mono); font-size: 38px; font-weight: 600; letter-spacing: -0.04em; }
.gauge-num .l { font-size: 10.5px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.12em; margin-top: 2px; }

/* === Chart === */
.chart-card { padding: 20px; }
.chart-area { height: 220px; position: relative; }

/* === Vital tiles === */
.vitals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.vital {
  padding: 16px 18px;
  border-radius: 14px;
  background: oklch(21% 0.018 220 / 0.6);
  border: 1.5px solid oklch(40% 0.05 220 / 0.4);
  position: relative;
  overflow: hidden;
  transition: all 200ms ease;
}
.vital::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, oklch(60% 0.08 220), oklch(55% 0.07 220));
  border-radius: 14px 14px 0 0;
}
.vital-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-4);
  font-weight: 600;
}
.vital-val {
  font-family: var(--mono);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.03em;
  margin-top: 10px;
  display: flex; align-items: baseline; gap: 4px;
  color: oklch(60% 0.08 220);
}
.vital-val .u { font-size: 11px; color: var(--ink-4); font-weight: 500; margin-left: 2px; }
.vital.crit .vital-val { color: oklch(65% 0.16 25); }
.vital.warn .vital-val { color: oklch(70% 0.15 70); }
.vital-bar {
  margin-top: 12px;
  height: 6px;
  border-radius: 3px;
  background: oklch(26% 0.02 220);
  overflow: hidden;
  position: relative;
}
.vital-bar i {
  position: absolute; left: 0; top: 0; bottom: 0;
  background: linear-gradient(90deg, oklch(60% 0.08 220), oklch(55% 0.07 220));
  border-radius: 3px;
  transition: width 500ms ease;
}
.vital.crit .vital-bar i { background: linear-gradient(90deg, oklch(60% 0.16 25), oklch(65% 0.15 25)); }
.vital.warn .vital-bar i { background: linear-gradient(90deg, oklch(65% 0.15 70), oklch(70% 0.14 70)); }
.vital.crit { background: oklch(22% 0.025 25 / 0.4); border-color: oklch(50% 0.10 25 / 0.5); }
.vital.crit::before { background: linear-gradient(90deg, oklch(60% 0.16 25), oklch(65% 0.15 25)); }
.vital.warn { background: oklch(23% 0.022 70 / 0.4); border-color: oklch(55% 0.09 70 / 0.5); }
.vital.warn::before { background: linear-gradient(90deg, oklch(65% 0.15 70), oklch(70% 0.14 70)); }

/* === Modal === */
.modal-overlay {
  position: fixed; inset: 0;
  background: oklch(8% 0.01 165 / 0.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  animation: fadeIn 200ms ease;
}
.modal {
  width: min(560px, 92vw);
  max-height: 88vh;
  overflow: auto;
  border-radius: 18px;
  background: linear-gradient(180deg, oklch(22% 0.025 165 / 0.95), oklch(16% 0.018 165 / 0.98));
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -20px oklch(5% 0.01 165 / 0.7), 0 0 0 1px var(--line);
  animation: rise 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px;
  border-bottom: 1px solid var(--line-soft);
}
.modal-head h2, .modal-head .modal-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.modal-body { padding: 22px; }

/* Template picker cards */
.template-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin-top: 8px; }
.template-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 16px;
  background: oklch(18% 0.018 165 / 0.6);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  cursor: pointer;
  transition: background 160ms, border-color 160ms, transform 160ms;
}
.template-card:hover { background: oklch(24% 0.025 165 / 0.7); border-color: oklch(42% 0.10 162 / 0.5); transform: translateY(-1px); }
.template-card strong { font-size: 13.5px; font-weight: 700; color: var(--ink); }
.template-card span { font-size: 12px; color: var(--ink-3); line-height: 1.4; }
.template-card small { font-size: 11px; color: var(--ink-4); font-family: var(--mono); margin-top: 4px; }

/* Attach-question picker list */
.attach-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.attach-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: oklch(16% 0.016 165 / 0.5);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: background 160ms, border-color 160ms;
  font-size: 13px;
}
.attach-item:hover { background: oklch(24% 0.025 165 / 0.7); border-color: oklch(42% 0.10 162 / 0.5); color: var(--ink); }
.modal-foot {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 22px;
  border-top: 1px solid var(--line-soft);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { transform: translateY(10px) scale(0.98); opacity: 0; } to { transform: none; opacity: 1; } }

/* === Toast === */
.toast-host {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 300;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, oklch(24% 0.025 165 / 0.95), oklch(18% 0.020 165 / 0.95));
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px -8px oklch(5% 0.01 165 / 0.6);
  font-size: 13px;
  min-width: 240px;
  animation: rise 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.toast.ok i { background: var(--emerald-bright); }
.toast.crit i { background: var(--crit); }
.toast i { width: 6px; height: 24px; border-radius: 3px; }

/* === Login (variation) === */
.login-stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  position: relative;
  overflow: hidden;
}
.login-stage::before, .login-stage::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.5;
  pointer-events: none;
}
.login-stage::before {
  width: 600px; height: 600px;
  top: -200px; left: -200px;
  background: oklch(50% 0.18 162);
}
.login-stage::after {
  width: 500px; height: 500px;
  bottom: -150px; right: -150px;
  background: oklch(40% 0.14 162);
}
.login-card {
  width: 100%;
  max-width: 1000px;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, oklch(22% 0.025 165 / 0.7), oklch(16% 0.018 165 / 0.85));
  backdrop-filter: blur(28px);
  box-shadow: 0 30px 80px -20px oklch(4% 0.01 165 / 0.7), 0 0 0 1px var(--line);
  position: relative;
  z-index: 1;
}
@media (max-width: 880px) { .login-card { grid-template-columns: 1fr; } .login-side { display: none; } }

.login-side {
  padding: 48px;
  display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid var(--line-soft);
  background:
    radial-gradient(circle at 15% 0%, oklch(38% 0.10 162 / 0.4), transparent 50%),
    radial-gradient(circle at 100% 100%, oklch(30% 0.08 162 / 0.4), transparent 50%);
  position: relative;
}
.login-form { padding: 48px; }

.login-eye {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: oklch(18% 0.018 165 / 0.6);
  font-size: 11.5px;
  letter-spacing: 0.06em;
  color: var(--ink-3);
  text-transform: uppercase;
  font-weight: 600;
}
.login-h {
  font-size: clamp(34px, 3.6vw, 48px);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin-top: 24px;
}
.login-h .em {
  background: linear-gradient(135deg, oklch(82% 0.18 162), oklch(60% 0.14 162));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-sub { color: var(--ink-2); margin-top: 16px; font-size: 15px; max-width: 38ch; line-height: 1.5; }

.login-stat-row {
  display: flex; gap: 24px;
  margin-top: 32px;
}
.login-stat-row > div {
  border-left: 1px solid var(--line);
  padding-left: 14px;
}
.login-stat-row .v { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: -0.03em; }
.login-stat-row .l { font-size: 11px; color: var(--ink-4); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }

.field-stack { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; }
.field-label {
  font-size: 11.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}

/* === Timeline === */
.tl {
  position: relative;
  padding-left: 28px;
}
.tl::before {
  content: "";
  position: absolute;
  left: 9px; top: 8px; bottom: 8px;
  width: 1px;
  background: linear-gradient(180deg, var(--line), transparent);
}
.tl-item {
  position: relative;
  padding: 0 0 22px;
}
.tl-item::before {
  content: "";
  position: absolute;
  left: -23px; top: 6px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: oklch(20% 0.02 165);
  border: 2px solid var(--line);
}
.tl-item.ok::before   { background: var(--emerald-bright); border-color: oklch(60% 0.14 162); box-shadow: 0 0 0 4px var(--emerald-glow); }
.tl-item.warn::before { background: var(--warn); border-color: oklch(60% 0.13 75); box-shadow: 0 0 0 4px oklch(75% 0.15 75 / 0.25); }
.tl-item.crit::before { background: var(--crit); border-color: oklch(50% 0.18 25); box-shadow: 0 0 0 4px oklch(60% 0.20 25 / 0.25); }

.tl-time { font-family: var(--mono); font-size: 11.5px; color: var(--ink-4); }
.tl-title { font-weight: 600; font-size: 14px; margin-top: 3px; }
.tl-body { font-size: 13px; color: var(--ink-3); margin-top: 4px; line-height: 1.5; }

/* === Chat === */
.chat {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100%;
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  background: oklch(15% 0.016 165 / 0.7);
}
.chat-list {
  border-right: 1px solid var(--line-soft);
  display: flex; flex-direction: column;
  min-height: 0;
}
.chat-search {
  padding: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.chat-search .input { padding: 9px 12px 9px 36px; font-size: 13px; }
.chat-list-scroll { overflow-y: auto; flex: 1; }
.chat-li {
  display: flex; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  cursor: pointer;
  transition: background 160ms;
}
.chat-li:hover { background: oklch(20% 0.02 165 / 0.7); }
.chat-li.active { background: oklch(28% 0.04 162 / 0.45); border-left: 2px solid var(--emerald-bright); padding-left: 12px; }
.chat-li-name { font-size: 13.5px; font-weight: 600; }
.chat-li-last { font-size: 12px; color: var(--ink-3); margin-top: 3px; line-height: 1.3; max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-li-time { font-size: 10.5px; color: var(--ink-4); font-family: var(--mono); margin-left: auto; flex-shrink: 0; }

.chat-pane {
  display: flex; flex-direction: column;
  min-width: 0;
}
.chat-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: oklch(18% 0.02 165 / 0.7);
}
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  display: flex; flex-direction: column;
  gap: 4px;
  background:
    radial-gradient(circle at 50% 0%, oklch(22% 0.04 162 / 0.2), transparent 50%),
    oklch(13% 0.014 165);
}
.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.45;
  position: relative;
}
.bubble.in {
  background: oklch(22% 0.022 165);
  border: 1px solid var(--line-soft);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.bubble.out {
  background: linear-gradient(135deg, oklch(34% 0.10 162), oklch(28% 0.07 162));
  border: 1px solid oklch(45% 0.12 162 / 0.5);
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  color: oklch(96% 0.02 162);
}
.bubble-meta { display: flex; gap: 6px; font-size: 10px; color: var(--ink-4); margin-top: 6px; font-family: var(--mono); }
.bubble.out .bubble-meta { color: oklch(80% 0.04 162); }
.bubble-card {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  background: oklch(18% 0.018 165 / 0.6);
  border: 1px solid var(--line-soft);
  font-size: 12px;
  font-family: var(--mono);
  color: var(--ink-2);
}

/* === Section turn indicator === */
.section-mark {
  align-self: center;
  font-size: 11px;
  color: var(--ink-4);
  background: oklch(20% 0.02 165 / 0.7);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--line-soft);
  margin: 8px 0;
  font-family: var(--mono);
}

/* === State machine viz === */
.state-vis {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
}
.state-node {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
  background: oklch(20% 0.02 165 / 0.5);
  display: flex; align-items: center; gap: 6px;
}
.state-node.active {
  color: var(--ink);
  border-color: oklch(50% 0.14 162);
  background: linear-gradient(180deg, oklch(35% 0.10 162), oklch(28% 0.07 162));
  box-shadow: 0 0 0 4px var(--emerald-glow), 0 4px 16px -4px oklch(60% 0.16 162 / 0.5);
}
.state-arrow { color: var(--ink-4); font-family: var(--mono); }

/* === Variation B (Spectrum) overrides === */
body[data-variant="spectrum"] {
  background:
    linear-gradient(180deg, oklch(11% 0.012 165) 0%, oklch(8% 0.008 165) 100%);
}
body[data-variant="spectrum"]::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(oklch(28% 0.02 165 / 0.18) 1px, transparent 1px),
    linear-gradient(90deg, oklch(28% 0.02 165 / 0.18) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}
body[data-variant="spectrum"] .shell { position: relative; z-index: 1; }
body[data-variant="spectrum"] .glass,
body[data-variant="spectrum"] .kpi,
body[data-variant="spectrum"] .p-row,
body[data-variant="spectrum"] .vital,
body[data-variant="spectrum"] .glass-strong {
  border-radius: 4px;
}
body[data-variant="spectrum"] .btn,
body[data-variant="spectrum"] .input,
body[data-variant="spectrum"] .form-group input,
body[data-variant="spectrum"] .form-group textarea,
body[data-variant="spectrum"] .form-group select,
body[data-variant="spectrum"] .topbar-search input,
body[data-variant="spectrum"] .badge {
  border-radius: 4px;
}
body[data-variant="spectrum"] .nav-item,
body[data-variant="spectrum"] .chat-li.active {
  border-radius: 4px;
}
body[data-variant="spectrum"] .kpi-glow::before { display: none; }
body[data-variant="spectrum"] .page-title {
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: -0.04em;
}
body[data-variant="spectrum"] .brand-name {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: -0.04em;
  text-transform: uppercase;
  font-size: 13px;
}
body[data-variant="spectrum"] .login-h {
  font-family: var(--mono);
  font-weight: 500;
  letter-spacing: -0.05em;
}
body[data-variant="spectrum"] .login-card { border-radius: 4px; }

/* Utility */
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.grow { flex: 1; }
.gap-sm { gap: 6px; }
.gap-lg { gap: 18px; }
.muted { color: var(--ink-3); }
.muted-2 { color: var(--ink-4); }
.center { text-align: center; }
.hidden { display: none !important; }

.split {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
}
@media (max-width: 1100px) { .split { grid-template-columns: 1fr; } }

.split-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}
@media (max-width: 1100px) { .split-3 { grid-template-columns: 1fr; } }


/* ════════════════════════════════════════════════════════════
   PROTOCOL BUILDER
   ════════════════════════════════════════════════════════════ */

.builder-bd {
  position: fixed; inset: 0; z-index: 100;
  background: oklch(8% 0.01 165 / 0.78);
  backdrop-filter: blur(8px);
  display: flex; align-items: stretch; justify-content: center;
  padding: 24px;
  overflow-y: auto;
  animation: modalIn .2s ease-out;
}
@keyframes modalIn { from { opacity: 0; } to { opacity: 1; } }

.builder {
  width: 100%;
  background: transparent;
  display: flex; flex-direction: column;
  min-height: calc(100vh - 76px);
  animation: builderIn .3s cubic-bezier(.2,.8,.2,1);
}
@keyframes builderIn { from { transform: translateY(20px) scale(0.98); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }

.builder-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px;
  padding: 22px var(--pad);
  border-bottom: 1px solid var(--line-soft);
}

.stepper {
  display: flex; align-items: center;
  padding: 22px var(--pad);
  gap: 12px;
  border-bottom: 1px solid var(--line-soft);
  overflow-x: auto;
}
.step {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  padding: 6px 4px;
  flex-shrink: 0;
  transition: opacity .2s;
  opacity: 0.55;
}
.step:hover { opacity: 0.85; }
.step.active { opacity: 1; }
.step.done { opacity: 1; }
.step-num {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  background: oklch(20% 0.02 165);
  border: 1px solid var(--line);
  color: var(--ink-3);
  transition: all .25s;
}
.step.active .step-num {
  background: var(--emerald-bright);
  border-color: var(--emerald-bright);
  color: oklch(15% 0.02 165);
  box-shadow: 0 0 0 4px oklch(60% 0.16 162 / 0.18);
}
.step.done .step-num {
  background: oklch(28% 0.10 162);
  border-color: oklch(50% 0.14 162);
  color: var(--emerald-bright);
}
.step-label { font-size: 13px; font-weight: 500; color: var(--ink-2); white-space: nowrap; }
.step-line {
  flex: 1; min-width: 32px;
  height: 1px;
  background: var(--line);
  transition: background .3s;
}
.step-line.done { background: oklch(50% 0.14 162 / 0.5); }

.builder-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  flex: 1;
  min-height: 0;
  gap: 0;
}
.builder-main {
  padding: 28px var(--pad) 28px var(--pad);
  display: flex; flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.builder-foot {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 0 0 0;
  margin-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.builder-preview {
  background: oklch(9% 0.01 165 / 0.5);
  border-left: 1px solid var(--line-soft);
  padding: 28px 22px;
  display: flex; flex-direction: column;
  gap: 18px;
  position: sticky; top: 76px;
  max-height: calc(100vh - 76px);
  overflow-y: auto;
}
.preview-eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-4);
  font-family: var(--mono);
}
.preview-phone {
  border-radius: 18px;
  background: oklch(13% 0.012 160);
  border: 1px solid var(--line-soft);
  overflow: hidden;
  box-shadow: 0 20px 50px -10px oklch(0% 0 0 / 0.5);
}
.phone-head {
  background: oklch(20% 0.02 165);
  padding: 10px 12px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.phone-body {
  padding: 14px 10px;
  display: flex; flex-direction: column;
  gap: 8px;
  background:
    linear-gradient(180deg, oklch(14% 0.014 165), oklch(12% 0.012 165));
  min-height: 280px;
  max-height: 420px;
  overflow-y: auto;
}
.bubble {
  padding: 8px 11px;
  border-radius: 10px;
  font-size: 12.5px;
  line-height: 1.4;
  position: relative;
}
.bubble.in {
  background: oklch(20% 0.02 165);
  align-self: flex-start;
  border-bottom-left-radius: 3px;
}
.bubble.out {
  background: oklch(35% 0.10 162);
  align-self: flex-end;
  border-bottom-right-radius: 3px;
  color: oklch(96% 0.02 165);
}
.bubble-meta {
  font-size: 9.5px;
  font-family: var(--mono);
  color: var(--ink-4);
  margin-top: 4px;
  text-align: right;
}
.bubble-card {
  margin-top: 8px;
  padding: 8px 10px;
  background: oklch(16% 0.014 165);
  border-radius: 8px;
  font-size: 11px;
}

.preview-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 14px;
  background: oklch(13% 0.014 165 / 0.5);
  border: 1px solid var(--line-soft);
  border-radius: 12px;
}

/* Builder forms */
.section-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.section-h h3 { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.section-h .meta { font-size: 11.5px; color: var(--ink-4); }

.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: oklch(15% 0.014 165 / 0.6);
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  transition: all .2s;
}
.q-row:hover { border-color: oklch(50% 0.14 162 / 0.4); transform: translateX(2px); }
.q-num {
  font-size: 11px;
  color: var(--ink-4);
  letter-spacing: 0.05em;
  flex-shrink: 0;
}
.q-text { font-size: 13.5px; font-weight: 500; line-height: 1.35; }
.q-meta { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
.q-type {
  font-size: 10px; font-family: var(--mono);
  padding: 2px 7px; border-radius: 5px;
  text-transform: uppercase; letter-spacing: 0.06em;
  background: oklch(20% 0.02 165); color: var(--ink-3);
  border: 1px solid var(--line-soft);
}
.q-type-choice { color: oklch(75% 0.10 220); border-color: oklch(40% 0.10 220 / 0.4); }
.q-type-numeric { color: oklch(78% 0.10 162); border-color: oklch(40% 0.10 162 / 0.4); }
.q-type-yesno { color: oklch(75% 0.10 80); border-color: oklch(40% 0.10 80 / 0.4); }

.q-library {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.q-lib {
  position: relative;
  padding: 12px 14px;
  background: oklch(13% 0.012 165 / 0.5);
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  padding-right: 38px;
}
.q-lib:hover {
  border-color: oklch(50% 0.14 162 / 0.6);
  border-style: solid;
  background: oklch(18% 0.02 165 / 0.6);
  transform: translateY(-1px);
}
.q-lib.used {
  opacity: 0.5;
  cursor: default;
  border-style: solid;
  background: oklch(28% 0.10 162 / 0.15);
  border-color: oklch(50% 0.14 162 / 0.3);
}
.q-lib.used:hover { transform: none; }
.q-add {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 26px; height: 26px;
}
.q-lib.used .q-add { color: var(--emerald-bright); }
.empty {
  padding: 32px;
  text-align: center;
  color: var(--ink-4);
  font-size: 13px;
  border: 1px dashed var(--line-soft);
  border-radius: 10px;
}

/* Threshold slider visualization */
.thresh-bar { margin-top: 14px; }
.thresh-track {
  display: flex;
  height: 56px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--line-soft);
}
.thresh-zone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: width .3s cubic-bezier(.2,.8,.2,1);
  min-width: 60px;
  gap: 2px;
}
.thresh-zone.ok { background: linear-gradient(180deg, oklch(35% 0.12 162), oklch(28% 0.10 162)); color: oklch(92% 0.04 162); }
.thresh-zone.warn { background: linear-gradient(180deg, oklch(50% 0.14 75), oklch(42% 0.12 75)); color: oklch(96% 0.04 75); }
.thresh-zone.crit { background: linear-gradient(180deg, oklch(50% 0.18 25), oklch(40% 0.15 25)); color: oklch(96% 0.04 25); }
.thresh-zone span:last-child { font-size: 10px; opacity: 0.85; }
.thresh-marks {
  display: flex; justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-4);
}

.thresh-input { padding: 16px; background: oklch(15% 0.014 165 / 0.6); border: 1px solid var(--line-soft); border-radius: 12px; }
.thresh-input.warn { border-color: oklch(50% 0.14 75 / 0.3); }
.thresh-input.crit { border-color: oklch(50% 0.18 25 / 0.3); }
.thresh-input input[type="range"] {
  width: 100%; margin-top: 10px;
  accent-color: oklch(60% 0.16 162);
}
.thresh-input.warn input[type="range"] { accent-color: oklch(72% 0.18 75); }
.thresh-input.crit input[type="range"] { accent-color: oklch(70% 0.20 25); }
.thresh-input-val { font-size: 22px; font-weight: 600; margin-top: 6px; }

.review-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 24px;
}
.review-l { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-4); margin-bottom: 4px; }
.review-v { font-size: 15px; font-weight: 500; }

/* ════════════════════════════════════════════════════════════
   MOBILE RESPONSIVENESS
   ════════════════════════════════════════════════════════════ */

.topbar-menu { display: none; }
.side-scrim { display: none; }

@media (max-width: 980px) {
  :root { --pad: 20px; }
  .shell { grid-template-columns: 1fr; }
  .side {
    position: fixed; top: 0; left: 0;
    z-index: 60;
    transform: translateX(-100%);
    transition: transform .25s cubic-bezier(.2,.8,.2,1);
    width: 280px;
    box-shadow: 20px 0 60px -10px oklch(0% 0 0 / 0.5);
  }
  .side.side-open { transform: translateX(0); }
  .side-scrim {
    display: block;
    position: fixed; inset: 0;
    background: oklch(0% 0 0 / 0.6);
    z-index: 55;
    backdrop-filter: blur(4px);
    animation: fadeIn .2s;
  }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .topbar-menu { display: inline-flex; }
  .topbar-clock { display: none; }
  .topbar-search { max-width: none; }

  .builder-grid { grid-template-columns: 1fr; }
  .builder-preview { border-left: none; border-top: 1px solid var(--line-soft); position: static; max-height: none; }
  .builder-main { padding: 18px var(--pad); }
  .stepper { padding: 14px var(--pad); gap: 8px; }
  .step-line { min-width: 16px; }
  .step-label { display: none; }
  .step.active .step-label { display: inline; }
  .builder-head { padding: 14px var(--pad); }
  .builder-head .btn { padding: 8px 12px; font-size: 12px; }
  .modal-bd { padding: 0; }

  .review-grid { grid-template-columns: 1fr; }
}

/* Doctor list row — responsive */
.doctor-row {
  display: grid;
  grid-template-columns: auto minmax(0, 2fr) minmax(0, 1.4fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  transition: background 160ms;
}
.doctor-row:hover { background: oklch(24% 0.025 165 / 0.4); }
@media (max-width: 880px) {
  .doctor-row {
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas:
      "avatar name actions"
      "avatar email email"
      "avatar meta  status";
    row-gap: 6px;
  }
  .doctor-row > :nth-child(1) { grid-area: avatar; }
  .doctor-row > :nth-child(2) { grid-area: name; min-width: 0; }
  .doctor-row > :nth-child(3) { grid-area: email; font-size: 12px !important; word-break: break-all; }
  .doctor-row > :nth-child(4) { grid-area: meta; }
  .doctor-row > :nth-child(5) { grid-area: status; justify-self: end; }
  .doctor-row > :nth-child(6) { grid-area: actions; justify-self: end; }
}

@media (max-width: 640px) {
  :root { --pad: 16px; }
  .page-title { font-size: 26px !important; }
  .kpi-row { grid-template-columns: 1fr 1fr !important; }
  .kpi { padding: 14px 16px; }
  .kpi-value { font-size: 28px !important; }
  .topbar { padding: 12px var(--pad); }
  .topbar-search input { padding: 9px 12px 9px 34px; font-size: 13px; }
  .topbar-search kbd { display: none; }
  .login-stage { padding: 16px; }
  .login-form { padding: 28px 22px !important; }
  .builder-head .btn { display: none; }
  .builder-head .btn.btn-primary { display: inline-flex; }
  .q-row { padding: 10px 12px; gap: 10px; }
  .q-num { display: none; }
  .builder-foot { gap: 10px; }
  .builder-foot .muted-2 { display: none; }
  .thresh-zone { font-size: 9px; min-width: 50px; }
  .thresh-zone span:last-child { font-size: 9px; }
  .review-grid { grid-template-columns: 1fr; }
  .preview-stats { grid-template-columns: repeat(3, 1fr); }
  .split, .split-3 { grid-template-columns: 1fr !important; }
  .chat { grid-template-columns: 1fr; grid-template-rows: 220px 1fr; }
  .chat-list { border-right: none; border-bottom: 1px solid var(--line-soft); }
  .chat-li-last { max-width: none; }
  .doctor-row { padding: 12px !important; gap: 10px; }
}

@media (max-width: 880px) {
  .chat { grid-template-columns: 260px 1fr; }
}

/* Custom auth wrapper for vanilla JS */
.shell--auth { grid-template-columns: 1fr !important; }

.p-row.selected { background: oklch(26% 0.03 165 / 0.75); border-color: var(--emerald-bright); }
.tab-row { display: flex; gap: 6px; padding: 4px; background: oklch(18% 0.018 165 / 0.6); border-radius: 10px; border: 1px solid var(--line-soft); width: fit-content; margin-bottom: 20px; }
.tab-btn { padding: 8px 14px; background: transparent; color: var(--ink-3); font-size: 13px; border: none; border-radius: 6px; cursor: pointer; transition: all .15s; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { background: oklch(28% 0.05 162 / 0.7); color: var(--ink); }
.tab-count { font-family: var(--mono); margin-left: 6px; opacity: 0.6; }
.tab-btn.active .tab-count { opacity: 0.8; }
