:root {
    color-scheme: light;
}

/* --- Variables & Design Tokens --- */
:root {
    --bg: #ffffff;
    --slate-900: #0f172a;
    --slate-800: #1e293b;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748b;
    --slate-300: #cbd5e1;
    --slate-200: #e2e8f0;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;

    --accent: #2563eb;
    --accent-light: #eff6ff;
    --green-300: #86efac;
    --red-300: #fca5a5;

    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
    --font-serif: 'Playfair Display', serif;
}

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

body {
    font-family: var(--font-sans);
    color: var(--slate-900);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
    background: linear-gradient(180deg, #f8fafc 0%, #ffffff 48%, #f1f5f9 100%);
}

.app-body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.08), transparent 35%),
        radial-gradient(circle at 80% 0%, rgba(14, 165, 233, 0.07), transparent 32%),
        linear-gradient(180deg, #f8fafc 0%, #ffffff 45%, #f8fafc 100%);
}

.page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px 64px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.content {
    display: flex;
    flex-direction: column;
    gap: 40px;
    margin-top: 16px;
}

/* --- Navigation --- */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 28px 0 12px;
    border-bottom: 1px solid var(--slate-200);
}

.navbar__left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--slate-900);
    font-weight: 600;
    letter-spacing: -0.02em;
    transition: opacity 0.2s ease;
}

.navbar__brand:hover {
    opacity: 0.85;
}

.brand__logo {
    height: 120px;
    width: auto;
}

.navbar__links {
    display: flex;
    gap: 18px;
    align-items: center;
}

.nav-link {
    position: relative;
    text-decoration: none;
    color: var(--slate-500);
    font-size: 14px;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: 12px;
    transition: all 0.2s ease;
}

.nav-link:hover {
    color: var(--slate-900);
    background: var(--slate-50);
}

.nav-link--active {
    color: var(--slate-900) !important;
    background: var(--accent-light);
    border: 1px solid rgba(37, 99, 235, 0.15);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--slate-500);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    background: transparent;
    border: none;
    padding: 0;
}

.back-link:hover {
    color: var(--accent);
    transform: none;
}

/* --- Sections --- */
.section {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 56px;
}

.section__title {
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 5vw, 3.25rem);
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -0.03em;
    color: var(--slate-900);
}

.section__lead {
    max-width: 760px;
    margin: 0 auto;
    color: var(--slate-600);
    font-size: 18px;
    line-height: 1.7;
}

.section__heading {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--slate-900);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
}

.hero-panel {
    margin-top: 8px;
    padding-bottom: 4px;
}

.section__header {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

/* --- Card System --- */
.card {
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 28px;
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: 0 16px 40px -22px rgba(15, 23, 42, 0.16);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card:hover {
    transform: none;
    border-color: #cbd5e1;
    box-shadow: 0 24px 48px -22px rgba(15, 23, 42, 0.15);
}

.card__title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    letter-spacing: -0.01em;
}

/* --- Model Dashboard Theme Alignment --- */
.model-dashboard .section__lead {
    color: var(--slate-600);
}

.model-dashboard .dashboard-select {
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
    color: var(--slate-800);
    background: #fff;
    box-shadow: 0 10px 18px -18px rgba(15, 23, 42, 0.35);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.model-dashboard .dashboard-select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.model-dashboard .model-card {
    background: transparent;
    border: none;
    box-shadow: none;
}

.model-dashboard .model-card__header {
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
}

.model-dashboard .model-card .target-label {
    color: var(--slate-900);
}

.model-dashboard .model-card .run-id {
    font-size: 9px;
    font-weight: 600;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
    color: var(--accent);
    background: var(--accent-light);
    border: 1px solid rgba(37, 99, 235, 0.2);
    padding: 2px 6px;
    border-radius: 999px;
}

.model-dashboard .metric-chip {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
}

.model-dashboard .metric-chip .metric-label {
    color: var(--slate-500);
}

.model-dashboard .metric-chip .metric-value {
    color: var(--slate-800);
}

.model-dashboard .position-badge {
    background: var(--slate-50);
    border: 1px solid var(--slate-200);
}

.model-dashboard .position-badge .position-value {
    color: var(--slate-700);
}

.model-dashboard .signal-section-divider {
    position: relative;
    padding: 1.25rem 0;
}

.model-dashboard .signal-section-divider::after {
    content: "";
    position: absolute;
    left: 7%;
    right: 7%;
    bottom: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.42) 18%, rgba(148, 163, 184, 0.42) 82%, transparent 100%);
}

.model-dashboard .signal-section-divider--keep-line::after {
    content: "";
}

.model-dashboard .signal-grid-divider {
    position: relative;
}

.model-dashboard .signal-results-grid {
    gap: 1.85rem;
    align-items: stretch;
}

.model-dashboard .signal-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.model-dashboard .signal-card__container {
    height: auto;
    min-height: 0;
}

.model-dashboard .signal-card--lg .signal-card__container {
    min-height: clamp(20rem, 42vh, 30rem);
}

.model-dashboard .signal-card--sm .signal-card__container {
    min-height: clamp(9rem, 16vh, 12rem);
}

.model-dashboard #signal-ensemble-card #signal-interval-component {
    padding-top: 1.5rem;
}

.model-dashboard #signal-ensemble-card .explorer-chart-container {
    overflow: visible;
}

.model-dashboard #signal-interval-component p,
.model-dashboard #signal-interval-component span {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.model-dashboard .signal-card .explorer-details {
    margin-top: 0.75rem;
}

.model-dashboard .signal-card--sm .explorer-details {
    margin-top: 0.35rem;
}

@media (min-width: 640px) {
    .model-dashboard #signal-ensemble-card #signal-interval-component {
        padding-top: 2rem;
    }
}

@media (min-width: 768px) {
    .model-dashboard .signal-grid-divider--md > * {
        position: relative;
    }

    .model-dashboard .signal-grid-divider--md > :nth-child(even):not(.signal-v-divider-skip)::before {
        content: "";
        position: absolute;
        top: 14%;
        bottom: 14%;
        left: calc(-0.75rem - 0.5px);
        width: 1px;
        background: linear-gradient(180deg, transparent 0%, rgba(148, 163, 184, 0.4) 15%, rgba(148, 163, 184, 0.4) 85%, transparent 100%);
    }

}

@media (min-width: 1024px) {
    .model-dashboard .signal-grid-divider--lg > * {
        position: relative;
    }

    .model-dashboard .signal-grid-divider--lg > :nth-child(even):not(.signal-v-divider-skip)::before {
        content: "";
        position: absolute;
        top: 14%;
        bottom: 14%;
        left: calc(-0.75rem - 0.5px);
        width: 1px;
        background: linear-gradient(180deg, transparent 0%, rgba(148, 163, 184, 0.4) 15%, rgba(148, 163, 184, 0.4) 85%, transparent 100%);
    }

    .model-dashboard .signal-grid-divider--lg > :nth-last-child(-n+2)::after {
        content: none;
    }

    .model-dashboard .signal-grid-divider--lg > :nth-child(n + 3):not(.signal-h-divider-skip)::after {
        content: "";
        position: absolute;
        top: calc(-0.925rem - 0.5px);
        left: 6%;
        right: 6%;
        height: 1px;
        background: linear-gradient(90deg, transparent 0%, rgba(148, 163, 184, 0.4) 12%, rgba(148, 163, 184, 0.4) 88%, transparent 100%);
    }

    .model-dashboard .signal-grid-divider--lg3 > * {
        position: relative;
    }

    .model-dashboard .signal-grid-divider--lg3 > :not(:nth-child(3n + 1)):not(.signal-v-divider-skip)::before {
        content: "";
        position: absolute;
        top: 14%;
        bottom: 14%;
        left: calc(-0.75rem - 0.5px);
        width: 1px;
        background: linear-gradient(180deg, transparent 0%, rgba(148, 163, 184, 0.4) 15%, rgba(148, 163, 184, 0.4) 85%, transparent 100%);
    }

}

.label {
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    color: var(--slate-500);
    margin-bottom: 6px;
}

.metric {
    font-size: 30px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.control-column {
    position: relative;
}

.chart-column {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chart-frame {
    width: 100%;
    border: none;
    background: transparent;
    box-shadow: none;
    overflow: visible;
}

.quadrant-legend {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 140px), 1fr));
    gap: 12px;
    padding-top: 10px;
    border-top: none;
}

.quadrant-legend__item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    text-align: center;
}

.quadrant-legend__label {
    display: block;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--q, var(--slate-700)); /* uses per-item color */
}

.quadrant-legend__value {
    font-size: 0.9rem;
    color: var(--slate-700);
}

.tab-btn {
    padding-bottom: 0.75rem;
    font-weight: 500;
    color: var(--slate-500);
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.tab-btn:hover {
    color: var(--slate-800);
}

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

.tab-pane {
    transition: opacity 0.2s ease-in-out;
}

.tab-pane.hidden {
    opacity: 0;
    pointer-events: none;
    z-index: -1;
}

.tab-pane.active {
    opacity: 1;
    pointer-events: auto;
    z-index: 10;
    position: relative;
}

.control-stack {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.diagnostic-card {
    gap: 14px;
    min-height: 280px;
    justify-content: space-between;
}

.field__label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--slate-700);
    margin-bottom: 6px;
}

.field__input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--slate-200);
    background: var(--slate-50);
    font-size: 14px;
    color: var(--slate-900);
    transition: all 0.2s ease;
}

.field__input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
    background: #fff;
}

/* --- Action area --- */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: var(--slate-900);
    color: white;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:hover:not(:disabled) {
    background: var(--slate-700);
    transform: none;
}

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

.btn-primary {
    background-color: var(--accent);
    color: white;
    font-weight: 700;
    padding: 12px 18px;
    border-radius: 10px;
    transition: all 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--slate-100);
    color: var(--slate-800);
    font-weight: 700;
    padding: 12px 18px;
    border-radius: 10px;
    border: 1px solid var(--slate-200);
    transition: all 0.2s ease;
}

.btn-secondary:hover:not(:disabled) {
    background-color: var(--slate-200);
}

.task-btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    font-weight: 700;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--slate-200);
    background: var(--slate-100);
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-700);
}

/* --- Typography helpers --- */
.muted {
    color: var(--slate-600);
    font-size: 14px;
    line-height: 1.6;
}

.text-center { text-align: center; }

/* --- Diagnostics --- */
.diagnostics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
    gap: 20px;
}

.icon-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: var(--slate-100);
    color: var(--slate-700);
    margin-bottom: 8px;
}

.icon-badge--blue { background: #e0edff; color: #1d4ed8; }
.icon-badge--amber { background: #fef3c7; color: #92400e; }
.icon-badge--green { background: #dcfce7; color: #166534; }
.icon-badge--purple { background: #f3e8ff; color: #6b21a8; }
.icon-badge--slate { background: var(--slate-100); color: var(--slate-700); }

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    text-align: center;
    min-height: 260px;
}

/* --- Pills & Tags --- */
.pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--slate-100);
    color: var(--slate-800);
    border-radius: 999px;
    padding: 8px 12px;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid var(--slate-200);
}

.pill--ghost { background: transparent; color: var(--slate-800); border-color: var(--slate-200); cursor: pointer; }

.full-width { width: 100%; justify-content: center; }

/* --- Regression Results --- */
/* --- Legend --- */
.legend-card { padding: 24px; display: flex; flex-direction: column; gap: 16px; }

.raw-variable-card {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.raw-variable-card__header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
}

.raw-variable-search {
    border-color: var(--slate-300);
}

.raw-variable-results {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 14px;
}

.raw-variable-empty {
    font-size: 13px;
    color: var(--slate-500);
    padding: 14px;
    background: var(--slate-50);
    border: 1px dashed var(--slate-300);
    border-radius: 10px;
}

.raw-variable-item {
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 14px;
    background: #fff;
    box-shadow: 0 10px 28px -26px rgba(15, 23, 42, 0.45);
}

.raw-variable-item__head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.raw-variable-item__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--slate-900);
    margin: 0;
}

.raw-variable-item__grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.raw-variable-meta {
    background: var(--slate-50);
    border-radius: 8px;
    padding: 8px;
}

.raw-variable-meta__label {
    display: block;
    font-size: 11px;
    color: var(--slate-500);
    margin-bottom: 2px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.raw-variable-meta__value {
    font-size: 12px;
    color: var(--slate-800);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    word-break: break-word;
}

.raw-variable-note {
    margin: 10px 0 0;
    font-size: 12px;
    color: var(--slate-600);
    line-height: 1.5;
}

.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-field {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--slate-200);
    border-radius: 10px;
    padding: 10px 12px;
    background: #fff;
    flex: 1;
    min-width: 240px;
}

.filter-field input {
    border: none;
    width: 100%;
    font-size: 14px;
    outline: none;
}

.dropdown { position: relative; }

.dropdown__menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 240px;
    background: #fff;
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    box-shadow: 0 20px 40px -24px rgba(15, 23, 42, 0.25);
    display: none;
}

.dropdown.open .dropdown__menu { display: block; }

.dropdown__options {
    max-height: 240px;
    overflow-y: auto;
    padding: 8px;
}

.dropdown__options button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: var(--slate-800);
}

.dropdown__options button:hover { background: var(--slate-50); }

.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead {
    background: var(--slate-50);
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid var(--slate-200);
}

.data-table tbody tr:hover { background: #f8fafc; }

.badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.badge--blue { background: #e0edff; color: #1d4ed8; }
.badge--green { background: #dcfce7; color: #166534; }
.badge--purple { background: #f3e8ff; color: #6b21a8; }
.badge--indigo { background: #e0e7ff; color: #3730a3; }
.badge--orange { background: #ffedd5; color: #c2410c; }
.badge--slate { background: var(--slate-100); color: var(--slate-800); }
.badge--outline { background: transparent; border: 1px solid var(--slate-200); color: var(--slate-600); }

.code-chip {
    display: inline-block;
    font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
    background: var(--slate-100);
    color: var(--slate-800);
    padding: 6px 8px;
    border-radius: 8px;
    font-size: 12px;
    border: 1px solid var(--slate-200);
}

.table-title { font-weight: 700; margin-bottom: 4px; }
.table-copy { color: var(--slate-600); font-size: 14px; }

.rotate-180 { transform: rotate(180deg); }

.table-empty td {
    text-align: center;
    padding: 18px 12px;
    color: var(--slate-600);
    font-weight: 600;
}

/* --- Footer --- */
.footer {
    padding: 36px 0 12px;
    border-top: 1px solid var(--slate-200);
    text-align: center;
    color: var(--slate-500);
    font-size: 13px;
    margin-top: auto;
}

.footer__note {
    margin-top: 6px;
    font-size: 12px;
}

/* --- Explorer Standardized Components --- */

/* Chart Toolbar Extensions */
.toolbar-btn {
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 600;
    color: var(--slate-500);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.toolbar-btn:hover {
    color: var(--slate-800);
}

.toolbar-btn.active {
    background: #fff;
    color: var(--slate-900);
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.toolbar-intervals {
    display: flex;
    gap: 4px;
    background: var(--slate-100);
    padding: 4px;
    border-radius: 6px;
    flex-wrap: wrap;
    max-width: 100%;
}

/* --- Legacy compatibility for JS-driven classes --- */
.card-content { flex-grow: 1; }
.nav-link.active { background: var(--accent-light); color: var(--accent); font-weight: 700; }

.fade-in { animation: fadeIn 0.6s ease-in-out; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Modal Overlay */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6); backdrop-filter: blur(4px);
    z-index: 9999; display: flex; justify-content: center; align-items: center;
}
.modal-overlay.hidden { display: none; }

.finder-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: #fff;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--slate-500);
    font-size: 1.5rem;
    line-height: 1;
    padding: 0.25rem;
    cursor: pointer;
    transition: color 0.2s ease;
}

.close-btn:hover {
    color: var(--slate-700);
}

.close-btn:focus {
    outline: none;
}

/* Finder Window */
.finder-modal-window {
    background: #fff;
    width: 900px;
    max-width: 95vw;
    height: 90vh;
    max-height: 700px;
    border-radius: 12px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}

.finder-searchbar {
    position: relative;
    padding: 0.75rem 1rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.finder-search-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.search-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid #e2e8f0;
    background: #fff;
    border-radius: 10px;
    padding: 0.55rem 0.75rem;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    flex: 1;
    min-width: 0;
}

.search-input-wrap input {
    border: none;
    outline: none;
    flex: 1;
    min-width: 0;
    font-size: 0.95rem;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-input-wrap input::placeholder {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.finder-search-results {
    position: absolute;
    top: calc(100% - 4px);
    left: 1rem;
    right: 1rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    list-style: none;
    max-height: 220px;
    overflow: auto;
    margin: 0;
    padding: 0.35rem 0;
    box-shadow: 0 15px 45px -18px rgba(15, 23, 42, 0.35);
    z-index: 3;
}

.finder-search-results.hidden { display: none; }

.finder-search-results li {
    padding: 0.5rem 0.9rem;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.finder-search-results li:hover { background: #eef2ff; }

/* 3-Column Layout */
.finder-body {
    flex: 1;
    display: flex;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    min-height: 0;
}
.finder-col {
    flex: 1;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
    min-width: 200px;
    min-height: 0;
}
.finder-col:last-child { border-right: none; }
.finder-col.wide { flex: 1.5; } /* Variable column is wider */

.finder-col-toggle {
    position: relative;
}
.col-header {
    padding: 0.75rem; font-weight: 600; font-size: 0.75rem; 
    text-transform: uppercase; color: #64748b; background: #fff; border-bottom: 1px solid #e2e8f0;
}

.aggregation-controls {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.aggregation-controls label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    font-weight: 600;
}

.aggregation-controls select {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
    font-size: 0.85rem;
    color: #0f172a;
    background: #fff;
}

.aggregation-controls.hidden {
    display: none;
}

/* Lists */
.finder-list {
    flex: 1;
    overflow-y: auto;
    list-style: none;
    padding: 0;
    margin: 0;
    min-height: 0;
}
.finder-list li { 
    padding: 0.6rem 1rem; cursor: pointer; font-size: 0.9rem; color: #334155; 
    display: flex; justify-content: space-between; align-items: center; 
}
.finder-list li:hover { background: #eef2ff; }
.finder-list li.active {
    background: #3b82f6; color: white;
}
/* Arrow for items with children */
#finder-apply {
    border-radius: 10px;
    padding: 0.7rem 1.2rem;
    min-width: 150px;
    height: 100%;
    box-shadow: 0 10px 25px -18px rgba(15, 23, 42, 0.35);
}

.transform-col {
    min-width: 220px;
    border-left: 1px solid #e2e8f0;
}

/* --- Tooltip Styles --- */
[data-tooltip] {
  position: relative;
  cursor: help;
}

/* The Tooltip Bubble */
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 125%; /* Position above element */
  left: 50%;
  transform: translateX(-50%);
  background-color: #1e293b; /* slate-800 */
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.75rem; /* text-xs */
  line-height: 1.4;
  font-weight: 500;
  white-space: normal;
  width: max-content;
  max-width: 220px; /* Prevent it from getting too wide */
  text-align: center;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* The Little Arrow */
[data-tooltip]::before {
  content: '';
  position: absolute;
  bottom: 115%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 6px;
  border-style: solid;
  border-color: #1e293b transparent transparent transparent;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s, visibility 0.2s;
  z-index: 100;
}

/* Show on Hover */
[data-tooltip]:hover::after,
[data-tooltip]:hover::before {
  opacity: 1;
  visibility: visible;
}

/* Gauge sizing: keep the Plotly canvas stable and centered */
#signal-gauge {
    min-height: 360px;
    height: 380px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Signal drivers chart container: ensure consistent height and padding */
#signal-drivers-chart {
    min-height: 380px;
    height: 400px;
    width: 100%;
}

/* Small legend / badge ergonomics */
/* Optional: tighter badge look for the Signal tab header */
#signal-badges .pill {
    padding: 7px 12px;
    font-size: 12.5px;
}

/* Signal hero card emphasis */
.signal-hero-card {
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.signal-hero-card.signal-hero--buy {
    background: rgba(134, 239, 172, 0.12);
}

.signal-hero-card.signal-hero--sell {
    background: rgba(252, 165, 165, 0.12);
}

.signal-hero-card.signal-hero--neutral {
    background: rgba(253, 224, 71, 0.12);
}

/* --- Refactored Styles from Regression Tab --- */

@media print {
    body * {
        visibility: hidden;
    }

    #reg-results-area,
    #reg-results-area * {
        visibility: visible;
    }

    #reg-results-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        display: block !important;
    }

    .control-column,
    .hero-panel,
    header,
    nav,
    footer,
    .btn {
        display: none !important;
    }

    .chart-column {
        width: 100% !important;
        max-width: none !important;
    }

    img,
    canvas {
        max-width: 100% !important;
        break-inside: avoid;
    }

    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }
}

/* Page Layout */
.page-grid {
    display: grid;
    gap: 24px;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
    align-items: start;
}

@media (min-width: 1024px) {
    .page-grid {
        grid-template-columns: 1.05fr 1.65fr;
    }
}

/* Card Components */
.card__header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem; /* mb-3 */
}

.card__header-row .card__title {
    margin-bottom: 0;
}

.card__description {
    color: var(--slate-600); /* muted */
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 1rem; /* mb-4 */
}

/* Button Variants */
.btn-text {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem; /* text-sm */
    font-weight: 600; /* font-semibold */
    color: var(--accent); /* blue-600 approx */
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-text:hover {
    color: #1e40af; /* blue-800 */
}

.btn-text-danger {
    font-size: 0.75rem; /* text-xs */
    font-weight: 500; /* font-medium */
    color: var(--slate-400);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.btn-text-danger:hover {
    color: #ef4444; /* red-500 */
}

.btn-spinner {
    margin-left: 0.5rem;
}

/* Placeholders */
.placeholder-box {
    min-height: 60px;
}

.placeholder-box--large {
    min-height: 420px;
}

/* --- Mobile-first hardening --- */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
}

img,
svg,
canvas {
    max-width: 100%;
    height: auto;
}

/* Prevent Plotly media layers from overflowing during view transitions */
.js-plotly-plot img,
.js-plotly-plot video,
.js-plotly-plot canvas {
    overflow: clip !important;
}

.page,
.content,
.section,
.card,
.chart-column,
.control-column {
    min-width: 0;
}

.nav-toggle {
    display: none;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 8px 12px;
    border-radius: 10px;
    border: none;
    background: transparent;
    color: var(--slate-700);
    font-weight: 600;
}

.tabs-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tabs-scroll nav {
    min-width: max-content;
}

.tabs-nav {
    display: flex;
    gap: 1.5rem;
    min-width: max-content;
    flex-wrap: nowrap;
}

.tab-content {
    overflow-x: hidden;
}

.tab-pane {
    overflow-x: hidden;
}

.tab-btn,
.nav-link,
.back-link,
.btn,
.btn-primary,
.btn-secondary,
.task-btn,
.toolbar-btn,
.dropdown__options button {
    min-height: 44px;
}

@media (hover: none) {
    .nav-link:hover,
    .card:hover,
    .btn:hover,
    .btn-primary:hover,
    .btn-secondary:hover,
    .task-btn:hover {
        transform: none;
    }
}

@media (max-width: 1023px) {
    .page {
        padding: 0 16px 48px;
    }

    .navbar {
        position: relative;
        flex-wrap: wrap;
        gap: 12px;
        align-items: flex-start;
    }

    .navbar__left {
        width: 100%;
        justify-content: space-between;
        gap: 12px;
    }

    .brand__logo {
        height: 78px;
    }

    .nav-toggle {
        display: inline-flex;
        margin-left: auto;
    }

    .navbar__links {
        display: none;
        width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(248, 250, 252, 0.96) 100%);
        backdrop-filter: none;
        border: 1px solid var(--slate-200);
        border-radius: 16px;
        padding: 8px;
        box-shadow: 0 12px 28px -18px rgba(15, 23, 42, 0.55);
        margin-top: 4px;
    }

    .navbar__links.is-open {
        display: flex;
    }

    .nav-link {
        display: block;
        width: 100%;
        padding: 12px 14px;
        border-radius: 12px;
        border-bottom: none;
        font-size: 15px;
        color: var(--slate-500);
        background: transparent;
        border-left: none;
        transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
    }

    .nav-link:hover {
        background: rgba(148, 163, 184, 0.12);
        color: var(--slate-900);
    }

    .nav-link:active {
        transform: scale(0.985);
    }

    .nav-link--active {
        position: relative;
        background: rgba(191, 219, 254, 0.55) !important;
        border: 1px solid rgba(37, 99, 235, 0.3) !important;
        color: var(--slate-900) !important;
        font-weight: 600;
        box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
    }

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

    #signal-drivers-chart {
        height: 320px;
        min-height: 320px;
    }

    #signal-gauge {
        min-height: 300px;
        height: 320px;
    }

    .finder-body {
        flex-direction: column;
        overflow-y: auto;
    }

    .finder-col-toggle {
        cursor: pointer;
        user-select: none;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .finder-col-toggle::after {
        content: '▾';
        margin-left: auto;
        color: #94a3b8;
        font-size: 0.85rem;
        line-height: 1;
    }

    .finder-col.is-collapsed .finder-col-toggle::after {
        content: '▸';
    }

    .finder-col.is-collapsed {
        flex: 0 0 auto;
        min-height: auto;
    }

    .finder-col.is-collapsed .finder-list,
    .finder-col.is-collapsed .aggregation-controls {
        display: none;
    }

    .finder-col,
    .transform-col {
        min-width: 0;
        border-right: none;
        border-left: none;
        border-bottom: 1px solid #e2e8f0;
    }

    .finder-col:last-child {
        border-bottom: none;
    }
}

@media (max-width: 767px) {
    .filter-field {
        min-width: 0;
    }

    .dropdown__menu {
        width: min(100vw - 48px, 240px);
        right: auto;
        left: 0;
    }

    #finder-apply {
        min-width: 0;
    }

    .finder-modal-window {
        width: 100%;
        max-width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .section__title {
        font-size: clamp(1.85rem, 9vw, 2.4rem);
    }

    .section__lead {
        font-size: 1rem;
    }

    .card,
    .legend-card {
        padding: 18px;
    }

    .tabs-scroll nav {
        gap: 12px !important;
        padding-inline: 0;
    }

    .tabs-nav {
        gap: 0.75rem;
    }
}

@media (min-width: 1024px) {
    .nav-toggle {
        display: none;
    }
}

/* tooltip accessibility for keyboard/touch */
[data-tooltip]:focus-visible::after,
[data-tooltip]:focus-visible::before {
  opacity: 1;
  visibility: visible;
}
