:root {
    /* Light theme tokens — Night Teal + Gold */
    --bg-primary: #f4f2ec;
    --bg-secondary: #ffffff;
    --bg-elevated: #ffffff;
    --bg-inset: #efeae0;
    --text-primary: #1a2b2f;
    --text-secondary: #5a6f74;
    --text-muted: #8a9ba0;
    --border-color: #e2ddd2;
    --border-strong: #cdc6b8;
    --brand: #b8863a;
    --brand-hover: #a5772f;
    --brand-subtle: #f7edd8;
    --interactive: #0e7d94;
    --interactive-hover: #0a6478;
    --ok: #0d9f6e;
    --ok-subtle: #e3f5ee;
    --warn: #d9691f;
    --warn-subtle: #fbeadd;
    --bad: #d64545;
    --bad-subtle: #fbe6e6;
    --neutral: #5a6f74;
    --neutral-subtle: #eef0ec;
    --font-display: "Space Grotesk", system-ui, sans-serif;
    --font-body: "Inter", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --fs-xs: 0.75rem; --fs-sm: 0.8125rem; --fs-base: 0.9375rem; --fs-md: 1.0625rem;
    --fs-lg: 1.375rem; --fs-xl: 1.875rem;
    --lh-tight: 1.25; --lh-body: 1.55;
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-6: 24px; --sp-8: 32px; --sp-12: 48px;
    --radius-sm: 6px; --radius-md: 12px;
    --shadow-card: 0 1px 2px rgba(20,26,46,.04), 0 4px 12px rgba(20,26,46,.06);
    --shadow-lg: 0 10px 15px -3px rgba(20,26,46,.08), 0 4px 6px -2px rgba(20,26,46,.05);

    /* Legacy aliases (kept so existing rules keep working) */
    --bg: var(--bg-primary);
    --card-bg: var(--bg-secondary);
    --text: var(--text-primary);
    --border: var(--border-color);
    --primary: var(--brand);
    --primary-hover: var(--brand-hover);
    --positive: var(--ok);
    --negative: var(--bad);
    --edge: var(--warn);
    --assertion: var(--brand);
    --radius: var(--radius-md);
    --shadow: var(--shadow-card);
    --accent-blue: var(--interactive);
    --accent-blue-hover: var(--interactive-hover);
    --input-bg: var(--bg-secondary);
    --input-text: var(--text-primary);
    --sidebar-bg: var(--bg-secondary);
    --sidebar-border: var(--border-color);
    --case-bg: var(--bg-inset);
    --tag-bg: var(--neutral-subtle);
    --tag-text: var(--text-secondary);
    --tooltip-bg: var(--text-primary);
    --tooltip-text: #ffffff;
    --error-bg: var(--bad-subtle);
    --error-text: var(--bad);
}

.dark {
    --bg-primary: #0f2127;
    --bg-secondary: #16303a;
    --bg-elevated: #1b3a45;
    --bg-inset: #0d1c22;
    --text-primary: #e6f0f0;
    --text-secondary: #94b0b4;
    --text-muted: #6a8991;
    --border-color: #244752;
    --border-strong: #356070;
    --brand: #e0b064;
    --brand-hover: #ecc078;
    --brand-subtle: #33280f;
    --interactive: #5fbfd6;
    --interactive-hover: #7dd3e6;
    --ok: #54cfa0;
    --ok-subtle: #0e2c24;
    --warn: #ff9d5c;
    --warn-subtle: #3a1e0e;
    --bad: #ff7a7a;
    --bad-subtle: #331416;
    --neutral: #8aa2a8;
    --neutral-subtle: #1c3640;
    --shadow-card: 0 1px 2px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.35);
    --shadow-lg: 0 10px 20px -3px rgba(0,0,0,.6), 0 4px 6px -2px rgba(0,0,0,.5);
    --primary: var(--brand);
    --primary-hover: var(--brand-hover);
    --input-bg: var(--bg-inset);
    --input-text: #eaf2ff;
    --tooltip-bg: var(--text-primary);
    --tooltip-text: #0b1020;
    --error-bg: var(--bad-subtle);
    --error-text: var(--bad);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    font-size: var(--fs-base);
    line-height: var(--lh-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color 200ms ease, color 200ms ease;
}

h1, h2, h3, .brand strong, .case-title, .section-title {
    font-family: var(--font-display);
    line-height: var(--lh-tight);
    font-weight: 600;
}

code, pre, .mono, .status-code, .case-id {
    font-family: var(--font-mono);
}

.footer a {
    color: var(--accent-blue);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

.source-link {
    font-family: var(--font-display);
    font-size: var(--fs-xs);
    font-weight: 500;
}

.subtitle {
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-size: 1rem;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card h2 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

/* Form */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-family: var(--font-display);
    font-weight: 500;
    margin-bottom: 0.375rem;
    font-size: var(--fs-sm);
    color: var(--text-primary);
}

.required {
    color: var(--negative);
}

.hint {
    font-weight: 400;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.hint-text {
    display: block;
    margin-top: 0.25rem;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
    font-size: 0.9375rem;
}

.checkbox-label input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    accent-color: var(--interactive);
    cursor: pointer;
}

.results-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

input[type="url"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9375rem;
    background: var(--input-bg);
    color: var(--input-text);
    transition: border-color 200ms ease, box-shadow 200ms ease, background-color 200ms ease;
    font-family: inherit;
}

input[type="url"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--interactive);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--interactive) 30%, transparent);
    background: var(--input-bg);
    color: var(--input-text);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

textarea {
    resize: vertical;
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.25rem;
    background: var(--brand);
    color: #2a1e08;
    border: none;
    border-radius: 6px;
    font-family: var(--font-display);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn-primary:hover {
    background: var(--brand-hover);
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-secondary:hover {
    background: var(--bg-inset);
}

.btn-secondary:disabled,
.btn-secondary.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    row-gap: 6px;
}

.label-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;   /* keeps the pair right-aligned even when the row wraps */
    flex-wrap: wrap;
}

.sample-btn {
    font-size: 13px;
    padding: 5px 12px;
    border-radius: 6px;
    border: 1px solid var(--accent-blue);
    background: transparent;
    color: var(--accent-blue);
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.sample-btn:hover {
    background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
}

/* Paste cURL panel */
.curl-panel {
    margin-top: 0.75rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: var(--bg-inset);
}

.curl-panel label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.85rem;
    font-weight: 500;
}

.curl-panel textarea {
    width: 100%;
    font-family: var(--font-mono);
    font-size: 0.8rem;
}

.curl-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.curl-feedback {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.85rem;
    line-height: 1.5;
}

.curl-feedback.is-ok {
    background: var(--ok-subtle);
    color: var(--ok);
}

.curl-feedback.is-err {
    background: var(--bad-subtle);
    color: var(--bad);
}

.curl-feedback .curl-note {
    display: block;
    color: var(--text-secondary);
}

.curl-feedback .curl-warn {
    display: block;
    color: var(--warn);
}

/* Spinner */
.spinner {
    display: inline-block;
    width: 1.125rem;
    height: 1.125rem;
    border: 2px solid rgba(255,255,255,0.4);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Dark ink spinner for gold primary buttons (white would wash out on gold) */
.btn-primary .spinner,
.btn-danger .spinner,
#runAllBtn .spinner {
    border-color: rgba(42, 30, 8, 0.35);
    border-top-color: #2a1e08;
}

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

/* Error Banner */
.error-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    font-size: 0.9375rem;
}

.error-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* Results */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.results-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.results-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
}

@media (min-width: 768px) {
    .results-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.result-group {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
}

.group-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--border);
}

.group-title.positive { border-color: var(--positive); }
.group-title.negative { border-color: var(--negative); }
.group-title.edge { border-color: var(--edge); }
.group-title.assertions { border-color: var(--assertion); }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    font-size: 0.75rem;
    background: var(--border);
    flex-shrink: 0;
}

/* Case Cards */
.case-item {
    background: var(--case-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    transition: box-shadow 0.15s;
}

.case-item:last-child {
    margin-bottom: 0;
}

.case-item:hover {
    box-shadow: var(--shadow-lg);
}

.case-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.case-id {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--neutral-subtle);
    border: 0.5px solid var(--border-color);
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    flex-shrink: 0;
}

.case-title {
    font-weight: 600;
    font-size: 0.9375rem;
    line-height: 1.3;
}

.case-desc {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}

.case-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.tag {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0.25rem 0.5rem;
    border-radius: 999px;
    background: var(--tag-bg);
    color: var(--tag-text);
}

.tag.status {
    background: var(--neutral-subtle);
    color: var(--text-secondary);
}

.tag.severity-critical {
    background: var(--bad-subtle);
    color: var(--bad);
}

.tag.severity-high {
    background: var(--warn-subtle);
    color: var(--warn);
}

.tag.severity-medium {
    background: var(--neutral-subtle);
    color: var(--neutral);
}

.tag.severity-low {
    background: var(--ok-subtle);
    color: var(--ok);
}

/* Assertion specific */
.assertion-rule {
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--text);
}

/* Footer */
.footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* CI/CD export */
.cicd-export {
    margin-top: 1.5rem;
}

.cicd-export h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.export-format-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.export-format-card {
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 8px;
    cursor: pointer;
    background: var(--card-bg);
    transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

.export-format-card:hover {
    box-shadow: var(--shadow-lg);
}

.export-format-card.selected {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}

.export-format-card strong {
    display: block;
    font-size: 0.9375rem;
    margin-bottom: 0.25rem;
}

.export-format-card p {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cicd-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.cicd-filename {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.cicd-preview-actions {
    display: flex;
    gap: 0.5rem;
}

.code-preview {
    background: var(--bg-inset);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-family: var(--font-mono);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    max-height: 480px;
    overflow-y: auto;
}

/* Test execution */
.case-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.btn-run {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.3rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.btn-run:hover:not(:disabled) {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.btn-run:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.case-details {
    margin-top: 0.25rem;
}

.detail-row {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.375rem;
}

.assertion-list {
    list-style: none;
    margin: 2px 0 0;
    padding-left: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.test-pass {
    border-left: 4px solid var(--ok) !important;
    background: color-mix(in srgb, var(--ok) 5%, transparent);
}

.test-fail {
    border-left: 4px solid var(--bad) !important;
    background: color-mix(in srgb, var(--bad) 5%, transparent);
}

.test-review {
    border-left: 4px solid var(--warn) !important;
    background: color-mix(in srgb, var(--warn) 5%, transparent);
}

.test-notrun {
    border-left: 4px solid var(--text-secondary) !important;
    background: color-mix(in srgb, var(--text-secondary) 5%, transparent);
}

.test-skipped {
    border-left: 4px solid var(--neutral) !important;
    background: color-mix(in srgb, var(--neutral) 5%, transparent);
    opacity: 0.85;
}

.case-skip-note {
    padding: 4px 12px 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.03em;
}

.status-badge.passed {
    background: var(--ok-subtle);
    color: var(--ok);
}

.status-badge.failed {
    background: var(--bad-subtle);
    color: var(--bad);
}

.status-badge.needs-review {
    background: var(--warn-subtle);
    color: var(--warn);
}

.status-badge.not-run {
    background: var(--bg-inset);
    color: var(--text-secondary);
}

.status-badge.skipped {
    background: var(--neutral-subtle);
    color: var(--neutral);
}

/* Login-state banner (functional + security results) */
.auth-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    margin-bottom: 1rem;
    border-radius: 8px;
    border: 1px solid var(--border, transparent);
    font-size: 0.9rem;
    line-height: 1.45;
}

.auth-banner-icon {
    flex-shrink: 0;
    font-size: 1.05rem;
    line-height: 1.4;
}

.auth-banner-text {
    min-width: 0;
}

.auth-banner-title {
    margin: 0 0 2px;
    font-weight: 700;
}

.auth-banner-body {
    margin: 0;
    color: var(--text-secondary);
}

.auth-banner--neutral {
    background: var(--neutral-subtle);
    border-left: 4px solid var(--neutral);
}

.auth-banner--ok {
    background: var(--ok-subtle);
    border-left: 4px solid var(--ok);
}

.auth-banner--ok .auth-banner-title {
    color: var(--ok);
}

.auth-banner--warn {
    background: var(--warn-subtle);
    border-left: 4px solid var(--warn);
}

.auth-banner--warn .auth-banner-title {
    color: var(--warn);
}

.auth-banner--bad {
    background: var(--bad-subtle);
    border-left: 4px solid var(--bad);
}

.auth-banner--bad .auth-banner-title {
    color: var(--bad);
}

.execution-progress {
    margin-bottom: 1rem;
}

.execution-progress-bar {
    height: 8px;
    background: var(--bg-inset);
    border-radius: 4px;
    overflow: hidden;
}

.execution-progress-bar-fill {
    height: 100%;
    background: var(--accent-blue);
    background-image: linear-gradient(45deg, rgba(255,255,255,0.15) 25%, transparent 25%, transparent 50%, rgba(255,255,255,0.15) 50%, rgba(255,255,255,0.15) 75%, transparent 75%, transparent);
    background-size: 1rem 1rem;
    animation: progress-stripes 1s linear infinite;
    width: 0;
    transition: width 0.3s ease;
}

@keyframes progress-stripes {
    from { background-position: 1rem 0; }
    to { background-position: 0 0; }
}

.execution-progress-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.execution-summary {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--card-bg);
    box-shadow: var(--shadow);
    padding: 12px 24px;
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-weight: 500;
    font-size: 0.9375rem;
}

.assertion-pass {
    color: var(--ok);
    font-size: 12px;
}

.assertion-fail {
    color: var(--bad);
    font-weight: 500;
    font-size: 12px;
}

/* Semantic status primitives: verified = ok + ✓, unverified = warn + ~, failed = bad + ✕ */
.pill { display: inline-flex; align-items: center; gap: 4px; font: 500 var(--fs-xs)/1 var(--font-display);
        padding: 3px 8px; border-radius: var(--radius-sm); white-space: nowrap; }
.pill--ok   { color: var(--ok);   background: var(--ok-subtle); }
.pill--warn { color: var(--warn); background: var(--warn-subtle); }
.pill--bad  { color: var(--bad);  background: var(--bad-subtle); }
.pill--neutral { color: var(--text-secondary); background: var(--neutral-subtle); }

/* Honest coverage scorecard: ring + pills + one honest sentence (both result views) */
.scorecard { display: flex; align-items: center; gap: 20px; background: var(--bg-secondary);
    border: 0.5px solid var(--border-color); border-radius: var(--radius-md);
    padding: 1rem 1.25rem; margin-bottom: 1rem; }
.scorecard-ring { position: relative; width: 96px; height: 96px; flex-shrink: 0; border-radius: 50%;
    background: conic-gradient(var(--ok) calc(var(--pct, 0) * 1%), var(--bg-inset) 0);
    display: flex; flex-direction: column; align-items: center; justify-content: center; }
.scorecard-ring::after { content: ""; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg-secondary); }
.scorecard-pct, .scorecard-pct-label { position: relative; z-index: 1; display: block; text-align: center; }
.scorecard-pct { font-size: 22px; font-weight: 600; color: var(--text-primary); line-height: 1; }
.scorecard-pct-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.scorecard--pending .scorecard-pct { color: var(--text-muted); }
.scorecard-body { flex: 1; min-width: 0; }
.scorecard-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.scorecard-note { font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.5; }
@media (max-width: 640px) {
    .scorecard { flex-direction: column; align-items: flex-start; }
}

.assertion-line { display: flex; gap: 8px; align-items: baseline; font-size: var(--fs-sm); }
.assertion-line--verified   { color: var(--ok); }
.assertion-line--unverified { color: var(--warn); }
.assertion-line--failed     { color: var(--bad); }
.assertion-line--info       { color: var(--text-secondary); }
.not-applicable-line {
    color: var(--text-secondary);
    font-size: var(--fs-sm);
    margin-top: 8px;
}

.scan-confirm-panel {
    margin-bottom: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--warn);
    border-radius: 8px;
    background: var(--warn-subtle);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.scan-confirm-msg {
    flex: 1 1 100%;
    margin: 0 0 4px;
    font-size: var(--fs-sm);
    color: var(--text-primary);
}

.response-preview {
    font-family: var(--font-mono);
    max-height: 320px;
    overflow-y: auto;
    background: var(--bg-inset);
    padding: 12px;
    border-radius: 6px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    margin-top: 6px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Security scanning mode */
.security-mode-active {
    background: var(--bg);
}

.btn-danger {
    background: var(--brand);
    color: #2a1e08;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background 0.15s ease;
}

.btn-danger:hover:not(:disabled) {
    background: var(--brand-hover);
}

.btn-danger:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.security-warning {
    background: var(--warn-subtle);
    border: 1px solid var(--warn);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: 6px;
    display: flex;
    gap: 8px;
    align-items: flex-start;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.warning-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--warn);
    line-height: 1;
}

.owasp-categories {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.owasp-category-item {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
    cursor: pointer;
}

.owasp-category-item:has(input:checked) {
    border-color: color-mix(in srgb, var(--interactive) 45%, transparent);
    background: color-mix(in srgb, var(--interactive) 8%, transparent);
}

.owasp-category-item input {
    margin-top: 0.15rem;
    accent-color: var(--accent-blue);
}

.owasp-category-item .cat-desc {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* the bare text <span> is a flex item; let it shrink and wrap instead of overflowing */
.owasp-category-item > span {
    min-width: 0;
}

.risk-score-gauge {
    margin-bottom: 1rem;
}

.risk-score-bar {
    height: 16px;
    background: var(--bg-inset);
    border-radius: 8px;
    overflow: hidden;
}

.risk-score-fill {
    height: 100%;
    width: 0;
    background: var(--ok);
    transition: width 1s ease-out, background 0.3s ease;
}

.risk-score-fill.risk-green { background: linear-gradient(to right, var(--ok), color-mix(in srgb, var(--ok) 70%, #000)); }
.risk-score-fill.risk-yellow { background: linear-gradient(to right, var(--warn), color-mix(in srgb, var(--warn) 70%, #000)); }
.risk-score-fill.risk-orange { background: linear-gradient(to right, var(--warn), color-mix(in srgb, var(--warn) 55%, #000)); }
.risk-score-fill.risk-red { background: linear-gradient(to right, var(--bad), color-mix(in srgb, var(--bad) 70%, #000)); }

.risk-score-label {
    margin-top: 0.375rem;
    font-weight: 600;
    font-size: 0.9375rem;
}

.scan-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: var(--fs-xs);
}

.scan-summary .chip {
    border: 1px solid transparent;
    border-radius: 999px;
    padding: 0.25rem 0.75rem;
    font-family: var(--font-display);
    font-weight: 500;
    background: var(--neutral-subtle);
    color: var(--text-secondary);
}

.scan-summary .chip--bad {
    background: var(--bad-subtle);
    color: var(--bad);
}

.scan-summary .chip--warn {
    background: var(--warn-subtle);
    color: var(--warn);
}

.sec-export-actions {
    margin-bottom: 1rem;
}

.findings-table {
    width: 100%;
    min-width: 420px;             /* below this the wrap scrolls rather than crushing columns */
    border-collapse: collapse;
    font-size: var(--fs-sm);
    table-layout: fixed;          /* columns fit the panel exactly, no overflow */
}

.findings-table-wrap { overflow-x: auto; }   /* last-resort scroll only when the panel is < min-width */

.findings-table th,
.findings-table td {
    border-bottom: 1px solid var(--border-color);
    padding: 8px 6px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: break-word;    /* wrap at word boundaries, not mid-character */
    word-break: normal;
}

/* Compact fixed columns sized to their real content minimums ("Critical"
   badge and "API10:2023" token must fit whole); Title takes a proportional
   share and Status gets the rest — both wrap to 2-3 lines at normal panel
   widths instead of scrolling or shattering. */
.findings-table .severity-badge { padding: 2px 7px; }   /* trim so the badge fits its column */
.findings-table col.col-sev    { width: 76px; }
.findings-table col.col-owasp  { width: 78px; }
.findings-table col.col-title  { width: 30%; }
.findings-table col.col-status { width: auto; }
.findings-table col.col-act    { width: 62px; }

/* Status chips wrap inside the column — long prose chips (e.g. "no stack
   traces / secrets", "Missing headers: ...") would overflow with nowrap */
.findings-table td:nth-child(4) code {
    display: inline-block;
    max-width: 100%;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    vertical-align: top;
}
.findings-table td:nth-child(4) {
    line-height: 1.5;
}

/* In-panel scan status: loading skeletons while a scan runs, error text on failure */
.scan-error {
    color: var(--bad);
    background: var(--bad-subtle);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-sm);
}

/* Narrow screens: findings become stacked, labeled cards. */
@media (max-width: 640px) {
    .findings-table,
    .findings-table thead,
    .findings-table tbody,
    .findings-table th,
    .findings-table td,
    .findings-table tr {
        display: block;
    }

    .findings-table {
        min-width: 0;               /* stacked cards fill the narrow viewport */
    }

    .findings-table thead {
        display: none;              /* column headers become per-cell labels */
    }

    .findings-table tbody tr {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin-bottom: 8px;
        padding: 8px;
    }

    .findings-table td {
        border: none;
        padding: 4px 2px;
    }

    .findings-table td::before {
        content: attr(data-label);
        font-size: var(--fs-xs);
        color: var(--text-muted);
        display: block;
        margin-bottom: 2px;
    }

    .findings-table .finding-detail-row td {
        border: 1px solid var(--border-color);
        border-radius: 8px;
        margin: 0 2px 8px;
    }

    .findings-table .finding-detail-row td::before {
        content: none;
    }
}

.findings-table th {
    color: var(--text-muted);
    font-size: var(--fs-xs);
    font-weight: 500;
    font-family: var(--font-display);
}

.findings-table tbody tr:hover td {
    background: var(--bg-inset);
}

.severity-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: var(--fs-xs);
    font-weight: 600;
    white-space: nowrap;
}

.severity-critical {
    background: var(--bad-subtle);
    color: var(--bad);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-red {
    0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 40%, transparent); }
    50% { box-shadow: 0 0 0 8px transparent; }
}
.severity-high { background: var(--bad-subtle); color: var(--bad); }
.severity-medium { background: var(--warn-subtle); color: var(--warn); }
.severity-low { background: var(--neutral-subtle); color: var(--neutral); }

.findings-table code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg-inset);
    padding: 1px 5px;
    border-radius: 4px;
}

.status-vulnerable { color: var(--bad); font-weight: 600; }
.status-secure { color: var(--ok); font-weight: 600; }
.status-error { color: var(--warn); font-weight: 600; }
.status-review { color: var(--warn); font-weight: 600; }

.finding-vulnerable { border-left: 4px solid var(--bad); }
.finding-secure { border-left: 4px solid var(--ok); }
.finding-review { border-left: 4px solid var(--warn); }

.ground-badge {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

button.ground-badge { border: none; cursor: pointer; font-family: inherit; line-height: inherit; }
button.ground-badge:focus-visible { outline: 2px solid var(--interactive); outline-offset: 2px; }
.ground-caret { font-size: 0.7em; margin-left: 2px; }

.ground-evidence { margin: 0 0.6rem 0.6rem; padding: 0.6rem 0.75rem;
  border-radius: 8px; font-size: 0.8rem; line-height: 1.5; }
.ground-evidence.is-ok   { background: var(--ok-subtle); }
.ground-evidence.is-warn { background: var(--warn-subtle); }
.ground-evidence .ev-title { font-weight: 600; margin-bottom: 0.25rem; }
.ground-evidence.is-ok .ev-title   { color: var(--ok); }
.ground-evidence.is-warn .ev-title { color: var(--warn); }
.ground-evidence .ev-grid { display: grid; grid-template-columns: 56px minmax(0, 1fr);
  gap: 2px 10px; }
.ground-evidence .ev-key { color: var(--text-secondary); }
.ground-evidence .ev-val { font-family: var(--font-mono); color: var(--text-primary);
  overflow-wrap: anywhere; }
.ground-evidence .ev-detail { color: var(--text-secondary); margin-top: 0.35rem; }

/* --- Stability check (tags reuse the evidence panel pattern) --- */
.stab-tag { font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 20px;
  white-space: nowrap; }
button.stab-tag { border: none; cursor: pointer; font-family: inherit; line-height: inherit; }
button.stab-tag:focus-visible { outline: 2px solid var(--interactive); outline-offset: 2px; }
.stab-stable, .stab-dynamic { color: var(--text-secondary); background: var(--neutral-subtle); }
.stab-flaky { color: var(--warn); background: var(--warn-subtle); }
.stab-legend-flaky { color: var(--warn); }

.stab-evidence { margin: 0 0.6rem 0.6rem; padding: 0.6rem 0.75rem;
  border-radius: 8px; font-size: 0.8rem; line-height: 1.5; }
.stab-evidence.is-warn { background: var(--warn-subtle); }
.stab-evidence.is-neutral { background: var(--neutral-subtle); }
.stab-evidence .ev-title { font-weight: 600; margin-bottom: 0.25rem; }
.stab-evidence.is-warn .ev-title { color: var(--warn); }
.stab-evidence.is-neutral .ev-title { color: var(--text-secondary); }
.stab-evidence .ev-detail { color: var(--text-secondary); margin-top: 0.35rem; }
.stab-evidence .stab-table { width: 100%; border-collapse: collapse; font-size: 0.75rem; }
.stab-evidence .stab-table th { text-align: left; font-weight: 500; color: var(--text-secondary);
  padding: 2px 8px 2px 0; }
.stab-evidence .stab-table td { text-align: left; padding: 2px 8px 2px 0;
  color: var(--text-secondary); overflow-wrap: anywhere; }
.stab-evidence .stab-table td:last-child { font-family: var(--font-mono);
  color: var(--text-primary); }

.stab-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin: 0 0 0.75rem; }
.stab-strip-title { font-size: 0.8rem; font-weight: 600; color: var(--text-primary); }
.stab-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.stab-skip { font-size: 0.8rem; color: var(--text-secondary); margin: 0 0 0.75rem; }

.checkbox-label.disabled { opacity: 0.5; cursor: not-allowed; }
.checkbox-label.disabled input[type="checkbox"] { cursor: not-allowed; }
.security-mode-active .stability { display: none; }

.ground-verified {
    color: var(--ok);
    background: var(--ok-subtle);
}

.ground-unverified {
    color: var(--warn);
    background: var(--warn-subtle);
}

.ground-legend {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 8px 2px 0;
}

.ground-legend .ground-verified,
.ground-legend .ground-unverified {
    padding: 0;
    background: none;
    font-weight: 500;
}

.degraded-banner {
    background: var(--warn-subtle);
    color: var(--warn);
    border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.degraded-banner strong {
    font-weight: 600;
}

.finding-detail-row td {
    background: var(--bg-inset);
    font-size: 0.8125rem;
}

.payload-display {
    font-family: var(--font-mono);
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 12px;
    border-radius: 6px;
    font-size: 12px;
    overflow-x: auto;
    margin: 0.375rem 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.expand-btn {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    cursor: pointer;
    color: var(--text-secondary);
}

/* OpenAPI import & contract testing */
.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.card-header-row h2 {
    margin-bottom: 0;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.openapi-modal {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1.5rem;
    width: 100%;
    max-width: 900px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.openapi-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.875rem;
    margin-top: 0.75rem;
    white-space: pre-wrap;
}

.openapi-info {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.endpoint-list {
    margin-top: 0.75rem;
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.endpoint-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-color);
}

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

.endpoint-item:hover {
    background: rgba(59, 130, 246, 0.08);
}

.endpoint-item .endpoint-path {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.endpoint-item .endpoint-summary {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 40%;
}

.method-badge {
    display: inline-block;
    min-width: 52px;
    text-align: center;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--neutral);
}

.method-badge-get,
.method-badge-post,
.method-badge-put,
.method-badge-delete,
.method-badge-patch {
    background: var(--neutral-subtle);
    color: var(--neutral);
}

.contract-panel {
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
}

.contract-panel h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.contract-valid {
    border: 1px solid var(--ok);
    background: color-mix(in srgb, var(--ok) 5%, transparent);
    color: var(--ok);
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.875rem;
}

.schema-violation {
    color: var(--bad);
    font-size: 0.8125rem;
    padding: 0.25rem 0;
}

.schema-violation .violation-path {
    font-family: var(--font-mono);
    font-weight: 600;
}

/* Phase 10: history items, dark toggle, toasts, skeletons */
.history-item {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.625rem;
    margin-bottom: 0.5rem;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

.history-item:hover {
    border-color: var(--accent-blue);
    box-shadow: var(--shadow);
}

.history-item .history-endpoint {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.history-item .history-meta {
    color: var(--text-secondary);
    font-size: 0.7rem;
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.history-item .history-actions {
    display: flex;
    gap: 0.375rem;
    margin-top: 0.375rem;
}

.history-item .history-actions button {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.7rem;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.history-item .history-actions button:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

/* Toast notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 320px;
}

.toast {
    background: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--accent-blue);
    border-radius: 6px;
    box-shadow: var(--shadow-lg);
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    animation: toast-slide-in 0.25s ease;
}

.toast.toast-success { border-left-color: var(--ok); }
.toast.toast-error { border-left-color: var(--bad); }

.toast.toast-leaving {
    opacity: 0;
    transform: translateX(20px);
    transition: opacity 200ms ease, transform 200ms ease;
}

@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Loading skeletons */
.skeleton {
    background: linear-gradient(90deg, var(--bg-secondary) 25%, var(--border-color) 50%, var(--bg-secondary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    min-height: 1rem;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.skeleton-card {
    height: 90px;
    margin-bottom: 0.75rem;
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .export-format-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Mobile */
.menu-toggle {
    display: none;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 0.5rem 0.75rem;
    font-size: 1.125rem;
    cursor: pointer;
    z-index: 110;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 98;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
        position: fixed;
        top: 16px;
        left: 16px;
    }

    .sidebar-backdrop.open {
        display: block;
    }

    input[type="url"],
    select {
        min-height: 44px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .results-actions {
        flex-wrap: wrap;
    }

    .export-format-cards {
        grid-template-columns: 1fr;
    }

    .openapi-modal {
        max-height: 90vh;
        padding: 1rem;
    }

    .execution-summary {
        flex-direction: column;
        gap: 8px;
        font-size: 0.8125rem;
    }
}

/* Phase A fixes: active-looking action buttons */
#importOpenapiBtn {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 200ms ease;
}

#importOpenapiBtn:hover {
    background: var(--accent-blue-hover);
}

#runAllBtn {
    background: var(--brand);
    color: #2a1e08;
    border: none;
    font-weight: 600;
    opacity: 1;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 200ms ease;
}

#runAllBtn:hover:not(:disabled) {
    background: var(--brand-hover);
}

#runAllBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.summary-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

/* Phase B: UX clarity */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
}

.empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.empty-state h2 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 0.9375rem;
    max-width: 480px;
    margin: 0 auto 1rem;
}

/* Tooltips */
[data-tooltip] {
    position: relative;
}

[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 60;
}

[data-tooltip]:hover::after {
    opacity: 1;
}

/* Inline field validation */
.input-invalid {
    border-color: var(--negative) !important;
}

.field-error {
    display: block;
    color: var(--negative);
    font-size: 12px;
    margin-top: 4px;
}

/* Error banner dismiss */
.error-dismiss {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.125rem;
    cursor: pointer;
    color: var(--error-text);
    line-height: 1;
}

/* Mode subtitle */
/* History empty state */
.history-empty {
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.history-empty-hint {
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Card hierarchy */
.case-title {
    font-weight: 600;
    font-size: 1rem;
}

.case-id {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-family: var(--font-mono);
}

.case-desc {
    color: var(--text-secondary);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.case-meta .tag {
    font-size: 0.6875rem;
    padding: 0.15rem 0.45rem;
    opacity: 0.85;
}

.status-badge.pending {
    background: var(--bg-inset);
    color: var(--text-secondary);
}

/* Phase C: visual polish */
html {
    scroll-behavior: smooth;
}

/* Smooth color switching (dark mode) */
* {
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

/* Page load fade-in */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Staggered card entrance */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.case-item {
    animation: slideUp 0.2s ease-out;
    animation-fill-mode: both;
}

.case-item:nth-child(1) { animation-delay: 0.02s; }
.case-item:nth-child(2) { animation-delay: 0.04s; }
.case-item:nth-child(3) { animation-delay: 0.06s; }
.case-item:nth-child(4) { animation-delay: 0.08s; }
.case-item:nth-child(5) { animation-delay: 0.10s; }
.case-item:nth-child(6) { animation-delay: 0.12s; }
.case-item:nth-child(7) { animation-delay: 0.13s; }
.case-item:nth-child(8) { animation-delay: 0.14s; }
.case-item:nth-child(9) { animation-delay: 0.15s; }
.case-item:nth-child(10) { animation-delay: 0.16s; }
.case-item:nth-child(11) { animation-delay: 0.17s; }
.case-item:nth-child(12) { animation-delay: 0.18s; }
.case-item:nth-child(n+13) { animation-delay: 0.2s; }

@media (prefers-reduced-motion: reduce) {
    .case-item { animation: none; }
}

/* Button micro-interactions */
button {
    transition: transform 0.15s ease, box-shadow 0.15s ease,
        background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

button:hover:not(:disabled) {
    transform: scale(1.02);
}

button:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:hover:not(:disabled),
#runAllBtn:hover:not(:disabled),
#importOpenapiBtn:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
    box-shadow: 0 4px 12px rgba(224, 176, 100, 0.25);
}

/* Generate button loading pulse */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.btn-loading {
    animation: pulse 1.5s infinite;
    pointer-events: none;
}

/* Card hover lift */
.case-item:hover,
.history-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease,
        background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.dark .case-item:hover,
.dark .history-item:hover {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

/* Copy/download success flash */
.btn-flash {
    background: var(--ok) !important;
    color: #fff !important;
    border-color: var(--ok) !important;
}

/* Custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Accessible focus rings */
*:focus-visible {
    outline: 2px solid var(--accent-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Active state indicators */
.history-item.selected {
    border-left: 3px solid var(--accent-blue);
}

/* Finding row expand chevron */
.expand-btn .chevron {
    display: inline-block;
    transition: transform 0.3s ease;
}

.expand-btn.expanded .chevron {
    transform: rotate(180deg);
}

/* Toast icons */
.toast {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toast .toast-icon {
    flex-shrink: 0;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* =========================================================
   Dashboard shell redesign (Apitrek)
   ========================================================= */
.app-shell {
    display: flex;
    align-items: stretch;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding: 1.25rem 0.875rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.25rem 0.5rem 1.25rem;
}

.brand-logo {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--brand), var(--brand-hover));
    color: #2a1e08;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.brand-text strong {
    font-size: 0.95rem;
    font-weight: 700;
}

.brand-text span {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.nav {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    flex: 1;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.nav-label {
    font-size: var(--fs-xs);
    color: var(--text-muted);
    padding: 0 0.75rem 0.35rem;
    font-weight: 500;
    font-family: var(--font-display);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    background: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
}

.nav-item:hover:not(.active) {
    background: var(--bg-inset);
    color: var(--text-primary);
}

.nav-item.active {
    color: var(--accent-blue);
    border-color: color-mix(in srgb, var(--accent-blue) 45%, transparent);
    background: color-mix(in srgb, var(--accent-blue) 12%, transparent);
    font-weight: 600;
}

.nav-item:hover:not(:disabled),
.nav-item:active:not(:disabled),
.theme-toggle:hover:not(:disabled) {
    transform: none;
}

.sidebar-footer {
    padding-top: 1rem;
}

.theme-toggle {
    width: 100%;
    background: var(--bg-inset);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
}

.theme-toggle:hover {
    border-color: var(--accent-blue);
}

/* Main content area */
.main {
    flex: 1;
    min-width: 0;
    padding: 1.75rem 2rem 2.5rem;
    max-width: 1240px;
    animation: fadeIn 0.4s ease-out;
}

.main-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.main-header h1 {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.main-header .subtitle {
    margin-top: 0.2rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.view {
    animation: fadeIn 0.3s ease-out;
}

/* Two-column workspace */
.workspace-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    gap: 1.5rem;
    align-items: start;
}

.col-left,
.col-right {
    min-width: 0;
}

.col-left .card,
.col-right .card {
    margin-bottom: 1.25rem;
}

.card {
    border: 1px solid var(--border-color);
}

.results-panel {
    min-height: 360px;
}

/* Context note for scans against public, auth-less demo APIs */
.risk-context-note {
    font-size: var(--fs-xs);
    line-height: 1.4;
    color: var(--text-secondary);
    background: var(--neutral-subtle);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.75rem;
}

/* results column fills the viewport better on tall desktops */
@media (min-width: 1024px) {
    .results-panel { min-height: calc(100vh - 220px); }
}

.panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Stack generated-case groups vertically inside the results panel */
.col-right .results-grid {
    grid-template-columns: 1fr;
}

/* Condensed form */
.form-row {
    display: flex;
    gap: 1rem;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
    margin-bottom: 1rem;
}

.form-row .autofetch {
    margin-bottom: 1.1rem;
    white-space: nowrap;
}

.advanced {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    background: var(--bg-inset);
}

.advanced > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.7rem 0.9rem;
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.advanced > summary::-webkit-details-marker {
    display: none;
}

.advanced .plus {
    font-size: 1.15rem;
    line-height: 1;
    transition: transform 0.2s ease;
}

.advanced[open] .plus {
    transform: rotate(45deg);
}

.advanced-body {
    padding: 0 0.9rem 0.5rem;
}

.advanced-body .form-group:first-child {
    margin-top: 0.25rem;
}

/* Empty / placeholder states inside panels */
.empty-state,
.placeholder-panel {
    background: none;
    box-shadow: none;
    padding: 3rem 1.5rem;
    text-align: center;
    margin-bottom: 0;
}

.empty-icon-circle {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    margin: 0 auto 1rem;
}

.empty-state h3,
.placeholder-panel h3 {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
}

.empty-state p,
.placeholder-panel p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    max-width: 380px;
    margin: 0 auto;
}

/* Documentation panel */
.docs-panel {
    line-height: 1.65;
}

.docs-panel h2 {
    font-size: 1.15rem;
    margin: 1.25rem 0 0.5rem;
}

.docs-panel h2:first-child {
    margin-top: 0;
}

.docs-panel p,
.docs-panel li {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.docs-panel ul {
    margin: 0.25rem 0 0.75rem 1.25rem;
}

.docs-panel code {
    font-family: var(--font-mono);
    background: var(--bg-inset);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.85em;
}

/* Import button: subtle pill (overrides the earlier accent-fill rule) */
#importOpenapiBtn {
    background: var(--bg-inset);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
}

#importOpenapiBtn:hover {
    background: var(--card-bg);
    border-color: var(--accent-blue);
}

/* Mobile: collapsible sidebar */
@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        height: 100%;
        width: 240px;
        z-index: 99;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar-backdrop.open {
        display: block;
    }

    .menu-toggle {
        display: block;
        position: fixed;
        top: 12px;
        left: 12px;
    }

    .main {
        padding: 4rem 1rem 2rem;
        max-width: none;
    }

    .workspace-grid {
        grid-template-columns: 1fr;
    }
}

/* History tabs (Functional / Security) */
.history-tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.history-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.5rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.history-tab:hover:not(.active):not(:disabled) {
    color: var(--text-primary);
    transform: none;
}

.history-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.history-tab-count {
    font-size: 0.7rem;
    font-weight: 600;
    background: var(--bg-inset);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.05rem 0.4rem;
    min-width: 1.2rem;
    text-align: center;
}

.history-tab.active .history-tab-count {
    background: color-mix(in srgb, var(--accent-blue) 18%, transparent);
    color: var(--accent-blue);
}

/* =========================================================
   Results UX: toolbar dropdown, category/severity tabs,
   compact case rows, collapsible CI/CD export
   ========================================================= */

/* Export dropdown */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 4px);
    min-width: 180px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    padding: 0.25rem;
    z-index: 60;
    display: flex;
    flex-direction: column;
}
.dropdown-menu button {
    text-align: left;
    background: none;
    border: none;
    border-radius: 6px;
    padding: 0.5rem 0.7rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    cursor: pointer;
}
.dropdown-menu button:hover:not(:disabled) { background: var(--bg-inset); transform: none; }

/* Category / severity tabs */
.result-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin: 0.5rem 0 1rem;
    border-bottom: 1px solid var(--border-color);
}
.result-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.45rem 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}
.result-tab:hover:not(.active):not(:disabled) { color: var(--text-primary); transform: none; }
.result-tab.active { color: var(--accent-blue); border-bottom-color: var(--accent-blue); }
.rt-count {
    font-size: 0.68rem;
    font-weight: 600;
    background: var(--bg-inset);
    color: var(--text-secondary);
    border-radius: 999px;
    padding: 0.02rem 0.38rem;
    min-width: 1.1rem;
    text-align: center;
}
.result-tab.active .rt-count {
    background: color-mix(in srgb, var(--accent-blue) 18%, transparent);
    color: var(--accent-blue);
}

/* Result groups */
.results-groups .result-group {
    background: none;
    box-shadow: none;
    padding: 0;
    margin-bottom: 1.25rem;
}
.results-groups .result-group:last-child { margin-bottom: 0; }
.results-groups.single-cat .group-title { display: none; }

/* Compact, expandable case rows */
.case-item {
    padding: 0;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.case-item:hover { transform: none; box-shadow: none; }
.case-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.7rem;
    cursor: pointer;
}
.case-row:hover { background: var(--bg-inset); }
.case-row .case-id {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
    background: var(--neutral-subtle);
    border: 0.5px solid var(--border-color);
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    flex-shrink: 0;
}
.case-row .case-title {
    flex: 1;
    min-width: 0;
    font-weight: 500;
    font-size: 0.85rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-top: 1px;
}
.case-row-tags { display: inline-flex; gap: 0.25rem; flex-shrink: 0; }
.case-row-meta { display: flex; gap: 6px; margin-left: auto; align-items: center; flex-shrink: 0; }
.case-row .btn-run { flex-shrink: 0; padding: 0.2rem 0.6rem; font-size: 0.75rem; }
.case-row .chevron { flex-shrink: 0; color: var(--text-secondary); transition: transform 0.2s ease; }
.case-item.open .chevron { transform: rotate(180deg); }
.case-body {
    padding: 0.5rem 0.7rem 0.7rem;
    border-top: 1px solid var(--border-color);
}
.case-body .case-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    margin: 0;
    display: block;
    -webkit-line-clamp: unset;
    overflow: visible;
}
.case-rules {
    margin: 0.4rem 0 0 1rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.empty-group { padding: 0.5rem 0.2rem; font-size: 0.82rem; }

/* Phase 2: verdict-led expanded body */
.case-row .case-id { opacity: 0.85; }

.outcome {
    display: flex;
    align-items: baseline;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: var(--fs-sm);
}
.outcome-verdict { font-family: var(--font-display); font-weight: 600; }
.outcome--pass { background: var(--ok-subtle); }
.outcome--pass .outcome-verdict { color: var(--ok); }
.outcome--fail { background: var(--bad-subtle); }
.outcome--fail .outcome-verdict { color: var(--bad); }
.outcome--review { background: var(--warn-subtle); }
.outcome--review .outcome-verdict { color: var(--warn); }
.outcome--skipped { background: var(--bg-inset); }
.outcome--skipped .outcome-verdict { color: var(--text-secondary); }
.outcome-status { color: var(--text-secondary); font-family: var(--font-mono); font-size: var(--fs-xs); }

/* Collapsible response body + description — recede behind the verdict/assertions */
.response-body,
.case-desc-wrap { margin-top: 10px; }
.response-body > summary,
.case-desc-wrap > summary {
    cursor: pointer;
    font-size: var(--fs-xs);
    color: var(--text-secondary);
    font-family: var(--font-display);
    list-style: none;
    padding: 4px 0;
    user-select: none;
}
.response-body > summary::-webkit-details-marker,
.case-desc-wrap > summary::-webkit-details-marker { display: none; }
.response-body > summary::before,
.case-desc-wrap > summary::before {
    content: "\25B8";
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s;
}
.response-body[open] > summary::before,
.case-desc-wrap[open] > summary::before { transform: rotate(90deg); }
.case-desc-wrap .case-desc { margin-top: 6px; }

/* Collapsible CI/CD export */
details.cicd-export {
    margin-top: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-inset);
}
details.cicd-export > summary {
    list-style: none;
    cursor: pointer;
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}
details.cicd-export > summary::-webkit-details-marker { display: none; }
details.cicd-export > summary::before { content: '\25B8'; margin-right: 0.5rem; color: var(--text-secondary); }
details.cicd-export[open] > summary::before { content: '\25BE'; }
details.cicd-export[open] > summary { border-bottom: 1px solid var(--border-color); }
details.cicd-export .export-format-cards { margin: 0.9rem; }
details.cicd-export #cicdPreview { margin: 0 0.9rem 0.9rem; }
