:root {
  /* night-shift HQ: deep indigo walls, lamp amber, brand neons */
  --bg: #100d22;
  --bg2: #17132e;
  --ink: #1c1733;
  --paper: #fff6e3;
  --card: rgba(183, 156, 255, 0.045);
  --card-strong: rgba(183, 156, 255, 0.09);
  --line: rgba(183, 156, 255, 0.12);
  --line-strong: rgba(183, 156, 255, 0.22);
  --text: #f3f0ff;
  --muted: #9b97b8;
  --amber: #ffb347;
  --green: #3ee08f;
  --red: #ff5a5a;
  --blue: #4cc9ff;
  --pink: #ff4fa3;
  --violet: #b79cff;
  --radius: 16px;
  --display: 'Pixelify Sans', 'Silkscreen', monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Figtree, system-ui, sans-serif;
  color: var(--text);
  font-size: 14px;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(900px 520px at 6% -10%, rgba(255, 179, 71, 0.16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(255, 79, 163, 0.14), transparent 60%),
    radial-gradient(1200px 700px at 50% 120%, rgba(76, 201, 255, 0.10), transparent 60%),
    linear-gradient(rgba(183, 156, 255, 0.035) 1px, transparent 1px) 0 0 / 16px 16px,
    linear-gradient(90deg, rgba(183, 156, 255, 0.035) 1px, transparent 1px) 0 0 / 16px 16px,
    var(--bg);
  background-attachment: fixed;
}
[hidden] { display: none !important; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--blue); }
/* Touch: no blue flash when you tap, and no 300 ms wait before the tap counts. */
button, a, summary, label.switch, .agent-row, .task, .feed .item, .review-item, .proposal, #office {
  -webkit-tap-highlight-color: transparent;
}
button, a, summary, label.switch { touch-action: manipulation; }

button {
  background: var(--amber);
  color: var(--ink);
  border: 0;
  border-radius: 10px;
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: inset 0 -3px 0 rgba(120, 50, 0, 0.35), 0 6px 18px -8px rgba(255, 179, 71, 0.75);
  transition: transform 0.08s ease, filter 0.15s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.22); }
button:disabled { opacity: 0.5; cursor: default; }
button.ghost { background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid var(--line-strong); box-shadow: none; font-weight: 600; }
button.ghost:hover { background: rgba(255, 255, 255, 0.08); }
button.danger { background: rgba(239, 68, 68, 0.08); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.4); box-shadow: none; }
button.small { padding: 5px 10px; font-size: 12px; border-radius: 8px; }
input, textarea, select {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(255, 179, 71, 0.55); outline-offset: 0; border-color: transparent; }
textarea { resize: vertical; line-height: 1.45; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.eyebrow {
  font-family: Silkscreen, monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.error { color: #fca5a5; min-height: 1.2em; margin: 0; }

/* login */
.login { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: min(380px, 100%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 30px 28px;
  display: grid;
  gap: 12px;
  text-align: center;
  backdrop-filter: blur(12px);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
}
.login-card h1 { margin: 4px 0 0; font: 700 28px/1.1 var(--display); }
.login-card p { margin: 0; color: var(--muted); }
.login-art {
  width: 96px; height: 96px; margin: 0 auto; image-rendering: pixelated;
  background: radial-gradient(circle at 50% 60%, rgba(255, 179, 71, 0.3), transparent 70%);
  border-radius: 50%;
}

/* layout */
#app { max-width: 1520px; margin: 0 auto; padding: 18px 22px 40px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.top { display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 40px; height: 40px; image-rendering: pixelated; border-radius: 12px;
  background: linear-gradient(135deg, #3b2a7a, #7a1450);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.brand h1 { margin: 0; font: 700 24px/1 var(--display); letter-spacing: 0.01em; }
.brand .sub { color: var(--muted); font-size: 12px; }
.search {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px;
  padding: 0 14px; width: min(340px, 40vw);
}
.search:focus-within { border-color: rgba(255, 179, 71, 0.55); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 2; flex: none; }
.search input { border: 0; background: transparent; padding: 9px 0; }
.search input:focus { outline: none; }
.top-right { display: flex; align-items: center; gap: 10px; }
.search-toggle { display: none; }
.search-toggle svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; }
.conn { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15); }
.conn.on { background: var(--green); box-shadow: 0 0 0 3px rgba(62, 224, 143, 0.15), 0 0 12px rgba(62, 224, 143, 0.6); }

.banner {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fde68a;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
}
.banner code { background: rgba(0, 0, 0, 0.3); padding: 1px 6px; border-radius: 6px; }

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9);
}
.card::before {
  content: '';
  position: absolute; inset: 0 16px auto; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
}
.card > header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; gap: 8px; }
.cards { display: grid; grid-template-columns: 1fr 1.3fr 1fr; gap: 16px; }

.avatars { display: flex; gap: 6px; flex-wrap: wrap; min-height: 40px; }
.avatar {
  width: 38px; height: 38px; border-radius: 12px;
  background: radial-gradient(circle at 50% 30%, #342a63, #1a1535);
  border: 2px solid rgba(255, 255, 255, 0.06);
  image-rendering: pixelated; cursor: pointer; flex: none;
  transition: transform 0.12s ease;
}
.avatar:hover { transform: translateY(-2px); }
.avatar.working { border-color: var(--green); box-shadow: 0 0 14px -2px rgba(62, 224, 143, 0.75); }
.avatar.queued { border-color: var(--amber); }
.avatar.error { border-color: var(--red); }
.avatar.done { border-color: var(--blue); }
.avatar.idle { opacity: 0.55; }
#working-names { margin: 8px 0 0; }

.review-list { display: grid; gap: 6px; }
.review-item {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 7px 9px; border-radius: 10px; background: rgba(255, 79, 163, 0.08);
  border: 1px solid rgba(255, 79, 163, 0.22); cursor: pointer; font-size: 12px;
}
.review-item:hover { border-color: rgba(255, 79, 163, 0.5); }
.review-item b { font-size: 12px; }
.review-item span { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.review-empty { color: var(--muted); font-size: 12px; margin: 0; }

.chart { display: flex; align-items: flex-end; gap: 3px; height: 52px; }
.chart .bar { flex: 1; background: rgba(255, 255, 255, 0.12); border-radius: 3px 3px 1px 1px; min-height: 2px; transition: background 0.15s; }
.chart .bar:hover { background: rgba(255, 255, 255, 0.3); }
.chart .bar.err { background: linear-gradient(to top, var(--red) var(--e), rgba(255, 255, 255, 0.14) var(--e)); }
.chart .bar.today { background: linear-gradient(to top, #e08a1e, var(--amber)); box-shadow: 0 0 10px rgba(255, 179, 71, 0.55); }
.totals { display: flex; gap: 18px; margin-top: 10px; flex-wrap: wrap; }
.totals b { font: 700 20px/1.1 var(--display); display: block; }
.totals span { color: var(--muted); font-size: 11px; }

.limits { display: grid; gap: 10px; }
.meter .reset { color: var(--muted); font-size: 11px; }
.autopilot { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line-strong); display: grid; gap: 4px; }
.autopilot p { margin: 0; }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 700; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .knob {
  width: 38px; height: 22px; border-radius: 99px; background: rgba(255, 255, 255, 0.12); position: relative; flex: none;
  transition: background 0.15s; box-shadow: inset 0 0 0 1px var(--line-strong);
}
.switch .knob::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #f3f0ff; transition: transform 0.15s;
}
.switch input:checked + .knob { background: var(--green); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--amber); outline-offset: 2px; }
.switch-label { font-family: var(--display); font-size: 15px; }

.backlog { display: grid; gap: 6px; }
.backlog-item {
  display: grid; grid-template-columns: 1fr auto auto; gap: 6px; align-items: center;
  padding: 8px 10px; border-radius: 10px; font-size: 12px;
  background: rgba(255, 210, 63, 0.07); border: 1px dashed rgba(255, 210, 63, 0.35);
}
.backlog-item span { overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.order .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.meter { display: grid; gap: 4px; }
.meter .row { display: flex; justify-content: space-between; font-size: 12px; }
.meter .track { height: 7px; background: rgba(255, 255, 255, 0.08); border-radius: 99px; overflow: hidden; }
.meter .fill { height: 100%; background: linear-gradient(90deg, #1fa866, var(--green)); border-radius: 99px; }
.meter .fill.warn { background: linear-gradient(90deg, #d97706, #fbbf24); }
.meter .fill.bad { background: linear-gradient(90deg, #b91c1c, #f87171); }

/* stage */
.stage { display: block; min-width: 0; }
.office-wrap {
  background: #0c0a1c;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 40px 90px -40px rgba(0, 0, 0, 0.95), 0 0 0 1px rgba(0, 0, 0, 0.6);
}
.office-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  background: linear-gradient(180deg, #171a26, #11131c);
  border-bottom: 1px solid var(--line);
}
.onair {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  font-family: Silkscreen, monospace; font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: #ffd1d1; background: rgba(255, 90, 90, 0.12); border: 1px solid rgba(255, 90, 90, 0.4);
  padding: 3px 8px; border-radius: 6px;
}
.onair i { width: 7px; height: 7px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); animation: pulse 1.4s infinite; }

/* The LED marquee: the office's live news ticker. */
.marquee {
  position: relative; flex: 1; min-width: 0; height: 26px; overflow: hidden;
  border-radius: 6px; border: 1px solid rgba(255, 179, 71, 0.25);
  background:
    radial-gradient(circle, rgba(255, 179, 71, 0.10) 0.6px, transparent 0.8px) 0 0 / 3px 3px,
    #0b0818;
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.8);
}
.marquee::after {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, #0b0818, transparent 6%, transparent 94%, #0b0818);
}
.ticker {
  display: flex; align-items: center; height: 100%; padding: 0 12px; gap: 28px; white-space: nowrap;
  font-family: Silkscreen, monospace; font-size: 11px; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--amber); text-shadow: 0 0 6px rgba(255, 179, 71, 0.8);
}
.ticker.rolling { animation: ticker var(--dur, 30s) linear infinite; width: max-content; }
.ticker b { color: #fff3d6; font-weight: 400; }
.ticker .t-ok { color: var(--green); text-shadow: 0 0 6px rgba(62, 224, 143, 0.8); }
.ticker .t-err { color: var(--red); text-shadow: 0 0 6px rgba(255, 90, 90, 0.8); }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
.office-clock {
  flex: none; font-family: Silkscreen, monospace; font-size: 12px; color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 179, 71, 0.7);
}
.legend-tip { margin-left: auto; font-style: italic; opacity: 0.8; }
@media (prefers-reduced-motion: reduce) {
  .ticker.rolling { animation: none; }
  .onair i { animation: none; }
}
.office-scroll { padding: 10px; }
#office { width: 100%; max-width: 100%; height: auto; display: block; image-rendering: pixelated; border-radius: 10px; aspect-ratio: 37 / 24; touch-action: manipulation; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; padding: 0 14px 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }

.panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 16px;
  backdrop-filter: blur(10px);
}
.panel-head p { margin: 4px 0 0; font-size: 13px; }
.panel-head b.g { color: var(--green); }
.panel-head b.a { color: var(--amber); }

.agent-list { display: grid; gap: 4px; }
.agent-row {
  position: relative;
  display: grid; grid-template-columns: 38px 1fr auto; gap: 10px; align-items: center;
  padding: 8px 8px 8px 12px; border-radius: 12px; border: 1px solid transparent; cursor: pointer;
  background: transparent; color: var(--text); text-align: left; font-weight: 400; box-shadow: none;
}
.agent-row::before {
  content: ''; position: absolute; left: 3px; top: 12px; bottom: 12px; width: 3px; border-radius: 3px;
  background: var(--status, transparent);
}
.agent-row.working { --status: var(--green); }
.agent-row.queued { --status: var(--amber); }
.agent-row.error { --status: var(--red); }
.agent-row.done { --status: var(--blue); }
.agent-row > div { min-width: 0; }
.agent-row:hover { background: var(--card-strong); border-color: var(--line); filter: none; }
.agent-row b { display: block; font: 700 14px/1.2 var(--display); letter-spacing: 0.02em; }
.agent-row small { color: var(--muted); font-size: 11px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  font-size: 11px; padding: 3px 8px; border-radius: 99px; white-space: nowrap; font-weight: 600;
  background: rgba(148, 163, 184, 0.14); color: #cbd5e1;
}
.chip.working, .chip.running { background: rgba(62, 224, 143, 0.15); color: #8ff5c1; }
.chip.queued { background: rgba(255, 179, 71, 0.16); color: #ffd199; }
.chip.error { background: rgba(239, 68, 68, 0.15); color: #fca5a5; }
.chip.done { background: rgba(56, 189, 248, 0.15); color: #7dd3fc; }
.chip.open { background: rgba(255, 79, 163, 0.16); color: #ffa3cf; }
.chip.merged { background: rgba(168, 85, 247, 0.18); color: #d8b4fe; }
.chip.closed, .chip.cancelled { background: rgba(148, 163, 184, 0.1); color: #94a3b8; }

.agent-detail { display: grid; gap: 12px; }
.ad-head { display: flex; gap: 12px; align-items: center; }
.ad-head .avatar { width: 52px; height: 52px; border-radius: 14px; }
.ad-head h2 { margin: 0; font: 700 22px/1.1 var(--display); }
.ad-head p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.ad-head .back { margin-left: auto; }
.kv { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: rgba(0, 0, 0, 0.15); }
.kv div { padding: 8px 10px; border-bottom: 1px solid var(--line); }
.kv div:nth-child(odd) { border-right: 1px solid var(--line); }
.kv div:nth-last-child(-n+2) { border-bottom: 0; }
.kv span { display: block; font-family: Silkscreen, monospace; font-size: 9px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kv b { font-size: 13px; font-weight: 600; }
.now-doing {
  background: linear-gradient(90deg, rgba(62, 224, 143, 0.14), rgba(62, 224, 143, 0.04));
  border: 1px solid rgba(62, 224, 143, 0.3); border-radius: 12px; padding: 10px; font-size: 13px;
  display: flex; gap: 10px; align-items: center;
}
.now-doing .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); animation: pulse 1.2s infinite; flex: none; box-shadow: 0 0 10px var(--green); }
@keyframes pulse { 50% { opacity: 0.3; } }
.order { display: grid; gap: 8px; }
.order .row { display: flex; gap: 8px; }
.order select { width: auto; flex: 1; }
.hint { font-size: 11px; color: var(--muted); margin: -2px 0 0; }

.tasks { display: grid; gap: 6px; }
.task {
  border: 1px solid var(--line); border-radius: 12px; padding: 9px 10px; display: grid; gap: 6px; cursor: pointer; background: rgba(0, 0, 0, 0.18);
  transition: border-color 0.15s, background 0.15s;
}
.task:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.03); }
.task .p { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.task .m { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 11px; color: var(--muted); }

.feed #feed { display: grid; gap: 2px; }
.feed .item { display: grid; grid-template-columns: 30px 90px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 6px; border-radius: 10px; cursor: pointer; font-size: 13px; }
.feed .item:hover { background: var(--card-strong); }
.feed .item .avatar { width: 28px; height: 28px; border-radius: 8px; }
.feed .item .who { font: 700 13px var(--display); }
.feed .item .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #cbd5e1; }
.feed .item .when { color: var(--muted); font-size: 11px; white-space: nowrap; }

/* dialog */
dialog {
  width: min(780px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  background: linear-gradient(180deg, #1a1535, #120f26);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  padding: 0;
  box-shadow: 0 40px 100px -30px rgba(0, 0, 0, 0.9);
}
dialog::backdrop { background: rgba(3, 4, 8, 0.65); backdrop-filter: blur(4px); }
.dialog-inner { padding: 20px; display: grid; gap: 12px; }
.dialog-inner > header { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.dialog-inner h2 { margin: 4px 0 0; font-size: 17px; line-height: 1.4; font-weight: 700; }
.td-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.td-meta span { background: var(--card-strong); padding: 4px 8px; border-radius: 8px; }
.td-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.td-actions:empty { display: none; }
.td-summary { white-space: pre-wrap; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.55; }
.td-summary:empty { display: none; }
details summary { cursor: pointer; color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 3px; max-height: 42vh; overflow: auto; font-size: 12px; }
.log li { display: grid; grid-template-columns: 58px 1fr; gap: 8px; padding: 5px 8px; border-radius: 8px; }
.log li time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log li.tool { color: #c4b5fd; }
.log li.text { color: var(--text); white-space: pre-wrap; background: rgba(255, 255, 255, 0.035); }
.log li.status { color: #7dd3fc; }
.log li.error { color: #fca5a5; background: rgba(239, 68, 68, 0.08); }
.followup { display: flex; gap: 8px; align-items: end; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: #221c42; border: 1px solid var(--line-strong); padding: 10px 16px; border-radius: 12px; z-index: 50;
  max-width: calc(100vw - 32px); box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.9);
}

@media (max-width: 1280px) {
  .cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 1100px) {
}
@media (max-width: 640px) {
  #app { padding: 12px 16px 32px; gap: 12px; }
  .top { flex-wrap: wrap; gap: 10px; }
  .search { order: 3; width: 100%; margin: 0; }
  .top-right { margin-left: auto; }
  .cards { grid-template-columns: 1fr; }
  .office-scroll { padding: 6px; overflow-x: auto; }
  #office { width: 720px; max-width: none; }
  .feed .item { grid-template-columns: 28px 1fr auto; }
  .feed .item .who, .feed .item .when { display: none; }
  .followup { flex-direction: column; align-items: stretch; }
}

/* ---------- team strip ---------- */
.team > header { margin-bottom: 12px; }
.team #office-summary b.g { color: var(--green); }
.team #office-summary b.a { color: var(--amber); }
.team .agent-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.team .agent-row {
  grid-template-columns: 42px 1fr auto; padding: 10px 10px 10px 14px; border-radius: 14px;
  background: rgba(183, 156, 255, 0.05); border: 1px solid var(--line);
}
.team .agent-row:hover { border-color: var(--line-strong); background: var(--card-strong); }
.team .agent-row.selected { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber), 0 10px 30px -18px rgba(255, 179, 71, 0.9); }
.team .agent-row .avatar { width: 42px; height: 42px; }
.agent-row em { display: block; font-style: normal; font-size: 11px; color: var(--amber); font-weight: 600; }
.note-badge {
  position: absolute; top: -6px; right: -6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
  background: #ffd23f; color: var(--ink); font: 700 11px/20px var(--display); text-align: center;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35); transform: rotate(4deg);
}

/* ---------- agent drawer ---------- */
.drawer {
  position: fixed; top: 14px; right: 14px; bottom: 14px; width: min(440px, calc(100vw - 28px)); z-index: 40;
  background: linear-gradient(180deg, rgba(34, 27, 70, 0.97), rgba(20, 16, 42, 0.98));
  border: 1px solid var(--line-strong); border-radius: 20px; padding: 16px;
  overflow-y: auto; overscroll-behavior: contain;
  box-shadow: -30px 0 80px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(0, 0, 0, 0.5);
  transform: translateX(calc(100% + 30px)); transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
  backdrop-filter: blur(14px);
}
.drawer.open { transform: none; }
.drawer.dragging { transition: none; }
.drawer .ad-head p b { color: var(--amber); font-weight: 600; }
/* On phones the panel is a bottom sheet, so it gets a dim backdrop you can tap. */
.scrim { display: none; }

/* ---------- composer ---------- */
.composer { display: grid; gap: 8px; border-radius: 14px; }
.composer.dropping { outline: 2px dashed var(--amber); outline-offset: 4px; }
.composer-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.composer-actions select { width: auto; flex: 1; min-width: 110px; padding: 7px 10px; }
.composer-actions .send { margin-left: auto; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs:empty { display: none; }
.thumb { position: relative; margin: 0; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line-strong); background: #0b0818; display: block; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb button {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0; border-radius: 6px;
  background: rgba(10, 6, 24, 0.85); color: #fff; font-size: 14px; line-height: 20px; box-shadow: none;
}
#td-images .thumb { width: 110px; height: 80px; }

/* ---------- ideas ---------- */
.ideas { display: grid; gap: 8px; }
.idea-list { display: grid; gap: 6px; }
.idea {
  text-align: left; font-weight: 500; font-size: 12.5px; line-height: 1.35; padding: 8px 10px 8px 28px; position: relative;
  background: rgba(76, 201, 255, 0.07); color: var(--text); border: 1px solid rgba(76, 201, 255, 0.22); box-shadow: none;
}
.idea::before { content: '+'; position: absolute; left: 10px; top: 7px; color: var(--blue); font: 700 14px var(--display); }
.idea:hover { background: rgba(76, 201, 255, 0.14); filter: none; }

@media (max-width: 640px) {
  .drawer { top: auto; left: 8px; right: 8px; bottom: 8px; width: auto; height: 82vh; border-radius: 20px 20px 16px 16px; transform: translateY(calc(100% + 20px)); }
  .drawer.open { transform: none; }
  .team .agent-list { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  .drawer, .scrim { transition: none; }
}
.team .avatar.idle { opacity: 1; }

/* ---------- reviews ---------- */
.chip.rv-pending { background: rgba(76, 201, 255, 0.14); color: #9fe2ff; }
.chip.rv-ok { background: rgba(62, 224, 143, 0.16); color: #8ff5c1; }
.chip.rv-changes { background: rgba(255, 210, 63, 0.16); color: #ffe38a; }
.chip.rv-risk, .chip.rv-failed { background: rgba(255, 90, 90, 0.16); color: #ffb0b0; }
.chip.rv-unclear { background: rgba(155, 151, 184, 0.16); color: #cfcbe6; }
.td-review {
  border-radius: 12px; padding: 12px 14px; font-size: 13px; line-height: 1.55; white-space: pre-wrap;
  border: 1px solid var(--line-strong); background: var(--card);
}
.td-review b { display: block; font: 700 15px var(--display); margin-bottom: 4px; white-space: normal; }
.td-review.rv-ok { border-color: rgba(62, 224, 143, 0.45); background: rgba(62, 224, 143, 0.07); }
.td-review.rv-changes { border-color: rgba(255, 210, 63, 0.45); background: rgba(255, 210, 63, 0.06); }
.td-review.rv-risk, .td-review.rv-failed { border-color: rgba(255, 90, 90, 0.5); background: rgba(255, 90, 90, 0.07); }
.td-review.rv-pending { border-color: rgba(76, 201, 255, 0.4); background: rgba(76, 201, 255, 0.06); }
.review-prs { display: grid; gap: 6px; }

/* ---------- phone ---------- */
.bottom-nav, .sheet-handle, .zoom-btn { display: none; }

@media (max-width: 760px) {
  html { scroll-padding-top: 10px; scroll-behavior: smooth; }
  #app {
    padding: 10px max(12px, env(safe-area-inset-right)) calc(86px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    gap: 12px;
  }
  .top { gap: 10px; flex-wrap: wrap; }
  .brand .sub { display: none; }
  .brand-logo { width: 34px; height: 34px; border-radius: 10px; }
  .brand h1 { font-size: 22px; }
  /* The search box only takes a row when you ask for it with the magnifier. */
  .search-toggle { display: inline-flex; align-items: center; }
  .top-right { margin-left: auto; }
  .search { order: 3; width: 100%; margin: 0; display: none; }
  .top.searching .search { display: flex; }
  .search input { font-size: 16px; }

  .office-wrap { border-radius: 16px; }
  .office-bar { padding: 8px 10px; gap: 8px; }
  .onair { padding: 3px 6px; font-size: 0; gap: 0; }
  .onair i { width: 8px; height: 8px; }
  .office-clock { display: none; }
  .zoom-btn { display: inline-flex; flex: none; }
  .office-scroll { padding: 4px; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; max-height: 72vh; max-height: 72dvh; }
  #office { width: 100%; max-width: none; border-radius: 8px; }
  .office-scroll.zoomed #office { width: 220%; }
  .legend { padding: 4px 10px 10px; gap: 10px; font-size: 11px; }
  .legend-tip { display: none; }

  /* team as a swipeable strip */
  .team { padding: 12px; }
  .team .agent-list {
    grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: 82%;
    overflow-x: auto; scroll-snap-type: x mandatory; padding: 6px 2px 8px; gap: 10px;
  }
  .team .agent-row { scroll-snap-align: start; min-height: 64px; }

  .cards { display: flex; flex-direction: column; gap: 12px; }
  #sec-aprobar { order: 1; }
  #sec-plan { order: 2; }
  .cards > .card:not(#sec-aprobar):not(#sec-plan) { order: 3; }

  /* Two lines per item: what was asked, then who and when under it. */
  .feed .item {
    grid-template-columns: 30px minmax(0, 1fr) auto;
    grid-template-areas: 'av what chip' 'av meta chip';
    gap: 2px 10px; padding: 8px 6px; min-height: 52px;
  }
  .feed .item > :first-child { grid-area: av; }
  .feed .item .what { grid-area: what; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  .feed .item .who { grid-area: meta; justify-self: start; font-size: 11px; color: var(--muted); }
  .feed .item .when { grid-area: meta; justify-self: end; display: block; }
  .feed .item .chip { grid-area: chip; }
  .task { padding: 11px 12px; }
  .review-item { min-height: 46px; padding: 9px 10px; }

  button { min-height: 40px; }
  button.small { min-height: 34px; padding: 6px 12px; font-size: 13px; }
  textarea, input, select { font-size: 16px; }

  /* agent panel as a bottom sheet */
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%; height: 92dvh; max-height: 92dvh;
    border-radius: 22px 22px 0 0; padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
    transform: translateY(105%); z-index: 60;
  }
  .drawer.open { transform: none; box-shadow: 0 -30px 80px rgba(0, 0, 0, 0.7); }
  /* Full-width strip so you can grab the handle anywhere and drag the sheet down. */
  .sheet-handle { display: grid; place-items: center; width: 100%; height: 26px; margin: 0 0 4px; touch-action: none; cursor: grab; }
  .sheet-handle::before { content: ''; width: 44px; height: 5px; border-radius: 99px; background: var(--line-strong); }
  .kv { grid-template-columns: 1fr 1fr; }
  .composer-actions select { flex: 1 1 100%; min-width: 0; }
  .composer-actions .send { flex: 1 1 100%; margin-left: 0; min-height: 46px; font-size: 15px; }
  .idea { font-size: 13.5px; padding: 11px 12px 11px 30px; }

  /* task detail full screen */
  dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .dialog-inner { padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); }
  .dialog-inner > header {
    position: sticky; top: 0; z-index: 3; margin: -14px -14px 0; padding: 12px 14px;
    background: rgba(26, 21, 53, 0.96); border-bottom: 1px solid var(--line);
  }
  #td-followup {
    position: sticky; bottom: 0; z-index: 3;
    margin: 4px -14px calc(-20px - env(safe-area-inset-bottom));
    padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
    background: rgba(18, 15, 38, 0.96); border-top: 1px solid var(--line);
  }
  .log { max-height: none; }
  .td-actions > * { flex: 1 1 auto; }
  .td-actions button { width: 100%; }

  .bottom-nav {
    display: grid; grid-template-columns: repeat(4, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    padding: 6px max(8px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    background: rgba(16, 13, 34, 0.92); backdrop-filter: blur(14px);
    border-top: 1px solid var(--line-strong);
  }
  .bottom-nav a {
    position: relative; display: grid; align-content: center; justify-items: center; gap: 2px; padding: 6px 0; min-height: 48px;
    color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; border-radius: 12px;
  }
  .bottom-nav a.active { color: var(--amber); background: rgba(255, 179, 71, 0.08); }
  .bottom-nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  .nav-badge {
    position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--pink); color: #fff; font-size: 10px; line-height: 18px; text-align: center;
  }
  .toast { bottom: calc(90px + env(safe-area-inset-bottom)); }

  .scrim {
    display: block; position: fixed; inset: 0; z-index: 55; touch-action: none;
    background: rgba(3, 4, 8, 0.55); backdrop-filter: blur(2px);
    opacity: 0; pointer-events: none; transition: opacity 0.24s ease;
  }
  body.sheet .scrim { opacity: 1; pointer-events: auto; }
}

/* ---------- night shift, proposals, morning ---------- */
.cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
#sec-morning { order: 0; grid-column: 1 / -1; }
#sec-aprobar { order: 1; }
#sec-propuestas { order: 2; }
#sec-plan { order: 3; }
#sec-noche { order: 4; grid-column: span 2; }
.cards > .card:not([id]) { order: 5; }
@media (max-width: 1280px) { .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.morning { background: linear-gradient(135deg, rgba(255, 179, 71, 0.14), rgba(255, 79, 163, 0.08)); border-color: rgba(255, 179, 71, 0.35); }
.morning ul { margin: 6px 0 0; padding-left: 18px; }
.morning p { margin: 0 0 4px; font-size: 14px; }

.proposals { display: grid; gap: 8px; max-height: 460px; overflow-y: auto; }
.proposal { border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: grid; gap: 6px; background: rgba(0, 0, 0, 0.18); }
.proposal .head { display: flex; gap: 8px; align-items: center; }
.proposal .head .avatar { width: 26px; height: 26px; border-radius: 8px; }
.proposal .head b { font-size: 13.5px; line-height: 1.3; }
.proposal .meta { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); align-items: center; }
.proposal p { margin: 0; font-size: 12.5px; color: #d9d5ef; line-height: 1.45; }
.proposal .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.chip.imp-alto { background: rgba(255, 90, 90, 0.16); color: #ffb0b0; }
.chip.imp-medio { background: rgba(255, 179, 71, 0.16); color: #ffd199; }
.chip.imp-bajo { background: rgba(155, 151, 184, 0.16); color: #cfcbe6; }

.night-card { background: linear-gradient(180deg, rgba(40, 30, 90, 0.35), rgba(255, 255, 255, 0.02)); }
.routines { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; margin-top: 8px; }
.routine { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 8px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); }
.routine.off { opacity: 0.5; }
.routine .avatar { width: 28px; height: 28px; border-radius: 8px; }
.routine b { font-size: 12.5px; display: block; }
.routine small { font-size: 11px; color: var(--muted); display: block; }
.routine .r-acts { display: flex; gap: 4px; }
.routine .r-acts button { padding: 4px 8px; font-size: 11px; min-height: 0; }
.add-routine { margin-top: 10px; }
.add-routine summary { cursor: pointer; font-size: 12px; color: var(--amber); }
.routine-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.routine-form textarea, .routine-form button, .routine-form input[name=name] { grid-column: 1 / -1; }
.audit-form { display: flex; gap: 8px; }
.audit-form select { flex: 1; }

@media (max-width: 760px) {
  #sec-noche { grid-column: auto; }
  .routines { grid-template-columns: 1fr; }
  .routine-form { grid-template-columns: 1fr; }
  .bottom-nav { grid-template-columns: repeat(5, 1fr); }
  .proposals { max-height: none; }
}

/* ---------- notifications, dictation, memory ---------- */
.push-btn { display: inline-flex; align-items: center; gap: 6px; }
.push-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; }
.push-btn.on { color: var(--green); border-color: rgba(62, 224, 143, 0.4); }
.mic-btn.listening { color: #fff; background: rgba(255, 90, 90, 0.2); border-color: rgba(255, 90, 90, 0.6); animation: pulse 1.2s infinite; }
.notes { list-style: none; margin: 6px 0 8px; padding: 0; display: grid; gap: 4px; }
.notes li { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: start; font-size: 12.5px; line-height: 1.4; padding: 6px 8px; border-radius: 8px; background: rgba(183, 156, 255, 0.06); }
.notes li.from-david { background: rgba(255, 179, 71, 0.1); border-left: 3px solid var(--amber); }
.notes li button { padding: 0 7px; min-height: 0; font-size: 13px; line-height: 20px; }
.teach { display: flex; gap: 6px; }
.teach input { padding: 7px 10px; }
@media (max-width: 760px) {
  .push-btn span { display: none; }
}
.data-line { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ---------- incidents ---------- */
.incident {
  display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-radius: var(--radius);
  background: linear-gradient(90deg, rgba(255, 90, 90, 0.22), rgba(255, 90, 90, 0.06));
  border: 1px solid rgba(255, 90, 90, 0.55); color: #ffe1e1;
}
.incident b { display: block; font: 700 15px var(--display); }
.incident span { font-size: 13px; }
.incident .since { margin-left: auto; color: #ffb0b0; font-size: 12px; white-space: nowrap; }
.incident .siren { width: 12px; height: 12px; border-radius: 50%; background: var(--red); box-shadow: 0 0 14px var(--red); animation: pulse 0.9s infinite; flex: none; }
.vps-hook { border: 1px dashed var(--line-strong); border-radius: 12px; padding: 8px 10px; }
.vps-hook summary { cursor: pointer; font-size: 12.5px; color: var(--amber); }
.hook-conf { background: #0b0818; border-radius: 8px; padding: 8px; font-size: 11px; white-space: pre-wrap; word-break: break-all; margin: 8px 0; }
@media (max-width: 760px) { .incident { flex-wrap: wrap; } .incident .since { margin-left: 0; } }
