:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dde1e7;
  --text: #16191d;
  --muted: #5c6673;
  --accent: #2456d6;
  --accent-text: #ffffff;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);

  --s-running: #1d4ed8;
  --s-paused: #475569;
  --s-blocked: #b45309;
  --s-done: #15803d;
  --s-stopped: #64748b;
  --s-failed: #b91c1c;
  --radius: 10px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e232b;
    --border: #2b323c;
    --text: #e8ebf0;
    --muted: #9aa5b3;
    --accent: #6b93ff;
    --accent-text: #0b1020;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 6px 24px rgba(0, 0, 0, 0.35);

    --s-running: #7ea4ff;
    --s-paused: #a7b3c4;
    --s-blocked: #f5a85a;
    --s-done: #5fd08a;
    --s-stopped: #94a3b8;
    --s-failed: #ff8b8b;
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
code, pre, .mono { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
  position: sticky; top: 0; z-index: 5;
}
.topbar h1 { font-size: 18px; margin: 0; }
.summary { margin: 0; color: var(--muted); flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; }

/* ---- buttons / inputs -------------------------------------------------- */
.btn {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible,
.link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: transparent; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--s-failed); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn:disabled { opacity: 0.55; cursor: progress; }

input, textarea, select {
  font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 10px; width: 100%;
}
textarea { resize: vertical; }

/* ---- layout ------------------------------------------------------------ */
main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.notice {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 14px;
  background: color-mix(in srgb, var(--s-blocked) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--s-blocked) 45%, var(--border));
}
.empty { color: var(--muted); text-align: center; padding: 48px 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }

/* ---- cards ------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); cursor: pointer;
}
.card.attention { border-color: var(--s-blocked); }
.card-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.link { all: unset; font-weight: 600; cursor: pointer; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }
.task, .detail { margin: 0; color: var(--muted); font-size: 13px; }
.task { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.now { margin: 0; font-size: 13px; overflow-wrap: anywhere; }
.output {
  margin: 0; padding: 8px 10px; background: var(--surface-2); border-radius: 8px; font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.output:empty { display: none; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--muted); font-size: 12px; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }

/* ---- status badge ------------------------------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600;
  padding: 2px 9px; border-radius: 999px; white-space: nowrap; text-transform: capitalize;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.badge.running::before { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { .badge.running::before { animation: none; } }
.awaiting_approval { --c: var(--s-blocked); }
.running { --c: var(--s-running); } .paused { --c: var(--s-paused); } .blocked { --c: var(--s-blocked); }
.done { --c: var(--s-done); } .stopped { --c: var(--s-stopped); } .failed { --c: var(--s-failed); }

/* ---- detail panel ------------------------------------------------------ */
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 100vw); z-index: 10;
  background: var(--bg); border-left: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 10px; padding: 14px; overflow: hidden;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
.panel-title h2 { margin: 0; font-size: 17px; overflow-wrap: anywhere; }
.config { font-size: 13px; }
.config summary { cursor: pointer; color: var(--muted); }
.config dl { margin: 8px 0 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
.config dt { color: var(--muted); }
.config dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 180px; overflow: auto; }
.logs {
  flex: 1; min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 8px;
}
.log { display: grid; grid-template-columns: 62px 56px 1fr; gap: 8px; padding: 5px 4px; border-bottom: 1px solid var(--border); font-size: 13px; }
.log:last-child { border-bottom: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; }
.log .kind { font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 2px; color: var(--muted); }
.log pre { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; }
.log.assistant .kind { color: var(--accent); }
.log.user .kind { color: var(--s-done); }
.log.error .kind, .log.error pre { color: var(--s-failed); }
.log.tool_call pre, .log.tool_result pre { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 12px; color: var(--muted); }
.log .more { all: unset; color: var(--accent); cursor: pointer; font-size: 12px; display: block; margin-top: 2px; }
.message { display: flex; gap: 8px; align-items: flex-end; }

/* ---- dialogs ----------------------------------------------------------- */
dialog {
  border: 1px solid var(--border); border-radius: 12px; padding: 20px; background: var(--surface);
  color: var(--text); width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 32px); overflow: auto;
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label, dialog fieldset { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
dialog label > input, dialog label > textarea, dialog label > select { margin-top: 4px; color: var(--text); }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; }
.checks label { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--text); }
.checks input { width: auto; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.hint { color: var(--muted); font-size: 13px; margin-top: 0; }
.form-error { color: var(--s-failed); font-size: 13px; margin: 0 0 8px; }

/* ---- result dialog ----------------------------------------------------- */
.result-dialog { width: min(920px, calc(100vw - 32px)); height: min(88vh, 1000px); padding: 0; overflow: hidden; }
.result-dialog[open] { display: flex; flex-direction: column; }
.r-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  padding: 20px 24px 16px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0;
}
.r-titles { min-width: 0; }
.r-kicker { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--s-done); }
.result-dialog h2 { margin: 0 0 6px; font-size: 22px; line-height: 1.25; color: var(--text); overflow-wrap: anywhere; }
.r-task {
  margin: 0 0 6px; color: var(--muted); font-size: 14px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.r-meta { margin: 0; color: var(--muted); font-size: 12px; }
.r-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; flex-shrink: 0; }
.r-scroll { flex: 1; min-height: 0; overflow: auto; padding: 28px 24px 40px; }

.md { max-width: 70ch; margin: 0 auto; font-size: 16px; line-height: 1.65; overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md p { margin: 0 0 1em; }
.md h3, .md h4, .md h5, .md h6 { line-height: 1.3; margin: 1.7em 0 0.5em; }
.md h3 { font-size: 1.45em; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.md h4 { font-size: 1.2em; }
.md h5 { font-size: 1.05em; }
.md h6 { font-size: 0.9em; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.md ul, .md ol { margin: 0 0 1em; padding-left: 1.5em; }
.md li { margin: 0.3em 0; }
.md li > ul, .md li > ol { margin: 0.3em 0 0; }
.md a { color: var(--accent); text-underline-offset: 2px; }
.md code { font-family: ui-monospace, "Cascadia Code", Menlo, Consolas, monospace; font-size: 0.9em; background: var(--surface-2); padding: 0.15em 0.4em; border-radius: 5px; }
.md pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; overflow: auto; margin: 0 0 1em; overflow-wrap: normal; }
.md pre code { background: none; padding: 0; font-size: 0.88em; white-space: pre; }
.md blockquote { margin: 0 0 1em; padding: 0.2em 1em; border-left: 3px solid var(--accent); color: var(--muted); }
.md blockquote > :last-child { margin-bottom: 0; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 1.8em 0; }
.md del { color: var(--muted); }
.md .table-wrap { overflow-x: auto; margin: 0 0 1.2em; border: 1px solid var(--border); border-radius: 8px; }
.md table { border-collapse: collapse; width: max-content; min-width: 100%; font-size: 0.95em; line-height: 1.5; }
.md th, .md td {
  padding: 9px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border);
  overflow-wrap: normal; word-break: normal; /* wide tables scroll sideways instead of breaking words */
}
.md td { max-width: 34ch; }
.md th { background: var(--surface-2); font-weight: 600; }
.md tbody tr:last-child td { border-bottom: 0; }
.md [data-align="center"] { text-align: center; }
.md [data-align="right"] { text-align: right; }
.log.result .kind { color: var(--s-done); }

/* ---- PC companion status pill ------------------------------------------- */
.pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); white-space: nowrap; }
.pill.online { color: var(--s-done); border-color: color-mix(in srgb, var(--s-done) 45%, transparent); }
.pill.offline { color: var(--muted); }
.a-desc { margin: 0; color: var(--muted); font-size: 14px; }

/* ---- approval dialog --------------------------------------------------- */
.r-kicker.warn { color: var(--s-blocked); }
.a-body { max-width: 70ch; margin: 0 auto; overflow-wrap: anywhere; }
.a-body h3 { font-size: 15px; margin: 1.6em 0 0.5em; }
.a-summary { font-size: 17px; line-height: 1.5; margin: 0 0 1em; }
.a-facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; font-size: 14px; }
.a-facts dt { color: var(--muted); }
.a-facts dd { margin: 0; font-weight: 600; }
.a-facts dd.ok { color: var(--s-done); font-weight: 500; }
.a-table { width: 100%; border-collapse: collapse; font-size: 14px; border: 1px solid var(--border); border-radius: 8px; }
.a-table th, .a-table td { padding: 8px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.a-table th { width: 34%; color: var(--muted); font-weight: 500; }
.a-table tr:last-child th, .a-table tr:last-child td { border-bottom: 0; }
.a-table td { white-space: pre-wrap; }
.a-shot { max-width: 100%; border: 1px solid var(--border); border-radius: 8px; display: block; }
.a-note { color: var(--muted); font-size: 13px; margin: 1.2em 0 0.6em; }
.a-status { font-weight: 600; margin: 0.6em 0; }
.a-status.waiting { color: var(--s-blocked); }
.a-status.executed { color: var(--s-done); }
.a-status.failed, .a-status.denied, .a-status.expired, .a-status.cancelled { color: var(--s-failed); }
.a-outcome { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; }
.a-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }

@media (max-width: 560px) {
  .result-dialog { width: 100vw; height: 100vh; max-height: 100vh; border: 0; border-radius: 0; }
  .a-actions { padding: 12px 16px; }
  .a-facts { grid-template-columns: 1fr; gap: 0 0; }
  .a-facts dd { margin-bottom: 8px; }
  .r-head { flex-direction: column; padding: 16px; }
  .r-actions { justify-content: flex-start; }
  .r-scroll { padding: 20px 16px 32px; }
}

@media (max-width: 560px) {
  .topbar { gap: 8px 12px; }
  .topbar h1 { flex: 1; }
  .summary { order: 3; flex-basis: 100%; }
  .row { grid-template-columns: 1fr; }
  .log { grid-template-columns: 56px 1fr; }
  .log .kind { grid-column: 2; }
  .log .body { grid-column: 1 / -1; }
}

/* ---- voice dock (Phase 4) ------------------------------------------------ */
.voice-dock {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 20; max-width: 980px; margin: 0 auto;
  display: grid; grid-template-columns: auto 1fr; gap: 10px 16px; align-items: center;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.voice-dock[hidden] { display: none; }
body:has(.voice-dock:not([hidden])) main { padding-bottom: 190px; }
.v-talk {
  font: inherit; font-weight: 600; color: var(--accent-text); background: var(--accent); border: 0; border-radius: 999px;
  padding: 14px 22px; min-width: 190px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.v-talk:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.v-talk:disabled { opacity: 0.6; cursor: progress; }
.v-dot { width: 10px; height: 10px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.v-talk.recording { background: var(--s-failed); color: #fff; }
.v-talk.recording .v-dot { opacity: 1; animation: pulse 0.9s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .v-talk.recording .v-dot { animation: none; } }
.v-text { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.v-status { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.v-heard { margin: 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.v-heard:empty { display: none; }
.v-form input { padding: 6px 10px; font-size: 13px; }
.v-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.v-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.v-check input { width: auto; }
dialog label.v-option { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-size: 14px; }
dialog label.v-option input { width: auto; margin-top: 4px; }
.log.spoken .kind { color: var(--muted); }
@media (max-width: 560px) {
  .voice-dock { grid-template-columns: 1fr; left: 8px; right: 8px; bottom: 8px; }
  .v-talk { width: 100%; }
}
/* ---- managed ecosystem: tree navigation, manager and job views ---------------------------- */
.waiting { --c: var(--s-paused); }
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); align-items: start; max-width: 1480px; margin: 0 auto; }
.shell .main { padding: 20px 20px 24px; max-width: none; margin: 0; min-width: 0; }
.tree { position: sticky; top: 61px; padding: 16px 10px 16px 16px; display: flex; flex-direction: column; gap: 14px; max-height: calc(100vh - 61px); overflow: auto; }
.tree-item {
  font: inherit; color: var(--text); background: transparent; border: 1px solid transparent; text-align: left; cursor: pointer;
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; width: 100%; padding: 7px 10px; border-radius: 8px;
}
.tree-item:hover { background: var(--surface-2); }
.tree-item.selected { background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); font-weight: 600; }
.tree-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tree-item.root { font-weight: 600; font-size: 16px; }
.tree-label { flex: 1 1 auto; }
.tree-children { position: relative; margin: 4px 0 0 14px; padding-left: 12px; border-left: 2px solid var(--border); display: flex; flex-direction: column; gap: 2px; }
.tree-children .tree-item { position: relative; }
.tree-children .tree-item::before { content: ""; position: absolute; left: -14px; top: 50%; width: 12px; border-top: 2px solid var(--border); }
.tree-chip { font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted); }
.tree-chip.run { color: var(--s-running); border-color: color-mix(in srgb, var(--s-running) 40%, transparent); }
.tree-chip.need { color: var(--s-blocked); border-color: color-mix(in srgb, var(--s-blocked) 50%, transparent); background: color-mix(in srgb, var(--s-blocked) 12%, transparent); }
.tree-legacy { border-top: 1px solid var(--border); padding-top: 10px; }

.view h2 { margin: 0 0 4px; font-size: 20px; overflow-wrap: anywhere; }
.view h3 { margin: 22px 0 8px; font-size: 15px; }
.view .hint { margin: 0 0 12px; }
.role-stats { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.request { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 22px; }
.request textarea, .box textarea, .changes textarea { width: 100%; }
.jobs { display: grid; gap: 10px; }
.job-card { cursor: default; }
.job-card .link { font-size: 15px; text-align: left; }
.job-link { font-size: 12px; color: var(--muted); font-weight: 400; text-align: left; }
.need-text { color: var(--s-blocked); font-weight: 600; }
.area-chip { padding: 0 8px; border-radius: 999px; border: 1px solid var(--border); font-size: 11px; }
.job-head { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; margin: 8px 0 6px; }
.job-head h2 { flex: 1; min-width: 0; }
.box { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.box.attention { border-color: var(--s-blocked); }
.box h3 { margin: 0; }
.box p { margin: 0; }
.q { margin: 0; white-space: pre-wrap; font-family: inherit; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tasks { border-collapse: collapse; width: 100%; font-size: 13px; }
.tasks th, .tasks td { padding: 8px 10px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.tasks th { color: var(--muted); font-weight: 500; }
.tasks tbody tr:last-child td { border-bottom: 0; }
.task-cell { min-width: 220px; overflow-wrap: anywhere; }
.row-actions { white-space: nowrap; }
.row-actions .btn + .btn { margin-left: 6px; }
.actions-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.action { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.action.attention { border-color: var(--s-blocked); }
.action-what { font-weight: 600; overflow-wrap: anywhere; }
.review { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 22px; margin: 0; max-width: none; }
.signoff { align-items: stretch; }
.signoff-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 10px 0; }
.changes { display: flex; flex-direction: column; gap: 6px; width: 100%; align-items: flex-start; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .tree { position: static; max-height: none; padding: 12px 16px 0; }
  .tree-children { display: flex; flex-direction: row; flex-wrap: wrap; border-left: 0; padding-left: 0; margin-left: 0; gap: 4px; }
  .tree-children .tree-item { width: auto; }
  .tree-children .tree-item::before { display: none; }
  .shell .main { padding: 12px 16px 24px; }
}
/* ---- Phase 6: tabs, goals, autonomy, connections, compare ------------------------------------ */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; border-bottom: 1px solid var(--border); }
.tab { font: inherit; color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 8px 12px; cursor: pointer; display: inline-flex; gap: 8px; align-items: center; }
.tab:hover { color: var(--text); }
.tab.selected { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.box.autonomy.on { border-color: var(--s-done); }
.meter { display: flex; flex-direction: column; gap: 4px; width: 100%; font-size: 13px; color: var(--muted); }
.meter progress { width: 100%; height: 10px; }
.limits { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px 14px; width: 100%; align-items: end; }
.limits label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.limits label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.limits label.check input { width: auto; }
.goal-form label { display: flex; flex-direction: column; gap: 4px; width: 100%; font-size: 13px; color: var(--muted); }
.conn h3 { margin: 0; }
.conn .check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.conn .check input { width: auto; margin-top: 4px; }
.verdict { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; max-width: 220px; }
.a-email { white-space: pre-wrap; font-family: inherit; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; margin: 0; overflow-wrap: anywhere; }
.cmp-body { max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.cmp-body label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.cmp-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cmp-cols section { border: 1px solid var(--border); border-radius: var(--radius); padding: 4px 16px 12px; background: var(--surface); min-width: 0; }
.cmp-cols .md { font-size: 14px; max-width: none; }
@media (max-width: 860px) { .cmp-cols { grid-template-columns: 1fr; } }

/* ---- each specialist's own dashboard (roleviews.js) ---- */
.ov { display: block; }
.ov-sec { margin: 0 0 26px; }
.ov-sec h3 { margin: 0 0 4px; }
.ov-empty { color: var(--muted); margin: 6px 0 0; padding: 14px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.ov-when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ov-chip { display: inline-block; padding: 1px 9px; border-radius: 999px; border: 1px solid var(--border); font-size: 12px; color: var(--muted); white-space: nowrap; }
.ov-chip.ok { color: var(--s-done); border-color: color-mix(in srgb, var(--s-done) 45%, transparent); }
.ov-chip.wait { color: var(--s-blocked); border-color: color-mix(in srgb, var(--s-blocked) 45%, transparent); }
.ov-chip.bad { color: var(--s-failed); border-color: color-mix(in srgb, var(--s-failed) 45%, transparent); }
.ov-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.ov-attn { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; margin: 0 0 18px; padding: 12px 14px; border: 1px solid var(--s-blocked); border-radius: var(--radius); background: color-mix(in srgb, var(--s-blocked) 8%, var(--surface)); }
.ov-note { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); margin: 0 0 10px; }

/* tables: a wide comparison scrolls inside its own box, never the page */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.tbl { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 13px; }
.tbl.wide { min-width: 860px; }
.tbl th { text-align: left; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; overflow-wrap: break-word; min-width: 90px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl a { color: var(--accent); white-space: nowrap; }
.stack { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; }
.stack small, .tbl small { display: block; color: var(--muted); font-size: 12px; }
.ov-minus { display: block; color: var(--muted); }
.ov-score { letter-spacing: 2px; color: var(--accent); white-space: nowrap; }

/* files */
.ov-files { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.ov-files.small { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 8px; }
.ov-file { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.ov-file-open { all: unset; cursor: pointer; display: block; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface); aspect-ratio: 1 / 1; }
.ov-file-open:hover { border-color: var(--accent); }
.ov-file-open:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.ov-thumb { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--surface-2, var(--bg)); }
.ov-doc { display: grid; place-items: center; width: 100%; height: 100%; font-weight: 700; color: var(--muted); letter-spacing: 1px; }
.ov-file figcaption { display: flex; flex-direction: column; font-size: 12px; min-width: 0; }
.ov-file-name { overflow-wrap: anywhere; }
.ov-file-meta { color: var(--muted); }

/* recent work */
.ov-tasks { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.ov-tasks li { padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.ov-task-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.ov-result { margin: 0; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }

/* sales pipeline board: columns scroll sideways inside the board */
.ov-board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 6px; align-items: flex-start; }
.ov-col { flex: 0 0 210px; display: flex; flex-direction: column; gap: 8px; }
.ov-col h4 { margin: 0; font-size: 13px; display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.ov-client { border: 1px solid var(--border); border-radius: 8px; background: var(--surface); padding: 8px 10px; display: flex; flex-direction: column; gap: 3px; overflow-wrap: anywhere; }
.ov-client p { margin: 0; font-size: 13px; }
.ov-client small { color: var(--muted); }

/* content and gathered info */
.ov-content { gap: 8px; }
.ov-body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.ov-content summary { cursor: pointer; }
.ov-facts { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.ov-facts dt { color: var(--muted); }
.ov-facts dd { margin: 0; overflow-wrap: anywhere; }

/* onboarding progress */
.ov-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.ov-bar span { display: block; height: 100%; background: var(--s-done); }

@media (max-width: 640px) {
  .ov-files { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .ov-col { flex-basis: 78vw; }
}
/* draft websites (Sales) */
.ov-draft { gap: 10px; }
.ov-previews { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; align-items: start; }
.ov-previews .ov-file-open { aspect-ratio: auto; max-height: 260px; }
.ov-previews .ov-thumb { object-fit: cover; object-position: top; }
.ov-warn { border: 1px solid var(--s-blocked); background: color-mix(in srgb, var(--s-blocked) 8%, var(--surface)); border-radius: var(--radius); padding: 8px 12px; }
.ov-warn ul { margin: 6px 0 0; padding-left: 18px; }
.ov-prompt { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 280px; overflow: auto; font: 12px/1.5 ui-monospace, Consolas, monospace; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
.ov-findings { list-style: none; margin: 8px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
