/* ============================================================
   Twin Lions operator console — design system (spec §12.1)
   Light, roomy, card-first: a floating sidebar card, a top bar
   card and a content panel on a cool canvas. Palette is the
   five-colour set the product owner chose — NCS blue accent,
   deep navy, Caribbean green / sunflower / paradise pink as the
   status trio. Plus Jakarta Sans for UI, Geist Mono for IDs.
   ============================================================ */

:root {
  /* Light (default) — ink-900/800/700 keep their old names as
     canvas / surface / raised so existing templates need no edits. */
  --ink-900: #E9EDF0;   /* canvas behind the cards */
  --ink-800: #FFFFFF;   /* cards, sidebar, top bar */
  --ink-700: #F1F4F6;   /* raised, row hover, input wells */
  --panel:   #F6F8F9;   /* the content panel the white cards sit on */
  --line:    #E1E6EA;   /* hairline borders */
  --text-hi: #0B2530;   /* navy-black */
  --text-lo: #62757F;

  --accent:          #118AB2;   /* NCS blue */
  --accent-hover:    #0F7DA1;
  --accent-contrast: #FFFFFF;
  --accent-dim:      #118AB214;
  --accent-deep:     #073B4C;   /* deep navy — featured card, brand tile */
  --brand-blue:      #073B4C;
  --brand-gold:      #FFD166;

  /* Status: *-fill is the raw palette colour for dots, cells and bars;
     the bare token is a darkened version that reads as text on white. */
  --live-fill: #06D6A0;  --live: #05936E;  --live-dim: #06D6A01F;
  --warn-fill: #FFD166;  --warn: #9C6A00;  --warn-dim: #FFD16640;
  --down-fill: #EF476F;  --down: #D2274F;  --down-dim: #EF476F1A;

  --shadow-card: 0 1px 2px rgba(7, 59, 76, .04), 0 10px 28px -20px rgba(7, 59, 76, .18);
  --shadow-lift: 0 16px 34px -20px rgba(17, 138, 178, .35);

  --font-ui: "Plus Jakarta Sans", "Helvetica Neue", Arial, sans-serif;
  --font-display: "Plus Jakarta Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --frame: 12px;               /* gap between canvas edge and the cards */
  --sidebar-w: 256px;
  --sidebar-w-collapsed: 80px;
  --radius: 12px;              /* controls */
  --radius-card: 20px;         /* cards, sidebar, top bar */
  --row-h: 54px;
}

[data-theme="dark"] {
  --ink-900: #071A22;
  --ink-800: #0C2530;
  --ink-700: #12313F;
  --panel:   #0A2029;
  --line:    #1B3B49;
  --text-hi: #E6F0F4;
  --text-lo: #8BA3AE;

  --accent:          #3DB3DC;
  --accent-hover:    #56C0E4;
  --accent-contrast: #05222C;
  --accent-dim:      #3DB3DC24;
  --accent-deep:     #0B4A5E;

  --live: #06D6A0;  --warn: #FFD166;  --down: #FF6B8B;
  --live-dim: #06D6A024;  --warn-dim: #FFD16624;  --down-dim: #EF476F2A;

  --shadow-card: none;
  --shadow-lift: 0 16px 34px -20px rgba(0, 0, 0, .7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--ink-900);
  color: var(--text-hi);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-dim); }

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

code, .mono {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: -0.01em;
}

/* ---------- App frame: floating sidebar card → main column ---------- */

.app {
  display: flex; gap: var(--frame);
  min-height: 100vh; padding: var(--frame);
}

.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  position: sticky; top: var(--frame);
  height: calc(100vh - var(--frame) * 2);
  overflow: hidden;
  transition: width .18s ease;
}

.sidebar-head {
  display: flex; align-items: center; gap: 12px;
  padding: 22px 20px 10px;
}
.tile {
  width: 40px; height: 40px; flex: none;
  border-radius: 12px;
  background: var(--brand-blue);
  color: var(--brand-gold);
  display: grid; place-items: center;
  font-family: var(--font-display);
  font-weight: 800; font-size: 15px; letter-spacing: -0.02em;
}
.sidebar-head .names { min-width: 0; }
.sidebar-head .app-name {
  font-size: 16px; font-weight: 700; line-height: 1.15; letter-spacing: -0.01em;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.sidebar-head .workspace {
  color: var(--text-lo); font-size: 11px; margin-top: 2px;
  text-transform: uppercase; letter-spacing: .08em; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Only the nav scrolls (head and foot stay pinned), and it scrolls without a
   visible bar — the frame is too narrow to carry one gracefully. */
.sidebar nav {
  padding: 6px 16px 10px; flex: 1; min-height: 0;
  overflow-y: auto; overflow-x: hidden;
  scrollbar-width: none;
}
.sidebar nav::-webkit-scrollbar { display: none; }

.nav-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .1em;
  color: var(--text-lo);
  padding: 22px 8px 8px;
}

.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%;
  padding: 10px 8px;
  border-radius: 10px;
  color: var(--text-lo);
  font: inherit; font-size: 15px; font-weight: 500;
  border: none; background: transparent; cursor: pointer;
  text-align: left;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--ink-700); color: var(--text-hi); text-decoration: none; }
/* Active = dark bold text, blue icon, and a bar flush with the card's left edge */
.nav-item.active { color: var(--text-hi); font-weight: 700; background: transparent; }
.nav-item.active::before {
  content: ""; position: absolute; left: -16px; top: 50%;
  width: 4px; height: 28px; transform: translateY(-50%);
  border-radius: 0 4px 4px 0; background: var(--accent);
}
.nav-item svg {
  width: 20px; height: 20px; flex: none;
  stroke-width: 1.8; color: var(--text-lo);
  transition: color .12s ease;
}
.nav-item:hover svg { color: var(--text-hi); }
.nav-item.active svg { color: var(--accent); }
.nav-item .label {
  flex: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-item .badge {
  flex: none; min-width: 22px; padding: 1px 7px; border-radius: 7px;
  background: var(--accent); color: var(--accent-contrast);
  font-size: 11px; font-weight: 700; text-align: center; line-height: 1.6;
}
.nav-item .chev {
  width: 15px; height: 15px;
  color: var(--text-lo);
  transition: transform .14s ease;
}
.nav-item .chev.open { transform: rotate(90deg); }

/* Sub-links: indented under the item, hairline guide */
.nav-sub {
  margin: 2px 0 6px 18px;
  border-left: 1px solid var(--line);
  padding-left: 10px;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-sub a {
  display: block;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-lo);
  font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub a:hover { background: var(--ink-700); color: var(--text-hi); text-decoration: none; }
.nav-sub a.active { color: var(--text-hi); font-weight: 700; }

.sidebar-foot {
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}

/* Collapsed: icon rail */
.app.collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app.collapsed .sidebar-head { justify-content: center; padding: 22px 0 10px; }
.app.collapsed .sidebar-head .names,
.app.collapsed .nav-label,
.app.collapsed .nav-item .label,
.app.collapsed .nav-item .badge,
.app.collapsed .nav-item .chev,
.app.collapsed .nav-sub { display: none; }
.app.collapsed .sidebar nav { padding: 6px 14px 10px; }
.app.collapsed .nav-item { justify-content: center; padding: 12px 0; }
.app.collapsed .nav-item.active::before { left: -14px; }
.app.collapsed .sidebar-foot .nav-item { justify-content: center; }

.main {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; gap: var(--frame);
}

/* ---------- Top bar ---------- */

.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 12px 16px 12px 18px;
}
.search {
  position: relative; flex: 1; max-width: 420px;
}
.search svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--text-lo); stroke-width: 1.8;
  pointer-events: none;
}
.search input[type=search] {
  width: 100%;
  background: var(--ink-700);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-hi);
  padding: 11px 14px 11px 42px;
  font: inherit; font-size: 14px;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.search input[type=search]::placeholder { color: var(--text-lo); }
.search input[type=search]:focus {
  outline: none; background: var(--ink-800);
  border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim);
}
.search input[type=search]::-webkit-search-cancel-button { -webkit-appearance: none; }

.topbar .spacer { flex: 1; }

/* Round icon button with an optional count badge (the "bell") */
.icon-btn {
  position: relative;
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--ink-800); color: var(--text-hi);
  transition: background .12s ease, border-color .12s ease;
}
.icon-btn:hover { background: var(--ink-700); text-decoration: none; }
.icon-btn svg { width: 19px; height: 19px; stroke-width: 1.8; }
.icon-btn .count {
  position: absolute; top: -6px; right: -6px;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--down-fill); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
  border: 2px solid var(--ink-800);
}

.who-bar {
  display: flex; align-items: center; gap: 12px;
  padding-left: 6px;
}
.who-bar .name { font-weight: 700; font-size: 14.5px; line-height: 1.2; }
.who-bar .email { color: var(--text-lo); font-size: 12.5px; }
.avatar {
  width: 40px; height: 40px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-dim); color: var(--accent);
  font-weight: 700; font-size: 15px;
  letter-spacing: -0.01em;
}
.avatar.anon { background: var(--ink-700); color: var(--text-lo); }
.avatar.sm { width: 36px; height: 36px; font-size: 14px; }
.avatar.gold { background: var(--brand-blue); color: var(--brand-gold); }

/* ---------- Content panel ---------- */

.content {
  flex: 1; min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  padding: 24px 28px 40px;
}

/* ---------- Page header ---------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  margin-bottom: 22px; gap: 20px;
}
.page-head h1 {
  font-size: 30px; font-weight: 700; margin: 0;
  letter-spacing: -0.02em; line-height: 1.1;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.page-head .sub { color: var(--text-lo); font-size: 14.5px; margin-top: 6px; }

/* ---------- Cards ---------- */

.card {
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  margin-bottom: 16px;
}
.card > h3 {
  margin: 0 0 16px; font-size: 17px; font-weight: 700; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card > h3 .pill { font-size: 12px; }
.card .hint { color: var(--text-lo); font-size: 14px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 16px;
}
.card-head h3 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.01em; }
.card.flush { padding: 8px 24px 12px; }

.two-col { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.two-col > .card { margin-bottom: 0; }
@media (max-width: 1100px) { .two-col { grid-template-columns: 1fr; } }

@media (prefers-reduced-motion: no-preference) {
  .content > * { animation: rise .32s cubic-bezier(.2,.7,.2,1) both; }
  .content > *:nth-child(2) { animation-delay: .04s; }
  .content > *:nth-child(3) { animation-delay: .08s; }
  .content > *:nth-child(4) { animation-delay: .12s; }
  .content > *:nth-child(5) { animation-delay: .16s; }
  @keyframes rise { from { opacity: 0; transform: translateY(6px); } }
}

/* ---------- Tables ---------- */

table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left; font-size: 11.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-lo);
  padding: 4px 14px 12px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.grid td {
  height: var(--row-h);
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
  white-space: nowrap;
  font-size: 14.5px;
}
table.grid tbody tr:last-child td { border-bottom: none; }
table.grid td.wrap { white-space: normal; }
table.grid tbody tr { transition: background .1s ease; }
table.grid tbody tr:hover { background: var(--ink-700); }
table.grid tbody tr:hover td:first-child { border-top-left-radius: 10px; border-bottom-left-radius: 10px; }
table.grid tbody tr:hover td:last-child { border-top-right-radius: 10px; border-bottom-right-radius: 10px; }
table.grid .num { text-align: right; font-family: var(--font-mono); font-size: 13.5px; }
td .mono { color: var(--text-lo); }

/* Rows that are being edited inline: no hover wash, the form gets its own panel */
table.grid tbody tr:has(.edit-panel):hover,
table.grid tbody tr:has(form.row):hover { background: transparent; }
table.grid td:has(.edit-panel) { padding: 8px 0; white-space: normal; height: auto; }
.edit-panel {
  background: var(--ink-800);
  border: 1px solid var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
  border-radius: 16px;
  padding: 22px 24px 18px;
  display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 0 28px;
}
@media (max-width: 1000px) { .edit-panel { grid-template-columns: 1fr; } }
.edit-panel .flash { grid-column: 1 / -1; margin: 4px 0 12px; }
.edit-panel .edit-actions {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 10px;
  padding-top: 16px; margin-top: 4px;
  border-top: 1px solid var(--line);
}

/* Customer cell: avatar + name, ID as the quiet second line */
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who .name { font-weight: 700; color: var(--text-hi); line-height: 1.25; }
.who .id { font-family: var(--font-mono); font-size: 12px; color: var(--text-lo); margin-top: 1px; }
a.who:hover { text-decoration: none; }
a.who:hover .name { color: var(--accent); }

/* ---------- Forms ---------- */

label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 11.5px; font-weight: 700;
  color: var(--text-lo); text-transform: uppercase; letter-spacing: .07em;
  margin-bottom: 6px;
}
input[type=text], input[type=number], input[type=time], input[type=date],
input[type=password], input[type=email], input[type=file], select, textarea {
  width: 100%;
  background: var(--ink-800);
  color: var(--text-hi);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 13px;
  font: inherit; font-size: 14.5px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
select {
  appearance: none; -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2362757F' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
}
textarea { resize: vertical; font-family: var(--font-ui); }
textarea.mono { font-family: var(--font-mono); font-size: 13px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
input.cell {
  width: 100px; padding: 6px 8px; font-family: var(--font-mono); font-size: 13px;
}
input.cell-time { width: 96px; padding: 6px 8px; font-family: var(--font-mono); font-size: 13px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filters select, .filters input { width: auto; min-width: 150px; }

/* ---------- Buttons: pills ---------- */

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--ink-800);
  color: var(--text-hi);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 20px;
  font: inherit; font-size: 14.5px; font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .05s ease, color .12s ease;
}
.btn:hover { border-color: var(--text-lo); background: var(--ink-700); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; stroke-width: 2.2; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
}
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--down); }
.btn.sm { padding: 7px 14px; font-size: 13px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-lo); }
.btn.ghost:hover { color: var(--text-hi); border-color: var(--line); background: var(--ink-700); }
.btn.ghost.danger:hover { color: var(--down); }
.btn.round { width: 36px; height: 36px; padding: 0; justify-content: center; }

/* ---------- Status ---------- */

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 7px; }
.dot.live { background: var(--live-fill, var(--live)); }
.dot.warn { background: var(--warn-fill, var(--warn)); }
.dot.down { background: var(--down-fill, var(--down)); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5;
}
.pill.live { background: var(--live-dim); color: var(--live); }
.pill.warn { background: var(--warn-dim); color: var(--warn); }
.pill.down { background: var(--down-dim); color: var(--down); }
.pill.neutral { background: var(--ink-700); color: var(--text-lo); }
.pill.accent { background: var(--accent-dim); color: var(--accent); }

/* ---------- Channel strip ---------- */

.strip { display: flex; flex-wrap: wrap; gap: 6px; }
.strip a.cell {
  width: 26px; height: 26px;
  border-radius: 8px;
  display: block;
  transition: transform .12s ease, box-shadow .12s ease;
}
.strip a.cell:hover { transform: scale(1.25); z-index: 1; }
.strip a.cell.live { background: var(--live-fill, var(--live)); }
.strip a.cell.live:hover { box-shadow: 0 0 0 4px var(--live-dim); }
.strip a.cell.warn { background: var(--warn-fill, var(--warn)); }
.strip a.cell.warn:hover { box-shadow: 0 0 0 4px var(--warn-dim); }
.strip a.cell.down { background: var(--down-fill, var(--down)); animation: pulse 2s ease infinite; }
.strip a.cell.down:hover { box-shadow: 0 0 0 4px var(--down-dim); }
@keyframes pulse { 50% { opacity: .55; } }
.strip-legend { display: flex; gap: 18px; margin-top: 14px; color: var(--text-lo); font-size: 13.5px; }
.channel-rows { margin-top: 18px; border-top: 1px solid var(--line); }
.channel-rows a.item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 8px; margin: 0 -8px; border-radius: 12px; color: var(--text-hi);
  border-bottom: 1px solid var(--line);
  transition: background .1s ease;
}
.channel-rows a.item:last-child { border-bottom: none; }
.channel-rows a.item:hover { background: var(--ink-700); text-decoration: none; }
.channel-rows .body { flex: 1; min-width: 0; }
.channel-rows .name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.channel-rows .sub { color: var(--text-lo); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.channel-rows .more { display: block; padding: 10px 0 0; font-size: 13px; color: var(--text-lo); }

/* ---------- Stat cards ---------- */

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 16px;
}
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 6px;
  background: var(--ink-800); border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 22px 18px; min-height: 148px;
  color: var(--text-hi);
  transition: transform .18s ease, box-shadow .18s ease;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.stat .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stat .k { color: var(--text-hi); font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.stat .v {
  font-size: 42px; font-weight: 700; line-height: 1;
  letter-spacing: -0.03em; margin: 6px 0 auto;
  font-variant-numeric: tabular-nums;
}
.stat .foot {
  display: inline-flex; align-items: center; gap: 8px; align-self: flex-start;
  margin-top: 12px; padding: 4px 10px 4px 6px; border-radius: 999px;
  background: var(--ink-700); color: var(--text-lo);
  font-size: 12.5px; font-weight: 500;
}
.stat .foot .chip {
  padding: 1px 7px; border-radius: 999px;
  background: var(--accent-dim); color: var(--accent);
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
}
.stat .foot .chip.up { background: var(--live-dim); color: var(--live); }
.stat .foot .chip.down { background: var(--down-dim); color: var(--down); }
.stat .foot .chip.warn { background: var(--warn-dim); color: var(--warn); }
.stat .go {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid var(--text-hi); color: var(--text-hi); background: transparent;
  transition: background .12s ease, transform .12s ease;
}
.stat .go svg { width: 15px; height: 15px; stroke-width: 2.2; }
.stat .go:hover { background: var(--ink-700); text-decoration: none; transform: translate(1px, -1px); }
.stat > .v + .k { color: var(--text-lo); font-size: 13px; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; }

/* The featured card: NCS blue into deep navy, the one thing the eye lands on */
.stat.featured {
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(255,255,255,.16), transparent 55%),
    linear-gradient(150deg, var(--accent) 0%, var(--accent-deep) 100%);
  border-color: transparent; color: #fff;
  box-shadow: 0 18px 36px -20px rgba(7, 59, 76, .6);
}
.stat.featured .k { color: rgba(255,255,255,.92); }
.stat.featured .v { color: #fff; }
.stat.featured .go { border-color: rgba(255,255,255,.6); color: #fff; background: rgba(255,255,255,.1); }
.stat.featured .go:hover { background: rgba(255,255,255,.22); }
.stat.featured .foot { background: rgba(255,255,255,.14); color: rgba(255,255,255,.92); }
.stat.featured .foot .chip { background: var(--brand-gold); color: #3A2A00; }

/* ---------- Recent list ---------- */

.list { display: flex; flex-direction: column; }
.list a.item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 8px; margin: 0 -8px; border-radius: 12px;
  color: var(--text-hi);
  transition: background .1s ease;
}
.list a.item:hover { background: var(--ink-700); text-decoration: none; }
.list a.item + a.item { border-top: 1px solid var(--line); }
.list .item .body { flex: 1; min-width: 0; }
.list .item .name { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list .item .sub { color: var(--text-lo); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.list .item .when { color: var(--text-lo); font-size: 12.5px; font-family: var(--font-mono); flex: none; }

/* ---------- Progress bars ---------- */

.bar {
  height: 10px; border-radius: 999px;
  background: var(--ink-700);
  overflow: hidden;
}
.bar > span {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .4s ease;
}
.bar > span.warn { background: var(--warn-fill, var(--warn)); }
.bar > span.down { background: var(--down-fill, var(--down)); }

/* ---------- Chat log ---------- */

.chat { display: flex; flex-direction: column; gap: 8px; max-width: 680px; }
.msg {
  padding: 10px 14px; border-radius: 16px;
  max-width: 78%; font-size: 15px; overflow-wrap: anywhere;
}
.msg .text { white-space: pre-wrap; }  /* line breaks live here, not in the markup */
.msg.in  { background: var(--ink-700); align-self: flex-start; border-bottom-left-radius: 6px; }
.msg.out { background: var(--accent-dim); color: var(--text-hi); align-self: flex-end; border-bottom-right-radius: 6px; }
.msg .meta {
  display: block; margin-top: 4px; text-align: right;
  color: var(--text-lo); font-size: 11.5px; font-family: var(--font-mono);
  opacity: .85;
}
.msg.note { background: transparent; border: 1px dashed var(--line); color: var(--text-lo); align-self: center; font-size: 13px; }
.msg.failed { background: var(--down-dim); border: 1px solid var(--down); }
.msg.failed .meta { color: var(--down); font-weight: 600; }

/* ---------- Misc ---------- */

.muted { color: var(--text-lo); }
.small { font-size: 13.5px; }
.right { text-align: right; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
hr.hairline { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

.flash {
  border: 1px solid var(--line); border-left: 4px solid var(--live-fill, var(--live));
  background: var(--ink-800); border-radius: var(--radius);
  padding: 12px 16px; margin-bottom: 16px; font-size: 14.5px;
}
.flash.error { border-left-color: var(--down-fill, var(--down)); }
.flash.warning { border-left-color: var(--warn-fill, var(--warn)); }

.empty {
  border: 1px dashed var(--line); border-radius: 16px;
  padding: 40px 24px; text-align: center; color: var(--text-lo);
  font-size: 14.5px;
}
.empty strong { color: var(--text-hi); display: block; margin-bottom: 6px; font-size: 16px; }

.htmx-swapping { opacity: 0; transition: opacity .12s ease; }

/* ---------- Toolbar (search + count above a table) ---------- */

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.toolbar .search { max-width: 380px; }
.toolbar .search input[type=search] { background: var(--ink-800); border-color: var(--line); }
.toolbar .count { color: var(--text-lo); font-size: 13.5px; }

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(7, 59, 76, .45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 24px;
}
.modal {
  width: 100%; max-width: 560px;
  background: var(--ink-800);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: 0 30px 70px -30px rgba(7, 59, 76, .55);
  padding: 26px 28px 24px;
}
.modal.wide { max-width: 720px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.modal-head h2 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.015em; }
.modal-head .sub { color: var(--text-lo); font-size: 14px; margin-top: 4px; }
.modal-close {
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: transparent; color: var(--text-lo);
  transition: background .12s ease, color .12s ease;
}
.modal-close:hover { background: var(--ink-700); color: var(--text-hi); }
.modal-close svg { width: 16px; height: 16px; stroke-width: 2; }
.modal .fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal .fields .span { grid-column: 1 / -1; }
@media (max-width: 640px) { .modal .fields { grid-template-columns: 1fr; } }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.dropzone {
  border: 1.5px dashed var(--line); border-radius: 14px;
  padding: 22px; text-align: center; color: var(--text-lo); font-size: 14px;
  background: var(--ink-700);
}
.dropzone input[type=file] { margin-top: 12px; background: var(--ink-800); }
[x-cloak] { display: none !important; }

/* ---------- Assistant editor ---------- */

.editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
@media (max-width: 1180px) { .editor { grid-template-columns: 1fr; } }
.editor .side { position: sticky; top: calc(var(--frame) + 82px); display: flex; flex-direction: column; gap: 16px; }
.editor .side .card { margin-bottom: 0; }

.field-help { color: var(--text-lo); font-size: 13px; margin: -8px 0 14px; line-height: 1.45; }
.field-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
label.field > .field-row > span:first-child {
  font-size: 11.5px; font-weight: 700; color: var(--text-lo);
  text-transform: uppercase; letter-spacing: .07em;
}
.field-row .counter { color: var(--text-lo); font-size: 12px; font-family: var(--font-mono); }
textarea.prompt { font-family: var(--font-ui); font-size: 14.5px; line-height: 1.55; min-height: 260px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; }
@media (max-width: 720px) { .grid-2 { grid-template-columns: 1fr; } }

/* Range slider (temperature) */
.range-wrap { padding: 4px 2px 0; }
.range-wrap .scale { display: flex; justify-content: space-between; color: var(--text-lo); font-size: 12px; margin-top: 4px; }
input[type=range] { width: 100%; accent-color: var(--accent); height: 28px; cursor: pointer; }
.field-row .val {
  font-family: var(--font-mono); font-size: 12.5px; font-weight: 600;
  background: var(--accent-dim); color: var(--accent);
  padding: 2px 8px; border-radius: 999px;
}

/* On/off switch — a POST form button, no JS needed */
.switch {
  display: inline-flex; align-items: center; gap: 10px;
  padding: 6px 14px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--ink-800); color: var(--text-hi);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.switch:hover { background: var(--ink-700); }
.switch .track {
  width: 40px; height: 24px; border-radius: 999px; position: relative; flex: none;
  background: var(--text-lo); transition: background .15s ease;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform .15s ease;
}
.switch.on .track { background: var(--live-fill, var(--live)); }
.switch.on .track::after { transform: translateX(16px); }
.switch[disabled] { cursor: default; opacity: .7; }

/* FAQ list */
.faq-list { display: flex; flex-direction: column; }
.faq { display: flex; gap: 14px; align-items: flex-start; padding: 14px 0; border-bottom: 1px solid var(--line); }
.faq:last-child { border-bottom: none; }
.faq .q { font-weight: 700; font-size: 14.5px; }
.faq .a { color: var(--text-lo); font-size: 14px; margin-top: 3px; white-space: pre-wrap; }
.faq .body { flex: 1; min-width: 0; }
.faq .actions { display: flex; gap: 4px; flex: none; opacity: 0; transition: opacity .12s ease; }
.faq:hover .actions, .faq:focus-within .actions { opacity: 1; }
.faq .edit-panel { grid-template-columns: 1fr; width: 100%; padding: 18px 20px 14px; }

/* Test panel */
.test-log { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; max-height: 52vh; overflow-y: auto; }
.test-log:empty { display: none; }
.test-log .msg { max-width: 92%; font-size: 14px; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-flex; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Login ---------- */

.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(720px 480px at 18% 8%, var(--accent-dim), transparent 62%),
    radial-gradient(520px 380px at 90% 100%, rgba(255,209,102,.14), transparent 60%),
    var(--ink-900);
}
.login-card {
  width: 392px; background: var(--ink-800);
  border: 1px solid var(--line); border-radius: 24px;
  box-shadow: var(--shadow-card);
  padding: 32px;
}
.login-card .tile { margin-bottom: 18px; }
.login-card h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 4px; }
.login-card .sub { color: var(--text-lo); font-size: 14.5px; margin-bottom: 24px; }
