/* ============================================================
   DecisionDNA Analysis Engine — Website-Aligned Stylesheet
   Two-tone design: dark headers (#0A0A0A) + white body (#FFFFFF)
   Accent: #B8451A (burnt orange)
   Fonts: Alata (display), Inter (body), JetBrains Mono (mono)
   ============================================================ */

:root {
    /* ---- Website Palette Tokens ---- */
    --black: #0A0A0A;
    --dark: #111111;
    --dark-grey: #1A1A1A;
    --charcoal: #222222;
    --mid-dark: #333333;
    --mid: #666666;
    --mid-light: #999999;
    --silver: #BCBCBC;
    --light-grey: #CCCCCC;
    --border-dark: #333333;
    --border-light: #E0E0E0;
    --off-white: #F5F5F5;
    --near-white: #FAFAFA;
    --white: #FFFFFF;
    --accent: #B8451A;
    --accent-hover: #9A3A16;

    /* ---- Engine Semantic Tokens (mapped to website palette) ---- */
    --color-primary: var(--dark-grey);
    --color-secondary: var(--mid);
    --color-accent: var(--accent);
    --color-bg: var(--white);
    --color-bg-dark: var(--black);
    --color-card: var(--white);
    --color-card-dark: var(--dark);
    --color-text: var(--dark-grey);
    --color-text-light: var(--mid);
    --color-border: var(--border-light);

    --color-bg-elevated: var(--near-white);
    --color-card-hover: var(--off-white);
    --color-accent-bright: var(--accent);
    --color-text-dim: var(--mid-light);
    --color-border-active: var(--light-grey);

    /* ---- Status Colors ---- */
    --color-success: #2C5F2D;
    --color-failure: #990011;
    --color-mixed: #E67E22;
    --color-neutral: #95A5A6;

    /* ---- Archetype Colors ---- */
    --color-elite: #2C5F2D;
    --color-constrained: #3498DB;
    --color-structured: #9B59B6;
    --color-reactive: #E67E22;
    --color-chaotic: #990011;

    /* ---- MDC Zone Colors ---- */
    --color-cowboy: #990011;
    --color-sweet-spot: #2C5F2D;
    --color-friction: #E67E22;
    --color-paralysis: #990011;

    /* ---- Typography ---- */
    --font-heading: 'Alata', sans-serif;
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'IBM Plex Mono', 'Roboto Mono', monospace;

    /* ---- Spacing (8px grid) ---- */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* ---- Layout ---- */
    --max-width: 1280px;
    --nav-height: 64px;
    --radius: 0;
    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: none;
    --shadow-hover: none;
}

/* ============================================================
   Reset & Base
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-width: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    color: var(--color-primary);
    line-height: 1.3;
    font-weight: 400;
}

h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }

a { color: var(--color-accent-bright); text-decoration: none; }
a:hover { color: var(--accent-hover); }

.metric, .score, td.numeric, th.numeric {
    font-family: var(--font-mono);
}

::selection {
    background: rgba(184, 69, 26, 0.20);
    color: var(--dark-grey);
}

:focus-visible {
    outline: 2px solid var(--color-accent-bright);
    outline-offset: 2px;
}

/* ============================================================
   Layout
   ============================================================ */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ============================================================
   Navigation — Website-aligned dark fixed bar
   ============================================================ */
nav {
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 0 var(--space-xl);
    height: var(--nav-height);
    display: flex;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-dark);
    box-shadow: none;
}

nav .logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

nav .logo .brand-name {
    color: var(--white);
    font-family: 'Montserrat', sans-serif;
    font-size: 1.125rem;
    letter-spacing: 0.5px;
}

nav .logo .brand-decision {
    font-weight: 500;
}

nav .logo .brand-dna {
    font-weight: 300;
}

nav .nav-links {
    margin-left: auto;
    display: flex;
    gap: var(--space-xl);
}

nav .nav-links a {
    color: var(--silver);
    text-decoration: none;
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 8px 0;
    transition: color 400ms var(--ease);
}

nav .nav-links a:hover {
    color: var(--accent);
}

nav .nav-links a.active {
    color: var(--white);
    font-weight: 700;
}

/* ============================================================
   Cards — White default, dark data variant
   ============================================================ */
.card {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    box-shadow: none;
    padding: 24px;
    margin-bottom: 16px;
    transition: border-color 400ms var(--ease);
}

.card:hover {
    border-color: var(--accent);
    box-shadow: none;
}

.card h3 {
    margin-bottom: 12px;
}

/* Data surface — light background, dark text */
.card--data {
    background: var(--white);
    border-color: var(--border-light);
    color: var(--dark-grey);
}

.card--data:hover {
    border-color: var(--accent);
}

.card--data h3,
.card--data h4 {
    color: var(--dark-grey);
}

.card--data .data-table td,
.card--data .metric,
.card--data td.numeric {
    color: var(--dark-grey);
}

.card--data .data-table th {
    color: var(--mid);
    border-bottom-color: var(--border-light);
}

.card--data .data-table td {
    border-bottom-color: var(--border-light);
}

.card--data .score-trio .score-value {
    color: var(--dark-grey);
}

.card--data .score-trio .score-label {
    color: var(--mid);
}

.card--data .score-trio .score-context {
    color: var(--mid-light);
}

.card--data .score-trio {
    border-top-color: var(--border-light);
}

.card--data .pct-badge-top    { background: rgba(44, 95, 45, 0.15); color: var(--color-success); }
.card--data .pct-badge-low    { background: rgba(230, 126, 34, 0.15); color: var(--color-mixed); }
.card--data .pct-badge-bottom { background: rgba(153, 0, 17, 0.12); color: var(--color-failure); }

.card--data .ddna-tooltip .tooltip-icon {
    background: rgba(0, 0, 0, 0.06);
    color: var(--mid);
}

.card--data .tooltip-text {
    background: var(--white);
    border-color: var(--border-light);
    color: var(--dark-grey);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.card--data .tooltip-text::after {
    border-top-color: var(--border-light);
}

/* ============================================================
   Filter Bar
   ============================================================ */
.filter-bar {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    box-shadow: none;
    padding: 10px 16px;
    margin: 8px 0 16px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.filter-bar select {
    font-family: var(--font-body);
    font-size: 12px;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    background: var(--white);
    color: var(--color-text);
    min-width: 0;
    max-width: 160px;
    outline: none;
    transition: border-color 0.2s;
}

.filter-bar select option {
    background: var(--white);
    color: var(--color-text);
}

.filter-bar select:focus {
    border-color: var(--accent);
}

.filter-bar .filter-count {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-light);
    white-space: nowrap;
}

.filter-bar button.clear-filters {
    background: none;
    border: 1px solid var(--color-border);
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-light);
    transition: all 0.2s;
}

.filter-bar button.clear-filters:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================================
   Case Table
   ============================================================ */
.case-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.case-table thead {
    background: var(--near-white);
    color: var(--dark-grey);
}

.case-table th {
    padding: 10px 12px;
    text-align: left;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-light);
    color: var(--dark-grey);
}

.case-table th:hover {
    background: var(--off-white);
}

.case-table th .sort-arrow {
    margin-left: 4px;
    opacity: 0.4;
    font-size: 9px;
}

.case-table th.sorted .sort-arrow {
    opacity: 1;
    color: var(--accent);
}

.case-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    max-width: 240px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--dark-grey);
}

.case-table tbody tr {
    cursor: pointer;
    transition: background 0.15s;
}

.case-table tbody tr:hover {
    background: rgba(0, 0, 0, 0.02);
}

/* ============================================================
   Badges
   ============================================================ */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: rgba(44, 95, 45, 0.12); color: var(--color-success); }
.badge-failure { background: rgba(153, 0, 17, 0.10); color: var(--color-failure); }
.badge-mixed   { background: rgba(230, 126, 34, 0.12); color: var(--color-mixed); }

.archetype-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.archetype-elite       { background: rgba(44, 95, 45, 0.12); color: var(--color-elite); }
.archetype-constrained { background: rgba(52, 152, 219, 0.12); color: var(--color-constrained); }
.archetype-structured  { background: rgba(155, 89, 182, 0.12); color: var(--color-structured); }
.archetype-reactive    { background: rgba(230, 126, 34, 0.12); color: var(--color-reactive); }
.archetype-chaotic     { background: rgba(153, 0, 17, 0.10); color: var(--color-chaotic); }

/* ============================================================
   Autocomplete
   ============================================================ */
.autocomplete-wrapper {
    position: relative;
    width: 100%;
    max-width: 480px;
}

.autocomplete-wrapper input {
    width: 100%;
    padding: 12px 16px;
    font-family: var(--font-body);
    font-size: 16px;
    border: 1px solid var(--color-border);
    background: var(--white);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.2s;
}

.autocomplete-wrapper input::placeholder {
    color: var(--color-text-dim);
}

.autocomplete-wrapper input:focus {
    border-color: var(--accent);
}

.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--color-border);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    max-height: 360px;
    overflow-y: auto;
    z-index: 200;
    display: none;
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-item {
    padding: 10px 16px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.1s;
}

.autocomplete-item:hover,
.autocomplete-item.highlighted {
    background: rgba(0, 0, 0, 0.04);
}

.autocomplete-item .org-name {
    font-weight: 500;
    color: var(--color-text);
}

.autocomplete-item .episode-count {
    font-family: var(--font-mono);
    font-size: 12px;
    color: var(--color-text-light);
}

/* ============================================================
   Profile Grid
   ============================================================ */
.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

.profile-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px;
    margin: 16px 0;
}

/* ============================================================
   Radar Chart
   ============================================================ */
.radar-container {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
}

/* ============================================================
   Composite Score Display
   ============================================================ */
.score-trio {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 12px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.score-trio .score-item {
    text-align: center;
}

.score-trio .score-label {
    font-size: 11px;
    color: var(--color-text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    display: flex;
    justify-content: center;
}

.score-trio .score-label .ddna-tooltip {
    justify-content: center;
}

.score-trio .score-value {
    font-family: var(--font-mono);
    font-size: 26px;
    font-weight: 700;
    color: var(--color-text);
}

.score-trio .score-value.highlight {
    color: var(--accent);
}

.score-trio .score-context {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--color-text-dim);
    margin-top: 2px;
    letter-spacing: 0.2px;
}

/* ============================================================
   Benchmark Pills
   ============================================================ */
.benchmark-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 0;
}

.benchmark-pills button {
    font-family: var(--font-body);
    font-size: 12px;
    padding: 5px 12px;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    background: var(--white);
    color: var(--color-text-light);
    cursor: pointer;
    transition: all 0.2s;
}

.benchmark-pills button:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.benchmark-pills button.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

/* ============================================================
   Benchmark Bars
   ============================================================ */
.benchmark-row {
    display: flex;
    align-items: center;
    margin: 6px 0;
    gap: 10px;
}

.benchmark-row .dim-label {
    width: 80px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--color-text-light);
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.benchmark-row .bar-track {
    flex: 1;
    height: 22px;
    background: var(--off-white);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.benchmark-row .bar-fill {
    height: 100%;
    border-radius: 4px;
    background: var(--accent);
    transition: width 0.4s ease;
}

.benchmark-row .median-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--color-text-light);
    z-index: 2;
}

.benchmark-row .bar-value {
    width: 44px;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 13px;
    flex-shrink: 0;
    color: var(--color-text);
}

.benchmark-row .percentile-badge {
    width: 40px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 4px;
    background: rgba(184, 69, 26, 0.10);
    color: var(--accent);
    flex-shrink: 0;
}

.benchmark-row .delta-value {
    width: 80px;
    font-family: var(--font-mono);
    font-size: 11px;
    flex-shrink: 0;
}

.delta-positive { color: var(--color-success); }
.delta-negative { color: var(--color-failure); }
.delta-neutral  { color: var(--color-neutral); }

/* ============================================================
   MDC Zone
   ============================================================ */
.mdc-zone-indicator {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
}

.mdc-zone-cowboy     { background: rgba(153, 0, 17, 0.10); color: var(--color-cowboy); }
.mdc-zone-sweet-spot { background: rgba(44, 95, 45, 0.12); color: var(--color-success); }
.mdc-zone-friction   { background: rgba(230, 126, 34, 0.12); color: var(--color-friction); }
.mdc-zone-paralysis  { background: rgba(153, 0, 17, 0.10); color: var(--color-failure); }

/* ============================================================
   Episode Timeline
   ============================================================ */
.episode-list {
    list-style: none;
}

.episode-item {
    padding: 10px 14px;
    border-left: 3px solid var(--color-border);
    margin: 4px 0;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 0 4px 4px 0;
}

.episode-item:hover {
    border-left-color: var(--accent);
    background: rgba(0, 0, 0, 0.02);
}

.episode-item.current {
    border-left-color: var(--accent);
    background: rgba(0, 0, 0, 0.04);
}

/* Episode Sort Controls */
.episode-sort-controls {
    display: flex;
    gap: 4px;
}

.episode-sort-btn {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 8px;
    border: 1px solid var(--color-border);
    border-radius: 3px;
    background: transparent;
    color: var(--color-text-dim);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.episode-sort-btn:hover {
    border-color: var(--accent);
    color: var(--color-text-light);
}

.episode-sort-btn.active {
    border-color: var(--accent);
    color: var(--accent);
    background: rgba(184, 69, 26, 0.06);
}

/* ============================================================
   Pagination
   ============================================================ */
.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 16px 0;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid var(--color-border);
    background: var(--white);
    cursor: pointer;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--color-text-light);
    transition: all 0.15s;
}

.pagination button.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.pagination button:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================================
   Stat Row (landing page)
   ============================================================ */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.stat-row:last-child {
    border-bottom: none;
}

/* ============================================================
   Data Table (generic)
   ============================================================ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}

.data-table th {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 2px solid var(--color-border);
    font-size: 0.8125rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--color-text-light);
    letter-spacing: 0.04em;
}

.data-table td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

.data-table td.numeric {
    text-align: right;
    font-family: var(--font-mono);
}

/* ============================================================
   Warning
   ============================================================ */
.warning-banner {
    background: rgba(230, 126, 34, 0.08);
    border: 1px solid rgba(230, 126, 34, 0.25);
    padding: 8px 14px;
    font-size: 13px;
    color: var(--color-mixed);
    margin: 8px 0;
}

/* ============================================================
   Diagnose Split-Pane Layout
   ============================================================ */
.diagnose-split {
    display: grid;
    grid-template-columns: 1fr 0.67fr;
    gap: 16px;
    align-items: start;
}

.diagnose-main {
    min-width: 0;
}

.diagnose-sidebar {
    position: sticky;
    top: calc(var(--nav-height) + 16px);
    max-height: calc(100vh - var(--nav-height) - 32px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--color-border-active) transparent;
}

.diagnose-sidebar::-webkit-scrollbar {
    width: 5px;
}

.diagnose-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

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

/* ============================================================
   Collapsible
   ============================================================ */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.collapsible-header:hover .collapse-icon {
    color: var(--accent);
}

.collapse-icon {
    font-size: 16px;
    color: var(--color-text-light);
    transition: transform 0.2s;
}

.collapse-icon.collapsed {
    transform: rotate(-90deg);
}

.collapsible-body {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.collapsible-body.collapsed {
    max-height: 0;
    opacity: 0;
}

/* ============================================================
   Tooltips (CSS-only)
   ============================================================ */
.ddna-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tooltip-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.06);
    color: var(--color-text-light);
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: help;
    flex-shrink: 0;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--white);
    color: var(--color-text);
    font-size: 12px;
    font-weight: 400;
    font-family: var(--font-body);
    line-height: 1.5;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    width: max-content;
    max-width: 280px;
    z-index: 50;
    pointer-events: none;
    transition: opacity 0.15s, visibility 0.15s;
    text-transform: none;
    letter-spacing: normal;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.tooltip-text::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--color-border);
}

.ddna-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ============================================================
   Percentile Context Badges
   ============================================================ */
.pct-badge {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    font-family: var(--font-body);
    letter-spacing: 0.2px;
    white-space: nowrap;
}

.pct-badge-top    { background: rgba(44, 95, 45, 0.12); color: var(--color-success); }
.pct-badge-mid    { /* no badge shown for middle range */ }
.pct-badge-low    { background: rgba(230, 126, 34, 0.12); color: var(--color-mixed); }
.pct-badge-bottom { background: rgba(153, 0, 17, 0.10); color: var(--color-failure); }

/* ============================================================
   MDC Visual Gauge
   ============================================================ */
.mdc-gauge-container {
    margin: 16px 0 12px;
}

.mdc-gauge-track {
    position: relative;
    height: 32px;
    border-radius: 4px;
    overflow: visible;
    display: flex;
}

.mdc-gauge-zone {
    height: 100%;
}

.mdc-gauge-zone:first-child {
    border-radius: 4px 0 0 4px;
}

.mdc-gauge-zone:last-child {
    border-radius: 0 4px 4px 0;
}

.mdc-gauge-zone-cowboy     { background: rgba(153, 0, 17, 0.15); width: 30%; }
.mdc-gauge-zone-sweet-spot { background: rgba(44, 95, 45, 0.12); width: 20%; }
.mdc-gauge-zone-friction   { background: rgba(230, 126, 34, 0.12); width: 20%; }
.mdc-gauge-zone-paralysis  { background: rgba(153, 0, 17, 0.10); width: 30%; }

.mdc-gauge-marker {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--accent);
    border: 3px solid var(--white);
    box-shadow: 0 0 0 1px var(--color-border);
    z-index: 3;
}

.mdc-gauge-threshold {
    position: absolute;
    top: -4px;
    bottom: -4px;
    width: 0;
    border-left: 2px dashed var(--color-failure);
    z-index: 2;
}

.mdc-gauge-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: var(--color-text-light);
    font-family: var(--font-mono);
}

.mdc-gauge-zone-labels {
    display: flex;
    margin-top: 2px;
    font-size: 10px;
    color: var(--color-text-light);
}

.mdc-gauge-zone-labels span {
    text-align: center;
}

/* ============================================================
   Financial Panel — Decision Year Highlight
   ============================================================ */
.fin-decision-year {
    background: rgba(184, 69, 26, 0.06);
    font-weight: 500;
}

.fin-decision-year td:first-child {
    border-left: 3px solid var(--accent);
}

/* ============================================================
   Page Header — Dark banner with gradient transition
   Matches the website .page-header pattern
   ============================================================ */
.page-header {
    background: var(--black);
    background-image: url('../img/Header.png');
    background-size: cover;
    background-position: left bottom;
    background-repeat: no-repeat;
    color: var(--white);
    padding: calc(var(--nav-height) + 4rem) 2rem 4rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.page-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 80px;
    background: linear-gradient(to bottom, transparent, var(--white));
    z-index: 1;
}

.page-header h1 {
    font-family: var(--font-heading);
    font-weight: 400;
    font-size: clamp(1.5rem, 3vw, 2.25rem);
    color: var(--white);
    margin-bottom: var(--space-md);
    position: relative;
    z-index: 2;
}

.page-header__subtitle {
    font-size: 1.125rem;
    color: var(--light-grey);
    max-width: 640px;
    margin: 0 auto;
    line-height: 1.7;
    position: relative;
    z-index: 2;
}

/* Hero variant — taller for the landing page */
.page-header--hero {
    min-height: 50vh;
}

.page-header--hero h1 {
    font-size: clamp(1.75rem, 3.5vw, 2.75rem);
}

/* ============================================================
   Landing Page — White Body Section
   ============================================================ */
.landing-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-2xl) 0;
}

.landing-search {
    width: 100%;
    max-width: 520px;
    margin-bottom: 24px;
}

.landing-search .autocomplete-wrapper,
.landing-search form {
    max-width: 100%;
}

.landing-search input {
    width: 100%;
    padding: 14px 20px;
    font-family: var(--font-body);
    font-size: 16px;
    border: 1px solid var(--border-light);
    background: var(--white);
    color: var(--dark-grey);
    outline: none;
    transition: border-color 0.2s;
}

.landing-search input::placeholder {
    color: var(--mid-light);
}

.landing-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184, 69, 26, 0.10);
}

.landing-nav-links {
    display: flex;
    gap: 24px;
    margin-bottom: 48px;
}

.landing-nav-links a {
    font-family: var(--font-body);
    font-size: 14px;
    color: var(--mid);
    transition: color 0.2s;
}

.landing-nav-links a:hover {
    color: var(--accent);
}

.landing-stats-bar {
    display: flex;
    justify-content: center;
    gap: 0;
    border-top: 1px solid var(--border-light);
    padding-top: 24px;
    width: 100%;
    max-width: 800px;
}

.landing-stat {
    flex: 1;
    text-align: center;
    padding: 0 16px;
    border-right: 1px solid var(--border-light);
}

.landing-stat:last-child {
    border-right: none;
}

.landing-stat-value {
    font-family: var(--font-mono);
    font-size: 20px;
    font-weight: 700;
    color: var(--dark-grey);
    display: block;
    margin-bottom: 4px;
}

.landing-stat-label {
    font-family: var(--font-body);
    font-size: 11px;
    color: var(--mid-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================================
   Footer — Website-aligned dark footer
   ============================================================ */
.engine-footer {
    background: var(--black);
    color: var(--silver);
    text-align: center;
    padding: var(--space-lg);
    font-size: 0.75rem;
    font-family: var(--font-body);
    border-top: 1px solid var(--border-dark);
}

.engine-footer .brand-decision {
    font-weight: 500;
}

.engine-footer .brand-dna {
    font-weight: 300;
}

/* ============================================================
   Global Scrollbar
   ============================================================ */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--mid-light);
}

/* Firefox */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--light-grey) var(--white);
}

/* ============================================================
   Responsive Breakpoint
   ============================================================ */
@media (max-width: 1023px) {
    .diagnose-split {
        grid-template-columns: 1fr;
    }

    .diagnose-sidebar {
        position: static;
        max-height: none;
        overflow-y: visible;
    }

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

    .landing-stats-bar {
        flex-wrap: wrap;
        gap: 16px;
    }

    .landing-stat {
        border-right: none;
        min-width: 120px;
    }

    .page-header {
        min-height: 200px;
        padding: calc(var(--nav-height) + 2rem) 1.5rem 2rem;
    }

    .page-header--hero {
        min-height: 30vh;
    }
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
    nav, .filter-bar, .pagination, .autocomplete-wrapper,
    .benchmark-pills, .no-print {
        display: none !important;
    }

    body {
        background: #fff;
        color: #333;
        min-width: auto;
        -webkit-font-smoothing: auto;
    }

    .container {
        max-width: none;
        padding: 0;
    }

    .card, .card--data {
        box-shadow: none;
        border: 1px solid #ddd;
        background: #fff;
        color: #333;
        break-inside: avoid;
    }

    .card--data h3, .card--data h4,
    .card--data .data-table td,
    .card--data td.numeric,
    .card--data .metric {
        color: #333;
    }

    .card--data .data-table th {
        color: #666;
    }

    h1, h2, h3, h4 { color: #1A1A1A; }

    .page-break {
        break-before: page;
    }

    .diagnose-split {
        grid-template-columns: 1fr;
    }

    .diagnose-sidebar {
        position: static;
        max-height: none;
    }
}

/* ============================================================
   Case Browser — Search Bar
   ============================================================ */

.cb-search {
    margin: 16px 0 0;
}

.cb-search-field {
    position: relative;
    display: flex;
    align-items: center;
}

.cb-search-icon {
    position: absolute;
    left: 16px;
    color: var(--mid-light);
    pointer-events: none;
    flex-shrink: 0;
}

.cb-search-field input {
    width: 100%;
    padding: 12px 80px 12px 44px;
    font-family: var(--font-body);
    font-size: 15px;
    color: var(--dark-grey);
    background: var(--white);
    border: 1px solid var(--border-light);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.cb-search-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(184, 69, 26, 0.10);
}

.cb-search-field input::placeholder {
    color: var(--mid-light);
    font-size: 14px;
}

/* Icon buttons inside the input — positioned right side */
.cb-search-helpbtn,
.cb-search-clearbtn {
    position: absolute;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--mid-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, background 0.15s;
    padding: 0;
}

.cb-search-helpbtn { right: 42px; }
.cb-search-clearbtn { right: 10px; opacity: 0; pointer-events: none; transition: opacity 0.15s, color 0.15s, background 0.15s; }

/* Show clear button only when input has content (toggled by JS) */
.cb-search-field.has-text .cb-search-clearbtn { opacity: 1; pointer-events: auto; }

.cb-search-helpbtn:hover,
.cb-search-clearbtn:hover {
    color: var(--dark-grey);
    background: rgba(0, 0, 0, 0.04);
}

.cb-search-status {
    font-size: 12px;
    color: var(--mid);
    padding: 6px 4px 0;
    min-height: 22px;
}

.cb-search-status strong { color: var(--dark-grey); }
.cb-search-status .search-query-echo { font-family: var(--font-mono); color: var(--accent); }


/* ============================================================
   Search Help Popover — fixed floating card
   ============================================================ */

.shp {
    display: none;
    position: fixed;
    z-index: 9999;
    width: 380px;
    background: var(--white);
    border: 1px solid var(--border-light);
    padding: 16px 20px 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
}

.shp.visible { display: block; }

.shp-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.shp-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--mid);
    font-weight: 600;
}

.shp-label--pad { display: block; margin-bottom: 4px; }

.shp-x {
    width: 22px;
    height: 22px;
    border: none;
    background: none;
    color: var(--mid-light);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
    transition: color 0.15s, background 0.15s;
}

.shp-x:hover { color: var(--dark-grey); background: rgba(0, 0, 0, 0.04); }

.shp-tbl {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    margin-bottom: 2px;
}

.shp-tbl td { padding: 3px 0; vertical-align: baseline; }
.shp-tbl td:first-child { white-space: nowrap; padding-right: 16px; }
.shp-tbl td:last-child { color: var(--mid); }

.shp-tbl code {
    font-family: var(--font-mono);
    font-size: 11.5px;
    color: var(--accent);
    background: none;
}

.shp-tbl b { color: var(--dark-grey); font-weight: 600; }

.shp-hr { height: 1px; background: var(--border-light); margin: 10px 0; }

.shp-ex {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.shp-ex code {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--mid);
    line-height: 1.7;
}

/* Search Result Snippets */
.search-snippet {
    font-size: 11px;
    color: var(--color-text-light);
    margin-top: 3px;
    line-height: 1.4;
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-snippet mark {
    background: rgba(184, 69, 26, 0.20);
    color: var(--accent);
    padding: 0 2px;
    border-radius: 2px;
}

/* Dim text for sponsor column */
.case-table td.dim-text {
    color: var(--mid-light);
    font-size: 12px;
}

/* ============================================================
   Evidence Tier Badges
   ============================================================ */
.evidence-tier-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    font-family: 'JetBrains Mono', monospace;
}

.tier-rich,
.tier-tier-1 {
    background: rgba(44, 95, 45, 0.12);
    color: var(--color-success, #2C5F2D);
}

.tier-moderate,
.tier-tier-2 {
    background: rgba(230, 126, 34, 0.12);
    color: var(--color-mixed, #E67E22);
}

.tier-thin,
.tier-tier-3 {
    background: rgba(153, 0, 17, 0.10);
    color: var(--color-failure, #990011);
}

.tier-none,
.tier-tier-4 {
    background: rgba(153, 153, 153, 0.10);
    color: var(--color-text-dim, #999);
}
