/* Stoei Voice — app.css
 *
 * App-specific layout layered on top of the Stoei design kit (stoei.css).
 * Design-system components — buttons (.st-btn*), inputs (.st-input),
 * cards (.st-card*), badges (.st-badge*), the auth card (.st-auth-card)
 * and typography utilities (.st-display, .st-label) — are provided by the
 * DS and are NOT redefined here. This file styles only the pieces the DS does
 * not ship (app shell, page header, modal, alerts, workspace grid). Every
 * look value comes from a setting (var(--st-...)): the defaults are in
 * ds/css/tokens.css and Stoei Voice's own values in css/theme.css. Voice's
 * own classes start with sv- (kit classes start with st-).
 * Buttons, fields and their sizes (.st-btn--sm) and states come from
 * ds/css/controls.css.
 * Check: php <stoei-core>/tools/check-css.php ds/css/tokens.css ds/css/base.css
 *        ds/css/controls.css ds/css/stoei.css ds/css/app-shell.css css/theme.css css/app.css
 */

/* The hidden attribute must always win, even over component classes that set
 * a display (e.g. .st-btn { display: inline-flex }), which otherwise leaves
 * `hidden` elements visible. */
[hidden] {
    display: none !important;
}

/* No underline on hover globally — individual links that need underline use it
 * in their base rule (e.g. .diag-caveat-btn), not only on hover. */
a:hover {
    text-decoration: none;
}

/* ─── App shell / header ─────────────────────────────────────────── */
.sv-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-4);
    padding: var(--st-space-3) var(--st-space-6);
    background: var(--st-color-surface);
    border-bottom: 1px solid var(--st-color-line);
}

.sv-header h1 {
    font-size: var(--st-text-10);
    color: var(--st-color-text);
    margin: 0;
}

.sv-header-left {
    display: flex;
    align-items: center;
    gap: var(--st-space-4);
    min-width: 0;
}

.sv-header-actions {
    display: flex;
    align-items: center;
    gap: var(--st-space-4);
}

.sv-header-user,
.sv-suggest-note,
.comp-discovery-empty,
.comp-history-run-provider,
.comp-history-count,
.diag-hub-card-count,
.settings-field-default {
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
}

/* Logo / app name is always a home link (../_shared/design-patterns.md),
 * styled as the brand wordmark rather than a plain underlined link. */
.sv-logo-link {
    font-size: var(--st-text-10);
    color: var(--st-color-text);
    text-decoration: none;
}

.sv-header h1 a,
.st-auth-card h1 a {
    color: inherit;
    text-decoration: none;
}

.sv-logo-link:hover,
.sv-header h1 a:hover,
.st-auth-card h1 a:hover {
    opacity: 0.85;
    text-decoration: none;
}

/* Secondary context beside the logo (e.g. the workspace name on the wizard):
 * smaller and muted so the app name stays prominent. */
.sv-header .sv-header-context {
    font-size: var(--st-text-3);
    font-weight: 400;
    color: var(--st-color-text-muted);
    margin: 0;
}

/* On auth pages (no header) the toggle floats in the top-right corner. */
.sv-theme-toggle-float {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 100;
}

/* ─── Main content ───────────────────────────────────────────────── */
.sv-main {
    max-width: 960px;
    margin: 0 auto;
    padding: var(--st-space-7) var(--st-space-6);
}

/* Title and its primary action sit together, left-aligned in one row.
 * No actions in the top-right (see ../_shared/design-patterns.md). */
.sv-page-header {
    display: flex;
    align-items: center;
    gap: var(--st-space-4);
    margin-bottom: var(--st-space-6);
}

.sv-page-header h2 {
    font-size: var(--st-text-13);
    color: var(--st-color-text);
    margin: 0;
}

/* Descriptive subtitle/deck under a page title — its own line, not hung beside
 * the heading. The negative top margin tucks it under the title (collapsing
 * against the header's bottom margin); the bottom margin spaces it from content. */
.sv-page-sub {
    margin: -0.75rem 0 var(--st-space-6);
    max-width: 70ch;
    color: var(--st-color-text-muted);
    font-size: var(--st-text-5);
    line-height: 1.5;
}

.sv-hint {
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
    margin-top: var(--st-space-1);
}

/* ─── Empty state ────────────────────────────────────────────────── */
.sv-empty {
    text-align: center;
    padding: var(--st-space-9) var(--st-space-6);
    color: var(--st-color-text-muted);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
}

.sv-empty p {
    margin: 0 0 var(--st-space-4);
}

.sv-empty p:last-child {
    margin-bottom: 0;
}

/* ─── Workspace grid ─────────────────────────────────────────────── */
.sv-workspace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--st-space-4);
}

/* Card visuals come from .st-card / .st-card--interactive; this only sets
 * the internal stacking and neutralises the global link hover styles. */
.sv-workspace-card {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-3);
    color: inherit;
}

.sv-workspace-card:hover {
    opacity: 1;
    text-decoration: none;
}

/* ─── Card elevation ─────────────────────────────────────────────
 * Adds to the kit card: a subtle shadow lifts cards off the page bg.
 * Interactive cards gain shadow on hover for clear affordance. */
.st-card {
    box-shadow: var(--st-shadow-1);
}

.st-card--interactive:hover,
.diag-hub-card:hover {
    box-shadow: var(--st-shadow-2);
    border-color: var(--st-color-accent);
}

.sv-workspace-card-name {
    font-weight: 600;
    font-size: var(--st-text-7);
    color: var(--st-color-text);
}

.sv-workspace-card-role {
    align-self: flex-start;
}

/* ─── Form fields ────────────────────────────────────────────────── */
.sv-field {
    margin-bottom: var(--st-space-6);
}

.sv-field label {
    display: block;
    margin-bottom: var(--st-space-2);
}

.sv-field-hint {
    display: block;
    margin-top: var(--st-space-2);
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}

/* ─── Alerts ─────────────────────────────────────────────────────── */
.sv-alert {
    padding: var(--st-space-3) var(--st-space-4);
    border-radius: var(--st-radius-1);
    font-size: var(--st-text-3);
    margin-bottom: var(--st-space-4);
}

.sv-alert--success {
    background: color-mix(in srgb, var(--st-color-ok) 10%, transparent);
    color: var(--st-color-ok);
    border: 1px solid color-mix(in srgb, var(--st-color-ok) 35%, transparent);
}

.sv-alert--error {
    background: var(--st-color-bad-tint);
    color: var(--st-color-bad);
    border: 1px solid color-mix(in srgb, var(--st-color-bad) 35%, transparent);
}

/* Notice / gaps warning — no amber token exists, so use the blue notice palette. */
.sv-alert--warn {
    background: var(--st-color-accent-tint);
    color: var(--st-color-accent);
    border: 1px solid color-mix(in srgb, var(--st-color-accent) 45%, transparent);
}

.sv-alert--warn a {
    color: var(--st-color-accent);
    text-decoration: underline;
    font-weight: 600;
}

/* Primary button gets a subtle shadow to give it weight against surfaces. */
.st-btn--primary {
    box-shadow: var(--st-shadow-1);
}

.st-btn--primary:hover {
    box-shadow: none;
}

/* ─── Modal ──────────────────────────────────────────────────────────
   Matches FloBox modal anatomy: head (title + close) / body / foot.
   Old flat modals (sv-modal-actions) continue to work via the compat
   alias below. ──────────────────────────────────────────────────── */
.sv-modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--st-space-4);
    background: var(--st-color-backdrop);
}
.sv-modal[hidden] {
    display: none;
}

.sv-modal-box {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-6);
    width: 100%;
    max-width: 440px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* fallback scroll for old flat-box modals */
    box-shadow: var(--st-shadow-3);
    animation: modal-in 0.2s ease;
}
.sv-modal-box--sm {
    max-width: 360px;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

/* Head: title row + optional close button */
.sv-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-2);
    padding: var(--st-space-4) var(--st-space-5);
    border-bottom: 1px solid var(--st-color-line);
    flex-shrink: 0;
}
.sv-modal-head h2 {
    font-size: var(--st-text-4);
    font-weight: 600;
    color: var(--st-color-text);
    margin: 0;
}
.sv-modal-close {
    border: none;
    background: none;
    color: var(--st-color-text-muted);
    padding: var(--st-space-1) var(--st-space-2);
    border-radius: var(--st-radius-1);
    cursor: pointer;
    font-size: var(--st-text-7);
    line-height: 1;
    flex-shrink: 0;
}
.sv-modal-close:hover {
    background: var(--st-color-bg);
    color: var(--st-color-text);
}

/* Body: scrollable content area */
.sv-modal-body {
    padding: var(--st-space-5);
    display: flex;
    flex-direction: column;
    gap: var(--st-space-4);
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}
.sv-modal-body > p {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* Foot: primary action row */
.sv-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: var(--st-space-2);
    padding: var(--st-space-4) var(--st-space-5);
    border-top: 1px solid var(--st-color-line);
    flex-shrink: 0;
}

/* Compat alias: old modals that use .sv-modal-actions keep working */
.sv-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: var(--st-space-2);
    margin-top: var(--st-space-5);
}

/* ─── Auth pages ─────────────────────────────────────────────────── */
.st-auth-card h1 {
    text-align: center;
    font-size: var(--st-text-13);
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-1);
}

.sv-auth-sub {
    text-align: center;
    color: var(--st-color-text-muted);
    margin: 0 0 var(--st-space-6);
}

.sv-auth-footer {
    text-align: center;
    margin-top: var(--st-space-6);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

/* ─── Button width utility (DS has no full-width modifier) ────────── */
.sv-btn-full {
    width: 100%;
    justify-content: center;
}

/* ─── Onboarding wizard ──────────────────────────────────────────── */
.sv-onboard-progress {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-3) var(--st-space-5);
    list-style: none;
    margin: 0 0 var(--st-space-6);
    padding: 0;
}

.sv-onboard-progress-item {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
}

.sv-onboard-progress-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: var(--st-radius-full);
    background: var(--st-color-line);
    color: var(--st-color-text-muted);
    font-size: var(--st-text-1);
    font-weight: 600;
}

.sv-onboard-progress-item.is-active {
    color: var(--st-color-text);
    font-weight: 600;
}

.sv-onboard-progress-item.is-active .sv-onboard-progress-num {
    background: var(--st-color-accent-fill);
    color: var(--st-color-on-accent);
}

.sv-onboard-progress-item[data-status="completed"] .sv-onboard-progress-num {
    background: var(--st-color-ok-fill);
    color: var(--st-color-on-accent);
}

.sv-onboard-progress-item[data-status="skipped"] .sv-onboard-progress-label {
    text-decoration: line-through;
}

.sv-onboard-panel {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-7);
}

.sv-onboard-step h3 {
    font-size: var(--st-text-7);
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-1);
}

.sv-onboard-step > p {
    margin: 0 0 var(--st-space-5);
    font-size: var(--st-text-3);
}

/* Structured Ritson objective: a small card stacking the controls. */
.sv-objective-row {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
    padding: var(--st-space-4);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    margin-bottom: var(--st-space-3);
}

.sv-objective-line {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-2);
}

.sv-objective-line .st-select {
    flex: 1 1 180px;
}

.sv-objective-line .st-input {
    flex: 1 1 220px;
}

.sv-objective-row .sv-objective-remove {
    align-self: flex-start;
}

.sv-onboard-budget-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--st-space-4);
}

#brand_split {
    width: 100%;
    accent-color: var(--st-color-accent);
}

.sv-split-readout {
    display: flex;
    justify-content: space-between;
    margin-top: var(--st-space-2);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

/* All footer actions sit together on the left (no right-pinned actions), per
 * ../_shared/design-patterns.md. */
.sv-onboard-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--st-space-3);
    margin-top: var(--st-space-6);
    padding-top: var(--st-space-5);
    border-top: 1px solid var(--st-color-line);
}

.sv-onboard-nav-right {
    display: flex;
    gap: var(--st-space-3);
    margin-left: auto;
}

.sv-onboard-subhead {
    font-size: var(--st-text-7);
    color: var(--st-color-text);
    margin: var(--st-space-7) 0 var(--st-space-1);
    padding-top: var(--st-space-6);
    border-top: 1px solid var(--st-color-line);
}

/* ─── AI setup (onboarding) ──────────────────────────────────────── */
.sv-onboard-verify,
.comp-history-run-meta {
    display: flex;
    align-items: center;
    gap: var(--st-space-3);
    flex-wrap: wrap;
}

.sv-key-status {
    font-size: var(--st-text-3);
    font-weight: 500;
}

.sv-key-status--ok {
    color: var(--st-color-accent);
}

.sv-key-status--bad {
    color: var(--st-color-bad);
}

/* ─── "Suggest with AI" (onboarding) ─────────────────────────────── */
.sv-onboard-suggest {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--st-space-3);
    margin-bottom: var(--st-space-4);
}
.sv-suggest-note--error {
    color: var(--st-color-bad);
}

.sv-suggest-keep {
    margin-inline-start: var(--st-space-3, 0.5rem);
    vertical-align: baseline;
}

/* AI-assist block: the suggest button + a contextual note explaining the
 * provider and whether live web search is in play. */
.sv-ai-assist {
    margin-bottom: var(--st-space-6);
    padding-bottom: var(--st-space-5);
    border-bottom: 1px solid var(--st-color-line);
}

.sv-ai-assist .sv-onboard-suggest {
    margin-bottom: var(--st-space-2);
}

/* ─── Positioning audit (guided) ─────────────────────────────────── */
.sv-audit-item {
    padding: var(--st-space-4) 0;
    border-bottom: 1px solid var(--st-color-line);
}

.sv-audit-item:last-of-type {
    border-bottom: none;
}

.sv-audit-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-3);
}

.sv-audit-question,
.comp-delta-details summary,
.comp-history-run-date {
    color: var(--st-color-text);
    font-size: var(--st-text-3);
    font-weight: 500;
}

.sv-audit-options {
    display: flex;
    gap: var(--st-space-4);
}

.sv-audit-option {
    display: inline-flex;
    align-items: center;
    gap: var(--st-space-2);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    cursor: pointer;
}

.sv-audit-option input {
    accent-color: var(--st-color-accent);
}

/* One plain-language sentence explaining FloMark's auto-selected answer. */
.sv-audit-explain {
    margin: var(--st-space-2) 0 0;
    font-size: var(--st-text-3);
    color: var(--st-color-accent);
}

/* Guided sub-questions: a smooth inline accordion, opened on "Unsure". */
.sv-audit-guided {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.sv-audit-guided.is-open {
    max-height: 44rem;
}

.sv-audit-guided-intro {
    margin: var(--st-space-3) 0 var(--st-space-2);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.sv-audit-sub {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-2) var(--st-space-4);
    padding: var(--st-space-2) 0 var(--st-space-2) var(--st-space-4);
    margin-bottom: var(--st-space-2);
    border-left: 2px solid var(--st-color-line);
}

.sv-audit-sub-q {
    flex: 1 1 22rem;
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}

.sv-audit-toggle {
    display: flex;
    flex-shrink: 0;
    gap: var(--st-space-4);
}

.sv-audit-ai {
    margin: var(--st-space-1) 0 0 var(--st-space-4);
}

/* ─── Module cards ───────────────────────────────────────────────── */
.sv-module-soon {
    opacity: 0.6;
}

/* ─── Competitor cards ───────────────────────────────────────────── */
.sv-competitor-card {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-3);
}

.sv-competitor-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--st-space-3);
}

.sv-competitor-site {
    font-size: var(--st-text-3);
    white-space: nowrap;
}

.sv-competitor-field {
    margin: 0;
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}

/* The .st-label inside a field renders as a small caption above the text. */
.sv-competitor-field .st-label {
    display: block;
    margin-bottom: 0.125rem;
}

.sv-competitor-actions {
    display: flex;
    gap: var(--st-space-2);
    margin-top: auto;
    padding-top: var(--st-space-2);
}

/* ─── Mobile ─────────────────────────────────────────────────────── */
@media (max-width: 640px) {

    .sv-onboard-budget-row {
        grid-template-columns: 1fr;
    }

    .sv-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--st-space-3);
    }

    .sv-page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sv-main {
        padding: var(--st-space-6) var(--st-space-4);
    }
}

/* ─── Provenance tags ────────────────────────────────────────────── */
/* Each data point shows a three-axis quality badge (docs/provenance.md).
 * Measured = solid, full-strength. Estimated = half-strength. Modelled = dashed/muted. */
.prov-tag {
    display: inline-flex;
    align-items: center;
    font-size: var(--st-text-1);
    border-radius: var(--st-radius-1);
    padding: 0.1rem var(--st-space-2);
    vertical-align: middle;
    border: 1px solid var(--st-color-line);
    cursor: default;
    white-space: nowrap;
    margin-left: var(--st-space-2);
}

.prov-measured {
    color: var(--st-color-text);
    background: var(--st-color-surface);
    border-color: var(--st-color-text);
    opacity: 1;
}

.prov-estimated {
    color: var(--st-color-text-muted);
    background: var(--st-color-surface);
    border-color: var(--st-color-line);
    opacity: 0.85;
}

.prov-modelled {
    color: var(--st-color-text-muted);
    background: var(--st-color-bg);
    border: 1px dashed var(--st-color-line);
    opacity: 0.7;
}

/* ─── Tag chips ─────────────────────────────────────────────────── */
/* Mirrors .prov-tag structure; used in table rows, modal picker, and Settings taxonomy. */
.sv-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    font-size: var(--st-text-1);
    border-radius: var(--st-radius-1);
    padding: 0.1rem var(--st-space-2);
    vertical-align: middle;
    border: 1px solid var(--st-color-line);
    background: var(--st-color-surface);
    color: var(--st-color-text-muted);
    white-space: nowrap;
    cursor: default;
    user-select: none;
}

/* Selected state in the tag picker (toggled by JS). */
.sv-tag-chip--selected {
    border-color: var(--st-color-accent);
    background: var(--st-color-accent-fill);
    color: var(--st-color-on-accent);
    cursor: pointer;
}

/* Picker chips are interactive buttons; unselected are also clickable. */
button.sv-tag-chip {
    cursor: pointer;
}
button.sv-tag-chip:hover:not(.sv-tag-chip--selected) {
    border-color: var(--st-color-text);
    color: var(--st-color-text);
}

/* Small action buttons inside a chip (rename pencil, delete ×). */
.sv-tag-chip-actions-btn,
.sv-tag-chip-delete-btn {
    background: none;
    border: none;
    padding: 0 0.1rem;
    cursor: pointer;
    color: inherit;
    font-size: var(--st-text-1);
    line-height: 1;
    opacity: 0.6;
}
.sv-tag-chip-actions-btn:hover,
.sv-tag-chip-delete-btn:hover {
    opacity: 1;
}

/* Tag chips inside a table cell. */
.dt-col-tags {
    white-space: normal;
}
.dt-col-tags .sv-tag-chip {
    margin: 0.1rem 0.15rem 0.1rem 0;
}

/* ─── Tag filter chip bar ────────────────────────────────────────── */
/* Rendered by data-table.js when data-dt-tag-filter is set on the table.
 * Sits between the toolbar and the top pagination strip. */
.dt-tag-filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--st-space-2);
    padding: var(--st-space-2) 0 var(--st-space-1);
}
.dt-tag-filter-label {
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    white-space: nowrap;
    margin-right: 0.125rem;
    user-select: none;
}
.dt-tag-filter-chip {
    cursor: pointer;
}
.dt-tag-filter-clear {
    margin-left: var(--st-space-2);
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}
.dt-tag-filter-clear:hover {
    color: var(--st-color-text);
}

/* ─── Signals provenance hint ───────────────────────────────────── */
/* "Inferred from: signal1; signal2" — shown on mined item rows and suggestion
 * cards. Soft, non-clickable; visually distinct from the Reference column link. */
.diag-signals-hint {
    display: block;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    margin-top: 0.2em;
    line-height: 1.4;
}
.diag-signals-label {
    font-style: italic;
}

/* Stale signals hint when content has changed in inline edit form. */
.diag-signals-hint--stale {
    opacity: 0.4;
    text-decoration: line-through;
}

/* ── Inline edit expand row ─────────────────────────────────────── */
.diag-inline-edit-cell {
    padding: 0;
    border-top: 2px solid var(--st-color-accent);
    border-bottom: 2px solid var(--st-color-accent);
    background: var(--st-color-sunk);
}
.diag-inline-edit-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--st-space-3) var(--st-space-4);
    padding: var(--st-space-4);
    align-items: start;
}
.diag-inline-edit-form .sv-field:nth-child(3),
.diag-inline-edit-form .diag-ie-signals,
.diag-inline-edit-form .diag-inline-edit-error,
.diag-inline-edit-form .diag-inline-edit-actions {
    grid-column: 1 / -1;
}
.diag-inline-edit-error {
    color: var(--st-color-bad);
    font-size: var(--st-text-3);
}
.diag-inline-edit-actions,
.settings-tags-group-actions {
    display: flex;
    gap: var(--st-space-2);
}
.diag-ie-content {
    resize: vertical;
}

/* Optional verified-link URL input on suggestion cards (confirm-time entry). */
.diag-sugg-url-input {
    display: block;
    width: 100%;
    margin-top: var(--st-space-2);
    margin-bottom: var(--st-space-1);
    font-size: var(--st-text-3);
}

/* Modal tag picker: groups of chip buttons. */
.tag-picker,
.diag-sugg-cards,
.comp-history-list {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}
.tag-picker-group-label {
    display: block;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    margin-bottom: var(--st-space-1);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.tag-picker-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-1);
}
.tag-picker-empty,
.diag-weight-label,
.comp-signal-date {
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}

/* Settings — Tags section. */
.settings-tags-empty,
.comp-suggestion-details {
    font-size: var(--st-text-3);
    margin: var(--st-space-2) 0;
}
.settings-tags-groups {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-5);
    margin-top: var(--st-space-3);
}
.settings-tags-group {
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-3) var(--st-space-4);
}
.settings-tags-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--st-space-3);
    margin-bottom: var(--st-space-2);
}
.settings-tags-group-name,
.diag-gate-status {
    font-weight: 600;
    font-size: var(--st-text-3);
}

.settings-tags-chips,
.diag-item-meta,
.sv-dt-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--st-space-2);
}

/* Inline input overlay for tag/group name entry (replaces native prompt). */
.settings-tags-inline-input {
    position: absolute;
    z-index: 200;
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-2) var(--st-space-2);
    box-shadow: var(--st-shadow-1);
}
.settings-tags-inline-input .st-input {
    width: 12rem;
}

/* ─── Diagnosis page ─────────────────────────────────────────────── */

/* Score bar: completeness % + gate status in a compact strip. */
.diag-score-bar {
    display: flex;
    align-items: center;
    gap: var(--st-space-4);
    padding: var(--st-space-4) var(--st-space-6);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    margin-bottom: var(--st-space-7);
    box-shadow: var(--st-shadow-1);
}

.diag-score-pct {
    font-size: var(--st-text-14);
    font-weight: 700;
    color: var(--st-color-text);
    line-height: 1;
}

.diag-score-label {
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    margin-bottom: var(--st-space-1);
}
.diag-gate-ready {
    color: var(--st-color-accent);
}

.diag-gate-locked {
    color: var(--st-color-text-muted);
}

.diag-score-mode-note {
    margin-left: auto;
}

/* Sections: each chunk is a card. */
.diag-section {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-7);
    margin-bottom: var(--st-space-7);
    box-shadow: var(--st-shadow-1);
}

.diag-section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--st-space-5);
}

.diag-section-head h3 {
    font-size: var(--st-text-7);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--st-color-text);
    margin: 0;
}

/* Qualitative item groups (one per item type). */
.diag-qual-group {
    margin-top: var(--st-space-7);
    padding-top: var(--st-space-7);
    border-top: 1px solid var(--st-color-line);
}

.diag-qual-group:first-of-type {
    margin-top: var(--st-space-3);
    padding-top: var(--st-space-3);
    border-top: none;
}

.diag-qual-head,
.comp-discovery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--st-space-2);
}

.diag-qual-title {
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text);
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
}

/* Qualitative item list. */
.diag-item-list {
    list-style: none;
    margin: var(--st-space-2) 0 0;
    padding: 0;
}

.diag-item {
    display: flex;
    align-items: flex-start;
    gap: var(--st-space-3);
    padding: var(--st-space-3) 0;
    border-bottom: 1px solid var(--st-color-line);
}

.diag-item:last-child {
    border-bottom: none;
}

.diag-item-empty {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    padding: var(--st-space-2) 0;
}

.diag-item-body {
    flex: 1;
    min-width: 0;
}

.diag-item-content {
    font-size: var(--st-text-3);
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-1);
    word-break: break-word;
}

.diag-item-actions {
    display: flex;
    gap: var(--st-space-1);
    flex-shrink: 0;
}

.diag-btn-delete {
    color: var(--st-color-bad);
}

/* ─── Brand funnel — card-per-brand layout ───────────────────────── */
/* Desktop: 4-column grid; mobile: stacked (one card per brand). */
.diag-funnel-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: var(--st-space-4);
    margin-bottom: var(--st-space-6);
}

.diag-brand-card {
    background: var(--st-color-bg);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-5);
}

.diag-brand-card-title {
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text);
    margin-bottom: var(--st-space-3);
}

.diag-metric-row {
    padding: var(--st-space-2) 0;
    border-bottom: 1px solid var(--st-color-line);
}

.diag-metric-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.diag-metric-label {
    display: block;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    margin-bottom: var(--st-space-1);
}

.diag-metric-input-wrap,
.sv-dt-bottom-right {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
}

.diag-metric-input-wrap .prov-tag {
    margin-left: 0;
}

/* Smaller input variant for brand card cells. */
.sv-input-sm {
    padding: var(--st-space-2) var(--st-space-2);
    font-size: var(--st-text-3);
}

/* Mobile: one card per row, full width. */
@media (max-width: 640px) {
    .diag-funnel-cards {
        grid-template-columns: 1fr;
    }
}

/* ─── ESOV section ───────────────────────────────────────────────── */
.diag-esov-wrap {
    margin-top: var(--st-space-6);
    padding-top: var(--st-space-5);
    border-top: 1px solid var(--st-color-line);
}

.diag-subsection-head {
    font-size: var(--st-text-5);
    font-weight: 600;
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-2);
}

/* Pre-PMF bypass notice. */
.diag-esov-bypass {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-3) var(--st-space-4);
    margin-bottom: var(--st-space-4);
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}

.diag-esov-cds {
    margin: var(--st-space-2) 0 0;
    color: var(--st-color-text-muted);
}

/* Computed ESOV result display. */
.diag-esov-result {
    margin-bottom: var(--st-space-4);
}

.diag-esov-nums {
    display: flex;
    flex-wrap: wrap;
    gap: var(--st-space-6);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.diag-esov-nums strong {
    color: var(--st-color-text);
}

.diag-esov-delta {
    font-weight: 600;
}

.diag-esov-pos strong {
    color: var(--st-color-accent);
}

.diag-esov-neg strong {
    color: var(--st-color-bad);
}

.diag-esov-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 var(--st-space-6);
}

@media (max-width: 640px) {
    .diag-esov-inputs {
        grid-template-columns: 1fr;
    }
}

/* ─── Readiness gate ─────────────────────────────────────────────── */
.diag-gate {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-7);
    margin-bottom: var(--st-space-8);
    box-shadow: var(--st-shadow-1);
}

.diag-gate h3 {
    font-size: var(--st-text-7);
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-2);
}

.diag-gate-list {
    list-style: none;
    margin: var(--st-space-4) 0 0;
    padding: 0;
}

.diag-gate-condition {
    display: flex;
    align-items: flex-start;
    gap: var(--st-space-3);
    padding: var(--st-space-4) 0;
    border-bottom: 1px solid var(--st-color-line);
}

.diag-gate-condition:last-child {
    border-bottom: none;
}

.diag-gate-icon {
    font-size: var(--st-text-5);
    flex-shrink: 0;
    width: 1.25rem;
    text-align: center;
    margin-top: 0.1rem;
}

.diag-gate-met .diag-gate-icon {
    color: var(--st-color-accent);
}

.diag-gate-miss .diag-gate-icon {
    color: var(--st-color-text-muted);
}

.diag-gate-body strong,
.diag-hub-cta-text {
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}

.diag-gate-cost {
    margin: var(--st-space-1) 0 0;
    font-size: var(--st-text-1);
    color: var(--st-color-bad);
    line-height: 1.4;
}

.diag-gate-unlock {
    margin-top: var(--st-space-6);
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-accent);
}

/* ── Locked-layer explain pages (Strategy / Tactics / Cadence) ─────────── */

.locked-layer-notice {
    display: flex;
    align-items: flex-start;
    gap: var(--st-space-3);
    padding: var(--st-space-4) var(--st-space-5);
    border: 1px solid var(--st-color-line);
    border-left: 4px solid var(--st-color-bad);
    border-radius: var(--st-radius-3);
    background: var(--st-color-sunk);
    margin-bottom: var(--st-space-7);
}

.locked-layer-badge {
    display: inline-block;
    padding: 0.2rem var(--st-space-3);
    border-radius: var(--st-radius-1);
    font-size: var(--st-text-1);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--st-color-bad-tint);
    color: var(--st-color-bad);
    white-space: nowrap;
    flex-shrink: 0;
}

.locked-layer-notice p {
    margin: 0;
    font-size: var(--st-text-3);
    color: var(--st-color-text);
    line-height: 1.55;
}

.locked-layer-list {
    margin: var(--st-space-2) 0 var(--st-space-6) var(--st-space-5);
    line-height: 1.7;
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}

.locked-layer-list li {
    margin-bottom: var(--st-space-2);
}

.locked-gate-list {
    margin-bottom: var(--st-space-6);
}

.locked-layer-action {
    margin-top: var(--st-space-2);
}

.locked-layer-footer {
    margin-top: var(--st-space-7);
    padding-top: var(--st-space-4);
    border-top: 1px solid var(--st-color-line);
}

/* ── AI mining result notes ────────────────────────────────────────────── */

.diag-mine-note {
    margin-top: var(--st-space-2);
    padding: var(--st-space-2) var(--st-space-3);
    border-radius: var(--st-radius-1);
    font-size: var(--st-text-3);
    line-height: 1.5;
    background: var(--st-color-sunk);
    color: var(--st-color-text);
    border-left: 3px solid var(--st-color-line);
}

.diag-mine-note--success {
    border-left-color: var(--st-color-accent);
    background: var(--st-color-accent-tint);
    color: var(--st-color-accent);
}

.diag-mine-note--unavailable,
.diag-mine-note--cannot_infer {
    border-left-color: var(--st-color-text-muted);
    color: var(--st-color-text-muted);
}

.diag-mine-note--error {
    border-left-color: var(--st-color-bad);
    background: var(--st-color-bad-tint);
    color: var(--st-color-bad);
}

/* Mining running state — shows while an AI mine request is in flight */
.diag-mine-note--running {
    color: var(--st-color-text);
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
}

@keyframes diag-mine-spin {
    to { transform: rotate(360deg); }
}

.diag-mine-spinner {
    display: inline-block;
    width: 0.875rem;
    height: 0.875rem;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: diag-mine-spin 0.7s linear infinite;
    flex-shrink: 0;
}

.diag-mine-signals,
.signal-rules-add-comp-btn {
    margin-top: var(--st-space-2);
    font-size: var(--st-text-1);
}

.diag-mine-signals summary {
    cursor: pointer;
    color: inherit;
    opacity: 0.8;
    user-select: none;
}

.diag-mine-signals ul {
    margin: var(--st-space-1) 0 0 var(--st-space-4);
    padding: 0;
    list-style: disc;
    opacity: 0.85;
}

.diag-mine-signals li {
    margin-bottom: 0.15rem;
}

.diag-mine-notes-text {
    margin: var(--st-space-2) 0 0;
    opacity: 0.8;
    font-size: var(--st-text-1);
}

/* Coverage caveat button — replaces the inline notes paragraph.
   Real <button> so keyboard users can activate it with Enter/Space. */
.diag-caveat-btn {
    display: inline-block;
    background: none;
    border: none;
    padding: 0;
    margin-top: var(--st-space-2);
    cursor: pointer;
    color: var(--st-color-text-muted);
    font-size: var(--st-text-1);
    font-family: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-align: left;
    line-height: 1.4;
}
.diag-caveat-btn:hover {
    color: var(--st-color-text);
}
.diag-caveat-btn:focus-visible {
    outline: 2px solid var(--st-color-accent);
    outline-offset: 2px;
    border-radius: 2px;
}

/* ── Permanent mine-caveat fixture — always visible near the Mine button ── */
/* Prominent red warning: mined data is Modelled quality, capped at Medium.  */
.diag-mine-caveat-fixture {
    margin-bottom: var(--st-space-4);
}

.diag-caveat-btn--fixture {
    display: inline-flex;
    align-items: center;
    gap: var(--st-space-2);
    background: var(--st-color-bad-tint);
    border: 1px solid var(--st-color-bad);
    border-radius: var(--st-radius-1);
    color: var(--st-color-bad);
    font-size: var(--st-text-3);
    font-weight: 600;
    padding: var(--st-space-2) var(--st-space-4);
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    line-height: 1.4;
}

.diag-caveat-btn--fixture:hover {
    opacity: 0.85;
}

.diag-caveat-btn--fixture:focus-visible {
    outline: 2px solid var(--st-color-bad);
    outline-offset: 2px;
    border-radius: 2px;
}

/* Mine button + caveat fixture on the same row inside the page header */
.diag-mine-group {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: var(--st-space-3, 0.5rem);
}
.diag-mine-group .diag-mine-caveat-fixture {
    margin-bottom: 0;
}

/* Secondary hint text in the mine-confirm modal body */
.diag-mine-confirm-hint {
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
    margin-top: var(--st-space-2);
}

/* ── Qualitative suggestion panels ──────────────────────────────────── */

.diag-sugg-panel {
    margin-top: var(--st-space-5);
    padding: var(--st-space-5);
    background: var(--st-color-sunk);
    border-radius: var(--st-radius-1);
    border: 1px solid var(--st-color-line);
}

.diag-sugg-panel-head {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    margin-bottom: var(--st-space-2);
    font-size: var(--st-text-3);
}

.diag-sugg-count {
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-pill);
    padding: 0.1rem var(--st-space-2);
}
.diag-sugg-card {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-2) var(--st-space-3);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--st-space-3);
    font-size: var(--st-text-3);
}

.diag-sugg-card--already,
.comp-suggestion-card--already-confirmed {
    opacity: 0.5;
    border-left: 3px solid var(--st-color-text-muted);
}

.diag-sugg-card--dismissed {
    opacity: 0.35;
    border-left: 3px solid var(--st-color-line);
}

.diag-sugg-card--confirmed,
.comp-suggestion-card--confirmed {
    opacity: 0.65;
    border-left: 3px solid var(--st-color-ok);
}

.diag-sugg-content {
    flex: 1;
    line-height: 1.4;
}

.diag-sugg-already-label {
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    white-space: nowrap;
}

.diag-sugg-actions {
    display: flex;
    gap: var(--st-space-2);
    flex-shrink: 0;
}

/* ── Competitor discovery panel ─────────────────────────────────────── */

.comp-discovery-panel {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-6) var(--st-space-7);
    margin-bottom: var(--st-space-7);
    box-shadow: var(--st-shadow-1);
}
.comp-discovery-title,
.comp-suggestion-name {
    font-weight: 600;
    font-size: var(--st-text-5);
}

.comp-discovery-close {
    padding: 0.1rem var(--st-space-2);
    font-size: var(--st-text-3);
}

.comp-discovery-intro {
    margin: 0 0 var(--st-space-3);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.comp-discovery-status {
    padding: var(--st-space-2) var(--st-space-3);
    border-radius: var(--st-radius-1);
    font-size: var(--st-text-3);
    margin-bottom: var(--st-space-3);
    border-left: 3px solid var(--st-color-line);
}

.comp-discovery-status--loading {
    border-left-color: var(--st-color-accent);
    background: var(--st-color-accent-tint);
    opacity: 0.85;
}

.comp-discovery-status--error {
    border-left-color: var(--st-color-bad);
    background: var(--st-color-bad-tint);
}

.comp-discovery-status--unavailable,
.comp-discovery-status--cannot-infer {
    border-left-color: var(--st-color-text-muted);
    background: var(--st-color-sunk);
}

.comp-discovery-status--provider {
    border-left-color: var(--st-color-accent);
    background: var(--st-color-accent-tint);
    font-size: var(--st-text-1);
    margin-bottom: var(--st-space-4);
}

.comp-discovery-results {
    display: flex;
    flex-direction: column;
    gap: var(--st-space-4);
}
.comp-discovery-hint {
    margin-top: var(--st-space-4);
    padding: var(--st-space-2) var(--st-space-3);
    border-left: 3px solid var(--st-color-text-muted);
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.comp-discovery-hint p {
    margin: 0;
}

/* ── Suggestion cards ───────────────────────────────────────────────── */

.comp-suggestion-card {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-5) var(--st-space-6);
    box-shadow: var(--st-shadow-1);
}

.comp-suggestion-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--st-space-2) var(--st-space-3);
    margin-bottom: var(--st-space-2);
}
.comp-suggestion-site {
    font-size: var(--st-text-3);
    color: var(--st-color-accent);
    text-decoration: none;
}

.comp-suggestion-site:hover {
    text-decoration: none;
}

.comp-suggestion-prov {
    margin-left: auto;
}

.comp-suggestion-field {
    margin: var(--st-space-2) 0;
    font-size: var(--st-text-3);
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.comp-suggestion-field .st-label {
    font-size: var(--st-text-1);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.7;
}
.comp-suggestion-details summary {
    cursor: pointer;
    user-select: none;
    opacity: 0.75;
    font-size: var(--st-text-1);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.comp-suggestion-details ul {
    margin: var(--st-space-2) 0 0 var(--st-space-4);
    padding: 0;
    list-style: disc;
}

.comp-suggestion-details li {
    margin-bottom: 0.15rem;
    color: var(--st-color-text-muted);
}

.comp-suggestion-actions {
    display: flex;
    gap: var(--st-space-2);
    margin-top: var(--st-space-4);
}

/* ── Confirmed / dismissed suggestion card states ───────────────────── */
.comp-suggestion-card--dismissed {
    opacity: 0.4;
    border-left: 3px solid var(--st-color-line);
}
.comp-suggestion-status-label {
    font-size: var(--st-text-3);
    color: var(--st-color-ok);
    font-weight: 600;
}

.comp-suggestion-status-label--dismissed,
.signal-rules-group-hint {
    color: var(--st-color-text-muted);
    font-weight: 400;
}

.comp-suggestion-status-label--already {
    color: var(--st-color-text-muted);
    font-weight: 400;
    font-style: italic;
}

/* ── Run metadata lines (shown in discovery panel header) ────────────── */

.comp-discovery-run-date {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: 0 0 var(--st-space-1);
}

.comp-discovery-notes {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: 0 0 var(--st-space-3);
    font-style: italic;
}

/* ── Cross-run delta panel ───────────────────────────────────────────── */

.comp-delta-section {
    margin-top: var(--st-space-7);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-left: 3px solid var(--st-color-warn);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-5) var(--st-space-6);
}

.comp-delta-heading {
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-2);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.comp-delta-caveat,
.comp-delta-meta {
    margin: 0 0 var(--st-space-2);
}

.comp-delta-empty {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: var(--st-space-2) 0 0;
}

.comp-delta-group {
    margin-top: var(--st-space-4);
}

.comp-delta-group + .comp-delta-group {
    margin-top: var(--st-space-3);
}

.comp-delta-group-label {
    font-size: var(--st-text-3);
    font-weight: 600;
    margin: 0 0 var(--st-space-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.comp-delta-group-label--first {
    color: var(--st-color-ok);
}

.comp-delta-group-label--not {
    color: var(--st-color-text-muted);
}

.comp-delta-group-label--changed {
    color: var(--st-color-warn);
}

.comp-delta-list,
.comp-signal-confirmed-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}

.comp-delta-item {
    display: flex;
    align-items: baseline;
    gap: var(--st-space-2);
    font-size: var(--st-text-3);
}

.comp-delta-item-name {
    font-weight: 500;
    color: var(--st-color-text);
}

.comp-delta-item-url {
    color: var(--st-color-text-muted);
    font-size: var(--st-text-2);
}
.comp-delta-fields {
    list-style: none;
    margin: var(--st-space-2) 0 0;
    padding: 0 0 0 var(--st-space-4);
    display: flex;
    flex-direction: column;
    gap: var(--st-space-2);
}

.comp-delta-field {
    font-size: var(--st-text-3);
    display: grid;
    grid-template-columns: 5rem 1fr auto 1fr;
    gap: var(--st-space-2);
    align-items: start;
}

.comp-delta-field-name {
    color: var(--st-color-text-muted);
    text-transform: uppercase;
    font-size: var(--st-text-1);
    letter-spacing: 0.05em;
    padding-top: 0.15rem;
}

.comp-delta-field-old {
    color: var(--st-color-text-muted);
    font-style: italic;
}

.comp-delta-field-arrow {
    color: var(--st-color-text-muted);
    padding-top: 0.05rem;
}

.comp-delta-field-new {
    color: var(--st-color-text);
}

/* ── Discovery run history section ──────────────────────────────────── */

.comp-history-section {
    margin-top: var(--st-space-7);
}

.comp-history-heading {
    font-size: var(--st-text-5);
    font-weight: 600;
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-3);
}
.comp-history-run {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-4) var(--st-space-5);
    box-shadow: var(--st-shadow-1);
}

.comp-history-run--active {
    border-color: var(--st-color-accent);
}

.comp-history-run-badge {
    font-size: var(--st-text-1);
    background: var(--st-color-accent-tint);
    color: var(--st-color-accent);
    padding: 0.125rem var(--st-space-2);
    border-radius: var(--st-radius-pill);
    font-weight: 600;
}
.comp-history-run-counts {
    display: flex;
    gap: var(--st-space-2);
    margin-top: var(--st-space-2);
    align-items: center;
}
.comp-history-count--confirmed {
    color: var(--st-color-ok);
}

.comp-history-count--dismissed {
    color: var(--st-color-text-muted);
}

.comp-history-count--pending {
    color: var(--st-color-warn);
}

.comp-history-view-btn {
    margin-top: var(--st-space-2);
}

.comp-history-run-suggestions {
    margin-top: var(--st-space-3);
    border-top: 1px solid var(--st-color-line);
    padding-top: var(--st-space-3);
}

.comp-history-empty,
.comp-history-error,
.settings-field-hint {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: 0;
}

.comp-history-error {
    color: var(--st-color-bad);
}

/* ── Empty-state action row ─────────────────────────────────────────── */

.sv-empty-actions {
    display: flex;
    gap: var(--st-space-3);
    justify-content: center;
    flex-wrap: wrap;
    margin-top: var(--st-space-2);
}

/* ═══════════════════════════════════════════════════════════════════════
   SHELL — Hub-and-spoke Ritson navigation layout
   ═══════════════════════════════════════════════════════════════════ */

.shell-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--st-color-bg);
}

/* Shell top header */
.shell-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--st-space-5);
    height: 3.25rem;
    border-bottom: 1px solid var(--st-color-line);
    background: var(--st-color-surface);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.shell-header-left,
.shell-header-right,
.settings-field-row {
    display: flex;
    align-items: center;
    gap: var(--st-space-3);
}

.shell-menu-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--st-text-8);
    color: var(--st-color-text);
    padding: var(--st-space-1) var(--st-space-2);
    line-height: 1;
}

/* Shell two-column layout */
.shell-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 3.25rem);
}

/* Sidebar */
.shell-sidebar {
    width: 220px;
    flex-shrink: 0;
    background: var(--st-color-surface);
    border-right: 1px solid var(--st-color-line);
    overflow-y: auto;
    padding: var(--st-space-4) var(--st-space-3) var(--st-space-7);
    display: flex;
    flex-direction: column;
    gap: var(--st-space-1);
}

.shell-ws-back {
    display: block;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    text-decoration: none;
    padding: var(--st-space-2) var(--st-space-2);
    border-radius: var(--st-radius-3);
    margin-bottom: var(--st-space-3);
}

.shell-ws-back:hover {
    color: var(--st-color-text);
    background: var(--st-color-sunk);
}

/* Competitors link — workspace-level nav between back-link and Diagnosis */
.shell-ws-competition {
    display: block;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    text-decoration: none;
    padding: var(--st-space-1) var(--st-space-2);
    border-radius: var(--st-radius-3);
    margin-bottom: var(--st-space-2);
}

.shell-ws-competition:hover,
.shell-ws-competition--active {
    color: var(--st-color-text);
    background: var(--st-color-sunk);
}

.shell-ws-competition--active {
    font-weight: 600;
}

/* Ritson layer blocks */
.shell-layer {
    border-radius: var(--st-radius-3);
    margin-bottom: var(--st-space-1);
}

.shell-layer--active {
    background: var(--st-color-sunk);
    border: 1px solid var(--st-color-line);
    padding: var(--st-space-3) var(--st-space-3) var(--st-space-2);
}

.shell-layer--locked,
.shell-layer--available {
    padding: var(--st-space-2) var(--st-space-2);
    opacity: 0.65;
}

.shell-layer--available {
    opacity: 1;
}

/* Active non-Diagnosis layer (Strategy/Tactics/Cadence current page) */
.shell-layer--current {
    padding: var(--st-space-2) var(--st-space-2);
    border-left: 2px solid var(--st-color-accent);
    padding-left: calc(var(--st-space-2) - 2px);
}

.shell-layer--current .shell-layer-name,
.diag-hub-coverage-count--capped {
    color: var(--st-color-accent);
    font-weight: 600;
}

.shell-layer-head {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    margin-bottom: var(--st-space-1);
}

.shell-layer-num {
    width: 1.25rem;
    height: 1.25rem;
    border-radius: 50%;
    background: var(--st-color-accent-fill);
    color: var(--st-color-on-accent);
    font-size: var(--st-text-0);
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.shell-layer--locked .shell-layer-num,
.shell-layer--available .shell-layer-num {
    background: var(--st-color-text-muted);
}

.shell-layer--available .shell-layer-num {
    background: var(--st-color-ok);
}

/* Diagnosis dot: gate-driven, consistent across all pages.
   Amber = Strategy gate unmet; green = gate complete.
   These beat the base .shell-layer-num and the --available override above
   (higher specificity: two-class selector 0,2,0 vs one-class 0,1,0). */
.shell-layer-num.shell-layer-num--gate-met   { background: var(--st-color-ok); }
.shell-layer-num.shell-layer-num--gate-unmet { background: var(--st-color-warn); }

.shell-layer-name {
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text);
    text-decoration: none;
    flex: 1;
}

a.shell-layer-name:hover {
    color: var(--st-color-accent);
}

.shell-layer-score-wrap {
    margin-left: auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.shell-layer-score {
    font-size: var(--st-text-1);
    font-weight: 600;
    color: var(--st-color-text-muted);
    line-height: 1.2;
}

.shell-layer-coverage-label {
    font-size: var(--st-text-0);
    font-weight: 400;
    color: var(--st-color-text-muted);
    opacity: 0.7;
    line-height: 1;
}

.shell-layer-lock-badge {
    font-size: var(--st-text-0);
    color: var(--st-color-text-muted);
    margin-left: auto;
}

/* Gate status line in sidebar */
.shell-layer--active .diag-gate-status {
    font-size: var(--st-text-1);
    margin-bottom: var(--st-space-2);
    padding: var(--st-space-1) var(--st-space-2);
    border-radius: var(--st-radius-3);
}

/* Sidebar sub-navigation */
.shell-subnav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.shell-subnav--nested {
    padding-left: var(--st-space-4);
    margin-top: 0.125rem;
    border-left: 2px solid var(--st-color-line);
}

.shell-subnav-item a,
.shell-subnav-group-label {
    display: block;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    text-decoration: none;
    padding: var(--st-space-1) var(--st-space-2);
    border-radius: var(--st-radius-3);
    cursor: pointer;
}

.shell-subnav-item a:hover,
.shell-subnav-group-label:hover {
    color: var(--st-color-text);
    background: var(--st-color-sunk, rgba(0,0,0,0.04));
}

.shell-subnav-item--active > a,
a.shell-subnav-group-label.shell-subnav-item--active {
    color: var(--st-color-accent);
    font-weight: 600;
    background: var(--st-color-accent-tint);
}

.shell-subnav-group,
.shell-subnav-group--open > .shell-subnav--nested {
    display: flex;
    flex-direction: column;
}

/* Sub-nav nested list: hidden by default; shown when group has --open */
.shell-subnav--nested {
    display: none;
}
/* Group label row: nav link + chevron toggle button side-by-side */
.shell-subnav-group-row {
    display: flex;
    align-items: center;
}

.shell-subnav-group-row .shell-subnav-group-label {
    flex: 1;
}

/* Chevron toggle button */
.shell-subnav-toggle {
    background: none;
    border: none;
    color: var(--st-color-text-muted);
    padding: var(--st-space-1);
    cursor: pointer;
    line-height: 0;
    border-radius: var(--st-radius-1, 0.25rem);
    flex-shrink: 0;
}
.shell-subnav-toggle:hover {
    color: var(--st-color-text);
}
/* Chevron SVG rotates when the group opens */
.shell-subnav-chevron {
    display: block;
    width: 12px;
    height: 12px;
    transition: transform 0.2s;
}
.shell-subnav-group--open .shell-subnav-chevron {
    transform: rotate(90deg);
}

.shell-subnav-group-label {
    font-weight: 500;
}

/* Main content area */
.shell-main {
    flex: 1;
    overflow-y: auto;
    padding: var(--st-space-7) var(--st-space-8);
    min-width: 0;
}

/* Spoke page header (title + optional action) */
.shell-page-header {
    display: flex;
    align-items: baseline;
    gap: var(--st-space-4);
    margin-bottom: var(--st-space-7);
    flex-wrap: wrap;
}

.shell-page-header h1 {
    margin: 0;
    font-size: var(--st-text-10);
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--st-color-text);
    line-height: 1.2;
}

/* Diagnosis hub — next-step CTA banner */
.diag-hub-cta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--st-space-3) var(--st-space-4);
    padding: var(--st-space-4) var(--st-space-5);
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-left: 3px solid var(--st-color-warn);
    border-radius: var(--st-radius-3);
    margin-top: var(--st-space-5);
}

.diag-hub-cta--ready {
    border-left-color: var(--st-color-ok);
}
/* Diagnosis hub overview cards */
.diag-hub-sections,
.diag-cv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--st-space-5);
    margin-top: var(--st-space-7);
}

.diag-hub-card {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-6) var(--st-space-7);
    text-decoration: none;
    display: block;
    transition: border-color 0.15s, box-shadow 0.15s;
    box-shadow: var(--st-shadow-1);
}
.diag-hub-card-title {
    font-weight: 700;
    font-size: var(--st-text-5);
    letter-spacing: -0.01em;
    color: var(--st-color-text);
    margin-bottom: var(--st-space-2);
}
/* Customer Voice sub-hub cards */
/* Mobile responsive */
@media (max-width: 700px) {
    .shell-menu-toggle {
        display: flex;
        align-items: center;
    }

    .shell-layout {
        position: relative;
        overflow: visible;
        height: auto;
    }

    .shell-sidebar {
        position: fixed;
        top: 3.25rem;
        left: -240px;
        bottom: 0;
        width: 240px;
        z-index: 90;
        transition: left 0.2s ease;
        box-shadow: var(--st-shadow-raised);
        height: auto;
    }

    .shell-sidebar--open {
        left: 0;
    }

    .shell-main {
        overflow-y: visible;
        padding: var(--st-space-6) var(--st-space-4);
    }

    .shell-layout-overlay {
        display: none;
        position: fixed;
        inset: 3.25rem 0 0 0;
        background: var(--st-color-backdrop);
        z-index: 89;
    }

    .shell-layout-overlay--visible {
        display: block;
    }
}

/* ═══════════════════════════════════════════════════════════════════════
   DATA TABLE — reusable sv-data-table component
   Used on vocabulary.php; adopt by adding data-sv-table to any <table>
   and including js/data-table.js in the page's scripts array.
   ═══════════════════════════════════════════════════════════════════ */

/* ── Outer wrapper: clips border-radius since border-collapse:collapse
   cancels border-radius on the table itself. ─────────────────────────── */
.sv-data-table-outer {
    border-radius: var(--st-radius-3);
    overflow: hidden;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--st-color-line);
    box-shadow: var(--st-shadow-1);
}

/* ── Table base ──────────────────────────────────────────────────────── */
.sv-data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--st-color-surface);
    font-size: var(--st-text-3);
    color: var(--st-color-text);
    table-layout: auto;
}

/* ── Header ──────────────────────────────────────────────────────────── */
.sv-data-table thead {
    background: var(--st-color-bg);
    border-bottom: 2px solid var(--st-color-line);
}

.sv-data-table thead th {
    padding: var(--st-space-3) var(--st-space-5);
    text-align: left;
    font-size: var(--st-text-1);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--st-color-text-muted);
    white-space: nowrap;
    user-select: none;
}

.sv-data-table thead th.dt-sortable {
    cursor: pointer;
}

.sv-data-table thead th.dt-sortable:hover {
    color: var(--st-color-text);
    background: var(--st-color-sunk);
}

/* Sort indicators */
.dt-sort-icon {
    display: inline-block;
    width: 0.75rem;
    margin-left: var(--st-space-1);
    vertical-align: middle;
    opacity: 0.3;
    font-style: normal;
}

.dt-sort-icon::after { content: "↕"; font-size: var(--st-text-0); }
.dt-sort-asc::after  { content: "↑"; font-size: var(--st-text-0); }
.dt-sort-desc::after { content: "↓"; font-size: var(--st-text-0); }
.dt-sort-asc,
.dt-sort-desc        { opacity: 0.7; }

/* ── Body rows ───────────────────────────────────────────────────────────
   CRITICAL: .diag-item base rule sets display:flex for the list layout.
   Override it here so <tr> stays display:table-row. ──────────────────── */
.sv-data-table tbody tr.diag-item {
    display: table-row;
    border-bottom: 1px solid var(--st-color-line);
    transition: background 0.1s;
}

.sv-data-table tbody tr.diag-item:last-child {
    border-bottom: none;
}

.sv-data-table tbody tr.diag-item:hover {
    background: var(--st-color-sunk);
}

/* Force table-cell so no other rule can flip a <td> to flex/block */
.sv-data-table tbody td {
    display: table-cell;
    padding: var(--st-space-4) var(--st-space-5);
    vertical-align: middle;
}

/* ── Row working state: pulsing glow on Enrich / Refresh rows ────────────
   Reduced-motion: steady accent wash with no animation.
   Full-motion: gentle pulse from transparent → accent-subtle and back.
   Applied to <td> because collapsed tables paint background per cell,
   and .sv-data-table-outer overflow:hidden clips any outer box-shadow. ── */
.comp-row-working td {
    background: var(--st-color-accent-tint);
}

@media (prefers-reduced-motion: no-preference) {
    @keyframes comp-row-working-glow {
        0%, 100% { background: transparent; }
        50%       { background: var(--st-color-accent-tint); }
    }

    .comp-row-working td {
        animation: comp-row-working-glow 1.8s ease-in-out infinite;
    }
}

/* Pagination hides rows via this class */
.sv-data-table tr.dt-hidden {
    display: none !important;
}

/* ── Column widths ───────────────────────────────────────────────────── */
.dt-th-num, .dt-col-num {
    width: 2.5rem;
    text-align: center;
    color: var(--st-color-text-muted);
    font-size: var(--st-text-1);
    user-select: none;
}
.dt-col-term   { width: auto; min-width: 180px; font-weight: 500; }
.dt-col-source { width: 150px; white-space: nowrap; }
.dt-col-prov   { width: 130px; white-space: nowrap; }
.dt-col-url    { width: 110px; white-space: nowrap; }

/* Name column (Competitors table): shrink to min-content so the freed
   width flows to the richer Positioning / Strengths / Weaknesses columns.
   white-space:nowrap lives on .comp-item-name (the text span) not the cell,
   so row-actions can wrap without setting the column floor to the full button row. */
.dt-col-name {
    width: 1%;
}

.comp-item-name {
    white-space: nowrap;
    display: block;
}

/* ── WordPress-style row actions ─────────────────────────────────────────
   Actions live inside the Term cell, below the term text.
   Hidden until row hover or keyboard focus-within. Always visible on touch. */
.dt-row-actions {
    display: block;
    visibility: hidden;     /* invisible until hover; no layout shift */
    margin-top: var(--st-space-1);
    line-height: 1.5;
}

.sv-data-table tr.diag-item:hover .dt-row-actions,
.sv-data-table tr.diag-item:focus-within .dt-row-actions {
    visibility: visible;
}

@media (pointer: coarse) {
    .sv-data-table tr.diag-item .dt-row-actions {
        visibility: visible;
    }
}


/* Action buttons styled as WP row-action text links — inline so they flow and wrap as text */
.dt-row-actions .st-btn {
    display: inline;
    padding: 0 var(--st-space-1);
    color: var(--st-color-text-muted);
    background: none;
    border: none;
    font-size: var(--st-text-1);
    min-height: auto;
    line-height: inherit;
    font-weight: 400;
}
.dt-row-actions .st-btn:hover {
    color: var(--st-color-text);
    background: none;
}
.dt-row-actions .diag-btn-delete:hover {
    color: var(--st-color-bad);
}

/* Pipe separator between row actions */
.dt-row-action-sep {
    color: var(--st-color-line);
    font-size: var(--st-text-0);
    padding: 0 0.125rem;
    user-select: none;
}

/* Merge marker: compact button showing how many items are consolidated here */
.dt-merge-marker {
    font-size: var(--st-text-1);
    color: var(--st-color-accent);
    padding: 0 var(--st-space-1);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
}
.dt-merge-marker:hover {
    color: var(--st-color-text);
}

/* Source URL link */
.dt-url-link {
    font-size: var(--st-text-1);
    color: var(--st-color-accent);
    text-decoration: none;
}
.dt-url-link:hover {
    text-decoration: none;
}
/* Dead-source state: muted colour + strikethrough.
   Framing: hard verification is gone, not that the finding is wrong. */
.dt-url-link--dead {
    color: var(--st-color-text-muted);
    text-decoration: line-through;
}
.dt-dead-flag-btn {
    display: block;
    margin-top: 2px;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}
.dt-dead-flag-btn:hover {
    color: var(--st-color-text);
}

/* ── Empty state row ─────────────────────────────────────────────────── */
.sv-data-table tr.diag-item-empty td {
    padding: var(--st-space-8) var(--st-space-4);
    text-align: center;
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
}

/* ── Toolbar (search + filter + rows-per-page + page info) ──────────── */
/* ── Bulk group — permanent WordPress-style fixture in toolbar ────────── */
.sv-dt-bulk-group {
    display: inline-flex;
    align-items: center;
    gap: var(--st-space-2);
    flex-shrink: 0;
}
.sv-dt-bulk-select {
    min-width: 140px;
}
.sv-dt-bulk-count {
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
    white-space: nowrap;
    min-width: 6rem;
}
.dt-th-check, .dt-col-check {
    width: 2rem;
    text-align: center;
    vertical-align: middle;
    padding-left: var(--st-space-2);
}
.dt-th-check input[type="checkbox"],
.dt-col-check input[type="checkbox"] {
    cursor: pointer;
    accent-color: var(--st-color-accent);
}

.sv-dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--st-space-3);
    margin-bottom: var(--st-space-3);
}
/* Search input: compact, not full-width */
.sv-dt-search {
    width: 200px;
    min-width: 0;
}

.sv-dt-filter,
.sv-dt-rpp {
    width: auto;
}

.sv-dt-page-info,
.sv-dt-page-info-bot {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    white-space: nowrap;
}

/* ── Top pagination strip — right-aligned ────────────────────────────── */
.sv-dt-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--st-space-3);
    margin-top: 0;
    margin-bottom: var(--st-space-3);
}

/* ── Bottom bar — bulk group left, page-info + pagination right ──────── */
.sv-dt-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
}

.sv-dt-page-label {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    min-width: 6rem;
    text-align: center;
}

/* ── Mobile: stack controls vertically ───────────────────────────────── */
@media (max-width: 640px) {
    .sv-dt-controls {
        flex-direction: column;
        align-items: stretch;
    }
    .sv-dt-search {
        width: 100%;
    }
}

/* ── Utility: safe hidden class ─────────────────────────────────────── */
/* Overrides any display rule so the HTML hidden attribute is not needed */
/* (author display rules beat the UA's [hidden]{display:none} otherwise) */
.hidden { display: none !important; }

/* ── List-View Standard: view-filter tabs (All / Trash) ─────────────── */
.diag-view-tabs {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    margin-bottom: var(--st-space-4);
    font-size: var(--st-text-3);
}
.diag-view-tab {
    color: var(--st-color-text-muted);
    text-decoration: none;
    padding: 0.125rem 0;
}
.diag-view-tab:hover {
    color: var(--st-color-text);
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}
.diag-view-tab--active {
    color: var(--st-color-text);
    font-weight: 600;
    text-decoration: none;
    cursor: default;
    pointer-events: none;
}
.diag-view-tab-sep {
    color: var(--st-color-text-muted);
    user-select: none;
}
.diag-empty-trash-btn {
    margin-left: auto;
}

/* ── Status banner (List-View Standard: action outcome) ─────────────── */
.diag-status-banner {
    display: flex;
    align-items: center;
    gap: var(--st-space-3);
    margin-bottom: var(--st-space-4);
    padding: var(--st-space-3) var(--st-space-4);
    background: var(--st-color-ok-tint);
    border: 1px solid var(--st-color-ok);
    border-radius: var(--st-radius-3);
    font-size: var(--st-text-3);
    color: var(--st-color-text);
}
.diag-status-banner__msg {
    flex: 1;
}
.diag-undo-btn {
    white-space: nowrap;
}
.diag-status-dismiss {
    background: none;
    border: none;
    color: var(--st-color-text-muted);
    cursor: pointer;
    font-size: var(--st-text-5);
    line-height: 1;
    padding: 0.125rem var(--st-space-1);
    border-radius: var(--st-radius-1);
}
.diag-status-dismiss:hover {
    background: var(--st-color-sunk);
}

/* ── Permanent-delete row action (trash view) ────────────────────────── */
.diag-btn-perm-delete {
    color: var(--st-color-bad);
}
.diag-btn-perm-delete:hover {
    background: var(--st-color-bad-tint);
    color: var(--st-color-bad);
}

/* ── Diagnosis hub — per-type coverage list ─────────────────────────── */
.diag-hub-coverage {
    list-style: none;
    padding: 0;
    margin: var(--st-space-2) 0 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.15rem;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
}

.diag-hub-coverage li {
    display: flex;
    justify-content: space-between;
    gap: var(--st-space-1);
}

.diag-hub-coverage-count {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.diag-hub-cap-badge {
    font-style: normal;
    font-size: var(--st-text-1);
    color: var(--st-color-accent);
    margin-left: 0.2rem;
}

/* ── Coverage info line on qual spoke pages ─────────────────────────── */
.diag-coverage-info {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    margin: var(--st-space-1) 0 var(--st-space-2);
}

/* ── Shell — Settings nav link ──────────────────────────────────────── */
.shell-sidebar-settings {
    margin-top: var(--st-space-6, 1.5rem);
    padding-top: var(--st-space-3, 0.5rem);
    border-top: 1px solid var(--st-color-line);
}

.shell-sidebar-settings-link {
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
    text-decoration: none;
    display: block;
    padding: var(--st-space-1) 0;
}

.shell-sidebar-settings-link:hover,
.shell-sidebar-settings-link--active {
    color: var(--st-color-text);
}

/* ── Settings page ──────────────────────────────────────────────────── */
.settings-section {
    background: var(--st-color-surface);
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-3);
    padding: var(--st-space-6);
    margin-bottom: var(--st-space-6);
}

.settings-section h2 {
    margin: 0 0 var(--st-space-1);
    font-size: var(--st-text-7);
}

.settings-section-header {
    display: flex;
    align-items: center;
    gap: var(--st-space-4);
    margin-bottom: var(--st-space-1);
}

.settings-subsection {
    margin-top: var(--st-space-5);
    padding-top: var(--st-space-5);
    border-top: 1px solid var(--st-color-line);
}

.settings-subsection:first-of-type {
    margin-top: var(--st-space-2);
    padding-top: 0;
    border-top: none;
}

.settings-subsection-heading {
    margin: 0 0 var(--st-space-2);
    font-size: var(--st-text-5);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
}

.settings-source-status {
    display: inline-block;
    padding: 0.1em 0.5em;
    font-size: var(--st-text-1);
    font-weight: 600;
    border-radius: var(--st-radius-1);
}

.settings-source-status--active {
    background: color-mix(in srgb, var(--st-color-ok) 15%, transparent);
    color: var(--st-color-ok);
}

.settings-source-status--inactive {
    background: color-mix(in srgb, var(--st-color-text-muted) 12%, transparent);
    color: var(--st-color-text-muted);
}

.settings-hint--warning {
    color: var(--st-color-text);
    background: color-mix(in srgb, var(--st-color-warn) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--st-color-warn) 30%, transparent);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-2) var(--st-space-3);
    margin-top: var(--st-space-2);
}

.settings-section-header h2 {
    margin: 0;
}

.settings-reset-form {
    margin-left: auto;
}

.settings-fields {
    display: grid;
    gap: var(--st-space-5);
    margin: var(--st-space-5) 0;
}

.settings-field {
    display: grid;
    gap: var(--st-space-1);
}
.settings-field-input {
    width: 6rem;
}

.settings-actions {
    padding-top: var(--st-space-2);
    border-top: 1px solid var(--st-color-line);
    margin-top: var(--st-space-2);
}

/* ── Competitor signal badge ───────────────────────────────────────────────── */

.comp-signal-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--st-space-1);
    padding: 0.1em 0.5em;
    font-size: var(--st-text-1);
    font-weight: 600;
    color: var(--st-color-accent);
    background: color-mix(in srgb, var(--st-color-accent) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--st-color-accent) 30%, transparent);
    border-radius: var(--st-radius-1);
    cursor: pointer;
    margin-left: var(--st-space-2);
    vertical-align: middle;
}

.comp-signal-badge:hover {
    background: color-mix(in srgb, var(--st-color-accent) 18%, transparent);
}

/* ── Signal panel row ─────────────────────────────────────────────────────── */

.comp-signal-panel-row td {
    padding: 0;
    background: var(--st-color-surface);
}

.comp-signal-panel-cell {
    padding: 0 !important;
}

.comp-signal-panel-inner {
    padding: var(--st-space-4) var(--st-space-5);
    border-top: 2px solid color-mix(in srgb, var(--st-color-accent) 25%, transparent);
    border-bottom: 1px solid var(--st-color-line);
}

.comp-signal-panel-loading,
.comp-signal-panel-empty,
.comp-signal-panel-error {
    display: block;
    color: var(--st-color-text-muted);
    font-size: var(--st-text-3);
    padding: var(--st-space-1) 0;
}

.comp-signal-panel-error {
    color: var(--st-color-bad);
}

.comp-signal-section-heading {
    margin: 0 0 var(--st-space-3);
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.comp-signal-pending-section {
    margin-bottom: var(--st-space-5);
}

.comp-signal-confirmed-section {
    margin-top: var(--st-space-1);
}

/* ── Signal cards (pending) ───────────────────────────────────────────────── */

.comp-signal-card {
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-3) var(--st-space-4);
    margin-bottom: var(--st-space-3);
    background: var(--st-color-bg);
}

.comp-signal-card--pending {
    border-left: 3px solid var(--st-color-accent);
}

.comp-signal-card-header {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    flex-wrap: wrap;
    margin-bottom: var(--st-space-2);
}

.comp-signal-link {
    font-size: var(--st-text-1);
    color: var(--st-color-accent);
}

.comp-signal-headline {
    margin: var(--st-space-1) 0 0;
    font-size: var(--st-text-3);
    font-weight: 500;
    color: var(--st-color-text);
}

.comp-signal-detail {
    margin: var(--st-space-1) 0 0;
    font-size: var(--st-text-3);
    color: var(--st-color-text-muted);
}

.comp-signal-actions {
    display: flex;
    gap: var(--st-space-2);
    margin-top: var(--st-space-3);
    padding-top: var(--st-space-2);
    border-top: 1px solid var(--st-color-line);
}

/* ── Confirmed signals list ───────────────────────────────────────────────── */
.comp-signal-confirmed-item {
    display: flex;
    align-items: baseline;
    gap: var(--st-space-2);
    font-size: var(--st-text-3);
    flex-wrap: wrap;
}

.comp-signal-confirmed-item .comp-signal-headline {
    font-weight: normal;
    margin: 0;
}

/* ── Signal rules (Settings) ─────────────────────────────────────── */

.signal-rules-group {
    border: 1px solid var(--st-color-line);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-3) var(--st-space-4);
    margin-bottom: var(--st-space-3);
}

.signal-rules-group-heading {
    font-size: var(--st-text-3);
    font-weight: 600;
    color: var(--st-color-text);
    margin: 0 0 var(--st-space-2);
}
.signal-rule-row {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    padding: var(--st-space-2) 0;
    border-bottom: 1px solid var(--st-color-line);
}

.signal-rule-row:last-of-type {
    border-bottom: none;
}

.signal-rule-toggle-wrap {
    display: flex;
    align-items: center;
    gap: var(--st-space-2);
    min-width: 0;
    flex: 0 0 auto;
    max-width: 40%;
    cursor: pointer;
}

.signal-rule-label {
    font-size: var(--st-text-3);
    color: var(--st-color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.signal-rule-query {
    flex: 1 1 0;
    font-size: var(--st-text-1);
    color: var(--st-color-text-muted);
    font-family: var(--st-font-mono);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.signal-rule-delete-btn {
    flex: 0 0 auto;
    color: var(--st-color-text-muted);
    border-color: transparent;
    background: transparent;
    padding: 0 var(--st-space-1);
    line-height: 1;
    font-size: var(--st-text-5);
}

.signal-rule-delete-btn:hover {
    color: var(--st-color-bad);
    background: var(--st-color-bg);
}
.signal-rule-add-inner {
    border: 1px solid var(--st-color-accent);
    border-radius: var(--st-radius-1);
    padding: var(--st-space-4);
    margin-top: var(--st-space-3);
    background: var(--st-color-surface);
}

.signal-rule-add-inner .settings-field {
    margin-bottom: var(--st-space-3);
}

.signal-rules-error {
    color: var(--st-color-bad);
}

.signal-rules-ok {
    color: var(--st-color-ok);
}

/* ─── Stoei wordmark ─────────────────────────────────────────── */
.sv-logo,
.sv-logo a {
    font-family: var(--st-font-display);
    font-style: italic;
    font-weight: 500;
    font-size: var(--st-text-10);
    letter-spacing: -0.01em;
    color: var(--st-color-text);
    text-decoration: none;
    display: inline-flex;
    align-items: baseline;
    gap: var(--st-space-2);
}
.sv-logo-app {
    font-family: var(--st-font-body);
    font-style: normal;
    font-size: var(--st-text-0);
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: var(--st-color-eyebrow);
}
.shell-theme-switch {
    color: var(--st-color-text-soft);
}

/* Auth pages: a button's message sits right under that button */
.auth-button-msg {
    margin-top: var(--st-space-3);
}

/* Competitors table on narrow screens: keep the long text columns readable
   (each at least ~16rem wide, text from the top) and let the table scroll
   sideways inside its frame instead of squeezing every column to a sliver. */
.comp-table td.comp-col-text {
    vertical-align: top;
    min-width: 16rem;
    line-height: 1.45;
}
@media (max-width: 900px) {
    .comp-table {
        min-width: 70rem;
    }
    .comp-table tbody td {
        padding: var(--st-space-3) var(--st-space-4);
    }
}
