:root {
  --bg: #f4f6f9; --surface: #fff; --ink: #1b2430; --muted: #5f6b7a; --line: #dfe4ea;
  --brand: #1d3557; --brand-2: #2b6cb0; --danger: #b42318; --danger-bg: #fdecea;
  --ok: #1a7f4b; --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.container { max-width: 1180px; margin: 0 auto; padding: 0 20px; }

.topbar { background: var(--brand); color: #fff; }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 22px; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 13px; color: #b8c7de; }
nav a { color: #d6e0f0; padding: 8px 14px; border-radius: 8px; margin-left: 4px; font-weight: 500; }
nav a:hover { background: rgba(255,255,255,.1); text-decoration: none; }
nav a.active { background: #fff; color: var(--brand); }

main.container { padding-top: 24px; padding-bottom: 32px; min-height: 70vh; }
.footer { color: var(--muted); font-size: 12.5px; padding-bottom: 28px; }

h2 { margin: 0 0 4px; font-size: 22px; }
h3 { margin: 0 0 10px; font-size: 16px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--muted); margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.card h3 + .sub { margin-top: -6px; margin-bottom: 10px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: inherit; display: block; border-top: 3px solid var(--c, var(--brand-2)); }
a.stat:hover { text-decoration: none; box-shadow: 0 2px 10px rgba(29,53,87,.12); }
.stat .n { font-size: 30px; font-weight: 700; line-height: 1.1; }
.stat .l { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat.total { --c: var(--brand); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: #fafbfc; }
tbody tr:hover { background: #fafcff; }
.table-wrap { overflow-x: auto; }
td.actions { white-space: nowrap; text-align: right; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; letter-spacing: .3px; background: #e8edf3; color: #3a4757; white-space: nowrap; }
.b-NEW { background: #e3eefc; color: #1c4f8f; } .b-ANALYZED { background: #e6e8fb; color: #3b3fa3; }
.b-QUALIFIED { background: #e1f4f1; color: #0c6b5f; } .b-DRAFT_READY { background: #fff2d6; color: #8a5a00; }
.b-APPROVED { background: #dcf3e4; color: #166534; } .b-CONTACTED { background: #e9e0f7; color: #5b2f9e; }
.b-REPLIED { background: #d9f0fa; color: #0b6a8e; } .b-CONVERTED { background: #c9f0d2; color: #0f6a2b; }
.b-CLOSED { background: #eceef1; color: #55606e; } .b-DO_NOT_CONTACT { background: #fde2df; color: #9b1c12; }
.b-PLANNED { background: #e3eefc; color: #1c4f8f; } .b-ACTIVE { background: #dcf3e4; color: #166534; }
.b-PAUSED { background: #fff2d6; color: #8a5a00; } .b-COMPLETED { background: #c9f0d2; color: #0f6a2b; }
.b-ARCHIVED { background: #eceef1; color: #55606e; }
.b-UNKNOWN { background: #eceef1; color: #55606e; } .b-VERIFIED_PRESENT { background: #dcf3e4; color: #166534; }
.b-VERIFIED_MISSING { background: #fde2df; color: #9b1c12; } .b-NOT_FOUND { background: #fff2d6; color: #8a5a00; }
.b-NOT_APPLICABLE { background: #e6e8fb; color: #3b3fa3; }

button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 7px 14px; border-radius: 8px; font-weight: 500; }
button:hover, .btn:hover { background: #f1f4f8; text-decoration: none; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: #274a78; }
button.danger { color: var(--danger); border-color: #f0c2bd; }
button.danger:hover { background: var(--danger-bg); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.small { padding: 3px 10px; font-size: 13px; }
button:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

.filters { display: grid; grid-template-columns: 2fr repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
@media (max-width: 860px) { .filters { grid-template-columns: 1fr 1fr; } }
input, select, textarea { font: inherit; width: 100%; padding: 8px 10px; border: 1px solid #c8d0da; border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 80px; resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; }
label .req { color: var(--danger); }
.field { margin-bottom: 12px; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--danger); }
.field .err { color: var(--danger); font-size: 12.5px; margin-top: 3px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.alert { background: var(--danger-bg); color: var(--danger); border: 1px solid #f0c2bd; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.alert.info { background: #eaf2fb; color: #1c4f8f; border-color: #c9dbf2; }
.alert.warn { background: #fff7e0; color: #7a5200; border-color: #f0dca6; }

dialog { border: 0; border-radius: 12px; padding: 22px; width: min(720px, 94vw); max-height: 92vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(20,30,45,.5); }
dialog h3 { font-size: 18px; margin-bottom: 14px; }

.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.25); max-width: 360px; }
.toast.error { background: var(--danger); }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 860px) { .detail-grid { grid-template-columns: 1fr; } }
dl.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; margin: 0; }
dl.kv dt { color: var(--muted); font-size: 13px; }
dl.kv dd { margin: 0; word-break: break-word; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }
.progress { height: 8px; background: #e8edf3; border-radius: 999px; overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--brand-2); }
.state-legend { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 10px; margin-top: 12px; }
.state-legend div { font-size: 13px; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted); font-size: 12.5px; }

/* Phase 2A: public page audit */
.audit-row { display: flex; gap: 10px; }
.audit-row input { flex: 1; }
.audit-form { margin-bottom: 14px; }
.small-note { font-size: 12.5px; margin-top: 4px; }
.audit-page { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.audit-page h4 { margin: 0; font-size: 15px; word-break: break-all; }
.ev-group { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 0 12px; }
.ev-group > summary { cursor: pointer; padding: 10px 0; font-weight: 600; }
.ev-group[open] > summary { border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.ev-value { word-break: break-word; }
.badge.b-RUNNING { background: #fff2d6; color: #8a5a00; }

/* Phase 2B: site discovery */
.stat.small { padding: 10px 12px; }
.stat.small .n { font-size: 22px; }
.sub-h { margin: 18px 0 8px; font-size: 14px; }
.cand-filters { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; }
.cand-filters select { width: auto; min-width: 240px; }
.inline-check { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 0; }
.inline-check input { width: auto; }
.wrap-url { word-break: break-all; }
.discovery-run { align-items: center; margin-bottom: 12px; }
.discovery-run .muted { flex: 1; }
.b-HOME { background: #e3eefc; color: #1c4f8f; } .b-SERVICE { background: #dcf3e4; color: #166534; }
.b-LOCATION { background: #e1f4f1; color: #0c6b5f; } .b-ABOUT { background: #e6e8fb; color: #3b3fa3; }
.b-CONTACT { background: #fff2d6; color: #8a5a00; } .b-BLOG { background: #e9e0f7; color: #5b2f9e; }
.b-ARTICLE { background: #f0e6fa; color: #6a3aa8; } .b-CATEGORY { background: #d9f0fa; color: #0b6a8e; }
.b-PRODUCT { background: #fde9d9; color: #9a4a10; } .b-LEGAL { background: #eceef1; color: #55606e; }
.b-OTHER { background: #f1f3f5; color: #55606e; }
.b-PARSED { background: #dcf3e4; color: #166534; } .b-SKIPPED_ROBOTS { background: #fff2d6; color: #8a5a00; }
.b-MALFORMED, .b-UNSUPPORTED { background: #fde2df; color: #9b1c12; }
.b-COMPLETED { background: #dcf3e4; color: #166534; } .b-COMPLETED_WITH_WARNINGS { background: #fff2d6; color: #8a5a00; }
.b-FAILED { background: #fde2df; color: #9b1c12; }

/* Phase 2C: site evidence audit */
.b-SKIPPED { background: #fff2d6; color: #8a5a00; }
.dup-list { margin: 6px 0 0; padding-left: 18px; }
.dup-list li { margin-bottom: 4px; }
.obs-row > td { padding: 0 12px 10px; background: #fafbfc; }
.obs-row summary { cursor: pointer; font-size: 13px; color: var(--muted); }
.sample-scope { margin-top: 10px; }

/* Phase 2D: performance & technical evidence (lab / field / transport are visibly separate) */
.perf-block { border: 1px solid var(--line); border-left: 5px solid var(--brand-2); border-radius: 8px; padding: 12px 16px; margin: 14px 0; }
.perf-block h4 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.perf-lab { border-left-color: #2b6cb0; }
.perf-field { border-left-color: #8a5a00; background: #fffdf5; }
.perf-transport { border-left-color: #1a7f4b; }
.perf-guard { border-left-color: #5f6b7a; }
.perf-kv dt { font-size: 13px; }
.perf-pick select { margin-top: 8px; }
.badge.b-LAB { background: #e3eefc; color: #1c4f8f; }
.badge.b-FIELD { background: #fff2d6; color: #8a5a00; }
.badge.b-TRANSPORT { background: #dcf3e4; color: #166534; }
.audit-row select { width: auto; min-width: 180px; }

/* Phase 2E: evidence changes - deliberately NEUTRAL: no green/red, no direction semantics */
.badge.chg { background: #eef1f6; color: #2f4a75; border: 1px solid #d3dae6; }
.badge.chg-UNCHANGED { background: #f6f7f9; color: #5f6b7a; border-color: #e3e7ee; }
.badge.chg-ADDED, .badge.chg-REMOVED, .badge.chg-NOT_AVAILABLE, .badge.chg-NOT_DIRECTLY_COMPARABLE, .badge.chg-CONTEXT { background: #fff; color: #5f6b7a; border: 1px dashed #b7c0cf; }
.badge.chg-STATE { background: #f6f7f9; color: #5f6b7a; border-color: #e3e7ee; font-weight: 500; }
.cmp-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: end; }
.cmp-go { padding-bottom: 1px; }
@media (max-width: 900px) { .cmp-controls { grid-template-columns: 1fr 1fr; } }
.cmp-runs { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin: 12px 0; }
@media (max-width: 860px) { .cmp-runs { grid-template-columns: 1fr; } }
.cmp-run { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.cmp-run h5 { margin: 0 0 6px; font-size: 14px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }

/* Content signals (Phase 3 prerequisite): neutral, observational */
.sig-block { border-top: 1px solid var(--line); padding: 10px 0; }
.sig-block h5 { margin: 0 0 6px; font-size: 14px; }
.sig-list { margin: 4px 0 0; padding-left: 18px; }
.sig-list li { margin-bottom: 2px; word-break: break-word; }
.sig-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }

/* Phase 3A business intelligence: states are told apart by shape/outline and text, not by traffic-light colour or score semantics */
.badge.st-SUPPORTED { background: #e3eefc; color: #1c4f8f; border: 1px solid #1c4f8f; }
.badge.st-CANDIDATE { background: transparent; color: #55606e; border: 1px dashed #8793a1; }
.badge.st-AMBIGUOUS { background: #fff2d6; color: #8a5a00; border: 1px dotted #8a5a00; }
.badge.st-UNKNOWN { background: #f1f3f5; color: #55606e; border: 1px solid #d5dae0; }
.bi-unknown { padding: 8px 10px; background: #f6f7f9; border: 1px solid #e3e6ea; border-radius: 6px; color: #55606e; }
.bi-table td { vertical-align: top; }
.bi-row.bi-CANDIDATE td { background: #fafbfc; }
.bi-support summary { cursor: pointer; font-size: 0.85em; color: #55606e; }

/* Phase 3B market evidence */
.b-PENDING { background: #fff2d6; color: #8a5a00; }
.check { display: block; margin: 8px 0; }
button.link { background: none; border: 0; color: #1c4f8f; text-decoration: underline; cursor: pointer; padding: 0; }
#market-research input[type="text"] { min-width: 14em; }

/* Phase 3C evidence matrix: states are told apart by outline and text only; no traffic-light or ranking semantics */
.badge.mx-state { background: transparent; color: #3b4654; border: 1px solid #8793a1; }
.badge.mx-NOT_COLLECTED { border-style: dashed; color: #55606e; }
.badge.mx-PENDING { border-style: dotted; color: #8a5a00; border-color: #8a5a00; }
.badge.mx-FAILED { background: #eceef1; color: #55606e; border-color: #c4cad2; }
.badge.mx-COLLECTED_METRICS_AVAILABLE, .badge.mx-COLLECTED_NO_PROVIDER_METRICS, .badge.mx-COLLECTED_NO_PROVIDER_ROW { background: #e3eefc; color: #1c4f8f; border-color: #1c4f8f; }
.mx-table td { vertical-align: top; }
.mx-prov { margin: 4px 0 8px; }

/* ---- Prospect workspace (tabs + factual status strip). Organisation only: panels are shown/hidden with [hidden], never re-created. */
.ws { min-width: 0; }
.ws-persistent { min-width: 0; }
.ws-status { margin: 0 0 14px; }
.ws-strip { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 6px; padding: 0; list-style: none; }
.ws-strip li { min-width: 0; max-width: 100%; }
.ws-chip { display: inline-flex; align-items: baseline; gap: 6px; max-width: 100%; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font: inherit; font-size: 13px; text-align: left; cursor: pointer; overflow-wrap: anywhere; }
.ws-chip:hover { border-color: var(--brand-2); }
.ws-chip .ws-glyph { font-size: 12px; }
.ws-state-warning { border-color: #b7791f; background: #fff8e6; }
.ws-state-review { border: 2px solid var(--brand-2); background: #eaf2fb; }
.ws-note { margin: 0; color: var(--muted); font-size: 12.5px; }
.ws-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; padding: 0; border-bottom: 2px solid var(--line); }
.ws-tab { appearance: none; margin: 0 0 -2px; padding: 9px 14px; border: 1px solid transparent; border-bottom: none; border-radius: var(--radius) var(--radius) 0 0; background: transparent; color: var(--muted); font: inherit; font-weight: 500; cursor: pointer; }
.ws-tab:hover { color: var(--brand); }
.ws-tab[aria-selected="true"] { background: var(--surface); border-color: var(--line); color: var(--brand); font-weight: 700; box-shadow: inset 0 3px 0 var(--brand-2); border-bottom: 2px solid var(--surface); }
.ws-flag { font-weight: 700; }
.ws-flag-warning { color: #8a5a00; }
.ws-flag-review { color: var(--brand-2); }
.ws-panel { min-width: 0; }
.ws-panel[hidden] { display: none; }
/* containment for existing section controls so a narrow screen never gets a horizontal page scrollbar (additive; section internals are untouched) */
.ws-panel select, .ws-panel textarea, .ws-panel input:not([type=checkbox]):not([type=radio]) { max-width: 100%; }
.ws-panel label { max-width: 100%; }
.ws-panel .audit-row { flex-wrap: wrap; }
.ws-panel .mono { overflow-wrap: anywhere; }
.ws-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
@media (max-width: 640px) {
  .ws-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; border-bottom: none; }
  .ws-tab { margin: 0; padding: 8px 6px; border: 1px solid var(--line); border-radius: 8px; text-align: center; overflow-wrap: anywhere; }
  .ws-tab[aria-selected="true"] { border: 2px solid var(--brand-2); box-shadow: none; }
}
@media (max-width: 420px) {
  .ws-tabs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Commercial Evidence Brief (read-only) */
.b-ok { background: #dcf3e4; color: #166534; } .b-info { background: #e3eefc; color: #1c4f8f; } .b-warn { background: #fff2d6; color: #8a5a00; }
.cb-item { margin-bottom: 12px; } .cb-layer { margin-top: 16px; }


/* Commercial Drafting (read-only text candidates): plain wrapped candidate text */
#commercial-draft .draft-text { white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f8fb; border: 1px solid #dde3ec; border-radius: 8px; padding: 10px 12px; margin: 8px 0; font: inherit; }

/* Confirmation checkboxes (Sender Profile, Human Commercial Review, Evidence Approval, Commercial Drafting): the checkbox sits immediately beside its own text on one flex row, wrapping normally. The global input { width: 100% } otherwise stretches the checkbox and pushes the text away. Only labels marked confirm-check are affected (not the hypothesis-selection checkboxes). */
.confirm-check { display: flex; align-items: flex-start; gap: 8px; }
.confirm-check input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 3px 0 0; padding: 0; }

/* Human Commercial Review hypothesis-selection checkboxes: the checkbox sits immediately beside its own label (a selection control, NOT a confirmation); same global input { width: 100% } cause as .confirm-check */
.hypothesis-check { display: flex; align-items: flex-start; gap: 8px; }
.hypothesis-check input[type="checkbox"] { width: auto; flex: 0 0 auto; margin: 3px 0 0; padding: 0; }

/* Outreach gate: the bound draft text (dialog and Workflow card) */
#modal .draft-text, #outreach-binding .draft-text { white-space: pre-wrap; overflow-wrap: anywhere; background: #f6f8fb; border: 1px solid #dde3ec; border-radius: 8px; padding: 10px 12px; margin: 8px 0; font: inherit; }

/* Offering-review dialog Confirm / Reject choices: each radio circle sits beside the FIRST line of its own label and wrapped text stays beside/under the label text, not under the circle. The global input { width: 100% } otherwise stretches the radio across the label and centres it above the text. Scoped to .od-choice only; the label stays one clickable target and the global :focus-visible ring still applies to the (now circle-sized) radio. */
.od-choice { display: flex; align-items: flex-start; gap: 8px; }
.od-choice input[type="radio"] { width: auto; flex: 0 0 auto; margin: 3px 0 0; padding: 0; }

/* sign-in / sign-out */
.linklike { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: .25rem .5rem; }
.login-wrap { max-width: 26rem; margin: 6vh auto; padding: 0 1rem; }
.login-wrap .card { padding: 1.25rem; }
.login-wrap .field { margin: .75rem 0; }

/* Client Acquisition register */
.b-RESEARCH_REQUIRED { background: #fff2d6; color: #8a5a00; } .b-DEPRIORITIZED, .b-LOW { background: #eceef1; color: #55606e; }
.b-READY_FOR_REVIEW, .b-MEDIUM { background: #e3eefc; color: #1c4f8f; } .b-HIGH { background: #fde8d6; color: #9a4a00; }
.b-NOT_INTERESTED, .b-REJECTED, .b-PENDING_REVIEW { background: #fde2df; color: #9b1c12; } .b-CLIENT { background: #c9f0d2; color: #0f6a2b; }
.acq-due { color: var(--danger); font-weight: 600; }
.acq-name { font-weight: 600; }
