/* ============================================================
   ORBIT NOC — Data Center Command Center
   Dark mission-control aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Surfaces */
  --bg-0: #05080f;          /* deepest — app background */
  --bg-1: #0a0e1a;          /* sidebar / topbar */
  --bg-2: #0d1424;          /* panel */
  --bg-3: #111a2e;          /* raised panel / hover */
  --bg-4: #16203a;          /* control / input */

  /* Borders */
  --line: #1c2740;
  --line-bright: #2a3a5e;
  --line-glow: rgba(34, 211, 238, 0.35);

  /* Text */
  --txt-0: #eef3ff;         /* primary */
  --txt-1: #aebbd4;         /* secondary */
  --txt-2: #6b7a99;         /* muted */
  --txt-3: #475068;         /* faint */

  /* Accent — cyan */
  --acc: #22d3ee;
  --acc-dim: #0e7490;
  --acc-glow: rgba(34, 211, 238, 0.4);

  /* Status */
  --ok: #34d399;
  --ok-glow: rgba(52, 211, 153, 0.35);
  --warn: #f59e0b;
  --warn-glow: rgba(245, 158, 11, 0.35);
  --crit: #f43f5e;
  --crit-glow: rgba(244, 63, 94, 0.4);
  --info: #60a5fa;
  --info-glow: rgba(96,165,250,0.35);
  --viol: #a855f7;
  --viol-glow: rgba(168,85,247,0.4);

  /* Type */
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;

  --sidebar-w: 248px;
  --topbar-h: 60px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg-0);
  color: var(--txt-0);
  font-family: var(--font-display);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

#root { height: 100vh; }

/* Subtle grid texture behind everything */
.app-bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(34, 211, 238, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, 0.025) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 80% at 70% 20%, #000 30%, transparent 100%);
}

/* ============================ LAYOUT ============================ */
.app {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    "sidebar topbar"
    "sidebar main";
  height: 100vh;
}

.sidebar { grid-area: sidebar; }
.topbar  { grid-area: topbar; }
.main {
  grid-area: main;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 22px 26px 60px;
}

/* Scrollbars */
.main::-webkit-scrollbar, .scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.main::-webkit-scrollbar-thumb, .scroll::-webkit-scrollbar-thumb {
  background: var(--line-bright); border-radius: 8px;
  border: 2px solid var(--bg-0);
}
.main::-webkit-scrollbar-track, .scroll::-webkit-scrollbar-track { background: transparent; }

/* ============================ SIDEBAR ============================ */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  position: relative;
  flex-shrink: 0;
}
.brand-mark svg { width: 30px; height: 30px; }
.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.5px;
}
.brand-name b { color: var(--acc); font-weight: 700; }
.brand-sub {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--txt-2);
  text-transform: uppercase;
}

.nav { padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.nav-label {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 2px;
  color: var(--txt-3);
  text-transform: uppercase;
  padding: 14px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--txt-1);
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  position: relative;
  transition: background .14s, color .14s;
  user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .85; }
.nav-item:hover { background: var(--bg-3); color: var(--txt-0); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(34,211,238,0.14), rgba(34,211,238,0.02));
  color: #fff;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 6px; bottom: 6px;
  width: 3px; border-radius: 3px;
  background: var(--acc);
  box-shadow: 0 0 10px var(--acc-glow);
}
.nav-item.active svg { opacity: 1; color: var(--acc); }
.nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--bg-4);
  color: var(--txt-1);
}
.nav-badge.crit { background: rgba(244,63,94,0.16); color: var(--crit); }

.sidebar-foot {
  border-top: 1px solid var(--line);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--acc-dim), var(--viol));
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px; color: #fff;
  flex-shrink: 0;
}

/* ============================ TOPBAR ============================ */
.topbar {
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 24px;
}
.page-title { font-size: 17px; font-weight: 600; }
.page-crumb { font-family: var(--font-mono); font-size: 10px; color: var(--txt-2); letter-spacing: 1px; text-transform: uppercase; }
.topbar-spacer { flex: 1; }

.global-search {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 12px;
  width: 300px;
  color: var(--txt-2);
  font-size: 13px;
}
.global-search svg { width: 15px; height: 15px; }
.global-search kbd {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--bg-4);
  border: 1px solid var(--line-bright);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--txt-2);
}

.tb-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--txt-1);
  display: grid; place-items: center;
  cursor: pointer;
  position: relative;
  transition: background .14s, border-color .14s;
}
.tb-btn:hover { background: var(--bg-3); border-color: var(--line-bright); }
.tb-btn svg { width: 17px; height: 17px; }
.tb-btn .dot {
  position: absolute; top: 7px; right: 8px;
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--crit);
  box-shadow: 0 0 6px var(--crit-glow);
  border: 1.5px solid var(--bg-1);
}

.clock {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--txt-0);
  letter-spacing: 0.5px;
  text-align: right;
}
.clock small { display: block; font-size: 9px; color: var(--txt-2); letter-spacing: 1.5px; }

/* ============================ PANELS ============================ */
.panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  position: relative;
}
.panel-pad { padding: 16px 18px; }
.panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.3px;
  display: flex; align-items: center; gap: 8px;
}
.panel-title svg { width: 15px; height: 15px; color: var(--acc); }
.panel-sub { font-family: var(--font-mono); font-size: 10px; color: var(--txt-2); text-transform: uppercase; letter-spacing: 1px; }
.panel-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.chip {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--bg-4);
  color: var(--txt-1);
  letter-spacing: 0.5px;
  border: 1px solid var(--line);
  display: inline-flex; align-items: center; gap: 5px;
  white-space: nowrap;
}
.chip.live { color: var(--ok); border-color: rgba(52,211,153,0.3); }
.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }

/* ============================ GRID ============================ */
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: repeat(2, 1fr); }
.cols-3 { grid-template-columns: repeat(3, 1fr); }
.cols-4 { grid-template-columns: repeat(4, 1fr); }
.cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ============================ STAT CARDS ============================ */
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: 15px 17px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--acc);
  opacity: .9;
}
.stat.ok::after { background: var(--ok); }
.stat.warn::after { background: var(--warn); }
.stat.crit::after { background: var(--crit); }
.stat.viol::after { background: var(--viol); }
.stat-top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stat-ico {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  background: var(--bg-4);
  color: var(--acc);
}
.stat.ok .stat-ico { color: var(--ok); }
.stat.warn .stat-ico { color: var(--warn); }
.stat.crit .stat-ico { color: var(--crit); }
.stat.viol .stat-ico { color: var(--viol); }
.stat-ico svg { width: 16px; height: 16px; }
.stat-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--txt-2); }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -0.5px; line-height: 1; }
.stat-value .unit { font-size: 14px; color: var(--txt-2); margin-left: 3px; }
.stat-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.stat-delta { font-family: var(--font-mono); font-size: 11px; display: flex; align-items: center; gap: 3px; }
.stat-delta.up { color: var(--ok); }
.stat-delta.down { color: var(--crit); }
.stat-spark { margin-top: 10px; height: 30px; }

/* ============================ TABLES ============================ */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--txt-2);
  font-weight: 500;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  position: sticky; top: 0;
  background: var(--bg-2);
  z-index: 2;
}
.tbl td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--txt-1);
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; cursor: pointer; }
.tbl tbody tr:hover { background: var(--bg-3); }
.tbl tbody tr.sel { background: rgba(34,211,238,0.07); }
.mono { font-family: var(--font-mono); }
.t0 { color: var(--txt-0); }
.t2 { color: var(--txt-2); }

/* status pill */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 9px 2px 7px;
  border-radius: 20px;
}
.pill .pd { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 6px currentColor; }
.pill.ok   { color: var(--ok);   background: rgba(52,211,153,0.12); }
.pill.warn { color: var(--warn); background: rgba(245,158,11,0.12); }
.pill.crit { color: var(--crit); background: rgba(244,63,94,0.13); }
.pill.info { color: var(--info); background: rgba(96,165,250,0.12); }
.pill.idle { color: var(--txt-2); background: var(--bg-4); }
.pill.viol { color: var(--viol); background: rgba(168,85,247,0.13); }

/* progress bar */
.bar { height: 6px; border-radius: 4px; background: var(--bg-4); overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--acc); transition: width .5s ease; }
.bar.ok > span { background: var(--ok); }
.bar.warn > span { background: var(--warn); }
.bar.crit > span { background: var(--crit); }

/* mini buttons */
.btn {
  font-family: var(--font-display);
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 7px;
  border: 1px solid var(--line-bright);
  background: var(--bg-3);
  color: var(--txt-0);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px;
  transition: background .14s, border-color .14s;
  white-space: nowrap;
}
.btn:hover { background: var(--bg-4); border-color: var(--acc-dim); }
.btn svg { width: 14px; height: 14px; }
.btn.primary { background: var(--acc); color: #04141a; border-color: var(--acc); font-weight: 600; }
.btn.primary:hover { background: #4ce0f5; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--txt-1); }
.btn.ghost:hover { background: var(--bg-3); color: var(--txt-0); }
.btn.sm { padding: 4px 9px; font-size: 11.5px; }

/* segmented control */
.seg { display: inline-flex; background: var(--bg-1); border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg button {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 11px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--txt-2);
  cursor: pointer;
  transition: background .12s, color .12s;
  letter-spacing: .5px;
}
.seg button:hover { color: var(--txt-0); }
.seg button.active { background: var(--bg-4); color: var(--acc); }

/* ============================ MISC ============================ */
.flex { display: flex; }
.ac { align-items: center; }
.jb { justify-content: space-between; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--txt-2); }
.fill { flex: 1; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }

.section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 16px; gap: 16px;
}
.section-head h2 { font-size: 18px; font-weight: 600; letter-spacing: 0.2px; }
.section-head p { color: var(--txt-2); font-size: 12.5px; margin-top: 3px; }

/* glow text for big numbers */
.glow { text-shadow: 0 0 18px var(--acc-glow); }
.glow-ok { text-shadow: 0 0 18px var(--ok-glow); }
.glow-crit { text-shadow: 0 0 18px var(--crit-glow); }

/* blinking live dot */
@keyframes blink { 0%,100% { opacity: 1; } 50% { opacity: .25; } }
.blink { animation: blink 1.6s ease-in-out infinite; }

@keyframes pulse-ring {
  0% { transform: scale(.8); opacity: .8; }
  100% { transform: scale(2.4); opacity: 0; }
}

@keyframes fadeup {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes riseup {
  from { transform: translateY(10px); }
  to { transform: translateY(0); }
}
.fadeup { animation: riseup .3s ease; }
@media (prefers-reduced-motion: reduce) { .fadeup { animation: none; } }

/* tooltip */
.tt {
  position: fixed;
  z-index: 1000;
  background: var(--bg-3);
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 12px;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(0,0,0,.5);
  max-width: 260px;
}
.tt-title { font-weight: 600; font-size: 12.5px; margin-bottom: 4px; }
.tt-row { display: flex; justify-content: space-between; gap: 18px; font-family: var(--font-mono); font-size: 11px; color: var(--txt-1); }
.tt-row span:first-child { color: var(--txt-2); }

/* drawer */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(3,6,12,.6);
  backdrop-filter: blur(2px);
  animation: fadeup .2s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 901;
  width: 460px; max-width: 92vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line-bright);
  box-shadow: -20px 0 60px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  animation: drawerin .26s cubic-bezier(.2,.8,.2,1);
}
@keyframes drawerin { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

.kv { display: grid; grid-template-columns: 120px 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--txt-2); font-family: var(--font-mono); font-size: 11px; padding-top: 1px; }
.kv dd { color: var(--txt-0); }

.legend { display: flex; flex-wrap: wrap; gap: 12px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--txt-1); font-family: var(--font-mono); }
.legend-sw { width: 10px; height: 10px; border-radius: 3px; }

.canvas-wrap { position: relative; width: 100%; }
.canvas-wrap canvas { display: block; width: 100%; }

/* topology overlay labels */
.topo-overlay { position: absolute; inset: 0; pointer-events: none; }
.topo-stat {
  position: absolute;
  background: rgba(10,14,26,.78);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 13px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

.heat-cell { border-radius: 2px; transition: transform .1s; }
.heat-cell:hover { transform: scale(1.35); z-index: 2; position: relative; }

/* iso rack */
.rack-scene { perspective: 1400px; }

/* density tweaks */
[data-density="compact"] .main { padding: 14px 18px 50px; }
[data-density="compact"] .grid { gap: 11px; }
[data-density="comfy"] .main { padding: 30px 36px 70px; }
[data-density="comfy"] .grid { gap: 22px; }

/* deploy form controls */
.deploy-select {
  width: 100%;
  margin-top: 6px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--txt-0);
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 7px 9px;
  outline: none;
  cursor: pointer;
}
.deploy-select:focus { border-color: var(--acc-dim); }
.deploy-select option { background: var(--bg-1); }

/* streaming log console */
.deploy-console {
  height: 252px;
  overflow-y: auto;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.7;
  background: #04060c;
  border-radius: 0 0 10px 10px;
}
.log-line { white-space: pre-wrap; word-break: break-word; }
.log-out { color: var(--txt-1); }
.log-out::before { content: '$ '; color: var(--txt-3); }
.log-sys { color: var(--acc); }
.log-ok { color: var(--ok); font-weight: 600; }
.log-err { color: var(--crit); font-weight: 600; }

/* API catalog */
.method-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 2px 7px;
  border-radius: 5px;
  border: 1px solid;
  background: color-mix(in srgb, currentColor 10%, transparent);
  display: inline-block;
}
.code-block {
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.65;
  color: var(--txt-1);
  background: #04060c;
  padding: 14px 16px;
  border-radius: 0 0 10px 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  min-height: 132px;
  margin: 0;
}

/* ===================== JESSI CHAT AI ===================== */
.jessi-btn {
  background: linear-gradient(120deg, var(--acc), var(--viol)) !important;
  color: #04141a !important;
  border: none !important;
  font-weight: 600 !important;
}
.jessi-btn:hover { filter: brightness(1.08); }
.jessi-btn svg { color: #04141a; }

.jessi-fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 880;
  width: 56px; height: 56px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--acc), var(--viol));
  display: grid; place-items: center;
  box-shadow: 0 10px 30px rgba(34,211,238,.35), 0 0 0 1px rgba(255,255,255,.08) inset;
  transition: transform .18s;
}
.jessi-fab:hover { transform: scale(1.06); }
.jessi-fab svg { color: #04141a; width: 24px; height: 24px; }
.jessi-fab::after {
  content: ''; position: absolute; inset: -4px; border-radius: 50%;
  border: 2px solid var(--acc); opacity: .5;
  animation: pulse-ring 2.4s ease-out infinite;
  pointer-events: none;   /* the expanding ring must never intercept clicks */
}

.jessi-panel {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 902;
  width: 420px; max-width: 94vw;
  background: var(--bg-1);
  border-left: 1px solid var(--line-bright);
  box-shadow: -20px 0 60px rgba(0,0,0,.55);
  display: flex; flex-direction: column;
  animation: drawerin .26s cubic-bezier(.2,.8,.2,1);
}
.jessi-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(120deg, rgba(34,211,238,.08), rgba(168,85,247,.06));
}
.jessi-ava {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--acc), var(--viol));
  display: grid; place-items: center; position: relative;
}
.jessi-ava svg { color: #04141a; width: 21px; height: 21px; }
.jessi-ava .stat-on {
  position: absolute; right: -2px; bottom: -2px;
  width: 11px; height: 11px; border-radius: 50%; background: var(--ok);
  border: 2px solid var(--bg-1); box-shadow: 0 0 6px var(--ok-glow);
}
.jessi-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.jessi-msg { display: flex; gap: 10px; max-width: 100%; animation: fadeup .25s ease; }
.jessi-msg.me { flex-direction: row-reverse; }
.jessi-bubble {
  padding: 10px 13px; border-radius: 13px; font-size: 13px; line-height: 1.5;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--txt-0);
  /* width cap comes from the fit-content wrapper; a % here collapses short replies to 1ch */
  max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
}
.jessi-msg.me .jessi-bubble {
  background: linear-gradient(120deg, var(--acc-dim), rgba(168,85,247,.5));
  border-color: transparent; color: #eafdff;
}
.jessi-mini-ava {
  width: 26px; height: 26px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--acc), var(--viol));
  display: grid; place-items: center;
}
.jessi-mini-ava svg { color: #04141a; width: 15px; height: 15px; }
.jessi-bubble b { color: var(--acc); font-weight: 600; }
.jessi-bubble .ji-crit { color: var(--crit); font-weight: 600; }
.jessi-bubble .ji-ok { color: var(--ok); font-weight: 600; }
.jessi-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.jessi-chip {
  font-size: 11.5px; padding: 5px 11px; border-radius: 20px; cursor: pointer;
  background: var(--bg-4); border: 1px solid var(--line-bright); color: var(--txt-1);
  transition: background .12s, color .12s; display: inline-flex; align-items: center; gap: 5px;
}
.jessi-chip:hover { background: var(--bg-3); color: var(--acc); border-color: var(--acc-dim); }
.jessi-typing { display: flex; gap: 4px; padding: 4px 2px; }
.jessi-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--txt-2); animation: jblink 1.2s infinite; }
.jessi-typing span:nth-child(2) { animation-delay: .2s; }
.jessi-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes jblink { 0%, 60%, 100% { opacity: .25; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
.jessi-foot { padding: 14px 16px; border-top: 1px solid var(--line); }
.jessi-suggest { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 11px; }
.jessi-input {
  display: flex; align-items: center; gap: 9px;
  background: var(--bg-2); border: 1px solid var(--line-bright); border-radius: 11px; padding: 8px 8px 8px 13px;
}
.jessi-input:focus-within { border-color: var(--acc-dim); }
.jessi-input input { flex: 1; background: none; border: none; outline: none; color: var(--txt-0); font-family: var(--font-display); font-size: 13.5px; }
.jessi-send {
  width: 34px; height: 34px; border-radius: 9px; border: none; cursor: pointer; flex-shrink: 0;
  background: linear-gradient(135deg, var(--acc), var(--viol)); display: grid; place-items: center;
}
.jessi-send:disabled { opacity: .4; cursor: default; }
.jessi-send svg { color: #04141a; width: 16px; height: 16px; }
.jessi-hist-pop {
  margin: 0 12px 6px; padding: 8px; background: var(--bg-2);
  border: 1px solid var(--line-bright); border-radius: 11px; box-shadow: 0 12px 30px rgba(0,0,0,.35);
}
.jessi-hist-foot {
  margin-top: 6px; padding: 7px 8px 3px; border-top: 1px solid var(--line);
  display: flex; align-items: center; gap: 5px; justify-content: center;
  font-size: 11.5px; color: var(--acc); cursor: pointer;
}
.jessi-mic {
  width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; cursor: pointer;
  border: 1px solid var(--line-bright); background: var(--bg-1); color: var(--txt-2);
  display: grid; place-items: center; transition: color .15s, border-color .15s, background .15s;
}
.jessi-mic:hover { color: var(--txt-0); border-color: var(--acc-dim); }
.jessi-mic:disabled { opacity: .4; cursor: default; }
.jessi-mic.listening { color: #fff; border-color: var(--crit); background: var(--crit); animation: mic-pulse 1.1s ease-in-out infinite; }
@keyframes mic-pulse { 0%, 100% { box-shadow: 0 0 0 0 var(--crit-glow, rgba(255,90,90,.5)); } 50% { box-shadow: 0 0 0 6px rgba(255,90,90,0); } }

/* Agent Fleet */
.agent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; padding: 12px; }
.agent-card {
  border: 1px solid var(--line); border-radius: 11px; padding: 12px; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.agent-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(0,0,0,.28); }
.agent-activity { font-size: 10.5px; color: var(--acc); margin-bottom: 4px; line-height: 1.4; max-height: 42px; overflow: hidden; }
.agent-open { font-size: 10px; color: var(--txt-2); display: inline-flex; align-items: center; gap: 2px; }
.agent-card:hover .agent-open { color: var(--acc); }
.agent-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); z-index: 901;
  width: 640px; max-width: 94vw; max-height: 88vh;
  background: var(--bg-1); border: 1px solid var(--line-bright); border-radius: 16px;
  box-shadow: 0 28px 70px rgba(0,0,0,.5); display: flex; flex-direction: column; overflow: hidden;
  animation: fadeup .18s ease;
}
.agent-modal-head { display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.agent-modal-body { padding: 16px; overflow-y: auto; }
.agent-status-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 12px; }
@media (max-width: 560px) { .agent-status-grid { grid-template-columns: repeat(3, 1fr); } }
.agent-chat-body { max-height: 280px; overflow-y: auto; padding: 10px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; display: flex; flex-direction: column; gap: 10px; }
/* schedule calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-head { text-align: center; font-size: 9.5px; color: var(--txt-2); font-family: var(--font-mono); padding-bottom: 2px; }
.cal-cell { position: relative; min-height: 42px; border: 1px solid var(--line); border-radius: 7px; padding: 4px; background: var(--bg-1); }
.cal-cell.empty { border-color: transparent; background: transparent; }
.cal-cell.today { border-color: var(--acc-dim); box-shadow: inset 0 0 0 1px var(--acc-dim); }
.cal-day { font-size: 10.5px; color: var(--txt-1); }
.cal-dot { position: absolute; bottom: 4px; right: 5px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--acc); color: #04141a; font-size: 9.5px; font-weight: 700; display: grid; place-items: center; }
/* live task console */
.task-console { max-height: 260px; overflow-y: auto; background: #060a12; border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-family: var(--font-mono); font-size: 11px; line-height: 1.6; }
.live-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 9px; font-weight: 700; letter-spacing: 1px; color: var(--crit); }
.live-dot span { width: 7px; height: 7px; border-radius: 50%; background: var(--crit); animation: mic-pulse 1.1s ease-in-out infinite; }
/* in-chat approval card + markdown */
.approval-card { margin-top: 8px; padding: 9px 10px; border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--bg-1)); border-radius: 9px; }
.md-pre { background: #060a12; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; overflow-x: auto; font-family: var(--font-mono); font-size: 11px; white-space: pre; margin: 6px 0; }
.md-code { background: var(--bg-2); border-radius: 4px; padding: 1px 5px; font-family: var(--font-mono); font-size: 11.5px; }
.jessi-bubble a { color: var(--acc); text-decoration: underline; }
.agent-activity-stream { margin-top: 7px; padding: 7px 9px; background: #060a12; border: 1px solid var(--line); border-radius: 8px; font-family: var(--font-mono); font-size: 11px; line-height: 1.7; max-height: 200px; overflow-y: auto; }
.md-img { max-width: 100%; border-radius: 8px; border: 1px solid var(--line); margin: 6px 0; display: block; }
/* Chat markdown tables — scroll horizontally so they fit the narrow slide-out too */
.md-tablewrap { overflow-x: auto; margin: 7px 0; border: 1px solid var(--line); border-radius: 8px; max-width: 100%; -webkit-overflow-scrolling: touch; }
.md-table { border-collapse: collapse; width: 100%; font-size: 11.5px; }
.md-table th, .md-table td { padding: 5px 9px; border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); text-align: left; white-space: nowrap; }
.md-table th { color: var(--txt-2); font-weight: 600; background: var(--bg-1); text-transform: none; }
.md-table tr:last-child td { border-bottom: none; }
.md-table td:last-child, .md-table th:last-child { border-right: none; }
/* Modal */
.modal-scrim { position: fixed; inset: 0; z-index: 1000; background: rgba(3,6,12,.66); backdrop-filter: blur(3px); display: grid; place-items: center; animation: fadeup .15s ease; }
.modal-card { width: 460px; max-width: 92vw; background: var(--bg-1); border: 1px solid var(--line-bright); border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,.6); overflow: hidden; animation: pop-in .18s cubic-bezier(.34,1.56,.64,1); }
.modal-head { padding: 16px 20px 10px; font-size: 16px; font-weight: 600; }
.modal-body { padding: 4px 20px 16px; }
.modal-foot { padding: 12px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 1px solid var(--line); background: var(--bg-2); }
@keyframes pop-in { from { opacity: 0; transform: scale(.94) translateY(8px); } to { opacity: 1; transform: none; } }
/* Prompt library popover */
.prompt-lib-pop {
  position: absolute; bottom: calc(100% + 8px); right: 0; z-index: 50;
  width: 290px; max-height: 340px; overflow-y: auto;
  background: var(--bg-2); border: 1px solid var(--line-bright); border-radius: 12px;
  padding: 10px; box-shadow: 0 16px 40px rgba(0,0,0,.55);
}
.prompt-lib-row { display: flex; align-items: center; gap: 8px; padding: 7px 8px; border-radius: 8px; cursor: pointer; }
.prompt-lib-row:hover { background: var(--bg-1); }
/* Play button: pop in on load + gentle attention pulse */
.play-btn { animation: play-pop .42s cubic-bezier(.34,1.56,.64,1) both, play-glow 2.4s ease-in-out .5s infinite; }
.play-btn:hover { animation: none; border-color: var(--acc); color: var(--acc); }
@keyframes play-pop { 0% { opacity: 0; transform: translateY(5px) scale(.85); } 100% { opacity: 1; transform: none; } }
@keyframes play-glow { 0%, 100% { box-shadow: 0 0 0 0 transparent; } 50% { box-shadow: 0 0 10px -2px var(--acc-glow); border-color: var(--acc-dim); } }
.agent-prog { height: 4px; background: var(--bg-2); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.agent-prog span { display: block; height: 100%; width: 32%; border-radius: 3px; background: linear-gradient(90deg, transparent, var(--acc), transparent); animation: agent-prog-slide 1.05s linear infinite; }
@keyframes agent-prog-slide { 0% { transform: translateX(-130%); } 100% { transform: translateX(380%); } }

/* text helpers */
.t1 { color: var(--txt-1); }
.t3 { color: var(--txt-3); }
.alert-row { transition: background .12s; }
.alert-row:hover { background: var(--bg-3); }

/* ===================== LOGIN ===================== */
.login-wrap {
  position: fixed; inset: 0; z-index: 1; overflow: hidden;
  display: grid; place-items: center;
  background: radial-gradient(ellipse 70% 60% at 50% 0%, #0d1730, var(--bg-0) 70%);
}
.login-bg-grid {
  position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(34,211,238,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(34,211,238,.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 60% 60% at 50% 40%, #000, transparent 80%);
}
.login-glow {
  position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: radial-gradient(circle, rgba(34,211,238,.16), transparent 65%);
  top: -160px; filter: blur(20px);
}
.login-card {
  position: relative; width: 420px; max-width: 92vw;
  background: var(--bg-2); border: 1px solid var(--line-bright);
  border-radius: 18px; padding: 30px 32px;
  box-shadow: 0 40px 90px rgba(0,0,0,.55);
}
.login-h1 { font-size: 21px; font-weight: 600; }
.login-sub { color: var(--txt-2); font-size: 13px; margin: 6px 0 22px; }
.login-label { display: block; font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: var(--txt-2); margin: 14px 0 6px; }
.login-field { display: flex; align-items: center; gap: 10px; background: var(--bg-1); border: 1px solid var(--line-bright); border-radius: 10px; padding: 11px 13px; color: var(--txt-2); }
.login-field:focus-within { border-color: var(--acc-dim); }
.login-field input { flex: 1; background: none; border: none; outline: none; color: var(--txt-0); font-family: var(--font-display); font-size: 14px; }
.login-link { color: var(--acc); font-size: 12.5px; cursor: pointer; }
.login-btn { width: 100%; justify-content: center; padding: 11px; font-size: 14px; margin-top: 4px; }
.login-or { display: flex; align-items: center; gap: 12px; margin: 18px 0; color: var(--txt-3); font-size: 11px; font-family: var(--font-mono); }
.login-or::before, .login-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.login-sso { justify-content: center; }
.login-foot { text-align: center; font-size: 9.5px; color: var(--txt-3); letter-spacing: .5px; margin-top: 22px; }
.mfa-row { display: flex; gap: 9px; justify-content: center; margin-top: 8px; }
.mfa-box {
  width: 48px; height: 56px; text-align: center; font-family: var(--font-mono); font-size: 22px;
  background: var(--bg-1); border: 1px solid var(--line-bright); border-radius: 11px; color: var(--txt-0); outline: none;
}
.mfa-box:focus { border-color: var(--acc); box-shadow: 0 0 0 3px var(--acc-glow); }

/* ===================== PROFILE ===================== */
.profile-ava {
  width: 88px; height: 88px; border-radius: 24px; margin: 6px auto 0;
  background: linear-gradient(135deg, var(--acc), var(--viol));
  display: grid; place-items: center; font-size: 32px; font-weight: 700; color: #04141a;
  box-shadow: 0 12px 30px rgba(34,211,238,.25);
}

/* ===================== ADMIN ===================== */
.adm-input {
  background: var(--bg-1); border: 1px solid var(--line-bright); border-radius: 8px;
  color: var(--txt-0); font-family: var(--font-display); font-size: 13px; padding: 7px 10px; outline: none;
}
.adm-input:focus { border-color: var(--acc-dim); }
select.adm-input { font-family: var(--font-mono); cursor: pointer; }
.tgl {
  width: 42px; height: 24px; border-radius: 20px; border: 1px solid var(--line-bright);
  background: var(--bg-4); cursor: pointer; position: relative; transition: background .18s, border-color .18s; padding: 0;
}
.tgl.on { background: var(--acc); border-color: var(--acc); }
.tgl-knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .18s; }
.tgl.on .tgl-knob { transform: translateX(18px); background: #04141a; }
.role-select {
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 6px;
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; padding: 4px 8px; cursor: pointer; outline: none;
}
.role-select:hover { border-color: var(--line-bright); }
.matrix-tbl td, .matrix-tbl th { white-space: nowrap; }
.matrix-cat td { background: var(--bg-1); font-family: var(--font-mono); font-size: 10px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--txt-2); padding: 7px 14px !important; }
.perm-cell {
  width: 26px; height: 26px; border-radius: 7px; border: 1px solid var(--line-bright);
  background: var(--bg-1); color: var(--txt-3); cursor: pointer; display: grid; place-items: center; transition: all .12s;
}
.perm-cell.on { background: color-mix(in srgb, currentColor 12%, transparent); }
.perm-cell.locked { cursor: not-allowed; opacity: .85; }
.perm-cell:not(.locked):hover { border-color: var(--acc-dim); }

/* ===================== CHAT PAGE ===================== */
.chat-page { display: grid; grid-template-columns: 240px 1fr; gap: 16px; height: calc(100vh - var(--topbar-h) - 44px); }
.chat-page.no-rail { grid-template-columns: 1fr; }
.chat-head .tb-btn { flex-shrink: 0; }
.chat-rail { display: flex; flex-direction: column; }
.chat-hist { display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px; cursor: pointer; transition: background .12s; }
.chat-hist:hover { background: var(--bg-2); }
.chat-rail-foot { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--line); }
.chat-surface { display: flex; flex-direction: column; overflow: hidden; }
.chat-head { display: flex; align-items: center; gap: 11px; padding: 13px 18px; border-bottom: 1px solid var(--line); }
.chat-body { flex: 1; overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; gap: 16px; }
.chat-hero { text-align: center; max-width: 720px; margin: auto; }
.chat-caps { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 26px; text-align: left; }
.chat-cap { display: flex; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg-1); cursor: pointer; transition: border-color .14s, background .14s; }
.chat-cap:hover { border-color: var(--acc-dim); background: var(--bg-3); }
.chat-input-wrap { padding: 14px 18px 16px; border-top: 1px solid var(--line); }

@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

/* ============================ MOBILE (Phase 1 shell + Phase 2 reflow) ============================ */
.topbar-menu { display: none; }
.nav-scrim { display: none; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 268px; max-width: 86vw; z-index: 1200;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.6);
    overflow-y: auto;
  }
  .app.nav-open .sidebar { transform: none; }
  .nav-scrim {
    display: block; position: fixed; inset: 0; z-index: 1150; background: rgba(0,0,0,.55);
    opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .app.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .topbar-menu { display: inline-flex; }

  .topbar { padding: 0 calc(12px + env(safe-area-inset-right)) 0 calc(12px + env(safe-area-inset-left)); gap: 8px; }
  .main { padding-left: calc(12px + env(safe-area-inset-left)); padding-right: calc(12px + env(safe-area-inset-right)); padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .global-search { display: none; }
  .page-crumb { display: none; }
  .page-title { font-size: 15px; }
  .jessi-btn span, .topbar > .chip { display: none; }

  .main { padding: 14px 12px 64px; }

  .cols-2, .cols-3 { grid-template-columns: 1fr; }
  .cols-4, .cols-5, .cols-6 { grid-template-columns: repeat(2, 1fr); }
  .grid { gap: 10px; }

  .panel-pad { padding: 12px 14px; }
  .scroll, .md-tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .tbl { min-width: 540px; }

  /* tables with data-label cells become stacked label:value cards (no side-scroll) */
  table.tbl-cards { min-width: 0; }
  .tbl-cards thead { display: none; }
  .tbl-cards, .tbl-cards tbody, .tbl-cards tr, .tbl-cards td { display: block; width: auto; }
  .tbl-cards tr { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 10px; padding: 4px 12px; background: var(--bg-1); }
  .tbl-cards td { border: none !important; padding: 7px 0; display: flex; justify-content: space-between; gap: 12px; align-items: center; }
  .tbl-cards td[data-label]::before { content: attr(data-label); color: var(--txt-3); font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; flex: 0 0 auto; }
  .tbl-cards td[data-label=""]::before { display: none; }
  .tbl-cards td[data-label="Manage"], .tbl-cards td[data-label=""] { justify-content: flex-start; flex-wrap: wrap; }

  .drawer, .jessi-panel { width: 100vw !important; max-width: 100vw !important; }
  .drawer-body, .jessi-body { padding-left: 14px; padding-right: 14px; }
  .modal-card { width: 94vw; max-width: 94vw; }
  .jessi-fab { right: 16px; bottom: 16px; }

  .btn, .tb-btn, .jessi-chip { min-height: 36px; }
  .nav-item { padding-top: 11px; padding-bottom: 11px; }
}

@media (max-width: 480px) {
  .cols-4, .cols-5, .cols-6 { grid-template-columns: 1fr; }
  .page-title { font-size: 14px; }
}
