/* ── Research Agent — design system (inspired by the original ui.py) ────────── */
:root {
  --font-ui:   -apple-system, "SF Pro Text", "Segoe UI", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", "Menlo", monospace;

  /* Surfaces — cool slate blue, calm on the eyes */
  --bg:            #dde4ed;
  --surface:       #eaf0f7;
  --elevated:      #e2e9f2;
  --text:          #1a2535;
  --muted:         #4d6080;
  --faint:         #8fa0b8;
  --border:        #c8d4e2;
  --border-strong: #b0c0d4;

  /* Teal accent */
  --accent:        #00a884;
  --accent-dark:   #009973;
  --accent-hover:  #00b894;
  --accent-subtle: #d0ede8;

  /* Semantic */
  --success: #009973; --danger: #c0392b; --danger-dim: #fde8e8;
  --warn:    #b45309; --info:   #2563b8; --red: #c0392b;

  /* Classification colors */
  --class-qualified:    #009973;
  --class-disqualified: #c0392b;
  --class-unsure:       #b45309;
  --class-human:        #2563b8;
  --class-adjacent:     #7c3aed;

  /* Navy header */
  --navy-top: #1a4060; --navy-mid: #0a2540; --navy-bot: #07203a;
  --navy-text: #eaf1f8; --navy-muted: #aebfd2;

  /* Fixed minimum width: below this the page scrolls sideways instead of
     re-flowing. The native window's min_size (webapp/server.py) matches it. */
  --app-min-width: 1180px;

  --radius: 14px; --radius-sm: 9px;
  --shadow: 0 1px 3px rgba(16,42,67,.06), 0 8px 24px rgba(16,42,67,.06);
  --shadow-sm: 0 1px 2px rgba(16,42,67,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; font-family: var(--font-ui); font-size: 14px; line-height: 1.55;
  color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-width: var(--app-min-width);
}

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 60px;
  background: linear-gradient(180deg, var(--navy-top) 0%, var(--navy-mid) 60%, var(--navy-bot) 100%);
  color: var(--navy-text); box-shadow: 0 2px 12px rgba(7,32,58,.18);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 800; font-size: 16px; letter-spacing: .2px; display: flex; align-items: center; gap: 11px; }
.brand-logo {
  /* Radius matches the mark's own corners (22%, see make_icon.py); the faint
     ring keeps the navy mark distinct from the navy top bar. */
  width: 30px; height: 30px; border-radius: 22%; display: block;
  box-shadow: 0 0 0 1px rgba(255,255,255,.16), 0 2px 10px rgba(0,168,132,.35);
}
.nav-links { display: flex; gap: 6px; }
.nav-links a {
  color: var(--navy-muted); text-decoration: none; padding: 7px 14px;
  border-radius: 8px; font-weight: 600; transition: all .18s;
}
.nav-links a:hover { color: var(--navy-text); background: rgba(255,255,255,.08); }
.nav-links a.active { color: #fff; background: rgba(0,168,132,.22); box-shadow: inset 0 0 0 1px rgba(0,168,132,.35); }
.active-pack {
  margin-left: auto; color: var(--navy-muted); font-size: 13px; text-decoration: none;
  padding: 6px 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.12);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 460px;
  transition: background .18s, border-color .18s;
}
.active-pack:hover { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.22); }
.active-pack strong { color: var(--navy-text); }
/* Portal: who's signed in */
.user-menu { display: flex; align-items: center; gap: 10px; flex-shrink: 0; padding-left: 16px; border-left: 1px solid rgba(255,255,255,.14); }
.user-name { color: var(--navy-text); font-weight: 700; font-size: 13px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { padding: 1px 8px; border-radius: 999px; background: rgba(0,168,132,.22); color: #c9f2e7;
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.user-menu form { margin: 0; }
.signout { background: transparent; color: var(--navy-muted); border: 1px solid rgba(255,255,255,.16); padding: 5px 12px; font-size: 12.5px; }
.signout:hover { color: var(--navy-text); background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.28); }

.content { padding: 24px; max-width: 1440px; margin: 0 auto; }

/* ── Panels / cards ──────────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; margin-bottom: 18px; box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0 0 16px; font-size: 12px; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
}
/* Panel title row: title on the left, status or actions on the right. */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 34px; margin-bottom: 14px; }
.panel-head h2 { margin: 0; }
.head-actions { display: flex; align-items: center; gap: 8px; }
.muted { color: var(--muted); font-size: 13px; }
.hint { color: var(--faint); font-size: 12px; margin: 8px 0 0; font-style: italic; }

/* ── Forms ───────────────────────────────────────────────────────────────── */
label { display: block; margin: 10px 0; color: var(--muted); font-size: 12.5px; font-weight: 600; }
label input, label select, select,
input[type=text], input[type=number], input[type=password], input[type=file] {
  display: block; width: 100%; margin-top: 6px; padding: 9px 11px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); color: var(--text); font-size: 13.5px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.row { display: flex; gap: 12px; } .row label { flex: 1; }
/* A narrow field (e.g. temperature) that shouldn't stretch full-width. */
label.narrow { max-width: 160px; }
.row label.narrow { flex: 0 0 130px; }
label.half { max-width: 50%; }
/* Subtle separator between grouped fields within a panel. */
.field-divider { height: 1px; background: var(--border); margin: 18px 0 6px; }

button {
  cursor: pointer; padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface);
  color: var(--text); font-size: 13px; font-weight: 600; transition: all .16s;
}
button:hover { background: var(--elevated); border-color: var(--faint); }
button.primary {
  background: linear-gradient(135deg, var(--accent-hover), var(--accent-dark));
  border-color: transparent; color: #fff; box-shadow: 0 2px 8px rgba(0,168,132,.32);
}
button.primary:hover { filter: brightness(1.05); box-shadow: 0 3px 12px rgba(0,168,132,.42); }
button.danger { border-color: var(--danger); color: var(--danger); background: var(--surface); }
button.danger:hover { background: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; filter: none; box-shadow: none; }
button.mini { padding: 3px 10px; font-size: 12px; }
button.mini.danger { padding: 3px 10px; }
button.linklike { background: none; border: none; color: var(--text); padding: 0; font-weight: 600; }
button.linklike:hover { color: var(--accent-dark); background: none; }

/* ── Dashboard layout ────────────────────────────────────────────────────── */
/* Top: the run form on the left; current run + live events stacked on the
   right, stretched to the same height. Below: runs & results, full width. */
.dashboard { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 18px; align-items: stretch; }
.dashboard .panel { margin-bottom: 0; min-width: 0; }
.dashboard .history { grid-column: 1 / -1; }
.dash-right { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

/* Checkbox + text on one line */
label.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
label.check input { display: inline-block; width: auto; margin: 0; }

.run-actions { display: flex; gap: 10px; margin-top: 16px; }
.run-actions .primary { flex: 1; }

/* Status pill (Current run header) with pulsing dot */
.status-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 10px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--elevated);
  color: var(--muted); font-size: 12px; font-weight: 700; text-transform: capitalize;
}
.status-pill.live { color: var(--accent-dark); background: var(--accent-subtle); border-color: transparent; }
.status-pill.done { color: var(--success); }
.status-pill.err { color: var(--danger); background: var(--danger-dim); border-color: transparent; }
.pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex-shrink: 0; transition: background .3s; }
.pulse.live { background: var(--accent); animation: ping 1.4s ease-in-out infinite; }
.pulse.done { background: var(--success); }
.pulse.err { background: var(--danger); }
.pulse.warn { background: var(--warn); }
[x-cloak] { display: none !important; }
/* Portal dashboard: the computer card and the queue */
.device-card { display: flex; align-items: center; gap: 12px; padding: 11px 13px; margin: -4px 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--elevated); }
.device-card.is-online { background: var(--accent-subtle); border-color: transparent; }
.device-card.is-offline { border-color: var(--warn); background: var(--surface); }
.device-card-text { flex: 1; min-width: 0; }
.device-card-title { font-weight: 700; font-size: 13px; color: var(--text); }
.device-card-detail { color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.device-card-link { flex-shrink: 0; font-size: 12.5px; font-weight: 700; color: var(--accent-dark); text-decoration: none; }
.device-card-link:hover { text-decoration: underline; }
.queue { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.queue-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.queue-title { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.queue-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin-bottom: 6px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.queue-row.waiting { border-left: 3px solid var(--warn); }
.queue-pos { font-weight: 800; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 22px; }
.queue-main { flex: 1; min-width: 0; }
.queue-name { font-weight: 700; font-size: 12.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue-why { color: var(--muted); font-size: 11.5px; line-height: 1.35; }
.queue-row button { flex-shrink: 0; }
@keyframes ping {
  0%   { box-shadow: 0 0 0 0 rgba(0,168,132,.55); }
  70%  { box-shadow: 0 0 0 8px rgba(0,168,132,0); }
  100% { box-shadow: 0 0 0 0 rgba(0,168,132,0); }
}
.error-line { color: var(--danger); font-size: 12.5px; margin: -4px 0 12px; word-break: break-word; }

/* Current run: progress on the left, result breakdown on the right */
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 0 28px; }
.results-area {
  display: grid; grid-template-columns: 112px minmax(0, 1fr); gap: 18px; align-items: center; align-content: start;
  padding-left: 28px; border-left: 1px solid var(--border);
}

/* Metrics */
.bigrow { display: flex; gap: 36px; margin-bottom: 6px; }
.metric-val { font-size: 34px; font-weight: 800; line-height: 1; color: var(--text); font-variant-numeric: tabular-nums; }
.metric-label { color: var(--faint); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; margin-top: 4px; }
.progress { height: 8px; background: var(--elevated); border-radius: 999px; overflow: hidden; margin: 16px 0; box-shadow: inset 0 0 0 1px var(--border); }
.progress .bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-hover)); border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); }
.current { display: flex; align-items: center; gap: 10px; min-height: 24px; color: var(--muted); font-size: 13px; }
.current .url { flex: 1; min-width: 0; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.current .stage { flex-shrink: 0; padding: 2px 9px; border-radius: 999px; background: var(--accent-subtle); color: var(--accent-dark); font-weight: 700; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.current .stage.live { animation: phasepulse 1.2s ease-in-out infinite; }
@keyframes phasepulse { 0%,100% { opacity: 1; } 50% { opacity: .55; } }

/* Phase tracker (scrape › research › validate › score › save) */
.phases { display: flex; gap: 4px; margin-top: 14px; }
.phase { flex: 1; text-align: center; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  color: var(--faint); padding: 6px 2px; border-radius: 6px; background: var(--elevated); transition: all .3s; }
.phase.active { color: #fff; background: var(--accent); box-shadow: 0 2px 6px rgba(0,168,132,.35); }
.phase.done { color: var(--accent-dark); background: var(--accent-subtle); }

/* Token usage strip */
.token-strip { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 36px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.mini-stat { display: flex; flex-direction: column; gap: 2px; }
.mini-label { color: var(--faint); font-size: 10.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.mini-val { color: var(--text); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.mini-val.muted { color: var(--muted); font-weight: 600; }

/* ── Results donut ───────────────────────────────────────────────────────── */
.donut-wrap { display: flex; justify-content: center; }
.donut { overflow: visible; width: 112px; height: 112px; }
.donut-rotor { transform: rotate(-90deg); transform-origin: 60px 60px; }
.donut-track { fill: none; stroke: var(--border); stroke-width: 13; }
.donut-seg { fill: none; stroke-width: 13; stroke-linecap: round;
  transition: stroke-dasharray .7s cubic-bezier(.2,.8,.2,1), stroke-dashoffset .7s cubic-bezier(.2,.8,.2,1); }
#seg_q { stroke: var(--class-qualified); }
#seg_d { stroke: var(--class-disqualified); }
#seg_u { stroke: var(--class-unsure); }
#seg_a { stroke: var(--class-adjacent); }
#seg_h { stroke: var(--class-human); }
.donut-total { fill: var(--text); font-size: 26px; font-weight: 800; font-family: var(--font-ui); }
.donut-sub { fill: var(--faint); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; font-family: var(--font-ui); }

.legend { min-width: 0; }
.result-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--border); }
.result-row:last-of-type { border-bottom: none; }
.result-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.result-dot.ok { background: var(--class-qualified); } .result-dot.no { background: var(--class-disqualified); }
.result-dot.adj { background: var(--class-adjacent); }
.result-dot.warn { background: var(--class-unsure); } .result-dot.unsure { background: var(--class-human); }
.result-cls { flex: 1; min-width: 0; font-weight: 600; font-size: 13px; }
.result-n { font-weight: 800; font-variant-numeric: tabular-nums; }

/* Event log — fills whatever height the row has left over, then scrolls */
.events { flex: 1 1 auto; display: flex; flex-direction: column; }
.event-log { flex: 1 1 0; height: 0; min-height: 150px; overflow-y: auto; margin: 0 -8px; }
.event-empty { padding: 6px 8px; }
.event-item { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 7px; font-size: 12.5px; transition: background .12s; }
.event-item:hover { background: var(--elevated); }
.event-item .ei-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; background: var(--faint); }
.event-item .ei-dot.ok { background: var(--class-qualified); } .event-item .ei-dot.no { background: var(--class-disqualified); }
.event-item .ei-dot.warn { background: var(--class-unsure); } .event-item .ei-dot.info { background: var(--class-human); }
.event-item .ei-text { color: var(--muted); }

/* Runs & results */
.history-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; }
.history-bar select, .history-bar input[type=text] { margin-top: 0; min-width: 0; }
.history-bar .run-select { flex: 2 1 480px; }
.history-bar .filter-select { flex: 0 0 220px; }
.history-bar .search-input { flex: 1 1 220px; }
.table-wrap { max-height: 520px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.results-table { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 12.5px; }
.results-table col.c-domain { width: 250px; }
.results-table col.c-result { width: 210px; }
.results-table th { position: sticky; top: 0; background: var(--elevated); text-align: left; padding: 9px 12px;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); z-index: 1; }
.results-table td { padding: 9px 12px; border-top: 1px solid var(--border); vertical-align: top; }
.results-table tbody tr:hover td { background: rgba(255,255,255,.35); }
.results-table td.domain { font-weight: 600; overflow-wrap: anywhere; }
.results-table td.result { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.results-table td .result-dot { display: inline-block; vertical-align: middle; }
.results-table td.expl { color: var(--muted); }
.table-foot { margin: 10px 0 0; }

.badge { background: var(--accent); color: #fff; padding: 2px 9px; border-radius: 999px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; flex-shrink: 0; }

/* ── Verticals page ──────────────────────────────────────────────────────── */
.packs-page { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: start; }
.packs-sidebar { display: flex; flex-direction: column; }

/* Pack cards */
.pack-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.pack-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all .15s;
}
.pack-card:hover { border-color: var(--border-strong); background: var(--elevated); }
.pack-card.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.pack-card.active { border-left: 3px solid var(--accent); }
.pack-card-main { flex: 1; min-width: 0; }
.pack-card-name { font-weight: 700; font-size: 14px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pack-card-id { font-family: var(--font-mono); font-size: 11px; color: var(--faint); margin-top: 1px; }
.pack-card-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* Create panel */
.create-panel .block { width: 100%; margin-top: 6px; }
button.block { width: 100%; }

/* Editor column */
.packs-editor { min-width: 0; }
.editor-empty { text-align: center; padding: 60px 30px; }
.editor-empty-icon { font-size: 42px; color: var(--border-strong); line-height: 1; }
.editor-empty h3 { margin: 16px 0 8px; color: var(--text); font-size: 16px; }
.editor-empty .muted { max-width: 380px; margin: 0 auto; }

.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.editor-title { font-size: 17px; font-weight: 800; color: var(--text); margin-top: 2px; }
.editor-id { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--faint); }
.editor-head-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* File tabs — labeled, two-line */
.file-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 14px; }
.ftab {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface); text-align: left; transition: all .15s;
}
.ftab:hover { background: var(--elevated); border-color: var(--border-strong); }
.ftab.active { background: var(--accent); border-color: transparent; box-shadow: 0 2px 8px rgba(0,168,132,.3); }
.ftab-label { font-size: 12.5px; font-weight: 700; color: var(--text); }
.ftab-file { font-family: var(--font-mono); font-size: 10px; color: var(--faint); }
.ftab.active .ftab-label, .ftab.active .ftab-file { color: #fff; }
.ftab.active .ftab-file { color: rgba(255,255,255,.75); }

.file-desc { color: var(--muted); font-size: 12.5px; margin: 0 0 10px; padding: 8px 12px; background: var(--accent-subtle); border-radius: var(--radius-sm); border-left: 3px solid var(--accent); }

textarea.code {
  width: 100%; height: 460px; background: #0d1524; color: #cfe0ff;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 14px; font-family: var(--font-mono); font-size: 12.5px; line-height: 1.6;
  tab-size: 2;
}
textarea.code:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.editor-actions, .actions { display: flex; align-items: center; gap: 14px; margin-top: 12px; }
.errors { color: var(--danger); font-size: 12.5px; }
.ok { color: var(--success); font-weight: 700; }

/* ── Settings ────────────────────────────────────────────────────────────── */
/* One column of sections: title + explanation on the left, fields on the
   right. Save lives in a header that stays visible while scrolling. */
.settings { max-width: 1080px; margin: 0 auto; }
.page-head {
  position: sticky; top: 60px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  margin: -24px 0 18px; padding: 22px 0 16px;
  background: var(--bg); border-bottom: 1px solid var(--border);
  /* Paint the background past the column edges so panel shadows scrolling
     underneath don't peek out at the sides. */
  box-shadow: 0 0 0 100vmax var(--bg); clip-path: inset(0 -100vmax);
}
.page-head h1 { margin: 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
.page-head p { margin: 4px 0 0; }
.page-head .actions { margin-top: 0; flex-shrink: 0; }
.settings-section { display: grid; grid-template-columns: 270px minmax(0, 1fr); gap: 36px; }
.section-intro h2 { margin: 2px 0 8px; font-size: 15px; font-weight: 800; letter-spacing: 0; text-transform: none; color: var(--text); }
.section-intro p { margin: 0; color: var(--muted); font-size: 13px; }
.section-fields > label:first-child, .section-fields > .row:first-child label { margin-top: 0; }
.section-fields > label:last-child { margin-bottom: 0; }
.label-line { display: flex; align-items: center; gap: 8px; }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--border);
  background: var(--elevated); color: var(--faint);
  font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
}
.chip.ok { background: var(--accent-subtle); color: var(--accent-dark); border-color: transparent; }
.connect-card {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--elevated);
}
.connect-text { flex: 1; min-width: 0; }
.connect-title { font-weight: 700; font-size: 13.5px; color: var(--text); }
.connect-card button { flex-shrink: 0; }
.warn-hint { color: var(--warn); }
.field-title { color: var(--muted); font-size: 12.5px; font-weight: 600; margin: 0 0 2px; }
.field-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
details.more { margin-top: 14px; }
.chip.paid { background: var(--elevated); color: var(--warn); border-color: transparent; }
ol.route { list-style: none; margin: 8px 0 6px; padding: 0; counter-reset: route; }
.route-step { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 6px; background: var(--surface); }
.route-step.off { background: var(--elevated); }
.route-step.off .route-line label, .route-step.off .route-note { opacity: .6; }
.route-line { display: flex; align-items: center; gap: 10px; }
.route-line label.check { margin: 0; flex: 1; min-width: 0; color: var(--text); }
.route-line label.check::before { counter-increment: route; content: counter(route) "."; color: var(--faint); font-weight: 700; min-width: 16px; }
.route-move { display: flex; gap: 4px; flex-shrink: 0; }
.route-move.muted { font-size: 11.5px; }
.route-note { font-size: 12px; color: var(--muted); margin: 4px 0 0 28px; }
.route-note.warn-hint { color: var(--warn); }
/* Settings: section links, field helpers, sub-groups */
.settings-nav { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 16px; }
.settings-nav a { padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-size: 12.5px; font-weight: 600; text-decoration: none; }
.settings-nav a:hover { color: var(--text); border-color: var(--faint); }
.settings-section { scroll-margin-top: 150px; }
.field-help { display: block; margin-top: 5px; color: var(--faint); font-size: 11.5px; font-weight: 500; line-height: 1.4; }
.field-help.block { margin: 2px 0 8px; }
.subsection { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.section-intro p + p { margin-top: 8px; }
details.more summary { cursor: pointer; color: var(--muted); font-size: 12.5px; font-weight: 600; }

/* Settings: one tab at a time */
.settings-tabs { display: flex; gap: 4px; margin: -4px 0 16px; padding: 4px; border-radius: 12px; width: fit-content;
  background: var(--elevated); border: 1px solid var(--border); }
.settings-tabs button { border: none; background: transparent; color: var(--muted); padding: 7px 16px; border-radius: 9px;
  font-size: 13px; font-weight: 700; box-shadow: none; display: inline-flex; align-items: center; gap: 7px; }
.settings-tabs button:hover { color: var(--text); background: rgba(255,255,255,.45); }
.settings-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.step-title { margin: 18px 0 8px; }
.step-title:first-child { margin-top: 0; }
.step-n { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-subtle);
  color: var(--accent-dark); font-size: 11px; font-weight: 800; }
.get-app { display: grid; gap: 8px; }
.get-app-row { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); }
.get-app-row.mine { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); }
.get-app-text { flex: 1; min-width: 0; }
a.button { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 700;
  text-decoration: none; flex-shrink: 0; cursor: pointer; }
a.button:hover { background: var(--elevated); }
a.button.primary { border: none; color: #fff; background: linear-gradient(180deg, var(--accent-hover), var(--accent-dark));
  box-shadow: 0 2px 8px rgba(0,168,132,.3); }
a.button.disabled { opacity: .45; pointer-events: none; }
details.install-help { margin-top: 8px; }
details.install-help summary, details.fold summary { cursor: pointer; }
details.install-help summary { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.install-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.install-cols b { color: var(--text); }
.install-cols ol { margin: 6px 0 0; padding-left: 18px; }
.install-cols li { margin-bottom: 4px; }
details.fold { margin-top: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
details.fold summary { list-style: none; display: grid; grid-template-columns: auto auto 1fr; align-items: center; gap: 4px 10px;
  padding: 11px 14px; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::after { content: "›"; grid-column: 3; grid-row: 1; justify-self: end; color: var(--muted); font-size: 20px; line-height: 1; transition: transform .15s; }
details.fold[open] summary::after { transform: rotate(90deg); }
.fold-title { font-weight: 700; font-size: 13.5px; color: var(--text); }
.fold-sub { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.fold-body { padding: 0 14px 14px; border-top: 1px solid var(--border); }

/* Portal: Settings › Your computer */
.pair-card { padding: 14px 16px; margin-bottom: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--elevated); transition: border-color .2s, box-shadow .2s; }
.pair-card.live { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-subtle); background: var(--surface); }
.pair-idle { display: flex; align-items: center; gap: 14px; }
.pair-idle button { flex-shrink: 0; }
.pair-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.pair-code { font-family: var(--font-mono); font-size: 30px; font-weight: 700; letter-spacing: .14em; color: var(--text);
  margin: 4px 0 8px; user-select: all; font-variant-numeric: tabular-nums; }
.pair-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; font-size: 12.5px; }
.pair-wait { display: inline-flex; align-items: center; gap: 7px; color: var(--accent-dark); font-weight: 600; }
.pair-meta .linklike { margin-left: auto; }
.ok-hint { color: var(--accent-dark); }
.device-list-title { margin-top: 18px; }
.device-list { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); margin-top: 6px; }
.device-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--border); }
.device-row:first-child { border-top: none; }
.device-main { flex: 1; min-width: 0; }
.device-name { font-weight: 700; font-size: 13.5px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-meta { font-size: 12px; }
.device-empty { padding: 12px 14px; color: var(--muted); font-size: 13px; }
/* Portal: Settings › Team settings (read-only for non-admins) */
dl.kv { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 12.5px; font-weight: 600; padding-top: 1px; }
dl.kv dd { margin: 0; color: var(--text); font-size: 13px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
ol.kv-route { margin: 0; padding-left: 18px; }
ol.kv-route li { margin: 0 0 4px; }
ol.kv-route li.kv-off > span:first-child { color: var(--faint); }
.keys-problem { margin: 0 0 10px; font-style: normal; }
.readonly-note { display: flex; align-items: center; gap: 10px; padding: 10px 14px; margin-bottom: 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--elevated); color: var(--muted); font-size: 13px; }

/* Import/export buttons on the Verticals page */
.creds-upload-label {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: all .16s; white-space: nowrap;
}
.creds-upload-label:hover { background: var(--elevated); border-color: var(--faint); }

/* Scrollbars */
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: var(--faint); }

/* ── Portal sign-in page (webapp/templates/login.html) ──────────────────────
   Its own body class, not the app shell: no --app-min-width floor, so it
   re-flows cleanly at phone widths instead of forcing sideways scroll. */
.login-body {
  margin: 0; min-width: 0; min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg); font-family: var(--font-ui); color: var(--text);
  -webkit-font-smoothing: antialiased;
}
.login-wrap { width: 100%; padding: 24px; }
.login-card {
  width: 100%; max-width: 360px; margin: 0 auto; padding: 28px 26px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-brand {
  display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px;
  margin-bottom: 20px;
}
.login-brand .brand-logo { width: 30px; height: 30px; border-radius: 22%; display: block; }
.login-alert {
  background: var(--danger-dim); color: var(--danger); border: 1px solid var(--danger);
  border-radius: var(--radius-sm); padding: 9px 12px; font-size: 13px; font-weight: 600;
  margin-bottom: 14px; overflow-wrap: break-word; word-break: break-word;
}
.login-submit { width: 100%; margin-top: 6px; padding: 10px 16px; font-size: 13.5px; }
.login-foot { margin: 16px 0 0; font-size: 12px; text-align: center; }

@media (max-width: 420px) {
  .login-wrap { padding: 16px; }
  .login-card { padding: 22px 18px; }
}
