:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --border: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --accent: #2f6feb;
  --accent-soft: #eaf1fe;
  --connected: #1a9d63;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1214;
    --surface: #171a1d;
    --border: #262b30;
    --text: #e8eaed;
    --muted: #9aa3ad;
    --accent: #6ea8ff;
    --accent-soft: #17263f;
    --connected: #35c98a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 -apple-system, "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 14px 24px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 9px; }
.brand-logo { width: 22px; height: 22px; flex: none; color: var(--accent); }
.env-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px;
}

.nav { color: var(--accent); text-decoration: none; font-size: 13px; }
.user-box { margin-left: auto; display: flex; align-items: center; gap: 12px; font-size: 13px; }
.user-box .who { color: var(--muted); text-decoration: none; }
.user-box a.who:hover { color: var(--accent); }
.user-box .logout { color: var(--accent); text-decoration: none; }

.shell { max-width: 1240px; margin: 0 auto; display: flex; align-items: flex-start; gap: 28px; padding: 0 24px; }
.wrap { flex: 1 1 auto; min-width: 0; padding: 32px 0 64px; }

.sidebar { flex: 0 0 236px; padding-top: 32px; }
.side-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; position: sticky; top: 24px; }
.side-h { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.side-cap { font-size: 11px; color: var(--muted); margin: 5px 0 12px; line-height: 1.45; }
.prop-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.prop { list-style: none; }
.prop-sum { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 600; color: var(--text); padding: 6px 8px; border-radius: 8px; }
.prop-sum::-webkit-details-marker { display: none; }
.prop-sum:hover { background: var(--accent-soft); }
.caret { flex: none; width: 0; height: 0; border-left: 5px solid var(--muted);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent; transition: transform .12s; }
.prop-d[open] > .prop-sum .caret { transform: rotate(90deg); }
.prop-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--connected); }
.prop-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.market-list { list-style: none; margin: 1px 0 0; padding: 0; }
.market { font-size: 12px; font-weight: 400; color: var(--muted); padding: 2px 8px 2px 29px; position: relative; }
.market::before { content: ""; position: absolute; left: 18px; top: 11px; width: 5px; height: 1px; background: var(--border); }
.prop-manage { display: inline-block; margin: 4px 0 6px 29px; font-size: 12px; color: var(--accent); text-decoration: none; }
.prop-manage:hover { text-decoration: underline; }
.prop-empty { font-size: 12px; color: var(--muted); font-style: italic; padding: 4px 8px; }

/* Property (manage) page */
.icon.big { font-size: 30px; line-height: 1; }
.status-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 1px 9px; border-radius: 999px; border: 1px solid currentColor; }
.st-active { color: var(--connected); }
.st-onboarding { color: #c58a00; }
.st-paused { color: var(--muted); }
.p-h { font-size: 14px; margin: 0 0 12px; }
.p-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 14px 0 6px; }
.p-note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.p-dl { display: grid; grid-template-columns: 210px 1fr; gap: 8px 18px; margin: 0; }
.p-dl dt { color: var(--muted); font-size: 13px; }
.p-dl dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.review + .review, form + div, form .review { margin-top: 14px; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; }
.persona { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; margin-bottom: 6px; }
.persona summary { cursor: pointer; font-weight: 600; }
.persona-body { margin-top: 8px; white-space: pre-wrap; color: var(--muted); font-size: 13px; }
.edit-actions { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
@media (max-width: 560px) { .p-dl { grid-template-columns: 1fr; gap: 2px 0; } .p-dl dt { margin-top: 10px; } }

/* Guide (How it works) page */
.guide-steps { list-style: decimal; margin: 0; padding-left: 22px; }
.guide-steps li { padding-bottom: 16px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.guide-steps li:last-child { border-bottom: none; padding-bottom: 0; margin-bottom: 0; }
.guide-step-title { font-weight: 700; margin-bottom: 4px; }
.guide-step-detail { color: var(--muted); line-height: 1.5; }
.guide-step-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.guide-tag { font-size: 12px; padding: 2px 9px; border-radius: 999px; border: 1px solid currentColor; white-space: nowrap; }
.guide-tag-model { color: var(--accent); }
.guide-tag-api { color: var(--connected); }

/* Handoff (Infrastructure & migration) page */
.data-table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; min-width: 560px; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: .03em; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: none; }
.data-table code { font-size: 12px; }
.risk-tag { font-size: 11px; font-weight: 700; color: #d03b3b; border: 1px solid currentColor; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.risk-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.risk-item { padding: 8px 12px; border-left: 3px solid #d03b3b; background: var(--bg); border-radius: 0 6px 6px 0; font-size: 14px; line-height: 1.5; }
.side-add { display: block; text-align: center; margin-top: 12px; padding: 8px 10px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--accent); color: var(--accent); border-radius: 8px; text-decoration: none; }
.side-add:hover { background: var(--accent-soft); }

@media (max-width: 820px) {
  .shell { flex-direction: column; gap: 0; padding: 0 16px; }
  .sidebar { flex: none; width: 100%; padding-top: 20px; }
  .side-card { position: static; }
  .wrap { width: 100%; padding-top: 20px; }
}

.login-wrap { min-height: 90vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 28px; width: 100%; max-width: 360px; }
.login-card h1 { font-size: 20px; margin: 0; }
.login-card .sub { color: var(--muted); margin: 4px 0 18px; }
.login-card .dev-note { color: var(--muted); font-size: 12px; margin: 14px 0 0; }

.hero h1 { font-size: 26px; margin: 0 0 4px; }
.hero p { color: var(--muted); margin: 0 0 24px; }

.actions { margin-bottom: 28px; }
.action-card {
  display: flex; align-items: center; gap: 14px;
  padding: 16px 18px; border: 1px solid var(--accent);
  background: var(--accent-soft); border-radius: var(--radius);
  text-decoration: none; color: var(--text);
}
.action-text { display: flex; flex-direction: column; }
.action-text small { color: var(--muted); }

.group { margin-top: 28px; }
.group h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }

.card {
  display: block; padding: 18px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius);
  text-decoration: none; color: var(--text); transition: border-color .12s, transform .12s;
}
.card:hover { border-color: var(--accent); transform: translateY(-1px); }
.card h3 { margin: 8px 0 4px; font-size: 17px; }
.card p { margin: 0; color: var(--muted); font-size: 13px; }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card-soon { opacity: .6; }
.card-info { border-style: dashed; background: transparent; }
.card-info h3 { color: var(--muted); font-weight: 600; }
.pill {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px;
}

.icon { font-size: 22px; }
.icon.big { font-size: 40px; }

.back { color: var(--accent); text-decoration: none; font-size: 14px; }
.service-head { display: flex; gap: 16px; align-items: flex-start; margin: 16px 0 24px; }
.service-head h1 { margin: 0 0 6px; }
.lede { margin: 0 0 6px; color: var(--text); }
.meta { margin: 0; color: var(--muted); font-size: 13px; }

.run-form {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; max-width: 520px;
}
.field { display: block; margin-bottom: 16px; }
.field .label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.tmpl-link { font-size: 12px; color: var(--accent); text-decoration: none; margin-left: 6px; }
.tmpl-link:hover { text-decoration: underline; }
.field input, .field select, .field textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text);
  font: inherit; resize: vertical;
}
.field input.cb { width: auto; margin-top: 2px; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 16px; padding: 4px 0; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.check input { width: auto; }
.run-btn {
  padding: 10px 16px; border: none; border-radius: 8px;
  background: var(--accent); color: #fff; font-weight: 600; opacity: .6; cursor: not-allowed;
}

.wiring { margin-top: 20px; color: var(--muted); font-size: 13px; }
.wiring h4 { margin: 0 0 4px; color: var(--text); }
code { background: var(--accent-soft); padding: 1px 5px; border-radius: 4px; }

.foot {
  max-width: 940px; margin: 0 auto; padding: 20px 24px;
  color: var(--muted); font-size: 12px; border-top: 1px solid var(--border);
}

/* Content Decay dashboard */
.stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0 22px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 20px; min-width: 110px; }
.stat-n { font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat-n.hi { color: #d9534f; } .stat-n.md { color: #c26a00; } .stat-n.lo { color: var(--muted); }
.stat-l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.decay-list { display: flex; flex-direction: column; gap: 12px; }
.decay-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.decay-top { display: flex; align-items: center; gap: 10px; }
.decay-title { font-weight: 700; font-size: 16px; flex: 1; }
.prio { font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; color: #fff; white-space: nowrap; }
.prio-high { background: #d9534f; } .prio-medium { background: #c26a00; } .prio-low { background: var(--muted); }
.decay-url { display: inline-block; margin: 6px 0; font-size: 13px; color: var(--accent); text-decoration: none; word-break: break-all; }
.decay-metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin: 6px 0; font-size: 13px; color: var(--muted); }
.decay-metrics .metric b { color: var(--text); }
.delta { font-weight: 600; } .delta.up { color: var(--good); } .delta.down { color: #d9534f; }
.decay-why { font-size: 14px; margin: 8px 0 4px; }
.decay-action { font-size: 14px; margin: 4px 0; }
.decay-date { font-size: 12px; color: var(--muted); margin-top: 8px; }
.badge-status.status-updated { color: #fff; background: var(--good); border-color: var(--good); }
.badge-status.status-ignored { color: var(--muted); }
.badge-status.status-new { color: var(--accent); border-color: var(--accent); }
.badge-status.status-in-progress { color: #8a6d00; background: #fff6d6; border-color: #f0e0a0; }

/* Runs history */
.muted { color: var(--muted); }
.runs-scroll { overflow-x: auto; max-width: 100%; }
.runs-table { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; min-width: 620px; }
.run-row { display: grid; grid-template-columns: 120px 130px 1fr 160px 90px; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  text-decoration: none; color: var(--text); font-size: 13px; }
a.run-row:hover { border-color: var(--accent); }
.run-head { background: transparent; border: none; color: var(--muted); font-size: 11px;
  text-transform: uppercase; letter-spacing: .05em; padding-bottom: 0; }
.rr-when { color: var(--muted); }
.rr-svc { font-weight: 600; }
.rr-sum, .rr-who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-who { color: var(--muted); }

/* Admin activity */
.admin-tag { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  border: 1px solid var(--border); border-radius: 999px; padding: 1px 8px; vertical-align: middle; }
.filterbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0; }
.chip-link { font-size: 13px; color: var(--text); text-decoration: none; border: 1px solid var(--border);
  border-radius: 999px; padding: 3px 10px; background: var(--surface); }
.chip-link.on { border-color: var(--accent); color: var(--accent); }
.act-row { grid-template-columns: 120px 170px 130px 1fr; }
.user-row { grid-template-columns: 2fr 110px 1.4fr; }
.userbar { margin: 14px 0; }
.role-pill { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em;
  padding: 1px 9px; border-radius: 999px; border: 1px solid currentColor; }
.role-admin { color: var(--accent); }
.role-operator { color: var(--connected); }
.role-viewer { color: var(--muted); }
.pw-cell { display: flex; align-items: center; gap: 10px; }
.pw { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 13px; letter-spacing: .02em; }
.pw-copy { font-size: 12px; color: var(--accent); background: transparent; border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 8px; cursor: pointer; }
.pw-copy:hover { border-color: var(--accent); }
.act-kind { font-size: 12px; font-weight: 600; }
.act-login { color: var(--muted); }
.act-run { color: var(--accent); }
.act-persona_approved, .act-article_written, .act-brief_from_idea, .act-generate_more_ideas { color: var(--good); }

/* --- P1: enabled forms, runs, status --- */
.run-btn.go { opacity: 1; cursor: pointer; }
.run-btn.go:hover { filter: brightness(1.06); }
.error-banner { background: #fdecea; color: #a1201a; border: 1px solid #f5c6c0;
  padding: 10px 12px; border-radius: 8px; max-width: 520px; margin: 0 0 16px; }
@media (prefers-color-scheme: dark){ .error-banner{ background:#3a1d1b; color:#f2b8b2; border-color:#5c2a26 } }

.status-row { display:flex; align-items:center; gap:10px; margin: 8px 0 16px; }
.badge { font-size:12px; font-weight:700; text-transform:uppercase; letter-spacing:.04em;
  padding:3px 10px; border-radius:999px; border:1px solid var(--border); }
.badge-queued { color: var(--muted); }
.badge-running { color:#8a6d00; background:#fff6d6; border-color:#f0e0a0; }
.badge-done { color:#fff; background:var(--good); border-color:var(--good); }
.badge-failed { color:#fff; background:#d9534f; border-color:#d9534f; }
.badge-review { color: var(--accent); border-color: var(--accent); }
@media (prefers-color-scheme: dark){ .badge-running{ background:#3a3320; color:#e8cf6a; border-color:#5c5230 } }
.raw { color: var(--muted); font-size: 13px; }

.inputs-summary { display:flex; flex-wrap:wrap; gap:8px; margin-bottom:16px; }
.chip { background: var(--accent-soft); border:1px solid var(--border); border-radius:999px;
  padding:2px 10px; font-size:12px; color:var(--text); }

.run-result { background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius); padding: 16px; }
.run-result:empty { display:none; }
.run-result pre { white-space: pre-wrap; word-break: break-word; background: var(--bg);
  padding:12px; border-radius:8px; max-height:360px; overflow:auto; font-size:13px; }
.run-result ul { margin: 6px 0 0; padding-left: 18px; }
.run-result .err { color:#d9534f; }
.run-result .sim-warn { color: #d9534f; }
.run-result .meta-block summary { cursor: pointer; }
.ref { color: var(--muted); font-size: 12px; margin-top: 14px; }

/* Topical Authority idea rows + actions */
.ideas { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 14px; }
.idea { display: flex; align-items: center; gap: 12px; justify-content: space-between;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--bg); }
.idea-main { font-size: 14px; }
.idea-main small { color: var(--muted); }
.risk { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--border); }
.risk-none { color: var(--good); }
.risk-low { color: #8a6d00; }
.risk-medium { color: #c26a00; }
.risk-high { color: #d9534f; border-color: #d9534f; }
.mini { padding: 6px 12px; border: 1px solid var(--accent); background: var(--accent); color: #fff;
  border-radius: 8px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.mini[disabled] { opacity: .6; cursor: default; }
.mini.ghost { background: transparent; color: var(--accent); }
.brief-done { color: var(--good); font-size: 13px; font-weight: 600; white-space: nowrap; }

.factcheck-pill { display: inline-block; margin: 0 0 14px; padding: 7px 15px; border-radius: 999px;
  background: #d9534f; color: #fff; font-weight: 700; font-size: 13px; text-decoration: none; }
.factcheck-pill:hover { filter: brightness(1.06); }

.copywrap { margin-top: 10px; }
.copy-btn { display: block; margin-bottom: 6px; }

/* Betting: review-the-tip step */
.review { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.review > p { margin-top: 0; }
.review details { margin-bottom: 10px; }
.review summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.review pre { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; font-size: 13px; max-height: 220px; overflow: auto; }
.persona { border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; background: var(--bg); }
.persona-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; gap: 10px; }
.persona-text { width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; resize: vertical; }
