/* LeadForge design system — calm, premium, trustworthy, low cognitive load.
   No framework. Intentionally restrained: generous whitespace, quiet palette,
   minimal borders, no gradients/animation gimmicks. */

:root {
    --ink: #1a2332;
    --ink-soft: #4a5568;
    --ink-faint: #718096;
    --paper: #ffffff;
    --canvas: #f7f8fa;
    --line: #e3e7ed;
    --accent: #1f5c8b;
    --accent-deep: #16435f;
    --accent-soft: #eaf1f7;
    --ok: #2f7d4f;
    --warn: #b07a1e;
    --bad: #b0413e;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow-1: 0 1px 2px rgba(26, 35, 50, 0.06);
    --shadow-2: 0 4px 16px rgba(26, 35, 50, 0.08);
    --font: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    color: var(--ink);
    background: var(--canvas);
    font-size: 16px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    color: var(--ink);
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 0.5rem;
    letter-spacing: -0.01em;
}

h1 { font-size: 1.9rem; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

p { margin: 0 0 0.9rem; color: var(--ink-soft); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-deep); text-decoration: underline; }

/* ---------- layout shells ---------- */

.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand-link { display: flex; align-items: center; gap: 0.65rem; }
.brand-link:hover { text-decoration: none; }

.brand-mark {
    width: 32px; height: 32px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    display: grid; place-items: center;
    font-weight: 700; font-size: 0.8rem;
    letter-spacing: 0.02em;
}

.brand-name { font-weight: 600; color: var(--ink); font-size: 1.05rem; }
.brand-name:hover { color: var(--ink); text-decoration: none; }

.topnav { display: flex; gap: 1.4rem; align-items: center; }
.topnav a {
    color: var(--ink-soft);
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
}
.topnav a:hover { color: var(--accent); text-decoration: none; }
.topnav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.main { flex: 1; }
.content { max-width: 1040px; margin: 0 auto; padding: 2.5rem 1.5rem; }
.content-narrow { max-width: 680px; margin: 0 auto; padding: 2.5rem 1.5rem; }

.footer {
    border-top: 1px solid var(--line);
    background: var(--paper);
    padding: 1.4rem 1.5rem;
    font-size: 0.85rem;
    color: var(--ink-faint);
}
.footer-inner {
    max-width: 1040px; margin: 0 auto;
    display: flex; flex-wrap: wrap; gap: 1rem 2rem;
    align-items: center; justify-content: space-between;
}
.footer nav { display: flex; flex-wrap: wrap; gap: 0.6rem 1.2rem; }
.footer a { color: var(--ink-faint); }
.footer a:hover { color: var(--accent); }

/* ---------- admin/broker app layout (sidebar) ---------- */

.app-body { display: flex; flex: 1; min-height: 0; }

.sidebar {
    width: 232px;
    background: var(--paper);
    border-right: 1px solid var(--line);
    padding: 1.25rem 0.9rem;
    flex-shrink: 0;
}

.sidebar-section {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    padding: 0.9rem 0.75rem 0.35rem;
    font-weight: 600;
}

.sidebar a {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    font-size: 0.93rem;
    font-weight: 500;
    margin-bottom: 2px;
}
.sidebar a:hover { background: var(--canvas); color: var(--ink); text-decoration: none; }
.sidebar a.active { background: var(--accent-soft); color: var(--accent-deep); }

.app-main { flex: 1; min-width: 0; }
.app-content { padding: 2rem 2.25rem; max-width: 1160px; }

/* ---------- cards, panels, tables ---------- */

.panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.4rem 1.5rem;
    box-shadow: var(--shadow-1);
}

.panel + .panel { margin-top: 1rem; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem;
    margin: 0.9rem 0 0.2rem;
}
.summary-card {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-height: 82px;
    padding: 0.8rem 0.9rem;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    background: var(--canvas);
}
.summary-card strong { font-size: 1.35rem; line-height: 1.2; }
.summary-card span { color: var(--ink-soft); font-size: 0.82rem; }
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
}

.table-wrap { overflow-x: auto; }
.table-wrap .table { min-width: 700px; }

.panel-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}
.panel-head h2 { margin-bottom: 0; }

.filter-nav { display: flex; gap: 1rem; }
.filter-nav a {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--ink-faint);
    padding-bottom: 2px;
    border-bottom: 2px solid transparent;
}
.filter-nav a:hover { color: var(--accent); text-decoration: none; }
.filter-nav a.active { color: var(--accent); border-bottom-color: var(--accent); }

.page-head { margin-bottom: 1.5rem; }
.page-head h1 { margin-bottom: 0.25rem; }
.page-head .subtitle { color: var(--ink-faint); font-size: 0.95rem; margin: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.table th {
    text-align: left;
    color: var(--ink-faint);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--line);
}
.table td { padding: 0.7rem 0.75rem; border-bottom: 1px solid var(--line); color: var(--ink-soft); }
.table tr:last-child td { border-bottom: none; }

/* Keep saved company comparison evidence readable in the narrow admin panel. */
details.panel { overflow-wrap: anywhere; }
details.panel .table { table-layout: fixed; }
details.panel .table th, details.panel .table td { overflow-wrap: anywhere; }

/* ---------- buttons, badges, forms ---------- */

.btn {
    display: inline-block;
    background: var(--accent);
    color: #fff;
    border: 1px solid var(--accent);
    border-radius: var(--radius-sm);
    padding: 0.5rem 1.1rem;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    font-family: var(--font);
}
.btn:hover { background: var(--accent-deep); border-color: var(--accent-deep); color: #fff; text-decoration: none; }
.btn-quiet {
    background: var(--paper);
    color: var(--ink-soft);
    border-color: var(--line);
}
.btn-quiet:hover { background: var(--canvas); color: var(--ink); border-color: var(--line); }

.btn-sm { padding: 0.25rem 0.7rem; font-size: 0.82rem; }

.row-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }
.row-actions form { margin: 0; }
.reject-form { display: flex; gap: 0.4rem; align-items: center; width: 100%; }
.reject-form input { max-width: 180px; padding: 0.3rem 0.5rem; font-size: 0.85rem; }

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-deep);
}
.badge-muted { background: var(--canvas); color: var(--ink-faint); border: 1px solid var(--line); }

/* Slice 36: delivery lifecycle badges — calm, honest colours from the palette. */
.badge-status-new { background: var(--canvas); color: var(--ink-soft); border: 1px solid var(--line); }
.badge-status-contacted { background: var(--accent-soft); color: var(--accent-deep); }
.badge-status-quoted { background: #f8f1e3; color: var(--warn); }
.badge-status-won { background: #e8f3ec; color: var(--ok); }
.badge-status-lost { background: #f7eaea; color: var(--bad); }
.badge-status-declined { background: var(--canvas); color: var(--ink-faint); border: 1px solid var(--line); }

.status-form { display: flex; gap: 0.4rem; align-items: center; }
.status-form select { width: auto; max-width: 170px; padding: 0.3rem 0.5rem; font-size: 0.85rem; }
.delivery-details-display { min-width: 190px; max-width: 340px; overflow-wrap: anywhere; }
.delivery-details-display > div { margin-bottom: 0.25rem; white-space: pre-wrap; }
.delivery-details-editor { margin-top: 0.45rem; min-width: 220px; }
.delivery-details-editor summary { color: var(--accent-deep); cursor: pointer; font-size: 0.85rem; font-weight: 600; }
.details-form { display: grid; gap: 0.35rem; margin-top: 0.6rem; min-width: 220px; }
.details-form label { font-size: 0.82rem; font-weight: 600; }
.details-form input, .details-form textarea { font-size: 0.85rem; padding: 0.4rem 0.55rem; }
.details-form textarea { resize: vertical; }

input, select, textarea {
    font-family: var(--font);
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
    width: 100%;
    max-width: 420px;
}
input:focus, select:focus, textarea:focus {
    outline: 2px solid var(--accent-soft);
    border-color: var(--accent);
}

label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--ink); margin-bottom: 0.3rem; }
.field { margin-bottom: 1.1rem; }
.hint { font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.25rem; }

/* ---------- hero (public pages) ---------- */

.hero {
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 4rem 1.5rem;
}
.hero-inner { max-width: 760px; margin: 0 auto; text-align: center; }
.hero h1 { font-size: 2.3rem; margin-bottom: 0.9rem; }
.hero .lede { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 1.6rem; }

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.09em;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.cta-row {
    display: flex;
    gap: 0.7rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- homepage sections ---------- */

.section { margin-bottom: 3rem; }
.section h2 { margin-bottom: 0.4rem; }
.section-lede { color: var(--ink-soft); max-width: 640px; margin-bottom: 1.4rem; }

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
}

.card {
    display: block;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.3rem 1.4rem;
    box-shadow: var(--shadow-1);
    transition: border-color 0.15s ease;
}
.card:hover { border-color: var(--accent); text-decoration: none; }
.card h3 { color: var(--ink); margin-bottom: 0.4rem; }
.card p { font-size: 0.92rem; margin-bottom: 0.7rem; }
.metric-value { color: var(--ink); font-size: 2rem !important; font-weight: 700; line-height: 1.15; margin: 0 !important; }
.card-link { font-size: 0.88rem; font-weight: 600; color: var(--accent); }

.steps {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 1rem;
}

.step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1.2rem 1.4rem;
}
.step h3 { margin-bottom: 0.25rem; }
.step p { margin-bottom: 0; font-size: 0.93rem; }

.step-number {
    flex-shrink: 0;
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent-deep);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 0.95rem;
}

.check-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.check-list li {
    padding: 0.55rem 0 0.55rem 1.7rem;
    position: relative;
    color: var(--ink-soft);
    font-size: 0.95rem;
    border-bottom: 1px solid var(--line);
}
.check-list li:last-child { border-bottom: none; }
.check-list li::before {
    content: "✔";
    position: absolute;
    left: 0;
    color: var(--ok);
    font-size: 0.85rem;
}
.check-list strong { color: var(--ink); }

.cta-band {
    background: var(--accent-soft);
    border: 1px solid #d4e2ee;
    border-radius: var(--radius);
    padding: 2rem 1.5rem;
    text-align: center;
}
.cta-band h2 { margin-bottom: 0.3rem; }
.cta-band .section-lede { margin: 0 auto 1.2rem; }

.notice {
    background: var(--accent-soft);
    border: 1px solid #d4e2ee;
    border-radius: var(--radius-sm);
    padding: 0.8rem 1rem;
    font-size: 0.88rem;
    color: var(--accent-deep);
}

.notice-error {
    background: #fdf3f2;
    border-color: #f0c9c7;
    color: var(--bad);
}

.legal-review-notice {
    background: #fff7e8;
    border-color: #ecd39f;
    color: #684b14;
    margin-bottom: 1.5rem;
}
.legal-review-notice p { color: inherit; margin: 0.35rem 0 0; }
.legal-copy .section { padding-top: 0.5rem; }
.legal-copy li { color: var(--ink-soft); margin-bottom: 0.45rem; }
.legal-copy ul { padding-left: 1.3rem; }
.data-company + .data-company { border-top: 1px solid var(--line); margin-top: 1.5rem; padding-top: 1.5rem; }

/* ---------- misc ---------- */

.empty-state {
    text-align: center;
    color: var(--ink-faint);
    padding: 3rem 1rem;
    font-size: 0.95rem;
}

.reason-list {
    list-style: none;
    padding: 0;
    margin: 0.5rem 0;
    font-size: 0.9rem;
}
.reason-list li { padding: 0.15rem 0; }
.reason-pass { color: var(--ok); }
.reason-fail { color: var(--bad); }

.progress {
    height: 6px;
    background: var(--line);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 1.4rem;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
}

.radio-row {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.3rem 0;
    font-size: 0.94rem;
    color: var(--ink-soft);
    font-weight: 400;
    margin-bottom: 0;
    cursor: pointer;
}
.radio-row input { width: auto; max-width: none; }
.radio-row:hover { color: var(--ink); }

.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.55rem 0;
    font-size: 0.93rem;
    color: var(--ink-soft);
    font-weight: 400;
    margin-bottom: 0;
    cursor: pointer;
}
.checkbox-row input { width: auto; max-width: none; margin-top: 0.2rem; flex-shrink: 0; }
.checkbox-row strong { color: var(--ink); }

fieldset.field { border: none; padding: 0; margin: 0 0 1.3rem; }

.filter-divider {
    width: 1px;
    align-self: stretch;
    background: var(--line);
    margin: 0 0.2rem;
}

.sort-link { color: inherit; }
.sort-link:hover { color: var(--accent); text-decoration: none; }

.score-badge { font-variant-numeric: tabular-nums; cursor: help; }
.score-high { background: #e8f4ec; color: #235c39; }
.score-medium { background: #fdf3e0; color: #8a5f16; }
.score-low { background: var(--canvas); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    background: #fff3f2;
    color: var(--bad);
    border-top: 1px solid #f0c9c7;
    padding: 0.6rem 1.25rem;
    z-index: 1000;
}

@media (max-width: 720px) {
    .app-body { flex-direction: column; }
    .sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--line); }
    .app-content { padding: 1.25rem; }
    .hero { padding: 2.5rem 1.25rem; }
    .hero h1 { font-size: 1.75rem; }
    .content, .content-narrow { padding: 1.5rem 1.1rem; }
    .step { flex-direction: row; padding: 1rem 1.1rem; }
    .cta-row .btn { flex: 1 1 auto; }
}

/* ---------- Field guidance (operator clarity pass) ----------
   Every important input should answer, without hovering and on a phone:
   what it means, why we need it, what to type, the format, an example,
   whether it is required, and what blank means. Guidance is always visible
   text - never a tooltip, because tooltips are invisible on touch devices. */

/* Plain-English explanation, shown between the label and the input. */
.field-help {
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.5;
    margin: 0 0 0.5rem;
    max-width: 62ch;
}

/* Small example or consequence, shown under the input. */
.field-example {
    font-size: 0.8rem;
    color: var(--ink-faint);
    line-height: 1.45;
    margin-top: 0.4rem;
    max-width: 62ch;
}

.field-help code, .field-example code, .hint code {
    font-size: 0.92em;
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.05rem 0.3rem;
}

/* Required / optional marker, inline with the label. */
.field-tag {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.1rem 0.42rem;
    border-radius: 999px;
    margin-left: 0.45rem;
    vertical-align: middle;
    white-space: nowrap;
}
.field-tag-required { background: var(--accent-soft); color: var(--accent-deep); }
.field-tag-optional { background: var(--canvas); color: var(--ink-faint); border: 1px solid var(--line); }

/* Explains what each option in a select or radio group actually does. */
.option-list {
    margin: 0.45rem 0 0;
    padding: 0;
    list-style: none;
    font-size: 0.82rem;
    color: var(--ink-soft);
    line-height: 1.45;
    max-width: 62ch;
}
.option-list li { margin-bottom: 0.35rem; }
.option-list li:last-child { margin-bottom: 0; }
.option-list strong { color: var(--ink); font-weight: 600; }

/* A short, proportionate warning before a consequential button. */
.action-consequence {
    font-size: 0.84rem;
    color: var(--ink-soft);
    line-height: 1.45;
    background: var(--canvas);
    border-left: 3px solid var(--line);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0.55rem 0.75rem;
    margin: 0.75rem 0;
    max-width: 64ch;
}
.action-consequence.is-serious { border-left-color: var(--bad); }

/* Guidance inside narrow table cells should use the full cell width. */
.details-form .field-help, .details-form .field-example,
.delivery-details-editor .field-help, .delivery-details-editor .field-example { max-width: none; }

@media (max-width: 640px) {
    .field { margin-bottom: 1.4rem; }
    .field-help { font-size: 0.9rem; }
    .field-tag { display: block; width: fit-content; margin: 0.3rem 0 0; }
}

/* ---------- Operator clarity pass (part 2) ---------- */

/* Visually hidden but available to screen readers (labels that would
   otherwise clutter a dense table cell). */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Let inline row forms (reject/skip reason + button) wrap their guidance
   onto its own line instead of forcing it into one cramped row. */
.reject-form { flex-wrap: wrap; }
.reject-form .field-example { flex-basis: 100%; margin-top: 0.3rem; }

/* In-table transparent scoring: the reasons are printed, not hidden behind
   a hover tooltip, so they work on touch devices and screen readers. */
.score-breakdown, .match-reasons { margin-top: 0.45rem; }
.score-breakdown strong, .match-reasons strong {
    display: block;
    font-size: 0.74rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-faint);
    margin-bottom: 0.15rem;
}
.score-breakdown .option-list, .match-reasons .option-list { margin-top: 0; }

/* Email subject shown inline (was a tooltip before). */
.attempt-subject { color: var(--ink-soft); }

/* Configuration sample shown on the Brokers page (pilot walkthrough). */
.config-sample {
    background: var(--canvas);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    margin: 0.6rem 0;
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.5;
}
.config-sample code { background: none; border: 0; padding: 0; font-size: inherit; }

/* Live Companies House discovery progress. */
.discovery-live {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--canvas);
}
.discovery-live-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.discovery-live-head p { margin-bottom: 0.5rem; }
.discovery-progress-bar { display: block; width: 100%; height: 0.75rem; margin: 0.45rem 0 0.8rem; accent-color: var(--accent); }
.discovery-live-counts { display: flex; flex-wrap: wrap; gap: 0.45rem 1rem; margin: 0.5rem 0 0.75rem; color: var(--ink-soft); font-size: 0.9rem; }
.discovery-live-counts strong { color: var(--ink); }
.discovery-live-list { max-height: 24rem; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--paper); }
.discovery-live-list .table { margin: 0; }
.discovery-live-list .table th { position: sticky; top: 0; background: var(--canvas); }
