:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --text: #0f172a;
  --muted: #5b6475;
  --border: #dde2ec;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --code-bg: #0f172a;
  --code-text: #e2e8f0;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1020;
    --surface: #131a2e;
    --surface-2: #1b2340;
    --text: #e6e9f2;
    --muted: #97a0b5;
    --border: #273150;
    --accent: #818cf8;
    --accent-text: #0b1020;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --code-bg: #060912;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", "Noto Sans Gujarati", "Shruti", sans-serif;
}
a { color: var(--accent); }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top));
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); text-decoration: none; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.warn { color: var(--warn); }
main { max-width: 960px; margin: 0 auto; padding: 20px 16px 48px; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 24px 0 8px; }
.sub { color: var(--muted); margin: 0 0 20px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 14px; min-height: 120px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); text-decoration: none; transition: transform .12s, border-color .12s;
}
.tile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tile .ico { font-size: 30px; line-height: 1; }
.tile b { font-size: 15px; }
.tile small { color: var(--muted); font-size: 12.5px; line-height: 1.4; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 6px; }
textarea, input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
}
textarea { min-height: 150px; resize: vertical; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 5px 12px; }
.chips input { width: auto; }
button, .btn {
  font: inherit; font-weight: 600; cursor: pointer; border: 0; border-radius: 10px;
  padding: 10px 18px; background: var(--accent); color: var(--accent-text); text-decoration: none; display: inline-block;
}
button.ghost, .btn.ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: .55; cursor: wait; }
.hint { color: var(--muted); font-size: 13px; }
.err { color: var(--err); }
.ok { color: var(--ok); }

.status { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); }
.status.done { color: var(--ok); }
.status.failed { color: var(--err); }
.status.running, .status.queued { color: var(--warn); }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { border-left: 2px solid var(--border); padding: 0 0 12px 14px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.timeline .step { font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--muted); }
.timeline .txt { white-space: pre-wrap; word-break: break-word; font-size: 14px; }
pre { background: var(--code-bg); color: var(--code-text); padding: 14px; border-radius: 10px; overflow-x: auto; font-size: 13px; margin: 0; white-space: pre; }
.prose { white-space: pre-wrap; word-break: break-word; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
th, td { border-bottom: 1px solid var(--border); padding: 7px 9px; text-align: left; vertical-align: top; }
th { background: var(--surface-2); }
.list a.item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none; }
.list .meta { color: var(--muted); font-size: 12.5px; }
.list .q { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 14px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } .tile { transition: none; } }

/* swarm step chips (from the old CommandCenter UI) */
.steps { margin-bottom: 14px; }
.step-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.step-chip.done { color: var(--ok); border-color: var(--ok); }
.step-chip.active { color: var(--accent); border-color: var(--accent); }
.step-chip.error { color: var(--err); border-color: var(--err); }

/* clients, back button, live work indicator (additions; theme tokens unchanged) */
.btn.back { font-size: 17px; padding: 11px 22px; margin-bottom: 14px; }
.ref { font-size: 12px; font-weight: 700; color: var(--accent); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; vertical-align: middle; }
h1 .ref { font-size: 15px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile.client { min-height: 0; }
.mini { display: flex; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-size: 20px; }
.stat small { color: var(--muted); font-size: 12.5px; }
.stat.pos b { color: var(--ok); }
.stat.neg b { color: var(--err); }
.took { font-weight: 500; text-transform: none; color: var(--muted); }
.timeline li.now::before { background: var(--warn); }
.pill.live { color: var(--accent); text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.pill.live[hidden] { display: none; }
.working { display: flex; align-items: center; gap: 16px; border-color: var(--accent); }
.working .timer { font-variant-numeric: tabular-nums; font-weight: 700; margin-top: 4px; }
/* spinning glossy orb: reads as "busy", never as frozen */
.orb { display: inline-block; width: 14px; height: 14px; border-radius: 50%; vertical-align: -2px; position: relative;
  background: radial-gradient(circle at 35% 30%, #fff 0 12%, var(--accent) 45%, #1e1b4b 100%);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); animation: orb-spin 1.1s linear infinite; }
.orb::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid transparent;
  border-top-color: var(--accent); border-right-color: color-mix(in srgb, var(--accent) 40%, transparent); animation: orb-spin .8s linear infinite reverse; }
.orb.big { width: 44px; height: 44px; flex: none; }
.orb.big::after { inset: -7px; border-width: 3px; }
@keyframes orb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .orb, .orb::after { animation-duration: 3s; } }

/* AI team badges (additions; theme tokens unchanged) */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; margin: 2px 4px 2px 0; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; background: var(--surface); border: 1px solid var(--border); white-space: nowrap; }
.badge small { font-weight: 500; color: var(--muted); }
.badge .sym { font-size: 13px; }
.badge.off { opacity: .4; }
.prov-groq { color: #c2410c; border-color: #fdba74; }
.prov-gemini { color: #2563eb; border-color: #93c5fd; }
.prov-deepseek { color: #4338ca; border-color: #a5b4fc; }
.prov-kimi { color: #0f766e; border-color: #5eead4; }
.prov-claude { color: #b45309; border-color: #fcd34d; }
.prov-zai { color: #334155; border-color: #cbd5e1; }
.prov-sarvam { color: #be185d; border-color: #f9a8d4; }
.prov-tool { color: var(--text); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .prov-groq { color: #fdba74; }
  :root:not([data-theme="light"]) .prov-gemini { color: #93c5fd; }
  :root:not([data-theme="light"]) .prov-deepseek { color: #a5b4fc; }
  :root:not([data-theme="light"]) .prov-kimi { color: #5eead4; }
  :root:not([data-theme="light"]) .prov-claude { color: #fcd34d; }
}
.tile-badges { margin-top: auto; padding-top: 4px; }
.tile-badges .badge small { display: none; }
.team summary { cursor: pointer; list-style: revert; }
.team-row { display: grid; grid-template-columns: minmax(120px, 170px) 1fr; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); align-items: start; }
.team-step { font-weight: 600; font-size: 14px; }
.backups { margin-top: 4px; }
.team-tools { margin-top: 12px; }
.team-tools .badge { white-space: normal; }
.now-who { margin: 4px 0; font-size: 14px; }
@media (max-width: 520px) { .team-row { grid-template-columns: 1fr; gap: 4px; } }
