:root {
  --bg: #f6f7f9; --panel: #ffffff; --ink: #1c2330; --muted: #5f6b7c; --line: #e2e6ec;
  --accent: #3b5bdb; --accent-ink: #ffffff; --accent-soft: #e8edfd;
  --ok: #1f7a4a; --ok-soft: #e3f4ea; --warn: #9a6200; --warn-soft: #fdf1dc;
  --bad: #b42318; --bad-soft: #fde8e6; --run: #3b5bdb; --run-soft: #e8edfd;
  --field: #ffffff; --shadow: 0 1px 2px rgba(20, 30, 50, .06), 0 2px 8px rgba(20, 30, 50, .04);
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11141a; --panel: #181c24; --ink: #e6e9ef; --muted: #98a2b3; --line: #2a303c;
    --accent: #7c9cff; --accent-ink: #0d1220; --accent-soft: #232c45;
    --ok: #5fd39a; --ok-soft: #15301f; --warn: #f2bd5c; --warn-soft: #33270f;
    --bad: #ff8a80; --bad-soft: #3a1714; --run: #9db3ff; --run-soft: #212a45;
    --field: #11141a; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11141a; --panel: #181c24; --ink: #e6e9ef; --muted: #98a2b3; --line: #2a303c;
  --accent: #7c9cff; --accent-ink: #0d1220; --accent-soft: #232c45;
  --ok: #5fd39a; --ok-soft: #15301f; --warn: #f2bd5c; --warn-soft: #33270f;
  --bad: #ff8a80; --bad-soft: #3a1714; --run: #9db3ff; --run-soft: #212a45;
  --field: #11141a; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
code, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 24px; padding: 0 20px;
  height: 52px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { color: var(--ink); font-size: 16px; white-space: nowrap; }
.brand b { color: var(--accent); }
.top nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.top nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.top nav a:hover { text-decoration: none; background: var(--bg); color: var(--ink); }
.top nav a.on { color: var(--ink); background: var(--accent-soft); }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); white-space: nowrap; }
main { max-width: 1180px; margin: 0 auto; padding: 24px 16px 80px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.card { display: flex; flex-direction: column; gap: 8px; }
.card .title { font-weight: 600; font-size: 15px; }
.card .actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; padding-top: 6px; }
.tag { display: inline-block; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: var(--bg);
  color: var(--muted); border: 1px solid var(--line); }
.tag.studio { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

button, .btn { font: inherit; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 6px 12px; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: var(--muted); text-decoration: none; }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; padding: 0; color: var(--accent); }
button:disabled { opacity: .55; cursor: default; }
button.sm, .btn.sm { padding: 3px 8px; font-size: 12px; }

label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.f .req { color: var(--bad); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--field); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 9px; width: 100%; min-width: 0; }
textarea { resize: vertical; min-height: 64px; }
textarea.big { min-height: 280px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.fields { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.fields .wide { grid-column: 1 / -1; }

.run { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 14px; }
.run + .run { margin-top: 10px; }
.run .run-head { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.run .run-head select { width: auto; min-width: 180px; }
.run .num { width: 24px; height: 24px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  display: inline-grid; place-items: center; font-size: 12px; font-weight: 700; flex: none; }
.bar { position: sticky; bottom: 0; margin-top: 16px; padding: 12px 16px; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); display: flex; gap: 10px; align-items: center; box-shadow: var(--shadow); flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; }
tr.dirty td { background: var(--warn-soft); }
.scroll { overflow-x: auto; }
td textarea { min-height: 56px; }
td.label { font-family: ui-monospace, Consolas, monospace; font-size: 12px; white-space: nowrap; }

.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.chip.APPROVED, .chip.success { background: var(--ok-soft); color: var(--ok); }
.chip.DONE { background: var(--run-soft); color: var(--run); }
.chip.PENDING, .chip.queued { background: var(--warn-soft); color: var(--warn); }
.chip.error, .chip.REJECTED { background: var(--bad-soft); color: var(--bad); }
.chip.running { background: var(--run-soft); color: var(--run); }
.chip.cancelled, .chip.none { background: var(--bg); color: var(--muted); border: 1px solid var(--line); }
.warn-line { color: var(--warn); font-size: 12px; }

.login { max-width: 360px; margin: 12vh auto 0; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--panel);
  padding: 10px 16px; border-radius: 10px; max-width: min(640px, calc(100vw - 32px)); z-index: 20; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); color: #fff; }
.pill { background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; }
.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); padding: 8px 12px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); }
details summary { cursor: pointer; color: var(--muted); }
.picklist { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.picklist label { display: flex; gap: 8px; align-items: center; padding: 6px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picklist input { width: auto; }

@media (max-width: 720px) {
  .top { gap: 10px; padding: 0 12px; }
  .who span { display: none; }
  main { padding: 16px 12px 80px; }
  .fields { grid-template-columns: 1fr; }
}

/* guided flow */
.steps { display: flex; gap: 8px; margin: 0 0 14px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 13px; }
.step .dot { width: 22px; height: 22px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); font-size: 12px; font-weight: 700; }
.step.on { color: var(--ink); border-color: var(--accent); }
.step.on .dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step.done { color: var(--ok); }
.step.done .dot { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--run-soft); border-top-color: var(--run);
  animation: spin 0.9s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation: none; } }

/* review table: keep the status picker usable next to long labels */
td.label { white-space: normal; overflow-wrap: anywhere; max-width: 240px; min-width: 140px; }
td select { min-width: 150px; }

/* voice picker */
.overlay { position: fixed; inset: 0; background: rgba(10, 14, 22, .55); z-index: 30; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(1080px, 100%); height: min(88vh, 900px);
  display: flex; flex-direction: column; gap: 10px; padding: 16px; box-shadow: 0 10px 40px rgba(0, 0, 0, .25); }
.modal-body { flex: 1; overflow: auto; margin: 0 -4px; padding: 0 4px; }
.voice-filters { align-items: flex-end; gap: 8px; }
.voice-filters label.f { flex: 1; min-width: 120px; }
.voice-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.vcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; min-height: 150px; background: var(--panel); }
.vcard.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.vdesc { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 720px) { .modal { height: 94vh; padding: 12px; } }

/* users */
.creds { border-color: var(--ok); margin-bottom: 12px; }
.creds pre { margin: 0; padding: 10px 12px; background: var(--bg); border-radius: 8px; white-space: pre-wrap; user-select: all; }

tr.group td { background: var(--bg); padding-top: 10px; }

.alert { background: var(--bad-soft); color: var(--bad); border-bottom: 1px solid var(--bad); padding: 10px 20px; font-size: 13px; }
.alert a { color: var(--bad); font-weight: 700; text-decoration: underline; }
