/* GrowthOS v4 console — design system. Module-specific styles live in /views/<module>.css (loaded via ui.useStyles). */
:root {
  --ink: #0e1726; --ink-2: #16233a; --ink-3: #22324f;
  --bg: #f4f6fa; --surface: #ffffff; --surface-2: #f8fafc; --line: #e3e8f0; --line-2: #d3dbe7;
  --text: #0f1b2d; --muted: #5b6b82; --faint: #64748b;
  --brand: #2659e0; --brand-2: #5b8cff; --brand-soft: #e8efff;
  --teal: #0a7a69; --teal-soft: #e2f7f2;
  --amber: #d98a00; --amber-soft: #fff4dc;
  --red: #c53030; --red-soft: #fde8e8;
  --violet: #7a5cff;
  --excellent: #12b39a; --good: #2f6bff; --fair: #d98a00; --poor: #d64545; --unknown: #a3afc2;
  --radius: 14px; --radius-sm: 9px; --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgba(15, 27, 45, .06);
  --shadow: 0 1px 2px rgba(15, 27, 45, .05), 0 8px 24px -12px rgba(15, 27, 45, .14);
  --shadow-lg: 0 24px 60px -20px rgba(15, 27, 45, .35);
  --font: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sidebar-w: 248px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
/* Links inside running text must not rely on colour alone (WCAG 1.4.1). */
#main p a:not(.btn), #main li a:not(.btn), .login-wrap p a:not(.btn) { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 17px; font-weight: 650; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--surface-2); border: 1px solid var(--line); padding: 1px 5px; border-radius: 6px; }
pre code { background: transparent; border: 0; padding: 0; color: inherit; }
pre { background: var(--ink); color: #dbe6ff; padding: 14px 16px; border-radius: var(--radius-sm); overflow: auto; white-space: pre-wrap; word-break: break-word; max-height: 460px; }
pre.secret { font-size: 13px; user-select: all; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }
.icon { flex: none; }
.muted { color: var(--muted); }
.tiny { font-size: 12px; }
.unknown { color: var(--faint); font-style: normal; font-weight: 500; }
.danger-text { color: var(--red) !important; }
.skip-link { position: absolute; left: -999px; top: 8px; background: var(--brand); color: #fff; padding: 8px 12px; border-radius: 8px; z-index: 100; }
.skip-link:focus { left: 12px; }
.boot, .loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px; justify-content: center; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--line-2); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--ink); color: #c9d4e6; display: flex; flex-direction: column; padding: 18px 14px; gap: 18px; overflow-y: auto; }
.brandmark { display: flex; align-items: center; gap: 10px; color: #fff; padding: 4px 8px; text-decoration: none !important; }
.mark { display: inline-grid; grid-template-columns: repeat(3, 6px); gap: 3px; align-items: end; height: 22px; }
.mark i { display: block; width: 6px; border-radius: 3px; background: linear-gradient(180deg, #5b8cff, #37d6b4); }
.mark i:nth-child(1) { height: 9px; } .mark i:nth-child(2) { height: 15px; } .mark i:nth-child(3) { height: 22px; }
.wordmark { font-size: 18px; font-weight: 600; letter-spacing: -.02em; }
.wordmark b { font-weight: 800; color: #7fe8cf; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8597b3; padding: 14px 10px 6px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: #c9d4e6; font-weight: 500; transition: background .15s, color .15s; text-decoration: none !important; }
.nav-link:hover { background: var(--ink-2); color: #fff; }
.nav-link.active { background: linear-gradient(90deg, rgba(91, 140, 255, .22), rgba(91, 140, 255, .06)); color: #fff; box-shadow: inset 2px 0 0 #5b8cff; }
.sidebar-foot { margin-top: auto; font-size: 12px; color: #8597b3; display: flex; align-items: center; gap: 8px; padding: 0 10px; }
.sidebar-foot .dot { width: 7px; height: 7px; border-radius: 50%; background: #37d6b4; box-shadow: 0 0 0 3px rgba(55, 214, 180, .18); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: rgba(244, 246, 250, .86); backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a { color: var(--muted); } .crumbs span:last-child { color: var(--text); font-weight: 600; }
.crumbs .sep { color: var(--line-2); }
.top-actions { display: flex; align-items: center; gap: 10px; }
#main { padding: 28px; max-width: 1360px; width: 100%; margin: 0 auto; outline: none; }
.mobile-only { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(14, 23, 38, .45); z-index: 29; }
.user-menu { position: relative; }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--brand), var(--violet)); color: #fff; font-weight: 700; cursor: pointer; }
.menu { position: absolute; right: 0; top: 42px; min-width: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; z-index: 40; }
.menu-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; display: flex; flex-direction: column; }
.menu-head span { font-size: 12px; color: var(--muted); }
.menu button { display: flex; width: 100%; align-items: center; gap: 8px; padding: 8px 10px; border: 0; background: none; border-radius: 8px; cursor: pointer; font: inherit; color: var(--text); }
.menu button:hover { background: var(--surface-2); }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; transition: transform .12s, box-shadow .15s, background .15s, border-color .15s; text-decoration: none !important; white-space: nowrap; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); color: #fff; box-shadow: 0 6px 16px -8px rgba(47, 107, 255, .8); }
.btn.primary:hover:not(:disabled) { background: #245ae8; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line-2); }
.btn.ghost:hover:not(:disabled) { border-color: var(--brand-2); color: var(--brand); }
.btn.danger { background: var(--red); color: #fff; }
.btn.teal { background: var(--teal); color: #fff; }
.btn.small { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; color: var(--text); }
.form { display: grid; gap: 14px; }
.form.grid-2 { grid-template-columns: 1fr 1fr; }
.form .span-2 { grid-column: 1 / -1; }
.form label { display: grid; gap: 6px; font-weight: 600; font-size: 13px; color: var(--text); }
.form label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.form small { font-weight: 400; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--line-2); border-radius: 10px; padding: 9px 12px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { resize: vertical; min-height: 70px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(47, 107, 255, .15); }
.form-error { color: var(--red); background: var(--red-soft); padding: 8px 12px; border-radius: 8px; font-size: 13px; }

/* ---------- page primitives ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.lead { color: var(--muted); margin-top: 6px; max-width: 720px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); margin-bottom: 18px; }
.panel h2 { margin-bottom: 12px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.panel-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 8px 0 0; }
.chips > * { font-size: 12px; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); }
.chips .lang { background: var(--teal-soft); border-color: transparent; color: #0b7d6b; }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.badge-neutral { background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-info { background: var(--brand-soft); color: #1f4fd1; }
.badge-success { background: var(--teal-soft); color: #0b7d6b; }
.badge-warn { background: var(--amber-soft); color: #9a6200; }
.badge-danger { background: var(--red-soft); color: #b42f2f; }
.empty-state { text-align: center; padding: 56px 24px; background: var(--surface); border: 1px dashed var(--line-2); border-radius: var(--radius-lg); color: var(--muted); display: grid; justify-items: center; gap: 10px; }
.empty-state h3 { color: var(--text); font-size: 17px; }
.error-box { display: flex; gap: 12px; align-items: flex-start; background: var(--red-soft); color: #8f2626; border-radius: var(--radius); padding: 14px 16px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table .actions { white-space: nowrap; text-align: right; }

/* ---------- score ring ---------- */
.score-ring { position: relative; display: inline-grid; place-items: center; flex: none; }
.score-ring svg { position: absolute; inset: 0; }
.score-ring .track { stroke: #edf1f7; }
.score-ring .bar { transition: stroke-dashoffset .8s cubic-bezier(.2, .8, .2, 1); }
.score-ring.excellent .bar { stroke: var(--excellent); } .score-ring.good .bar { stroke: var(--good); }
.score-ring.fair .bar { stroke: var(--fair); } .score-ring.poor .bar { stroke: var(--poor); } .score-ring.unknown .bar { stroke: transparent; }
.score-ring .value { font-weight: 750; font-size: 20px; letter-spacing: -.02em; z-index: 1; }
.score-ring.unknown .value { color: var(--faint); }
.score-ring .ring-label { position: absolute; bottom: -20px; font-size: 11px; color: var(--muted); white-space: nowrap; }

/* ---------- overview: brand rows & lenses ---------- */
.brand-stack { display: grid; gap: 18px; }
.brand-row { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.brand-row-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.brand-title { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none !important; }
.brand-title small { display: block; color: var(--muted); font-size: 12.5px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.brand-avatar { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg, #1d2b45, #3a4f7a); color: #fff; font-weight: 700; flex: none; }
.brand-avatar.lg { width: 46px; height: 46px; border-radius: 12px; font-size: 18px; }
.brand-avatar.xl { width: 60px; height: 60px; border-radius: 16px; font-size: 24px; }
.lens-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.lens { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; background: var(--surface-2); display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.lens header { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.lens header h3 { font-size: 13px; color: var(--text); }
.lens header small { color: var(--faint); font-weight: 500; margin-left: 4px; }
.lens-body { display: flex; align-items: center; gap: 14px; }
.lens dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 10px; margin: 0; font-size: 12.5px; }
.lens dt { color: var(--muted); } .lens dd { margin: 0; font-weight: 600; }
.lens .kv { font-size: 13px; }
.lens-note { font-size: 11.5px; color: var(--faint); margin-top: auto; }
.lens-sub { font-size: 11.5px; color: var(--muted); }
.funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.funnel li { display: grid; grid-template-columns: 1fr auto 44px; align-items: center; gap: 8px; font-size: 12.5px; padding: 4px 8px; border-radius: 7px; background: linear-gradient(90deg, rgba(47, 107, 255, .09), transparent); }
.funnel li:nth-child(2) { background: linear-gradient(90deg, rgba(47, 107, 255, .07), transparent); }
.funnel li:nth-child(3) { background: linear-gradient(90deg, rgba(18, 179, 154, .09), transparent); }
.funnel li:nth-child(4) { background: linear-gradient(90deg, rgba(122, 92, 255, .09), transparent); }
.funnel li:nth-child(5) { background: linear-gradient(90deg, rgba(217, 138, 0, .11), transparent); }
.funnel em { font-style: normal; color: var(--muted); font-size: 11px; text-align: right; }

/* ---------- brand cards & detail ---------- */
.brand-card { display: flex; flex-direction: column; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; color: var(--text); text-decoration: none !important; box-shadow: var(--shadow-sm); transition: transform .18s, box-shadow .18s, border-color .18s; }
.brand-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-2); }
.brand-card-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.brand-card-title { color: var(--text); text-decoration: none !important; }
.brand-card-title:hover { color: var(--brand); }
.brand-card-open { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; }
.brand-card footer { margin-top: auto; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 12.5px; }
.brand-hero { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.brand-hero-main { display: flex; gap: 16px; align-items: center; }
.brand-hero h1 { font-size: 24px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; scrollbar-width: none; }
.tab { padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab-body > .lens-grid { margin-bottom: 14px; }

/* ---------- brand ledger strip ---------- */
.brand-ledger-strip {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tab-body > .brand-ledger-strip { margin-bottom: 18px; }
.ledger-strip-main { display: flex; flex-direction: column; gap: 8px; }
.ledger-strip-summary { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; font-size: 13px; }
.ledger-strip-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--brand);
  background: var(--brand-soft);
  padding: 2px 8px;
  border-radius: 999px;
}
.ledger-strip-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.ledger-next-badge { border: 1px solid rgba(47, 107, 255, .25); }
.ledger-strip-links { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 4px; border-top: 1px dashed var(--line); }
.badge-amber { background: var(--amber-soft); color: #9a6200; border: 1px solid rgba(217, 138, 0, .25); }
.badge-muted { background: var(--surface-2); color: var(--faint); border: 1px solid var(--line); }

/* ---------- multi-agent relay studio ---------- */
.relay-studio {
  border-color: rgba(47, 107, 255, .28);
  background: linear-gradient(180deg, rgba(232, 239, 255, .35) 0%, var(--surface) 90px);
}
.relay-studio-head { align-items: flex-start; margin-bottom: 16px; }
.relay-studio-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.relay-controls-bar {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 340px);
  gap: 14px;
  align-items: end;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 14px;
}
.relay-agent-groups { display: flex; flex-direction: column; gap: 10px; }
.relay-agent-group { display: flex; flex-direction: column; gap: 6px; }
.relay-group-label { font-size: 11.5px; font-weight: 650; color: var(--muted); letter-spacing: .02em; }
.relay-agent-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.relay-agent-tab {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: border-color .15s, background .15s, box-shadow .15s, transform .1s;
}
.relay-agent-tab strong { font-size: 13px; font-weight: 700; }
.relay-agent-tab small { font-size: 11px; color: var(--muted); font-weight: 500; }
.relay-agent-tab:hover { border-color: var(--brand-2); }
.relay-agent-tab.active {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: #163ea8;
  box-shadow: 0 2px 8px -3px rgba(47, 107, 255, .35);
}
.relay-agent-tab.active small { color: #2b57c9; }
.relay-agent-tab.relay-ops-tab.active {
  border-color: var(--teal);
  background: var(--teal-soft);
  color: #095e50;
}
.relay-agent-tab.relay-ops-tab.active small { color: #0b7d6b; }
.relay-module-picker { display: grid; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--text); }
.relay-prompt-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.relay-prompt-meta { display: flex; flex-direction: column; gap: 8px; }
.relay-prompt-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.relay-diagnostic-reason {
  font-size: 13px;
  color: var(--text);
  background: var(--surface-2);
  border-left: 3px solid var(--brand);
  padding: 8px 12px;
  border-radius: 0 8px 8px 0;
}
.relay-prompt-editor-wrap { display: grid; gap: 8px; }
.relay-prompt-pre { margin: 0; max-height: 320px; font-size: 12.5px; line-height: 1.5; }
.relay-prompt-textarea {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--surface-2);
  color: var(--text);
  min-height: 96px;
}
.relay-callback-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}
.relay-callback-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}
.relay-callback-pre { margin: 0; padding: 10px 12px; font-size: 12px; max-height: 110px; }
.relay-callback-pre code { background: transparent; border: 0; color: #7fe8cf; padding: 0; }

/* ---------- 12-module feature matrix ---------- */
.feature-matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}
.feature-module-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--surface-2);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.feature-module-card:hover { border-color: var(--line-2); box-shadow: var(--shadow-sm); }
.feature-module-card.status-recorded { border-left: 3px solid var(--teal); background: var(--surface); }
.feature-module-card.status-draft_for_review { border-left: 3px solid var(--amber); background: var(--surface); }
.feature-module-card.status-needs_inputs { border-left: 3px solid var(--red); background: var(--surface); }
.feature-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.feature-card-title { display: flex; align-items: center; gap: 7px; min-width: 0; }
.feature-card-title h3 { font-size: 13.5px; line-height: 1.3; }
.feature-code-badge {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  flex: none;
}
.feature-card-count { font-size: 12.5px; color: var(--text); }
.feature-card-summary { font-size: 12.5px; line-height: 1.45; }
.feature-evidence-chips { margin-top: 2px; }
.feature-card-actions {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
}

/* ---------- 48 checks & execution timeline ---------- */
.checks-breakdown-box {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.checks-breakdown-stats { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.checks-progress-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--line);
}
.checks-progress-bar .bar-seg { display: block; height: 100%; }
.checks-progress-bar .seg-evaluated { background: var(--teal); }
.checks-progress-bar .seg-candidate { background: var(--brand); }
.checks-progress-bar .seg-unknown { background: var(--unknown); }

.execution-timeline {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.timeline-item {
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timeline-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.timeline-sha { font-size: 11.5px; color: var(--muted); }
.timeline-body { display: flex; flex-direction: column; gap: 2px; }

/* ---------- dialogs & toasts ---------- */
.dialog { border: 0; padding: 0; border-radius: var(--radius-lg); width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); color: var(--text); }
.dialog-wide { width: min(860px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(14, 23, 38, .5); backdrop-filter: blur(2px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 20px; max-height: calc(100vh - 160px); overflow: auto; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.confirm-text { margin-bottom: 16px; }
#toast-host { position: fixed; right: 20px; bottom: 20px; display: grid; gap: 8px; z-index: 200; }
.toast { min-width: 220px; max-width: 380px; padding: 11px 16px; border-radius: 11px; background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(8px); transition: opacity .25s, transform .25s; font-weight: 500; }
.toast.show { opacity: 1; transform: none; }
.toast-success { background: #0b7d6b; } .toast-error { background: #b42f2f; } .toast-warn { background: #9a6200; }

/* ---------- login ---------- */
.login-body { background: var(--ink); min-height: 100vh; }
.login-wrap { display: grid; grid-template-columns: 1.1fr 1fr; min-height: 100vh; }
.login-art { position: relative; overflow: hidden; padding: 48px 56px; color: #dbe6ff; display: flex; flex-direction: column; justify-content: center; gap: 26px;
  background: radial-gradient(1200px 600px at -10% 110%, rgba(55, 214, 180, .22), transparent 60%), radial-gradient(900px 500px at 110% -10%, rgba(91, 140, 255, .35), transparent 60%), var(--ink); }
.login-brand { position: absolute; top: 40px; left: 56px; display: flex; gap: 10px; align-items: center; color: #fff; }
.login-art h1 { font-size: clamp(28px, 3.2vw, 42px); line-height: 1.2; color: #fff; max-width: 560px; letter-spacing: -.02em; }
.login-points { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; color: #b8c6e0; }
.login-points li::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #37d6b4; margin-right: 10px; box-shadow: 0 0 0 4px rgba(55, 214, 180, .15); }
.login-orbit { position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; pointer-events: none; }
.login-orbit span { position: absolute; inset: 0; border: 1px solid rgba(127, 232, 207, .18); border-radius: 50%; animation: orbit 18s linear infinite; }
.login-orbit span:nth-child(2) { inset: 50px; border-color: rgba(91, 140, 255, .25); animation-duration: 26s; animation-direction: reverse; }
.login-orbit span:nth-child(3) { inset: 110px; border-style: dashed; animation-duration: 40s; }
@keyframes orbit { to { transform: rotate(360deg); } }
.login-panel { background: var(--bg); display: grid; place-items: center; padding: 32px; }
.login-form { width: min(380px, 100%); background: var(--surface); padding: 32px; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.login-form h2 { font-size: 22px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) { .lens-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
  .mobile-only { display: inline-flex; }
  .topbar { padding: 10px 16px; }
  #main { padding: 18px 16px; }
  .two-col, .three-col { grid-template-columns: minmax(0, 1fr); }
  .form.grid-2 { grid-template-columns: minmax(0, 1fr); }
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .hide-sm { display: none; }
}
@media (max-width: 560px) {
  .lens-grid { grid-template-columns: 1fr; } h1 { font-size: 22px; }
  .topbar { gap: 8px; }
  .top-actions { gap: 6px; min-width: 0; }
  #brand-select { min-width: 0 !important; max-width: 128px; }
  .hide-xs { display: none; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
.noscript { padding: 24px; text-align: center; }

/* ---------- novice 3-step autopilot cockpit ---------- */
.autopilot-hero {
  background: linear-gradient(135deg, rgba(29,91,255,.06), rgba(11,148,136,.07));
  padding: 22px;
  border-radius: var(--radius-lg);
  border: 1px solid rgba(29,91,255,.22);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.autopilot-hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.autopilot-hero-top h2 {
  margin: 8px 0 4px;
  font-size: 19px;
}
.autopilot-steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.autopilot-step-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}
.autopilot-step-card h3 {
  font-size: 15px;
  margin: 0;
}
.autopilot-step-highlight {
  border: 1.5px solid var(--brand);
  box-shadow: 0 8px 24px -10px rgba(47, 107, 255, .25);
  background: linear-gradient(180deg, rgba(232, 239, 255, .42) 0%, var(--surface) 65%);
}
.autopilot-step-num {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
}
.autopilot-step-highlight .autopilot-step-num {
  background: var(--brand);
  color: #fff;
}
.autopilot-step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
  padding-top: 10px;
}
.autopilot-feedback {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  background: var(--brand-soft);
  border: 1px solid rgba(47, 107, 255, .25);
  color: #163ea8;
  font-size: 13px;
  font-weight: 500;
}
.autopilot-wizard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.autopilot-readiness-bar {
  position: relative;
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: 8px 0;
}
.autopilot-readiness-bar > span,
.autopilot-readiness-bar .fill,
.autopilot-readiness-fill {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand), var(--teal));
  transition: width .35s ease;
}
.autopilot-next-actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.autopilot-quick-agents {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

/* ---------- unified view tabs & merged classic panels ---------- */
.unified-view-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.unified-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, box-shadow .15s;
}
.unified-tab-btn:hover:not(.active) {
  border-color: var(--brand-2);
  color: var(--brand);
  background: var(--surface);
}
.unified-tab-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 4px 12px -4px rgba(47, 107, 255, .55);
}

.classic-merged-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 18px;
}
.classic-dim-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.classic-dim-card,
.classic-phase-card,
.classic-gate-card,
.classic-resource-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
  transition: border-color .15s, box-shadow .15s;
}
.classic-dim-card:hover,
.classic-phase-card:hover,
.classic-gate-card:hover,
.classic-resource-card:hover {
  border-color: var(--line-2);
  box-shadow: var(--shadow-sm);
}
.classic-phase-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.classic-checks-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
}
.classic-gates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.classic-resources-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 12px;
}
.classic-policy-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

/* ---------- novice 3-step quick guide strip ---------- */
.novice-guide-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  margin-bottom: 18px;
  border-radius: var(--radius);
  border: 1px solid rgba(47, 107, 255, .24);
  background: linear-gradient(135deg, rgba(47, 107, 255, .06), rgba(18, 179, 154, .06));
  box-shadow: var(--shadow-sm);
}

@media (max-width: 900px) {
  .autopilot-steps-grid,
  .autopilot-wizard-grid,
  .autopilot-next-actions-grid,
  .feature-matrix-grid,
  .relay-controls-bar {
    grid-template-columns: 1fr;
  }
}

/* Phone widths: long button labels, badges and code headings must wrap instead of widening the page. */
@media (max-width: 560px) {
  .row-actions { max-width: 100%; }
  .row-actions .btn { white-space: normal; height: auto; min-height: 32px; padding-top: 6px; padding-bottom: 6px; text-align: left; }
  .autopilot-hero-top > * { min-width: 0; max-width: 100%; }
  .autopilot-hero-top .badge { white-space: normal; }
}
.wf-drawer-section h3, .wf-drawer-section code { overflow-wrap: anywhere; }
@media (max-width: 560px) { .wf-code-toolbar > * { min-width: 0; max-width: 100%; } .wf-code-toolbar select { min-width: 0 !important; max-width: 100%; } }
@media (max-width: 560px) {
  /* Long hashes/IDs and inline-styled flex rows (many views use style="display:flex") must not widen the page. */
  #main { overflow-wrap: anywhere; }
  #main .btn { white-space: normal; height: auto; min-height: 32px; padding-top: 6px; padding-bottom: 6px; }
  #main [style*="display:flex"], #main [style*="display: flex"] { flex-wrap: wrap; }
  #main [style*="display:flex"] > *, #main [style*="display: flex"] > * { min-width: 0; max-width: 100%; }
}
