/* ==========================================================================
   Agency Command — control centre (v2)

   Structure of this file:
     1. Tokens              6. Ticker
     2. Reset + shell       7. Drawer
     3. Top bar             8. Everything app.js renders, restyled
     4. City stage          9. Command palette
     5. Glass HUD panels   10. Responsive: iPad, phone, reduced motion

   Colour discipline: ~70% dark neutrals, ~20% cyan family, ~10% violet/amber.
   Saturation is reserved for state. Amber means "this needs you" and is never
   spent on decoration — if everything glows, nothing glows.
   ========================================================================== */

/* ------------------------------------------------------------ 1. tokens -- */
:root {
  /* surface */
  --bg-0:        #05070E;
  --bg-1:        #0B1426;
  --glass:       rgba(10, 18, 34, 0.55);
  --glass-solid: rgba(9, 16, 30, 0.92);
  --line:        rgba(34, 211, 238, 0.18);
  --line-hot:    rgba(34, 211, 238, 0.42);
  --line-soft:   rgba(143, 163, 191, 0.13);

  /* accents */
  --cyan:      #22D3EE;
  --cyan-hot:  #00E5FF;
  --violet:    #8B5CF6;
  --blue:      #3B82F6;
  --amber:     #FF9F43;
  --red:       #FF4D5E;
  --green:     #35D39A;

  /* text */
  --txt:        #E6F1FF;
  --txt-dim:    #8FA3BF;
  --txt-faint:  #5A6E8C;

  /* aliases app.js writes inline — these must exist or its markup loses colour */
  --text-primary:   var(--txt);
  --text-secondary: var(--txt-dim);

  --sp-1: 4px; --sp-2: 8px; --sp-3: 14px; --sp-4: 22px; --sp-5: 34px;

  --r-sm: 8px; --r: 14px; --r-lg: 20px;

  --ui: 'Space Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  /* one easing family, used everywhere */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  --rail-w: 292px;
  --top-h: 56px;
  --tick-h: 40px;
}

/* -------------------------------------------------------- 2. reset/shell -- */
* { box-sizing: border-box; }
html, body { height: 100%; }
body.v2-body {
  margin: 0;
  font-family: var(--ui);
  color: var(--txt);
  background:
    radial-gradient(120% 80% at 50% -10%, rgba(34, 211, 238, 0.07), transparent 60%),
    radial-gradient(90% 70% at 50% 110%, rgba(139, 92, 246, 0.05), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 55%);
  background-attachment: fixed;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hidden { display: none !important; }
button { font: inherit; color: inherit; }
::selection { background: rgba(34, 211, 238, 0.28); }

/* Scrollbars: present, but part of the design rather than a system artefact. */
* { scrollbar-width: thin; scrollbar-color: rgba(143, 163, 191, 0.22) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(143, 163, 191, 0.20); border-radius: 99px; }
*::-webkit-scrollbar-thumb:hover { background: rgba(34, 211, 238, 0.34); }
*::-webkit-scrollbar-track { background: transparent; }

.v2-app {
  position: relative;          /* containing block for the demo banner */
  height: 100dvh;
  display: grid;
  grid-template-rows: var(--top-h) 1fr var(--tick-h);
  grid-template-columns: minmax(0, 1fr);   /* never widen to the header's max-content */
  overflow: hidden;
}

/* small tracked label — the type voice of the whole HUD */
.lbl, .p-head h2, .dc-head h3, .cc-k, .tk-k, .gauge-cap, .stat-k, .col-h, .vl,
.chart-legend-h, .route-head span, .dr-tabs button, .p-note, .kpi-u {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ------------------------------------------------------------- 3. login -- */
.v2-login {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background: radial-gradient(80% 60% at 50% 40%, rgba(34, 211, 238, 0.08), transparent 70%), var(--bg-0);
}
.v2-login-card {
  width: min(400px, 90vw); padding: 38px 34px 30px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: 0 40px 90px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  text-align: center;
  animation: rise 460ms var(--ease) both;
}
.v2-mark, .ht-mark {
  width: 40px; height: 40px; margin: 0 auto 16px;
  border-radius: 11px; display: grid; place-items: center;
  background: linear-gradient(145deg, rgba(34, 211, 238, 0.22), rgba(59, 130, 246, 0.10));
  border: 1px solid var(--line-hot);
  box-shadow: 0 0 24px rgba(34, 211, 238, 0.22);
}
.v2-mark span, .ht-mark span {
  width: 11px; height: 11px; border-radius: 3px;
  background: var(--cyan-hot); box-shadow: 0 0 14px var(--cyan-hot);
}
.v2-login-card h1 { margin: 0 0 4px; font-size: 21px; font-weight: 500; letter-spacing: -0.01em; }
.v2-login-card h1 em { font-style: normal; color: var(--cyan); }
.v2-login-card > p { margin: 0 0 24px; font-size: 12px; color: var(--txt-dim); }
.v2-field {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px; height: 44px; margin-bottom: 12px;
  background: rgba(5, 8, 16, 0.6); border: 1px solid var(--line-soft); border-radius: var(--r-sm);
  color: var(--txt-faint); transition: border-color 200ms var(--ease);
}
.v2-field:focus-within { border-color: var(--line-hot); }
.v2-field input {
  flex: 1; min-width: 0; background: none; border: 0; outline: none;
  color: var(--txt); font: 400 14px var(--ui);
}
.v2-err { margin: 12px 0 0; min-height: 16px; font-size: 12px; color: var(--red); }

.v2-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: rgba(34, 211, 238, 0.07);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background 180ms var(--ease), border-color 180ms var(--ease), transform 180ms var(--ease);
}
.v2-btn:hover { background: rgba(34, 211, 238, 0.14); border-color: var(--line-hot); }
.v2-btn:active { transform: translateY(1px); }
.v2-btn-primary {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.22), rgba(34, 211, 238, 0.10));
  border-color: var(--line-hot); color: var(--txt);
  box-shadow: 0 0 22px rgba(34, 211, 238, 0.14);
}
.v2-btn-primary:hover { background: linear-gradient(180deg, rgba(34, 211, 238, 0.32), rgba(34, 211, 238, 0.16)); }
.v2-btn-block { width: 100%; }
.btn-sm { height: 36px; padding: 0 14px; font-size: 12px; }

/* ----------------------------------------------------------- 3. top bar -- */
.hud-top {
  display: flex; align-items: center; gap: 14px;
  min-width: 0; padding: 0 16px;
  background: linear-gradient(180deg, rgba(11, 20, 38, 0.85), rgba(11, 20, 38, 0.4));
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line-soft);
  z-index: 40;
}
.ht-brand { display: flex; align-items: center; gap: 10px; }
.ht-mark { width: 28px; height: 28px; margin: 0; border-radius: 8px; }
.ht-mark span { width: 8px; height: 8px; }
.ht-names { display: flex; flex-direction: column; line-height: 1.15; }
.ht-names b { font-size: 11px; font-weight: 600; letter-spacing: 0.15em; }
.ht-names span { font-size: 9.5px; letter-spacing: 0.1em; color: var(--txt-faint); text-transform: uppercase; }

.ht-health { margin-left: 6px; padding-left: 14px; border-left: 1px solid var(--line-soft); }
.dock-status { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--txt-dim); }
.hs-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--txt-faint); flex: none; }
.hs-dot.ok { background: var(--green); box-shadow: 0 0 10px var(--green); animation: breathe 3.4s ease-in-out infinite; }
.hs-dot.busy { background: var(--amber); box-shadow: 0 0 10px var(--amber); animation: breathe 1.8s ease-in-out infinite; }
.hs-dot.warn { background: var(--red); box-shadow: 0 0 10px var(--red); animation: breathe 1.4s ease-in-out infinite; }
.dock-status.is-demo { color: var(--amber); }

.ht-spacer { flex: 1; }

.ht-search {
  display: flex; align-items: center; gap: 9px;
  height: 32px; padding: 0 10px 0 12px; min-width: 260px;
  background: rgba(5, 8, 16, 0.5); border: 1px solid var(--line-soft);
  border-radius: 99px; color: var(--txt-faint); font-size: 12px; cursor: pointer;
  transition: border-color 180ms var(--ease), color 180ms var(--ease);
}
.ht-search:hover { border-color: var(--line-hot); color: var(--txt-dim); }
.ht-search span { flex: 1; text-align: left; }
.ht-search kbd, .palette-input-wrap kbd {
  font: 500 10px var(--mono); padding: 2px 5px; border-radius: 4px;
  background: rgba(143, 163, 191, 0.12); color: var(--txt-faint);
}

.ht-clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.15; }
.ht-clock b { font: 500 14px var(--mono); letter-spacing: 0.02em; }
.ht-clock span { font-size: 9px; letter-spacing: 0.1em; color: var(--txt-faint); text-transform: uppercase; }

.ht-icon {
  position: relative; width: 32px; height: 32px; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: rgba(5, 8, 16, 0.5); border: 1px solid var(--line-soft);
  border-radius: 9px; color: var(--txt-dim);
  transition: border-color 180ms var(--ease), color 180ms var(--ease), background 180ms var(--ease);
}
.ht-icon:hover { border-color: var(--line-hot); color: var(--txt); background: rgba(34, 211, 238, 0.08); }
.ht-icon.hot { color: var(--amber); border-color: rgba(255, 159, 67, 0.45); }
.ht-badge {
  position: absolute; top: -5px; right: -5px; min-width: 16px; height: 16px;
  padding: 0 4px; border-radius: 99px; display: grid; place-items: center;
  background: var(--amber); color: #10151f; font: 700 10px var(--mono);
  box-shadow: 0 0 12px rgba(255, 159, 67, 0.55);
}
#refreshSpin { transition: transform 400ms var(--ease); }

.v2-demo {
  display: flex; align-items: center; gap: 10px;
  position: absolute; top: calc(var(--top-h) + 10px); left: var(--rail-w); right: var(--rail-w);
  z-index: 45; width: fit-content; max-width: 100%; margin: 0 auto; padding: 9px 16px;
  background: rgba(255, 159, 67, 0.10); border: 1px solid rgba(255, 159, 67, 0.4);
  border-radius: 99px; color: var(--amber); font-size: 11.5px;
  backdrop-filter: blur(14px);
  animation: rise 400ms var(--ease) both;
}
.v2-demo b { font-weight: 600; }
.v2-demo span { color: rgba(255, 200, 150, 0.86); }

/* -------------------------------------------------------- 4. city stage -- */
.hud-stage { position: relative; overflow: hidden; }
.city-stage { position: absolute; inset: 0; }
.city-mount { position: absolute; inset: 0; }
.city-canvas { display: block; width: 100%; height: 100%; }

.leader-lines { position: absolute; inset: 0; pointer-events: none; z-index: 12; }
.leader-lines polyline { fill: none; stroke: rgba(34, 211, 238, 0.30); stroke-width: 1; stroke-dasharray: 3 4; }
.leader-lines circle { fill: var(--cyan); }
.leader-lines .ll-pulse { fill: none; stroke: var(--cyan); stroke-width: 1; opacity: 0.7; animation: ping 2.6s var(--ease) infinite; }
@keyframes ping { 0% { r: 3; opacity: 0.7; } 100% { r: 13; opacity: 0; } }

.world-labels { position: absolute; inset: 0; pointer-events: none; z-index: 13; }
/* World-anchored tag: re-projected every frame so it tracks its structure
   through the orbit. DOM text, never canvas text — it stays crisp at any angle. */
.wl-tag {
  position: absolute; top: 0; left: 0;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px; white-space: nowrap;
  background: rgba(6, 11, 22, 0.72); backdrop-filter: blur(8px);
  border: 1px solid var(--line-soft); border-radius: 99px;
  font-size: 9.5px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--txt-dim);
  transition: opacity 260ms var(--ease), color 260ms var(--ease), border-color 260ms var(--ease);
}
.wl-tag .wl-dot { width: 5px; height: 5px; border-radius: 99px; background: var(--blue); flex: none; }
.wl-tag.live { color: var(--txt); border-color: var(--line); }
.wl-tag.live .wl-dot { background: var(--cyan-hot); box-shadow: 0 0 7px var(--cyan-hot); }
.wl-tag.attention { color: var(--amber); border-color: rgba(255, 159, 67, 0.4); }
.wl-tag.attention .wl-dot { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.wl-tag.error { color: var(--red); border-color: rgba(255, 77, 94, 0.35); }
.wl-tag.error .wl-dot { background: var(--red); }

.city-hover {
  position: absolute; top: 0; left: 0; z-index: 20; width: 250px;
  padding: 11px 13px; pointer-events: none;
  background: var(--glass-solid); backdrop-filter: blur(18px);
  border: 1px solid var(--line-hot); border-radius: var(--r);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.55), 0 0 26px rgba(34, 211, 238, 0.12);
  opacity: 0; transition: opacity 140ms var(--ease);
}
.city-hover.is-on { opacity: 1; }
.hv-name { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.hv-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--blue); flex: none; }
.hv-dot.live { background: var(--cyan-hot); box-shadow: 0 0 9px var(--cyan-hot); }
.hv-dot.attention { background: var(--amber); box-shadow: 0 0 9px var(--amber); }
.hv-dot.error { background: var(--red); box-shadow: 0 0 9px var(--red); }
.hv-role { margin-top: 3px; font-size: 11px; color: var(--txt-dim); line-height: 1.4; }
/* The one line that says WHY a structure is lit the way it is. */
.hv-why { margin-top: 7px; font-size: 11px; font-weight: 500; }
.hv-why.live { color: var(--cyan); }
.hv-why.attention { color: var(--amber); }
.hv-why.error { color: var(--red); }
.hv-why.idle { color: var(--txt-dim); }
.hv-stat { margin-top: 5px; font: 500 10.5px var(--mono); color: var(--txt-faint); }
.hv-hint { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--line-soft); font-size: 10px; color: var(--txt-faint); }

.city-caption {
  position: absolute; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 11; text-align: center; pointer-events: none;
  animation: rise 700ms var(--ease) 300ms both;
}
.cc-k { display: block; color: var(--cyan); opacity: 0.75; }
.cc-t { display: block; margin: 3px 0 2px; font-size: 26px; font-weight: 400; letter-spacing: -0.015em; }
.cc-s { display: block; font-size: 11px; color: var(--txt-faint); }

.city-rail {
  position: absolute; right: calc(var(--rail-w) + 26px); bottom: 22px; z-index: 14;
  display: flex; flex-direction: column; gap: 5px;
  padding: 5px; border-radius: 11px;
  background: var(--glass); backdrop-filter: blur(16px); border: 1px solid var(--line-soft);
}
.cr-btn {
  width: 30px; height: 30px; display: grid; place-items: center; cursor: pointer;
  border: 0; border-radius: 7px; background: transparent; color: var(--txt-faint);
  transition: background 160ms var(--ease), color 160ms var(--ease);
}
.cr-btn:hover { background: rgba(34, 211, 238, 0.12); color: var(--txt); }
.cr-btn.on { color: var(--cyan); background: rgba(34, 211, 238, 0.10); }

.city-legend {
  position: absolute; left: calc(var(--rail-w) + 26px); bottom: 22px; z-index: 14;
  display: flex; gap: 14px; padding: 7px 13px;
  background: var(--glass); backdrop-filter: blur(16px);
  border: 1px solid var(--line-soft); border-radius: 99px;
  font-size: 10.5px; color: var(--txt-dim);
}
.city-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 6px; height: 6px; border-radius: 99px; }
.lg.amber { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.lg.cyan  { background: var(--cyan-hot); box-shadow: 0 0 8px var(--cyan-hot); }
.lg.blue  { background: var(--blue); }
.lg.red   { background: var(--red); }

.city-fallback { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; overflow: auto; }
.cf-inner { max-width: 760px; }
.cf-inner h3 { margin: 0 0 6px; font-size: 18px; font-weight: 500; }
.cf-inner p { margin: 0 0 20px; font-size: 12.5px; color: var(--txt-dim); }
.cf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.cf-node {
  display: flex; flex-direction: column; gap: 3px; text-align: left; cursor: pointer;
  padding: 12px; border-radius: var(--r); background: var(--glass);
  border: 1px solid var(--line-soft);
}
.cf-node:hover { border-color: var(--line-hot); }
.cf-node b { font-size: 13px; font-weight: 600; }
.cf-node span:last-child { font-size: 10.5px; color: var(--txt-faint); line-height: 1.35; }
.cf-dot { width: 7px; height: 7px; border-radius: 99px; background: var(--blue); }
.cf-node.live .cf-dot { background: var(--cyan-hot); box-shadow: 0 0 8px var(--cyan-hot); }
.cf-node.attention .cf-dot { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.cf-node.error .cf-dot { background: var(--red); }

/* ------------------------------------------------------ 5. glass panels -- */
.hud-rail {
  position: absolute; top: 0; bottom: 0; width: var(--rail-w);
  padding: 16px 14px 26px; z-index: 15;
  display: flex; flex-direction: column; gap: 10px;
  overflow-y: auto; overscroll-behavior: contain;
  pointer-events: none;
  /* The rail must not become a wall between the viewer and the city. */
  mask-image: linear-gradient(180deg, transparent 0, #000 14px, #000 calc(100% - 18px), transparent 100%);
}
.hud-left { left: 0; }
.hud-right { right: 0; }
.hud-rail > * { pointer-events: auto; }

.glass {
  position: relative;
  padding: 12px 14px 13px;
  background: var(--glass);
  backdrop-filter: blur(20px) saturate(1.25);
  -webkit-backdrop-filter: blur(20px) saturate(1.25);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.34), inset 0 1px 0 rgba(255, 255, 255, 0.045);
  animation: rise 520ms var(--ease) both;
  transition: transform 220ms var(--ease), border-color 220ms var(--ease), box-shadow 220ms var(--ease);
}
.hud-rail .glass:nth-child(1) { animation-delay: 60ms; }
.hud-rail .glass:nth-child(2) { animation-delay: 130ms; }
.hud-rail .glass:nth-child(3) { animation-delay: 200ms; }
.hud-rail .glass:nth-child(4) { animation-delay: 270ms; }
.glass:hover {
  transform: translateY(-2px);
  border-color: var(--line-hot);
  box-shadow: 0 22px 52px rgba(0, 0, 0, 0.42), 0 0 30px rgba(34, 211, 238, 0.10), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.p-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.p-head h2 { margin: 0; color: var(--txt-dim); flex: 1; }
.p-dot { width: 6px; height: 6px; border-radius: 99px; background: var(--txt-faint); flex: none; }
.p-dot.ok { background: var(--green); box-shadow: 0 0 8px var(--green); }
.p-dot.warn { background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.p-note { color: var(--txt-faint); font-size: 9.5px; letter-spacing: 0.1em; max-width: 128px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: none; }

.p-kpi, .p-kpi-row { display: flex; align-items: baseline; gap: 8px; width: 100%; background: none; border: 0; padding: 0; text-align: left; }
.p-kpi.jump { cursor: pointer; }
.kpi-n { font: 300 38px var(--ui); letter-spacing: -0.03em; line-height: 1; color: var(--txt); font-variant-numeric: tabular-nums; }
.kpi-u { color: var(--txt-faint); }
.p-kpi-row .spark { flex: 1; height: 26px; }
.p-sub { margin-top: 9px; font-size: 11.5px; color: var(--txt-dim); line-height: 1.45; }
.p-gap { font-size: 11px; color: var(--txt-faint); font-style: italic; }
.p-cta {
  display: inline-flex; align-items: center; gap: 4px; margin-top: 11px;
  font-size: 11px; font-weight: 500; color: var(--cyan);
  opacity: 0; transform: translateX(-4px);
  transition: opacity 200ms var(--ease), transform 200ms var(--ease);
}
.panel-hero:hover .p-cta { opacity: 1; transform: none; }

/* The one panel allowed to raise its voice, and only when work is waiting. */
.panel-hero.is-hot { border-color: rgba(255, 159, 67, 0.42); box-shadow: 0 16px 44px rgba(0, 0, 0, 0.4), 0 0 34px rgba(255, 159, 67, 0.12); }
.panel-hero.is-hot .kpi-n { color: var(--amber); }
.panel-hero.is-hot .p-dot.warn { animation: breathe 1.9s ease-in-out infinite; }
.badge-count {
  position: absolute; top: 12px; right: 14px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px;
  display: grid; place-items: center; background: var(--amber); color: #10151f;
  font: 700 10px var(--mono);
}

.p-stat {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--line-soft);
  font-size: 11px; color: var(--txt-dim);
}
.p-stat b { font-size: 12px; color: var(--txt); }
.p-stat b.ok { color: var(--green); }

/* channel bar */
.p-chan { margin-top: 11px; }
.chan-bar { display: flex; height: 5px; border-radius: 99px; overflow: hidden; background: rgba(143, 163, 191, 0.10); }
.chan-bar i { display: block; height: 100%; }
.chan-bar i.wa, .chan-keys i.wa { background: var(--green); }
.chan-bar i.call, .chan-keys i.call { background: var(--cyan); }
.chan-bar i.oth, .chan-keys i.oth { background: var(--violet); }
.chan-keys { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 9px; font-size: 10.5px; color: var(--txt-dim); }
.chan-keys span { display: inline-flex; align-items: center; gap: 5px; }
.chan-keys i { width: 6px; height: 6px; border-radius: 2px; }
.chan-keys b { font: 500 11px var(--mono); color: var(--txt); }

/* client cards */
.client-cards { display: flex; flex-direction: column; gap: 9px; }
.client-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  padding: 11px 12px; border-radius: 11px;
  background: rgba(5, 8, 16, 0.42); border: 1px solid var(--line-soft);
  transition: border-color 180ms var(--ease), background 180ms var(--ease);
}
.client-card:hover { border-color: var(--line-hot); background: rgba(34, 211, 238, 0.06); }
/* Official logo file, drawn as-is. No filter, no tint, no mask — ever. A dark
   mark gets a light card behind it; the file itself is never touched. */
.cc-logo { display: block; height: 22px; width: auto; max-width: 130px; object-fit: contain; }
.cc-logo.plate-light { height: 26px; padding: 4px 8px; border-radius: 5px; background: #F2F6FB; }
.cc-stats { display: flex; gap: 14px; margin-top: 10px; }
.cc-stats span { display: flex; flex-direction: column; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--txt-faint); }
.cc-stats b { font: 500 17px var(--mono); color: var(--txt); letter-spacing: -0.02em; }
.cc-stats .hot b { color: var(--amber); }
.cc-mode { margin-top: 9px; font-size: 10px; color: var(--txt-dim); }
.cc-mode.err { color: var(--red); }

/* stat grid (app.js renderGauges) */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }
.stat-item { display: flex; align-items: center; gap: 8px; color: var(--txt-faint); }
.stat-body { display: flex; flex-direction: column; line-height: 1.1; }
.stat-n { font: 500 15px var(--mono); color: var(--txt); }
.stat-k { color: var(--txt-faint); font-size: 8.5px; }

/* ring gauges (app.js renderGauges) */
.gauge-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.gauge { text-align: center; }
.gauge-ring { position: relative; width: 100%; aspect-ratio: 1; max-width: 74px; margin: 0 auto; }
.gauge-ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.gauge-track { fill: none; stroke: rgba(143, 163, 191, 0.13); stroke-width: 5; }
.gauge-fill {
  fill: none; stroke-width: 5; stroke-linecap: round;
  transition: stroke-dashoffset 900ms var(--ease);
}
.gauge-fill.g-ok { stroke: var(--cyan); filter: drop-shadow(0 0 5px rgba(34, 211, 238, 0.6)); }
.gauge-fill.g-warn { stroke: var(--amber); filter: drop-shadow(0 0 5px rgba(255, 159, 67, 0.6)); }
.gauge-val {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 500 14px var(--mono); letter-spacing: -0.02em;
}
.gauge-cap { display: block; margin-top: 7px; color: var(--txt-dim); }
.gauge-sub { display: block; margin-top: 2px; font-size: 9.5px; color: var(--txt-faint); line-height: 1.3; }

/* activity chart (app.js renderActivityChart) */
.chart-wrap { display: flex; flex-direction: column; gap: 10px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chart-legend-h { display: none; }
.leg-item {
  display: inline-flex; align-items: center; gap: 5px; cursor: pointer;
  padding: 3px 8px; border-radius: 99px; font-size: 10px;
  background: rgba(5, 8, 16, 0.4); border: 1px solid var(--line-soft); color: var(--txt-dim);
  transition: opacity 180ms var(--ease), border-color 180ms var(--ease);
}
.leg-item:hover { border-color: var(--line-hot); }
.leg-item.off { opacity: 0.34; }
.leg-swatch { width: 6px; height: 6px; border-radius: 2px; flex: none; }
.leg-n { font: 500 10px var(--mono); color: var(--txt); }
.chart-stage { position: relative; height: 96px; }
.chart-stage svg { width: 100%; height: 100%; display: block; overflow: visible; }
.chart-grid-line { stroke: rgba(143, 163, 191, 0.09); stroke-width: 0.4; vector-effect: non-scaling-stroke; }
.chart-line { fill: none; stroke-width: 1.6; vector-effect: non-scaling-stroke; stroke-linejoin: round; filter: drop-shadow(0 0 4px currentColor); }
.chart-area { stroke: none; }
.chart-cursor { stroke: rgba(34, 211, 238, 0.55); stroke-width: 0.6; vector-effect: non-scaling-stroke; stroke-dasharray: 2 3; transition: opacity 140ms var(--ease); }
.chart-axis { display: flex; justify-content: space-between; margin-top: 5px; font: 400 9.5px var(--mono); color: var(--txt-faint); }
.chart-tip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 118px;
  padding: 7px 9px; border-radius: 9px;
  background: var(--glass-solid); border: 1px solid var(--line-hot);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.5);
  opacity: 0; transition: opacity 140ms var(--ease);
}
.chart-tip.is-on { opacity: 1; }
.chart-tip-d { font: 500 10px var(--mono); color: var(--cyan); margin-bottom: 4px; }
.chart-tip-r { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--txt-dim); }
.chart-tip-r b { margin-left: auto; font: 500 10.5px var(--mono); color: var(--txt); }

/* routing table (app.js renderRouting) */
/* Scrolls. The fade is the affordance — without it the clipped last row reads
   as a layout bug rather than as "there is more below". */
.route-body {
  display: flex; flex-direction: column; gap: 1px; max-height: 152px; overflow-y: auto;
  mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 22px), transparent 100%);
}
.route-head { display: none; }
.route-row {
  display: grid; grid-template-columns: 58px 1fr 1fr 26px 12px; align-items: center; gap: 6px;
  width: 100%; padding: 6px 6px; cursor: pointer; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 7px;
  font-size: 10.5px; color: var(--txt-dim);
  transition: background 150ms var(--ease), border-color 150ms var(--ease);
}
.route-row:hover { background: rgba(34, 211, 238, 0.07); border-color: var(--line); color: var(--txt); }
.route-row.sel { background: rgba(34, 211, 238, 0.12); border-color: var(--line-hot); color: var(--txt); }
.route-type { display: inline-flex; align-items: center; gap: 5px; font: 500 9px var(--mono); letter-spacing: 0.06em; color: var(--txt-faint); }
.route-dot { width: 5px; height: 5px; border-radius: 99px; background: var(--txt-faint); flex: none; }
.route-dot.live { background: var(--cyan-hot); box-shadow: 0 0 7px var(--cyan-hot); }
.route-ep { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.route-n { font: 500 10px var(--mono); text-align: right; color: var(--txt); }
.route-go { color: var(--txt-faint); display: grid; place-items: center; }

/* ---------------------------------------------------------- 6. ticker ---- */
.hud-ticker {
  display: flex; align-items: center; gap: 14px; padding: 0 16px;
  background: linear-gradient(0deg, rgba(11, 20, 38, 0.85), rgba(11, 20, 38, 0.35));
  backdrop-filter: blur(18px); border-top: 1px solid var(--line-soft);
  z-index: 30;
}
.tk-k { color: var(--cyan); flex: none; display: inline-flex; align-items: center; gap: 6px; }
.tk-k::before { content: ''; width: 5px; height: 5px; border-radius: 99px; background: var(--cyan-hot); box-shadow: 0 0 8px var(--cyan-hot); animation: breathe 2.2s ease-in-out infinite; }
.tk-track { flex: 1; display: flex; gap: 26px; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.tk-track::-webkit-scrollbar { display: none; }
.tk-item { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--txt-dim); flex: none; }
.tk-item i { width: 4px; height: 4px; border-radius: 99px; background: var(--txt-faint); }
.tk-item b { font: 500 10px var(--mono); color: var(--txt-faint); }
.tk-item.faint { color: var(--txt-faint); }
.tk-fps { font: 500 10px var(--mono); color: var(--txt-faint); flex: none; }
.tk-fps.ok { color: var(--green); }
.tk-fps.warn { color: var(--amber); }
.tk-fps.bad { color: var(--red); }

/* ---------------------------------------------------------- 7. drawer ---- */
.drawer-scrim {
  position: fixed; inset: var(--top-h) 0 0 0; z-index: 55;
  background: rgba(3, 5, 10, 0.5); backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity 300ms var(--ease);
}
.drawer-scrim.is-on { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; top: var(--top-h); right: 0; bottom: 0; z-index: 60;
  width: min(600px, 94vw);
  display: flex; flex-direction: column;
  background: linear-gradient(180deg, rgba(11, 20, 38, 0.96), rgba(6, 10, 20, 0.97));
  backdrop-filter: blur(28px) saturate(1.2);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.6);
  transform: translateX(102%);
  /* Hidden as well as translated: a closed drawer parked off the right edge
     still extended the document's horizontal extent and stayed focusable. */
  visibility: hidden;
  transition: transform 420ms var(--ease), visibility 0s linear 420ms;
}
.drawer.is-open { transform: none; visibility: visible; transition: transform 420ms var(--ease), visibility 0s; }

.dr-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.dr-title { flex: 1; min-width: 0; }
.dr-title h2 { margin: 0; font-size: 19px; font-weight: 500; letter-spacing: -0.015em; }
.dr-title p { margin: 3px 0 0; font-size: 11.5px; color: var(--txt-dim); }
.dr-close {
  width: 30px; height: 30px; flex: none; display: grid; place-items: center; cursor: pointer;
  background: rgba(5, 8, 16, 0.5); border: 1px solid var(--line-soft); border-radius: 8px; color: var(--txt-dim);
  transition: color 160ms var(--ease), border-color 160ms var(--ease);
}
.dr-close:hover { color: var(--txt); border-color: var(--line-hot); }

.dr-tabs { display: flex; gap: 4px; padding: 0 20px 12px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; scrollbar-width: none; }
.dr-tabs::-webkit-scrollbar { display: none; }
.dr-tabs button {
  padding: 7px 11px; cursor: pointer; white-space: nowrap;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: var(--txt-faint);
  transition: color 160ms var(--ease), background 160ms var(--ease), border-color 160ms var(--ease);
}
.dr-tabs button:hover { color: var(--txt-dim); background: rgba(34, 211, 238, 0.06); }
.dr-tabs button.active { color: var(--cyan); background: rgba(34, 211, 238, 0.11); border-color: var(--line); }

.dr-body { flex: 1; overflow-y: auto; padding: 18px 20px 40px; }
.workspace-view { display: none; }
.workspace-view.active { display: block; animation: rise 340ms var(--ease) both; }
.dr-stack { display: flex; flex-direction: column; gap: 14px; }

.dr-card {
  padding: 15px 16px; margin-bottom: 14px;
  background: rgba(10, 18, 34, 0.5); border: 1px solid var(--line-soft); border-radius: var(--r);
}
.dr-card:last-child { margin-bottom: 0; }
.dc-head { display: flex; align-items: center; gap: 9px; margin-bottom: 4px; }
.dc-head h3 { margin: 0; color: var(--txt-dim); flex: 1; }
.dc-sub { margin: 0 0 13px; font-size: 11.5px; color: var(--txt-faint); line-height: 1.45; }
.count-pill {
  padding: 2px 8px; border-radius: 99px; font: 500 10px var(--mono);
  background: rgba(34, 211, 238, 0.12); border: 1px solid var(--line); color: var(--cyan);
}

/* ================================================ 8. app.js output, restyled */

/* --- generic --------------------------------------------------------- */
.faint { color: var(--txt-faint); }
.mono { font-family: var(--mono); }
.state { padding: 22px 14px; text-align: center; }
.state .ico { font-size: 22px; opacity: 0.6; }
.state .t { margin-top: 8px; font-size: 13px; font-weight: 500; }
.state .d { margin-top: 4px; font-size: 11.5px; color: var(--txt-faint); line-height: 1.5; max-width: 380px; margin-inline: auto; }
.skel { background: linear-gradient(90deg, rgba(143,163,191,0.06), rgba(143,163,191,0.13), rgba(143,163,191,0.06)); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; border-radius: 7px; }
.skel-row { height: 44px; margin-bottom: 8px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px; border-radius: 99px; font-size: 10.5px; font-weight: 500;
  background: rgba(143, 163, 191, 0.10); border: 1px solid var(--line-soft); color: var(--txt-dim);
}
.chip .swatch { width: 6px; height: 6px; border-radius: 2px; background: var(--txt-faint); }
.chip.cc .swatch { background: var(--amber); }
.chip.jl .swatch { background: var(--violet); }

.badge {
  display: inline-flex; align-items: center; padding: 2px 7px; border-radius: 5px;
  font: 500 9.5px var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
  background: rgba(143, 163, 191, 0.12); color: var(--txt-dim);
}
.badge.ok { background: rgba(53, 211, 154, 0.13); color: var(--green); }
.badge.err { background: rgba(255, 77, 94, 0.13); color: var(--red); }
.badge.pending { background: rgba(255, 159, 67, 0.13); color: var(--amber); }
.badge.video { background: rgba(139, 92, 246, 0.15); color: var(--violet); }

.btn-ghost, .qapprove, .ctl-kill, .btn-copy, .filter-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; cursor: pointer; border-radius: 8px;
  font-size: 12px; font-weight: 500;
  border: 1px solid var(--line-soft); background: rgba(5, 8, 16, 0.5); color: var(--txt-dim);
  transition: background 170ms var(--ease), border-color 170ms var(--ease), color 170ms var(--ease), transform 170ms var(--ease);
}
.btn-ghost:hover, .btn-copy:hover, .filter-pill:hover { border-color: var(--line-hot); color: var(--txt); background: rgba(34, 211, 238, 0.08); }
.btn-ghost:active, .qapprove:active, .btn-copy:active { transform: translateY(1px); }
.btn-ghost:disabled, .qapprove:disabled, .ctl-kill:disabled { opacity: 0.45; cursor: default; }
.qapprove {
  background: linear-gradient(180deg, rgba(34, 211, 238, 0.24), rgba(34, 211, 238, 0.10));
  border-color: var(--line-hot); color: var(--txt); box-shadow: 0 0 20px rgba(34, 211, 238, 0.12);
}
.qapprove:hover { background: linear-gradient(180deg, rgba(34, 211, 238, 0.34), rgba(34, 211, 238, 0.16)); }
.ctl-kill { border-color: rgba(255, 77, 94, 0.42); color: var(--red); background: rgba(255, 77, 94, 0.08); }
.ctl-kill:hover { background: rgba(255, 77, 94, 0.16); }

/* --- approval queue -------------------------------------------------- */
.queue-list { display: flex; flex-direction: column; gap: 12px; }
.qitem {
  display: grid; grid-template-columns: 132px 1fr; gap: 13px;
  padding: 12px; border-radius: var(--r);
  background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft);
  animation: rise 380ms var(--ease) both;
}
/* app.js marks a video row `qblocked` when there is no clip to watch — but that
   row still has a media box. Collapsing it to one column stretched a 9:16 frame
   to the full drawer width and made the row 1043px tall. Rows WITH media keep
   two columns; the max-width is the belt-and-braces fix for browsers without
   :has(), so the frame can never balloon again. */
.qitem.qblocked, .qitem.qspend { grid-template-columns: 1fr; }
/* Today's Publishing tiles carry no media box, so one column and a state-toned
   left edge. .qnote is flex-basis:100% for the action row; tiles use .tnote. */
.qitem.today-tile { grid-template-columns: 1fr; border-left: 3px solid var(--line-soft); }
.qitem.today-tile.t-ok { border-left-color: rgba(53, 211, 154, 0.85); }
.qitem.today-tile.t-pending { border-left-color: rgba(255, 159, 67, 0.85); }
.qitem.today-tile.t-err { border-left-color: rgba(255, 77, 94, 0.85); }
.qitem.today-tile.t-faint { border-left-color: var(--line-soft); }
.today-tile .tnote { font-size: 10.5px; color: var(--txt-faint); line-height: 1.5; }
.qitem.qblocked:has(.qvid-state),
.qitem.qblocked:has(.qimg),
.qitem.qblocked:has(.qvid) { grid-template-columns: 132px 1fr; }
.qvid-state, .qmedia-missing { max-width: 132px; }
.qitem.qspend { border-color: rgba(255, 159, 67, 0.3); background: rgba(255, 159, 67, 0.045); }
.qitem.qblocked { border-color: rgba(255, 77, 94, 0.24); }
.qimg, .qvid { width: 100%; border-radius: 9px; display: block; background: #05070E; border: 1px solid var(--line-soft); }
.qvid { aspect-ratio: 9 / 16; object-fit: cover; }
.qvid-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  aspect-ratio: 9 / 16; padding: 10px; text-align: center; border-radius: 9px;
  background: rgba(5, 8, 16, 0.7); border: 1px dashed var(--line-soft);
}
.qvid-state .i { font-size: 18px; }
.qvid-state b { font-size: 11px; }
.qvid-state span { font-size: 9.5px; color: var(--txt-faint); line-height: 1.35; }
.qvid-state.err { border-color: rgba(255, 77, 94, 0.4); color: var(--red); }
.qbody { min-width: 0; }
.qhead { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.qhead b { font-size: 13px; font-weight: 600; }
.qcap { margin: 8px 0 12px; font-size: 12px; color: var(--txt-dim); line-height: 1.55; }
.qact { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.qnote { flex-basis: 100%; font-size: 10.5px; color: var(--txt-faint); line-height: 1.45; }
.qdone { font-size: 12px; color: var(--green); }
.qdone.err { color: var(--red); }

/* --- controls / ops -------------------------------------------------- */
.controls-grid { display: flex; flex-direction: column; gap: 11px; }
.ctl { padding: 13px; border-radius: 11px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); }
.ctl .qhead b { font-size: 13px; }

/* --- action log ------------------------------------------------------ */
.audit-list { display: flex; flex-direction: column; gap: 1px; max-height: 400px; overflow-y: auto; }
.audit-row {
  display: grid; grid-template-columns: 78px 108px 1fr; gap: 8px; align-items: baseline;
  padding: 8px 6px; border-bottom: 1px solid rgba(143, 163, 191, 0.07); font-size: 11px;
}
.au-ts { font: 400 10px var(--mono); color: var(--txt-faint); }
.au-action { font: 500 10px var(--mono); color: var(--cyan); overflow: hidden; text-overflow: ellipsis; }
.au-target { color: var(--txt-dim); }
.au-detail { grid-column: 3; color: var(--txt-faint); font-size: 10.5px; line-height: 1.45; }
.au-actor { display: none; }

/* --- signals --------------------------------------------------------- */
.sig { display: flex; flex-direction: column; gap: 9px; }
.sig-row { padding: 11px 12px; border-radius: 10px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); border-left-width: 2px; }
.sig-row.critical, .sig-row.high { border-left-color: var(--red); }
.sig-row.warn, .sig-row.medium { border-left-color: var(--amber); }
.sig-row.info, .sig-row.low { border-left-color: var(--cyan); }
.sig-head { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.sig-sev { font: 500 9px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--amber); }
.sig-kind { font-size: 10.5px; color: var(--txt-faint); }
.sig-when { margin-left: auto; font: 400 10px var(--mono); color: var(--txt-faint); }
.sig-msg { margin-top: 7px; font-size: 12.5px; line-height: 1.55; }
.why { margin-top: 9px; }
.why summary { cursor: pointer; font-size: 10.5px; color: var(--cyan); list-style: none; }
.why summary::-webkit-details-marker { display: none; }
.why summary::before { content: '▸ '; }
.why[open] summary::before { content: '▾ '; }
.why-body { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.ev { padding: 9px 10px; border-radius: 8px; background: rgba(5, 8, 16, 0.55); font-size: 11.5px; color: var(--txt-dim); line-height: 1.55; }
.ev .src { font: 500 9px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--txt-faint); margin-bottom: 4px; }

/* --- flow list / detail ---------------------------------------------- */
.flow-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.nlink {
  width: 100%; text-align: left; cursor: pointer; padding: 9px 11px; border-radius: 9px;
  background: rgba(5, 8, 16, 0.42); border: 1px solid var(--line-soft);
  transition: border-color 160ms var(--ease), background 160ms var(--ease);
}
.nlink:hover { border-color: var(--line-hot); background: rgba(34, 211, 238, 0.06); }
.nlink.sel { border-color: var(--line-hot); background: rgba(34, 211, 238, 0.12); }
.nlink.dormant { opacity: 0.55; }
.nl-path { font-size: 12px; font-weight: 500; }
.nl-sig { margin-top: 3px; font-size: 10.5px; color: var(--txt-faint); }
.nlink.live .nl-sig { color: var(--cyan); }

.flow-detail { padding: 12px; border-radius: 11px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); }
.fd-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 9px; margin-bottom: 10px; }
.fd-path { font-size: 13px; font-weight: 600; }
.fd-what { font-size: 11px; color: var(--txt-dim); }
.fd-meta { margin-left: auto; font: 400 10px var(--mono); color: var(--cyan); }
.fd-item { display: grid; grid-template-columns: 92px 1fr; gap: 9px; padding: 7px 0; border-top: 1px solid rgba(143, 163, 191, 0.07); font-size: 11.5px; }
.fd-item .ts { font: 400 10px var(--mono); color: var(--txt-faint); }
.fd-item .tx { color: var(--txt-dim); line-height: 1.5; }
.fd-empty { font-size: 11.5px; color: var(--txt-faint); font-style: italic; }
.fd-src { margin-top: 10px; padding-top: 8px; border-top: 1px solid rgba(143, 163, 191, 0.07); font: 400 9.5px var(--mono); color: var(--txt-faint); }

/* --- creative intelligence ------------------------------------------- */
.csums { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 13px; }
.csum { display: inline-flex; align-items: center; gap: 7px; font-size: 11px; color: var(--txt-dim); }
.cyc { padding: 12px; margin-bottom: 11px; border-radius: 11px; background: rgba(5, 8, 16, 0.42); border: 1px solid var(--line-soft); }
.cyc-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 11px; }
.cyc-title { font-size: 12px; font-weight: 500; }
.cyc-when { margin-left: auto; font: 400 10px var(--mono); color: var(--txt-faint); }
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 9px; }
.vcard { padding: 10px; border-radius: 9px; background: rgba(5, 8, 16, 0.55); border: 1px solid var(--line-soft); }
.vcard.win { border-color: rgba(53, 211, 154, 0.45); background: rgba(53, 211, 154, 0.06); }
.vl { color: var(--txt-faint); }
.vcard.win .vl { color: var(--green); }
.vh { margin: 6px 0 4px; font-size: 12px; font-weight: 500; line-height: 1.45; }
.va { font-size: 10.5px; color: var(--txt-dim); }
.vwhere { margin-top: 5px; font: 400 9.5px var(--mono); color: var(--txt-faint); }
.vm { margin-top: 7px; font-size: 10.5px; color: var(--txt-dim); }
.vnum { font: 500 13px var(--mono); color: var(--cyan); }
.vrail { height: 2px; margin-top: 9px; border-radius: 99px; background: rgba(143, 163, 191, 0.14); }
.vstage { margin-top: 7px; font-size: 10px; color: var(--txt-faint); line-height: 1.45; }
.cyc-win { margin-top: 11px; padding-top: 10px; border-top: 1px solid rgba(143, 163, 191, 0.09); font-size: 11.5px; color: var(--txt-dim); line-height: 1.55; }

/* --- critique -------------------------------------------------------- */
.crit { display: flex; flex-direction: column; gap: 9px; }
.crow { padding: 11px 12px; border-radius: 10px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); border-left-width: 2px; }
.crow.blocked { border-left-color: var(--red); }
.crow.review { border-left-color: var(--cyan); }
.chain { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; font-size: 11px; }
.chain .who { font-weight: 600; }
.chain .arw { color: var(--txt-faint); }
.cwhen { margin-left: auto; font: 400 10px var(--mono); color: var(--txt-faint); }
.ck { margin-top: 7px; font: 500 9.5px var(--mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--cyan); }
.cw { margin-top: 5px; font-size: 12px; line-height: 1.55; color: var(--txt-dim); }
.co { margin-top: 6px; font-size: 10.5px; color: var(--txt-faint); line-height: 1.5; }

/* --- mini grid / plans / studio -------------------------------------- */
.mini-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.mini { padding: 12px; border-radius: 11px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); }
.mini .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--txt-faint); }
.mini .v { margin-top: 6px; font: 400 24px var(--mono); letter-spacing: -0.03em; }
.mini .sub { margin-top: 4px; font-size: 10.5px; color: var(--txt-faint); line-height: 1.45; }

/* --- funnel tiles ---------------------------------------------------- */
.tiles-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 9px; }
.tile { padding: 12px; border-radius: 10px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); text-align: center; }
.tile b { display: block; font: 400 24px var(--mono); letter-spacing: -0.03em; }
.tile span { display: block; margin-top: 3px; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--txt-faint); }
.tile.accent { border-color: var(--line-hot); background: rgba(34, 211, 238, 0.07); }
.tile.accent b { color: var(--cyan); }
.tile.teal b { color: var(--green); }
.tile.chan { grid-column: 1 / -1; text-align: left; }
.tile.chan > span { margin-bottom: 8px; }

/* --- kanban boards --------------------------------------------------- */
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.col { min-width: 0; }
.col-h { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 0 2px 8px; color: var(--txt-faint); }
.col-h .n { font: 500 10px var(--mono); color: var(--txt-dim); }
.post { padding: 9px; margin-bottom: 7px; border-radius: 9px; background: rgba(5, 8, 16, 0.5); border: 1px solid var(--line-soft); }
.post b { font-size: 11.5px; }
.post .m { margin-top: 3px; font-size: 9.5px; color: var(--txt-faint); }
.post .cap { margin-top: 6px; font-size: 10.5px; color: var(--txt-dim); line-height: 1.45; }
.post .badges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.col-empty { padding: 14px 0; text-align: center; color: var(--txt-faint); font-size: 11px; }

/* --- ads log --------------------------------------------------------- */
.ads-log { margin-top: 13px; display: flex; flex-direction: column; gap: 2px; }
.logline { display: grid; grid-template-columns: 10px 74px 1fr; gap: 8px; align-items: baseline; padding: 8px 0; border-top: 1px solid rgba(143, 163, 191, 0.07); font-size: 11px; }
.logline .dot { width: 5px; height: 5px; margin-top: 5px; border-radius: 99px; background: var(--txt-faint); }
.logline.pending_approval .dot { background: var(--amber); box-shadow: 0 0 7px var(--amber); }
.logline.blocked .dot { background: var(--red); }
.logline .lt { font: 400 10px var(--mono); color: var(--txt-faint); }
.logline .lc b { font-size: 11.5px; margin-right: 6px; }

/* --- chat ------------------------------------------------------------ */
.chat-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 11px; }
.chat-tabs button {
  padding: 5px 10px; cursor: pointer; border-radius: 99px; font-size: 11px;
  background: rgba(5, 8, 16, 0.5); border: 1px solid var(--line-soft); color: var(--txt-dim);
  transition: all 160ms var(--ease);
}
.chat-tabs button:hover { border-color: var(--line-hot); color: var(--txt); }
.chat-tabs button.active { background: rgba(34, 211, 238, 0.14); border-color: var(--line-hot); color: var(--cyan); }
.chat-tabs button.jl.active { background: rgba(139, 92, 246, 0.16); border-color: rgba(139, 92, 246, 0.45); color: var(--violet); }
.chat-log {
  height: 260px; overflow-y: auto; padding: 12px; margin-bottom: 10px;
  display: flex; flex-direction: column; gap: 9px;
  border-radius: 11px; background: rgba(3, 5, 10, 0.5); border: 1px solid var(--line-soft);
}
.msg { max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; animation: rise 260ms var(--ease) both; }
.msg.ai { align-self: flex-start; background: rgba(34, 211, 238, 0.08); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: rgba(139, 92, 246, 0.14); border: 1px solid rgba(139, 92, 246, 0.3); border-bottom-right-radius: 4px; }
.msg.sys { align-self: center; max-width: 100%; background: none; color: var(--txt-faint); font-size: 11px; padding: 4px; }
.typing { display: inline-flex; gap: 4px; }
.typing i { width: 5px; height: 5px; border-radius: 99px; background: var(--cyan); animation: bounce 1.2s ease-in-out infinite; }
.typing i:nth-child(2) { animation-delay: 0.16s; }
.typing i:nth-child(3) { animation-delay: 0.32s; }
@keyframes bounce { 0%, 60%, 100% { opacity: 0.3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }

.composer { display: flex; gap: 8px; align-items: stretch; }
.composer-in-wrap { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; }
.composer-in-wrap input {
  width: 100%; height: 36px; padding: 0 54px 0 13px;
  background: rgba(3, 5, 10, 0.6); border: 1px solid var(--line-soft); border-radius: 8px;
  color: var(--txt); font: 400 12.5px var(--ui); outline: none;
  transition: border-color 180ms var(--ease);
}
.composer-in-wrap input:focus { border-color: var(--line-hot); }
.char-count { position: absolute; right: 10px; font: 400 9.5px var(--mono); color: var(--txt-faint); pointer-events: none; }
/* v1's .btn-primary is width:100% for the login form; inside a flex row that
   collapses the input. Scoped away here. */
.composer .btn-primary { width: auto; flex: none; }

/* --- video prompts --------------------------------------------------- */
.prompt-controls-wrap { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.prompt-search-wrap { position: relative; flex: 1; min-width: 160px; display: flex; align-items: center; }
.search-ico { position: absolute; left: 11px; color: var(--txt-faint); }
.prompt-search-in {
  width: 100%; height: 34px; padding: 0 12px 0 32px;
  background: rgba(3, 5, 10, 0.6); border: 1px solid var(--line-soft); border-radius: 8px;
  color: var(--txt); font: 400 12px var(--ui); outline: none;
}
.prompt-search-in:focus { border-color: var(--line-hot); }
.prompt-filter-bar { display: flex; gap: 5px; }
.filter-pill { height: 34px; padding: 0 11px; font-size: 11px; border-radius: 99px; }
.filter-pill.active { background: rgba(34, 211, 238, 0.14); border-color: var(--line-hot); color: var(--cyan); }

.prompts-grid { display: flex; flex-direction: column; gap: 11px; }
.prompt-card { padding: 13px; border-radius: 11px; background: rgba(5, 8, 16, 0.45); border: 1px solid var(--line-soft); }
.prompt-card-head { display: flex; align-items: center; gap: 9px; margin-bottom: 9px; }
.prompt-post-title { flex: 1; font-size: 12.5px; font-weight: 600; }
.prompt-text-wrap { max-height: 168px; overflow-y: auto; border-radius: 8px; background: rgba(3, 5, 10, 0.6); border: 1px solid var(--line-soft); }
.prompt-text { margin: 0; padding: 11px; font: 400 10.5px/1.65 var(--mono); color: var(--txt-dim); white-space: pre-wrap; word-break: break-word; }
.prompt-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 9px 0; font-size: 10.5px; color: var(--txt-faint); }
.btn-copy { width: 100%; }
.btn-copy.copied { border-color: rgba(53, 211, 154, 0.5); color: var(--green); background: rgba(53, 211, 154, 0.10); }

/* ------------------------------------------------------- 9. palette ------ */
.palette-modal { border: 0; padding: 0; background: transparent; max-width: 100vw; max-height: 100vh; }
.palette-modal::backdrop { background: rgba(3, 5, 10, 0.72); backdrop-filter: blur(6px); }
.palette-modal[open] { display: block; }
.palette-card {
  width: min(600px, 92vw); margin: 12vh auto 0;
  background: var(--glass-solid); backdrop-filter: blur(28px);
  border: 1px solid var(--line-hot); border-radius: var(--r-lg);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7), 0 0 50px rgba(34, 211, 238, 0.1);
  overflow: hidden; animation: rise 300ms var(--ease) both;
}
.palette-input-wrap { display: flex; align-items: center; gap: 11px; padding: 15px 17px; border-bottom: 1px solid var(--line-soft); color: var(--txt-faint); }
.palette-input-wrap input { flex: 1; background: none; border: 0; outline: none; color: var(--txt); font: 400 15px var(--ui); }
.palette-results { max-height: 54vh; overflow-y: auto; padding: 7px; }
.palette-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  padding: 9px 11px; border-radius: 9px; background: transparent; border: 1px solid transparent;
  transition: background 140ms var(--ease);
}
.palette-item:hover { background: rgba(34, 211, 238, 0.09); }
.palette-item.on { background: rgba(34, 211, 238, 0.12); border-color: var(--line); }
.pk { font: 500 9px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--txt-faint); flex: none; }
.pt { font-size: 12.5px; }
.pq { padding: 12px 15px 6px; font-size: 12.5px; color: var(--cyan); }
.pans { padding: 0 15px 15px; font-size: 12.5px; line-height: 1.65; color: var(--txt-dim); white-space: pre-wrap; }

/* -------------------------------------------------- 10. motion + responsive */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.42; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* iPad: reduced effects, rails narrow, city keeps the centre. */
@media (max-width: 1280px) {
  :root { --rail-w: 244px; }
  .glass { backdrop-filter: blur(12px); }
  .city-caption { display: none; }
  .city-legend { left: calc(var(--rail-w) + 12px); bottom: 12px; font-size: 9.5px; gap: 10px; }
  .city-rail { right: calc(var(--rail-w) + 12px); bottom: 12px; }
  .leader-lines { display: none; }
  .v2-demo { border-radius: 12px; }
  .gauge-cap { letter-spacing: 0.06em; font-size: 9px; }
}

/* Phone: no canvas, no rails — the same panels, stacked and scrollable. */
@media (max-width: 859px) {
  .v2-app { grid-template-rows: var(--top-h) 1fr auto; overflow: visible; overflow-x: clip; }
  .hud-stage { display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
  .city-stage { position: relative; inset: auto; order: 1; }
  .city-stage.is-flat .city-mount { display: none; }
  .hud-rail {
    position: static; width: 100%; max-width: 100%; padding: 12px;
    mask-image: none; flex-direction: column; overflow: visible;
  }
  .hud-left { order: 2; }
  .hud-right { order: 3; }
  .v2-demo {
    position: static; left: auto; right: auto; width: auto; margin: 8px 12px 0;
    border-radius: 12px; align-items: flex-start;
  }
  .city-rail, .city-legend, .city-caption, .leader-lines { display: none; }
  .gauge-row { grid-template-columns: repeat(3, 1fr); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  /* The fallback is the page on a phone, not an overlay on a canvas. */
  .city-fallback { position: static; display: block; padding: 12px; }
  .cf-grid { grid-template-columns: 1fr 1fr; }
  .drawer { width: 100vw; }
  .hud-top { gap: 8px; padding: 0 10px; }
  .ht-brand, .ht-health { min-width: 0; }
  .ht-names b { font-size: 10px; }
  .ht-health { margin-left: 0; padding-left: 8px; }
  .ht-search { min-width: 0; flex: none; width: 32px; padding: 0; justify-content: center; }
  /* The status line is already said by the dot and, when it matters, by the
     sample-data banner. On a phone it is the first thing that can go. */
  .ht-search span, .ht-search kbd, .ht-names span, .ht-clock, #stamp { display: none; }
  .qitem { grid-template-columns: 1fr; }
  .board { grid-template-columns: 1fr 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}


/* Approval media that failed to load. The row still shows its caption and its
   buttons — the creative is what is missing, not the decision. */
.qimg.is-broken, .qmedia-missing {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  aspect-ratio: 4 / 5; padding: 10px; text-align: center;
  border-radius: 9px; background: rgba(5, 8, 16, 0.7); border: 1px dashed var(--line-soft);
  font-size: 10px; color: var(--txt-faint); line-height: 1.4;
}
.qmedia-missing b { display: block; font-size: 11px; color: var(--txt-dim); }


/* Execution-feed readout. An unreadable feed is a finding, not a blank. */
#opsFeedState.ok { color: var(--green); }
#opsFeedState.err { color: var(--red); }
#panelHealth.feed-off { border-color: rgba(255, 159, 67, 0.34); }
#panelHealth.feed-off #opsFeedState { color: var(--amber); }
#panelHealth.is-failing { border-color: rgba(255, 77, 94, 0.42); box-shadow: 0 16px 44px rgba(0,0,0,0.4), 0 0 30px rgba(255, 77, 94, 0.10); }

/* ------------------------------------------------------------ KILL SWITCH --
   The one control that stops every automatic Facebook post. It is deliberately
   the loudest thing in the publishing card when it is engaged: a stopped agency
   must never be mistaken for a quiet one. */
.kill-switch {
  display: flex; flex-direction: column; gap: 6px;
  padding: 12px 14px; margin-bottom: 12px;
  border-radius: var(--r); border: 1px solid var(--line-soft);
  background: rgba(5, 8, 16, 0.5);
}
.kill-switch.is-paused { border-color: rgba(255, 77, 94, 0.42); background: rgba(255, 77, 94, 0.07); }
.kill-switch.is-live { border-color: rgba(53, 211, 154, 0.3); }
.ks-state { display: flex; align-items: center; gap: 8px; }
.ks-state b { font-size: 12.5px; letter-spacing: 0.08em; color: var(--txt); }
.kill-switch.is-paused .ks-state b { color: rgba(255, 122, 134, 0.98); }
.ks-lamp { width: 8px; height: 8px; border-radius: 50%; background: rgba(53, 211, 154, 0.9); flex: none; }
.kill-switch.is-paused .ks-lamp { background: rgba(255, 77, 94, 0.95); animation: ksPulse 1.8s ease-in-out infinite; }
@keyframes ksPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.ks-detail { font-size: 11px; color: var(--txt-faint); line-height: 1.5; }
.ks-act { margin-top: 4px; }
.ks-btn {
  font-family: inherit; font-size: 11.5px; font-weight: 600; letter-spacing: 0.02em;
  padding: 7px 13px; border-radius: 7px; cursor: pointer;
  border: 1px solid var(--line-soft); background: rgba(255, 255, 255, 0.05); color: var(--txt);
  transition: background-color 140ms ease, border-color 140ms ease;
}
.ks-btn:hover:not(:disabled) { background: rgba(255, 255, 255, 0.09); }
.ks-btn:disabled { opacity: 0.6; cursor: default; }
.ks-stop { border-color: rgba(255, 77, 94, 0.45); color: rgba(255, 138, 148, 0.98); }
.ks-stop:hover:not(:disabled) { background: rgba(255, 77, 94, 0.14); }
.ks-resume { border-color: rgba(53, 211, 154, 0.4); color: rgba(94, 224, 176, 0.98); }
.ks-resume:hover:not(:disabled) { background: rgba(53, 211, 154, 0.12); }
.p-dot.err { background: rgba(255, 77, 94, 0.95); box-shadow: 0 0 8px rgba(255, 77, 94, 0.5); }
