﻿:root {
    --bg: #f3f4f6;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --ink: #111111;
    --muted: #6b7280;
    --line: #d1d5db;
    --line-strong: #111111;
    --red: #d71920;
    --red-dark: #8f1117;
    --black: #050505;
    --gray-900: #1f2937;
    --gray-800: #2f3542;
    --gray-100: #f3f4f6;
    --shadow: 0 18px 40px rgba(17, 17, 17, 0.14);
    --chart-input-line: #111111;
    --chart-actual-line: #6b7280;
    --chart-forecast-line: #d71920;
    --chart-fitted-line: #b91c1c;
    --chart-confidence-fill: rgba(59, 130, 246, 0.45);
    --chart-separator-line: #d71920;
    --chart-synthetic-fill: rgba(31, 41, 55, 0.08);
    --chart-synthetic-marker: #111111;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
}

button,
input,
select {
    font: inherit;
}

button {
    letter-spacing: 0;
}

.app-shell {
    min-height: 100vh;
    background: var(--bg);
}

.lp-home {
    width: min(1480px, calc(100vw - 36px));
    min-height: calc(100vh - 36px);
    margin: 18px auto;
    padding: 28px;
    border: 2px solid var(--line-strong);
    background: #e5e7eb;
}

.lp-topbar {
    display: grid;
    grid-template-columns: minmax(220px, 360px) minmax(260px, 1fr) auto;
    align-items: center;
    gap: 20px;
    margin-bottom: 18px;
}

.lp-logo {
    height: 74px;
    border: 0;
    background: transparent;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.lp-logo-img {
    height: 64px;
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.lp-nav {
    grid-column: 3;
    display: flex;
    justify-content: flex-end;
    gap: 14px;
}

.lp-topbar-actions {
    grid-column: 2;
    align-items: center;
}

.lp-nav-link {
    border: 0;
    background: transparent;
    color: var(--gray-800);
    cursor: pointer;
    font-size: 20px;
    font-weight: 700;
    padding: 10px 12px;
    text-transform: uppercase;
}

    .lp-nav-link.active {
        color: var(--red);
    }

    .lp-nav-link:disabled {
        cursor: not-allowed;
        opacity: 0.45;
    }

.form-control {
    min-width: 0;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    padding: 11px 12px;
}

    .form-control:focus {
        border-color: var(--red);
        outline: 2px solid rgba(215, 25, 32, 0.16);
    }

.batch-buttons {
    display: flex;
    gap: 12px;
    align-items: stretch;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 4px;
    border: 1px solid transparent;
    padding: 10px 18px;
    cursor: pointer;
    font-weight: 700;
    text-decoration: none;
}

    .btn:disabled {
        cursor: not-allowed;
        opacity: 0.55;
    }

.btn-primary {
    background: var(--red);
    color: #ffffff;
}

    .btn-primary:hover:not(:disabled) {
        background: var(--red-dark);
    }

.btn-dark {
    background: var(--black);
}

.btn-secondary {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--line-strong);
}

    .btn-secondary:hover:not(:disabled) {
        border-color: var(--red);
        color: var(--red);
    }

.btn-danger {
    background: var(--red);
    color: #ffffff;
}

    .btn-danger:hover:not(:disabled) {
        background: var(--red-dark);
    }

.btn-compact {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 12px;
}

.btn-tiny {
    min-height: 26px;
    padding: 4px 8px;
    font-size: 11px;
}

.status-message,
.run-progress {
    margin: 0 0 14px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--gray-800);
}

    .status-message.error,
    .empty-panel.error {
        border-color: var(--red);
        color: var(--red);
    }

.run-progress {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(180px, 360px) auto;
    gap: 12px;
    align-items: center;
}

.progress-copy {
    font-weight: 700;
    color: var(--gray-900);
}

.progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #d1d5db;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--red);
    transition: width 0.2s ease;
}

.data-processor-loading {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 12px;
    align-items: center;
    margin: 0 0 14px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    padding: 12px;
}

    .data-processor-loading strong,
    .data-processor-loading span {
        display: block;
    }

    .data-processor-loading strong {
        color: var(--gray-900);
        font-size: 13px;
    }

    .data-processor-loading span {
        margin-top: 2px;
        color: var(--muted);
        font-size: 12px;
        overflow-wrap: anywhere;
    }

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid #d1d5db;
    border-top-color: var(--red);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.lp-workspace {
    display: grid;
    grid-template-columns: minmax(300px, 440px) minmax(420px, 1fr);
    align-items: stretch;
    gap: 20px;
    min-height: 560px;
}

.csv-pane,
.record-pane,
.runs-view {
    background: var(--surface);
    border: 1px solid var(--line-strong);
}

.csv-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    padding: 18px;
}

.record-pane {
    padding: 18px;
    position: relative;
    box-shadow: 10px 10px 0 #c8ccd2;
}

.pane-heading,
.view-heading,
.selected-file-bar,
.modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.pane-heading {
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

    .pane-heading h2,
    .selected-file-bar h2,
    .view-heading h1,
    .modal-header h2 {
        margin: 0;
        color: var(--ink);
        font-size: 20px;
        line-height: 1.2;
    }

    .pane-heading span,
    .selected-file-bar p,
    .view-heading p,
    .record-meta,
    .csv-meta {
        color: var(--muted);
        font-size: 12px;
    }

.datatype-picker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

    .datatype-picker span {
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

.datatype-select {
    min-width: 86px;
    height: 34px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    padding: 6px 28px 6px 10px;
    font-weight: 700;
}

    .datatype-select:focus {
        border-color: var(--red);
        outline: 2px solid rgba(215, 25, 32, 0.16);
    }

.product-search-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: 12px;
}

.product-search {
    width: 100%;
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    padding: 7px 10px;
    font-weight: 700;
}

    .product-search:focus {
        border-color: var(--red);
        outline: 2px solid rgba(215, 25, 32, 0.16);
    }

.csv-list {
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
    min-height: 0;
    max-height: 650px;
    overflow: auto;
}

.lp-workspace.details-open .csv-list {
    flex: 1 1 0;
    max-height: none;
}

.csv-pane > .empty-panel {
    flex: 1 1 auto;
}

.product-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.product-toggle {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: var(--surface);
    color: var(--ink);
    padding: 10px 11px;
    text-align: left;
    cursor: pointer;
}

    .product-toggle:hover,
    .product-toggle.active {
        border-color: var(--red);
        background: #fffafa;
    }

.product-chevron {
    color: var(--red);
    font-weight: 800;
    line-height: 1.25;
}

.product-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.product-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}

.product-host {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-meta {
    color: var(--muted);
    font-size: 12px;
}

.feature-list {
    display: flex;
    flex-direction: column;
    gap: 7px;
    padding-left: 18px;
    border-left: 2px solid #e5e7eb;
}

.csv-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 5px;
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--ink);
    padding: 12px;
    text-align: left;
    cursor: pointer;
}

    .csv-item:hover,
    .csv-item.active {
        border-color: var(--red);
        background: #fff5f5;
    }

.csv-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.feature-status-dot {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    background: #d1d5db;
}

    .feature-status-dot.used {
        border-color: #047857;
        background: #16a34a;
    }

    .feature-status-dot.unused {
        border-color: #9ca3af;
        background: #d1d5db;
    }

    .feature-status-dot.blocked {
        border-color: #991b1b;
        background: var(--red);
    }

.csv-name {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.empty-panel,
.right-placeholder {
    display: flex;
    min-height: 220px;
    align-items: center;
    justify-content: center;
    border: 1px dashed var(--line);
    background: var(--surface-2);
    color: var(--muted);
    padding: 22px;
    text-align: center;
}

.right-placeholder {
    flex-direction: column;
    gap: 14px;
    min-height: 360px;
    font-size: 17px;
    line-height: 1.45;
}

.placeholder-actions,
.file-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.action-with-help {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.selected-file-bar {
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
}

    .selected-file-bar p {
        margin: 5px 0 0;
        overflow-wrap: anywhere;
    }

.file-column-meta {
    color: var(--muted);
    font-size: 12px;
}

.selected-product-name {
    font-weight: 700;
    color: var(--gray-900) !important;
}

.eyebrow {
    margin-bottom: 4px;
    color: var(--red);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.record-card {
    width: 100%;
    margin-top: 16px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--ink);
    padding: 20px;
    text-align: left;
}

    .record-card.has-record {
        border-color: var(--line-strong);
        background: #ffffff;
    }

    .record-card h3 {
        margin: 0;
        font-size: 21px;
    }

    .record-card p {
        margin: 8px 0 0;
        color: var(--muted);
    }

.record-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.latest-record-details {
    margin-top: 14px;
}

.expand-indicator {
    flex: 0 0 auto;
    border: 1px solid var(--red);
    border-radius: 999px;
    background: #ffffff;
    color: var(--red);
    cursor: pointer;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 800;
}

    .expand-indicator:disabled {
        border-color: var(--line);
        color: var(--muted);
        cursor: not-allowed;
    }

.record-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.record-chip {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--gray-800);
    cursor: pointer;
    padding: 6px 10px;
    font-size: 12px;
}

    .record-chip.active {
        border-color: var(--red);
        color: var(--red);
    }

.expanded-record {
    margin-top: 16px;
}

.chart-panel {
    position: relative;
}

.chart-panel-expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 1200;
    display: flex;
    flex-direction: column;
    width: min(86vw, 1320px);
    height: min(76vh, 760px);
    min-height: 0;
    transform: translate(-50%, -50%);
    border: 2px solid var(--line-strong);
    background: #ffffff;
    box-shadow: var(--shadow);
    padding: 12px;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    width: max-content;
    max-width: 100%;
    gap: 3px;
    margin: 0 0 8px auto;
    border: 1px solid rgba(17, 24, 39, 0.14);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 4px 14px rgba(18, 24, 33, 0.10);
    padding: 4px;
}

.chart-tool-button {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    flex: 0 0 32px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--gray-800);
    cursor: pointer;
    transition: background-color 120ms ease, color 120ms ease, transform 120ms ease;
}

    .chart-tool-button:hover {
        background: var(--gray-100);
        color: var(--ink);
    }

    .chart-tool-button:focus-visible {
        outline: 2px solid var(--red);
        outline-offset: 1px;
    }

    .chart-tool-button:active {
        transform: translateY(1px);
    }

    .chart-tool-button.is-active {
        background: var(--gray-900);
        color: #ffffff;
    }

    .chart-tool-button svg {
        width: 18px;
        height: 18px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.8;
        stroke-linecap: round;
        stroke-linejoin: round;
    }

.chart-tool-separator {
    margin-left: 4px;
    box-shadow: -5px 0 0 -4px var(--line);
}

.chart-shell {
    position: relative;
    border: 4px solid var(--line-strong);
    background: #ffffff;
    overflow: hidden;
    padding: 8px;
    min-height: 454px;
}

    .chart-shell > .chart-canvas {
        width: 100%;
        height: 430px;
        min-height: 430px;
    }

    .chart-shell canvas,
    .chart-shell svg {
        width: 100% !important;
        height: 100% !important;
    }

.chart-panel-expanded .chart-shell {
    flex: 1;
    display: flex;
    min-height: 0;
    overflow: hidden;
}

    .chart-panel-expanded .chart-shell > .chart-canvas {
        flex: 1;
        height: 100%;
        min-height: 0;
    }

/* Metrics grid */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 12px 0;
}

/* When metrics appear below the chart instead of inside the record card */
.metrics-grid--below {
    margin-top: 14px;
    margin-bottom: 0;
}

.metrics-grid--three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--gray-900);
    color: #ffffff;
    padding: 13px 14px;
    text-align: center;
}

    .metric-card strong {
        display: block;
        margin-top: 5px;
        color: #ffffff;
        font-size: 20px;
    }

.metric-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #d1d5db;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.record-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.record-meta {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.band-summary {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    border: 1px solid var(--red);
    border-radius: 999px;
    background: #fff5f5;
    color: var(--red);
    padding: 6px 10px;
    font-size: 12px;
    line-height: 1.2;
}

    .band-summary strong {
        color: var(--red);
        font-weight: 900;
        white-space: nowrap;
    }

    .band-summary .metric-help summary {
        border-color: var(--red);
        background: #ffffff;
        color: var(--red);
    }

    .band-summary .metric-help[open] .insight-help-body {
        right: 0;
        color: var(--ink);
    }

.prediction-table-panel {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #ffffff;
}

.prediction-table-toggle {
    display: flex;
    width: 100%;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 0;
    background: var(--surface-2);
    color: var(--ink);
    cursor: pointer;
    padding: 11px 13px;
    text-align: left;
}

    .prediction-table-toggle strong {
        display: block;
        font-size: 13px;
    }

    .prediction-table-toggle small {
        display: block;
        margin-top: 2px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
    }

.prediction-table-toggle-copy {
    flex: 0 0 auto;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    background: #ffffff;
    padding: 5px 9px;
    color: var(--gray-800);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.prediction-table-body {
    border-top: 1px solid var(--line);
    padding: 12px;
}

.prediction-table-wrap {
    overflow-x: auto;
}

.prediction-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    font-size: 12px;
}

    .prediction-table th,
    .prediction-table td {
        border-bottom: 1px solid var(--line);
        padding: 8px 10px;
        text-align: right;
        white-space: nowrap;
    }

    .prediction-table th {
        background: var(--surface-2);
        color: var(--muted);
        font-size: 11px;
        font-weight: 900;
        text-transform: uppercase;
    }

    .prediction-table th:first-child,
    .prediction-table td:first-child {
        text-align: left;
    }

    .prediction-table tbody tr:last-child td {
        border-bottom: 0;
    }

.prediction-table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.prediction-table-actions {
    display: flex;
    gap: 8px;
}

.synthetic-summary,
.synthetic-indicator-row {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--gray-800);
    font-size: 12px;
    font-weight: 800;
}

.synthetic-summary {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-2);
    padding: 6px 10px;
}

.synthetic-dot {
    width: 9px;
    height: 9px;
    border: 2px solid var(--black);
    background: #ffffff;
    transform: rotate(45deg);
    flex: 0 0 auto;
}

/* Dataset health panel */

.model-health-panel {
    margin-top: 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #ffffff;
    padding: 14px;
}

.health-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.health-item {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    padding: 10px;
    cursor: pointer;
}

    .health-item:focus-visible {
        outline: 2px solid var(--red);
        outline-offset: 2px;
    }

    .health-item:hover,
    .health-item-open {
        border-color: var(--line-strong);
        background: #ffffff;
    }

.health-item-main {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

    .health-item-main > span {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        color: var(--muted);
        font-size: 11px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .health-item-main strong {
        display: inline-flex;
        width: fit-content;
        font-size: 13px;
    }

.health-feedback {
    margin-top: 8px;
    border-top: 1px solid var(--line);
    padding-top: 8px;
    color: var(--ink);
    font-size: 12px;
    line-height: 1.45;
}

    .health-feedback p {
        margin: 0;
    }

.health-detail-actions {
    margin-top: 8px;
}

.health-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 11px;
    font-weight: 800;
}

.health-healthy {
    border-color: #166534;
    color: #166534;
    background: #f0fdf4;
}

.health-monitor,
.health-warning,
.health-not_run,
.health-running {
    border-color: #6b7280;
    color: #111111;
    background: #f3f4f6;
}

.health-critical,
.health-failed {
    border-color: var(--red);
    color: var(--red);
    background: #fff5f5;
}

/* Evaluate anomaly table */

.anomaly-panel {
    margin-top: 12px;
}

.anomaly-panel-header {
    align-items: flex-start;
}

.anomaly-panel-summary {
    margin-top: 2px;
}

.anomaly-table-wrap {
    overflow-y: visible;
    position: relative;
}

.anomaly-table {
    min-width: 760px;
    table-layout: fixed;
}

    .anomaly-table .anomaly-col-time {
        width: 13%;
    }

    .anomaly-table .anomaly-col-actual {
        width: 9%;
    }

    .anomaly-table .anomaly-col-forecast {
        width: 9%;
    }

    .anomaly-table .anomaly-col-band {
        width: 17%;
    }

    .anomaly-table .anomaly-col-breach {
        width: 24%;
    }

    .anomaly-table .anomaly-col-streak {
        width: 28%;
    }

    .prediction-table.anomaly-table th,
    .prediction-table.anomaly-table td {
        padding: 11px 12px;
        vertical-align: top;
        line-height: 1.35;
        text-align: center;
    }

    .anomaly-table th {
        overflow: visible;
    }

    .anomaly-table th:has(.metric-help[open]) {
        z-index: 300;
    }

    .anomaly-table th:nth-child(5),
    .anomaly-table th:nth-child(6),
    .anomaly-table td:nth-child(5),
    .anomaly-table td:nth-child(6) {
        white-space: normal;
    }

    .anomaly-table th:nth-child(2),
    .anomaly-table th:nth-child(3),
    .anomaly-table th:nth-child(4),
    .anomaly-table td:nth-child(2),
    .anomaly-table td:nth-child(3),
    .anomaly-table td:nth-child(4) {
        font-variant-numeric: tabular-nums;
    }

    .anomaly-table th:nth-child(4),
    .anomaly-table td:nth-child(4) {
        white-space: nowrap;
    }

.anomaly-row-streak-start td {
    border-top: 2px solid var(--line-strong);
}

.anomaly-row {
    cursor: pointer;
}

    .anomaly-row:hover td,
    .anomaly-row:focus-within td,
    .anomaly-row-open td {
        background: #fffbeb;
    }

    .anomaly-row:focus-visible {
        outline: none;
    }

.anomaly-row-peak td {
    background: #fff8f1;
}

.prediction-table.anomaly-table .anomaly-row-detail td {
    padding: 0 12px 12px;
    background: #fffbeb;
    border-top: 0;
    text-align: left;
}

.anomaly-row-detail-card {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fffdf5;
}

.anomaly-row-detail-block {
    min-width: 0;
}

.anomaly-row-detail-label {
    margin-bottom: 4px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.anomaly-row-detail-copy {
    color: var(--ink);
    font-size: 13px;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.anomaly-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.anomaly-badge-severe,
.anomaly-badge-critical {
    border-color: var(--red);
    color: var(--red);
    background: #fff5f5;
}

.anomaly-badge-important,
.anomaly-badge-warning {
    border-color: #D97706;
    color: #92400E;
    background: #FFF7ED;
}

.anomaly-badge-mild,
.anomaly-badge-normal {
    border-color: var(--line-strong);
    color: var(--ink);
    background: var(--surface-2);
}

.anomaly-time-cell {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.anomaly-reason-meta {
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.anomaly-detail-cell {
    min-width: 0;
}

.anomaly-detail-cell > * {
    max-width: 100%;
}

.anomaly-detail-cell .anomaly-badge {
    margin-bottom: 4px;
}

.anomaly-header-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    overflow: visible;
    position: relative;
    z-index: 0;
}

    .anomaly-header-label .metric-help summary {
        border-color: var(--line-strong);
        color: var(--muted);
    }

    .anomaly-header-label .metric-help {
        position: relative;
        z-index: 2;
    }

    .anomaly-header-label .anomaly-header-help[open] {
        z-index: 500;
    }

    .anomaly-header-label .anomaly-header-help[open] .insight-help-body {
        position: fixed;
        top: var(--anomaly-help-top, 0);
        left: var(--anomaly-help-left, 0);
        right: auto;
        z-index: 600;
        width: min(320px, calc(100vw - 24px));
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: normal;
    }

/* Runs view */

.runs-view {
    padding: 20px;
}

.runs-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.runs-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 14px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

.runs-table-wrap {
    margin-top: 18px;
    overflow: auto;
    border: 1px solid var(--line);
}

.runs-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    font-size: 13px;
}

    .runs-table th,
    .runs-table td {
        border-bottom: 1px solid var(--line);
        padding: 10px 12px;
        text-align: left;
        white-space: nowrap;
    }

    .runs-table th {
        background: var(--black);
        color: #ffffff;
        font-size: 11px;
        text-transform: uppercase;
    }

.run-row-click {
    cursor: pointer;
}

    .run-row-click:hover td {
        background: #fff5f5;
    }

/* Modal */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.55);
}

.options-modal {
    width: min(760px, 100%);
    max-height: min(820px, calc(100vh - 48px));
    overflow: auto;
    border: 2px solid var(--black);
    background: #ffffff;
    box-shadow: var(--shadow);
    padding: 20px;
}

.options-modal.run-options-modal {
    position: relative;
    display: flex;
    height: min(820px, calc(100vh - 48px));
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}

.mode-tabs {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 210px));
    align-items: end;
    gap: 8px;
    min-height: 72px;
    flex: 0 0 auto;
    margin: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface-2);
    padding: 8px 68px 0 12px;
}

.mode-tab {
    display: flex;
    min-width: 0;
    min-height: 54px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
    border: 1px solid var(--line);
    border-bottom: 0;
    border-radius: 12px 12px 0 0;
    background: #e9ebef;
    color: var(--muted);
    cursor: pointer;
    padding: 10px 18px;
    text-align: left;
    transition: min-height 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.mode-tab:hover {
    background: #f5f6f8;
    color: var(--ink);
}

.mode-tab.active {
    min-height: 64px;
    margin-bottom: -1px;
    border-color: var(--line);
    border-bottom-color: #ffffff;
    background: #ffffff;
    color: var(--red);
    box-shadow: 0 -8px 18px rgba(18, 24, 33, 0.08);
}

.mode-tab:focus-visible {
    position: relative;
    z-index: 2;
    outline: 3px solid rgba(215, 25, 32, 0.22);
    outline-offset: 2px;
}

.mode-tab-name {
    font-size: 14px;
    font-weight: 800;
}

.mode-tab-description {
    overflow: hidden;
    max-width: 100%;
    font-size: 11px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mode-tab-panel {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    border: 0;
    border-radius: 0;
    background: #ffffff;
    padding: 24px;
    scrollbar-gutter: stable;
    box-shadow: none;
}

.run-options-close {
    position: absolute;
    z-index: 3;
    top: 17px;
    right: 18px;
}

.mode-panel-intro {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    border-left: 4px solid var(--red);
    border-radius: 0 8px 8px 0;
    background: var(--surface-2);
    padding: 11px 13px;
}

.mode-panel-intro strong {
    color: var(--ink);
    font-size: 13px;
}

.mode-panel-intro p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.4;
}

.icon-button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--line-strong);
    border-radius: 4px;
    background: #ffffff;
    cursor: pointer;
    font-weight: 800;
}

.modal-grid,
.advanced-panel {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    margin-top: 18px;
}

.field,
.check-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--gray-800);
    font-weight: 700;
}

    .field span,
    .check-field span {
        font-size: 12px;
    }

.span-2 {
    grid-column: 1 / -1;
}

.range-control {
    width: 100%;
    accent-color: var(--red);
}

.evaluation-split-panel {
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    padding: 14px;
}

.evaluation-split-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    color: var(--gray-800);
    font-size: 12px;
    font-weight: 800;
}

.evaluation-split-heading .metric-help summary {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--muted);
}

.evaluation-split-methods {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
}

.evaluation-split-method {
    min-height: 38px;
    border: 1px solid var(--line-strong);
    border-radius: 9px;
    background: #ffffff;
    color: var(--gray-800);
    cursor: pointer;
    font-size: 12px;
    font-weight: 800;
}

.evaluation-split-method.active {
    border-color: var(--red);
    background: #fff0f2;
    color: var(--red);
}

.evaluation-split-method:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.evaluation-split-content {
    margin-top: 12px;
}

.recent-period-controls {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.recent-period-prompt {
    color: var(--gray-800);
    font-size: 12px;
    font-weight: 800;
}

.recent-period-fields {
    display: grid;
    grid-template-columns: minmax(120px, 0.7fr) minmax(160px, 1fr);
    gap: 10px;
}

.recent-period-limit {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gray-500);
    font-size: 11px;
    font-weight: 700;
}

.evaluation-range-preview {
    border-left: 3px solid var(--red);
    border-radius: 6px;
    background: #ffffff;
    color: var(--ink-muted);
    padding: 9px 11px;
    font-size: 11px;
    line-height: 1.45;
}

.recent-period-exclusions {
    margin-top: 18px;
    overflow: hidden;
    border: 1px solid #f1b7bd;
    border-radius: 12px;
    background: #fff8f8;
}

.recent-period-exclusions > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    cursor: pointer;
    padding: 12px 14px;
    list-style: none;
}

.recent-period-exclusions > summary::-webkit-details-marker {
    display: none;
}

.recent-period-exclusions > summary > span:first-child {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 2px;
}

.recent-period-exclusions > summary strong {
    color: var(--gray-900);
    font-size: 12px;
}

.recent-period-exclusions > summary small {
    color: var(--gray-600);
    font-size: 11px;
    font-weight: 600;
}

.recent-period-exclusion-count {
    flex: 0 0 auto;
    border-radius: 999px;
    background: #fbdfe2;
    color: var(--red);
    padding: 4px 8px;
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
}

.recent-period-exclusion-summary-action {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 7px;
}

.recent-period-exclusion-chevron {
    color: var(--gray-600);
    font-size: 17px;
    line-height: 1;
    transition: transform 150ms ease;
}

.recent-period-exclusions[open] .recent-period-exclusion-chevron {
    transform: rotate(180deg);
}

.recent-period-exclusion-body {
    border-top: 1px solid #f1cbd0;
    padding: 12px 14px 14px;
}

.recent-period-exclusion-body > p {
    margin: 0 0 10px;
    color: var(--gray-600);
    font-size: 11px;
    line-height: 1.45;
}

.recent-period-exclusion-table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #ffffff;
}

.recent-period-exclusion-table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    font-size: 11px;
}

.recent-period-exclusion-table th,
.recent-period-exclusion-table td {
    border-bottom: 1px solid var(--line);
    padding: 9px 10px;
    text-align: left;
    white-space: nowrap;
}

.recent-period-exclusion-table th {
    background: var(--surface-2);
    color: var(--gray-600);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: 0.035em;
    text-transform: uppercase;
}

.recent-period-exclusion-table td:first-child {
    color: var(--gray-900);
    font-weight: 800;
}

.recent-period-exclusion-table tbody tr:last-child td {
    border-bottom: 0;
}

.model-picker {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 8px;
}

.model-picker-heading {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 18px;
    color: var(--gray-800);
    font-size: 12px;
    font-weight: 800;
}

.confidence-picker {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-top: 18px;
    padding: 12px;
    border: 1px solid var(--line);
    background: var(--surface-2);
}

    .confidence-picker span {
        display: block;
        color: var(--gray-800);
        font-size: 12px;
        font-weight: 800;
    }

    .confidence-picker small {
        color: var(--gray-500);
        font-weight: 700;
    }

.confidence-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.confidence-option {
    min-width: 58px;
    min-height: 36px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: #ffffff;
    color: var(--gray-800);
    cursor: pointer;
    font-weight: 800;
}

    .confidence-option.active {
        border-color: var(--red);
        background: #fff5f5;
        color: var(--red);
    }

.model-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    min-height: 50px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    font-weight: 800;
}

    .model-option.active {
        border-color: var(--red);
        color: var(--red);
        background: #fff5f5;
    }

    .model-option input {
        accent-color: var(--red);
    }

.model-option-select {
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: stretch;
    flex: 1;
    gap: 7px;
    min-width: 0;
    cursor: pointer;
}

.model-option-name {
    white-space: nowrap;
}

.model-recommended-badge {
    display: inline-flex;
    align-items: center;
    min-height: 16px;
    border: 1px solid rgba(215, 21, 42, 0.28);
    border-radius: 999px;
    background: #fff0f2;
    color: var(--red);
    padding: 2px 6px;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: 0.035em;
    line-height: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.model-picker-heading .metric-help summary,
.model-option .metric-help summary {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--muted);
}

.model-option.active .metric-help summary {
    border-color: rgba(215, 21, 42, 0.45);
    color: var(--red);
}

.advanced-toggle {
    margin-top: 16px;
    border: 0;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    font-weight: 800;
    padding: 0;
}

.advanced-panel {
    border: 1px solid var(--line);
    background: var(--surface-2);
    padding: 14px;
}

.check-field {
    flex-direction: row;
    align-items: center;
}

    .check-field input {
        accent-color: var(--red);
    }

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}

.missing-period-modal {
    width: min(820px, 100%);
}

.missing-period-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-top: 18px;
}

    .missing-period-summary > div {
        border: 1px solid var(--line);
        border-radius: 4px;
        background: var(--surface-2);
        padding: 12px;
    }

    .missing-period-summary strong {
        display: block;
        font-size: 22px;
        line-height: 1;
    }

    .missing-period-summary span,
    .missing-period-copy,
    .missing-period-item span,
    .synthetic-indicator-row {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
    }

.missing-period-copy {
    margin-top: 12px;
}

.missing-preview-panel {
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    padding: 12px;
}

.missing-preview-header,
.missing-period-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

    .missing-preview-header strong,
    .missing-preview-header span,
    .missing-period-list-header span {
        display: block;
    }

    .missing-preview-header strong {
        color: var(--gray-900);
        font-size: 13px;
    }

    .missing-preview-header span,
    .missing-period-list-header span {
        color: var(--muted);
        font-size: 12px;
        line-height: 1.45;
    }

.missing-preview-status-error {
    color: var(--red) !important;
}

.missing-preview-chart-shell {
    margin-top: 10px;
    border: 3px solid var(--line-strong);
    background: #ffffff;
    overflow: hidden;
    padding: 8px;
}

    .missing-preview-chart-shell > div {
        width: 100%;
        height: 320px;
        min-height: 320px;
    }

.missing-period-list-header {
    margin-top: 14px;
}

    .missing-period-list-header > div {
        display: inline-flex;
        gap: 12px;
    }

.missing-period-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    margin-top: 14px;
    overflow: auto;
}

.missing-period-item {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.3fr);
    gap: 12px;
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--surface-2);
    padding: 12px;
}

    .missing-period-item strong,
    .missing-period-item span {
        display: block;
    }

.missing-period-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-content: flex-start;
}

.missing-period-chip {
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #ffffff;
    color: var(--gray-800);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
}

    .missing-period-chip:hover,
    .missing-period-chip.active {
        border-color: var(--red);
        background: #fff5f5;
        color: var(--red);
    }

.synthetic-indicator-row {
    margin-top: 14px;
}


/* Insight panel */
.insight-panel {
    border: 1px solid var(--line);
    border-radius: 4px;
    background: var(--gray-900);
    color: #ffffff;
    padding: 20px;
}

.insight-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 16px;
}

.section-label {
    color: #d1d5db;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.insight-headline {
    margin-top: 4px;
    color: #ffffff;
    font-size: 14px;
    line-height: 1.4;
}

.insight-metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
    margin: 16px 0;
}

.insight-mini-card {
    min-width: 0;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.06);
    padding: 12px;
}

.insight-mini-label {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    color: #d1d5db;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.insight-mini-value {
    display: block;
    margin-top: 8px;
    overflow: hidden;
    color: #ffffff;
    font-size: 17px;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.insight-mini-sub {
    display: block;
    margin-top: 4px;
    color: #d1d5db;
    font-size: 10px;
}

.insight-lines {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.insight-line {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    color: #ffffff;
    font-size: 13px;
    line-height: 1.6;
}

.insight-highlight,
.insight-confidence,
.insight-positive,
.insight-negative,
.insight-stable {
    color: #ffffff;
    font-weight: 800;
}

.insight-negative {
    color: #f87171;
}

.insight-positive {
    color: #4ade80;
}

.action-line {
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    padding: 12px 14px;
}

.warning-line {
    color: #ffffff;
}

.trust-badge {
    flex: 0 0 auto;
    border: 1px solid #ffffff;
    border-radius: 999px;
    color: #ffffff;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    text-transform: capitalize;
    white-space: nowrap;
}

.insight-help {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

    .insight-help summary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 17px;
        height: 17px;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 999px;
        color: #ffffff;
        cursor: pointer;
        font-size: 10px;
        font-weight: 800;
        list-style-type: none;
    }

        .insight-help summary::marker {
            content: "";
        }

    .insight-help[open] .insight-help-body {
        position: absolute;
        top: 23px;
        right: 0;
        z-index: 50;
        width: min(360px, 78vw);
        border: 1px solid var(--line-strong);
        border-radius: 4px;
        background: #ffffff;
        color: var(--ink);
        box-shadow: var(--shadow);
        padding: 10px 12px;
        font-size: 12px;
        font-weight: 400;
        line-height: 1.4;
        text-transform: none;
    }

.insight-help-title {
    margin-bottom: 4px;
    font-weight: 800;
}

.action-line {
    margin-top: 4px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.07);
    padding: 8px 10px;
}

.warning-line {
    color: #ffffff;
}

.trust-badge {
    flex: 0 0 auto;
    border: 1px solid #ffffff;
    border-radius: 999px;
    color: #ffffff;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 800;
    text-transform: capitalize;
    white-space: nowrap;
}

.insight-help {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
}

    .insight-help summary {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 17px;
        height: 17px;
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 999px;
        color: #ffffff;
        cursor: pointer;
        font-size: 10px;
        font-weight: 800;
        list-style-type: none;
    }

        .insight-help summary::marker {
            content: "";
        }

    .insight-help[open] .insight-help-body {
        position: absolute;
        top: 23px;
        right: 0;
        z-index: 50;
        width: min(360px, 78vw);
        border: 1px solid var(--line-strong);
        border-radius: 4px;
        background: #ffffff;
        color: var(--ink);
        box-shadow: var(--shadow);
        padding: 10px 12px;
        font-size: 12px;
        font-weight: 400;
        line-height: 1.4;
        text-transform: none;
    }

.insight-help-title {
    margin-bottom: 4px;
    font-weight: 800;
}

.metric-help summary {
    width: 16px;
    height: 16px;
    border-color: rgba(255, 255, 255, 0.55);
    color: #ffffff;
    font-size: 10px;
}

.metric-help[open] .insight-help-body {
    min-width: 250px;
    text-align: left;
}

.mode-help summary {
    width: 18px;
    height: 18px;
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--ink);
}

.mode-help[open] .insight-help-body {
    right: auto;
    left: 0;
    min-width: 260px;
    color: var(--ink);
    text-align: left;
}

.health-item .metric-help summary {
    border-color: var(--line-strong);
    background: #ffffff;
    color: var(--ink);
}

.health-item .metric-help[open] .insight-help-body {
    right: auto;
    left: 0;
    width: min(320px, 72vw);
}

/* Blazor error UI */

#blazor-error-ui {
    position: fixed;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2000;
    display: none;
    border-top: 2px solid var(--red);
    background: #ffffff;
    color: var(--red);
    padding: 12px 16px;
}

/* Responsive */

@media (max-width: 1040px) {
    .lp-workspace {
        grid-template-columns: 1fr;
    }

    .lp-topbar {
        grid-template-columns: minmax(190px, 280px) minmax(260px, 1fr) auto;
        gap: 12px;
    }

    .record-pane {
        box-shadow: none;
    }
}

@media (max-width: 760px) {
    .lp-home {
        width: calc(100% - 20px);
        margin: 10px;
        padding: 14px;
    }

    .lp-topbar {
        grid-template-columns: 1fr;
    }

    .lp-logo,
    .lp-topbar-actions,
    .lp-nav {
        grid-column: 1;
    }

    .lp-logo {
        justify-content: flex-start;
    }

    .lp-nav,
    .batch-buttons {
        justify-content: flex-start;
    }

    .run-progress,
    .modal-grid,
    .advanced-panel,
    .model-picker,
    .runs-filter-grid,
    .metrics-grid,
    .health-grid,
    .insight-metric-grid,
    .missing-period-summary,
    .missing-period-item {
        grid-template-columns: 1fr;
    }

    .recent-period-fields,
    .evaluation-split-methods {
        grid-template-columns: 1fr;
    }

    .mode-tabs {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 4px;
        padding: 8px 58px 0 6px;
    }

    .mode-tab {
        padding-right: 12px;
        padding-left: 12px;
    }

    .mode-tab-description {
        white-space: normal;
    }

    .mode-tab-panel {
        padding: 18px 14px;
    }

    .batch-buttons,
    .confidence-picker,
    .file-actions,
    .runs-actions,
    .record-meta-row,
    .prediction-table-footer,
    .missing-preview-header,
    .missing-period-list-header,
    .modal-actions {
        flex-direction: column;
    }

    .record-meta-row,
    .prediction-table-footer {
        align-items: flex-start;
    }

    .band-summary {
        flex-wrap: wrap;
        border-radius: 4px;
    }

    .anomaly-table {
        min-width: 720px;
    }

    .anomaly-row-detail-card {
        grid-template-columns: 1fr;
    }
}

/* Modern application shell */

:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --ink: #17181a;
    --ink-muted: #5f6672;
    --muted: #6f7682;
    --line: #e2e5e9;
    --line-strong: #cbd0d7;
    --red: #d7152a;
    --red-dark: #ab1020;
    --black: #151517;
    --gray-900: #202226;
    --gray-800: #343840;
    --gray-500: #737b88;
    --gray-100: #f3f4f6;
    --shadow: 0 20px 50px rgba(18, 24, 33, 0.12);
    --shadow-soft: 0 8px 28px rgba(18, 24, 33, 0.07);
}

html,
body {
    background:
        radial-gradient(circle at 8% -10%, rgba(215, 21, 42, 0.07), transparent 30rem),
        var(--bg);
    font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.app-shell,
.lp-home {
    min-height: 100vh;
}

.lp-home {
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
}

.lp-topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) auto;
    align-items: center;
    gap: clamp(24px, 4vw, 64px);
    width: 100%;
    min-height: 88px;
    margin: 0 0 30px;
    padding: 12px clamp(24px, 4vw, 72px);
    border-bottom: 1px solid var(--line);
    background: #ffffff;
    box-shadow: 0 6px 24px rgba(18, 24, 33, 0.05);
}

.lp-brand {
    grid-column: 1;
    display: flex;
    align-items: center;
    gap: 18px;
    min-width: 0;
}

.lp-logo {
    width: 126px;
    height: 58px;
    justify-content: flex-start;
}

.lp-logo-img {
    width: 126px;
    height: auto;
    max-height: 52px;
}

.lp-product-title {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding-left: 18px;
    border-left: 1px solid var(--line);
    color: var(--gray-800);
    font-size: 14px;
    font-weight: 750;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.lp-nav {
    grid-column: 2;
    grid-row: 1;
    justify-content: flex-start;
    gap: 6px;
}

.lp-nav-link {
    position: relative;
    min-height: 44px;
    border-radius: 10px;
    color: var(--gray-800);
    font-size: 14px;
    font-weight: 700;
    padding: 11px 16px;
    text-transform: none;
    transition: color 160ms ease, background 160ms ease;
}

.lp-nav-link:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.lp-nav-link.active {
    background: #fff0f2;
    color: var(--red);
}

.lp-nav-link.active::after {
    position: absolute;
    right: 16px;
    bottom: 6px;
    left: 16px;
    height: 2px;
    border-radius: 999px;
    background: var(--red);
    content: "";
}

.lp-topbar-actions {
    grid-column: 3;
    grid-row: 1;
    justify-content: flex-end;
}

.lp-topbar-actions .mode-help[open] .insight-help-body {
    right: 0;
    left: auto;
}

.lp-home > .lp-workspace,
.lp-home > .runs-view,
.lp-home > .status-message,
.lp-home > .run-progress,
.lp-home > .data-processor-loading {
    width: min(1580px, calc(100vw - 48px));
    margin-right: auto;
    margin-left: auto;
}

.lp-home > .lp-workspace,
.lp-home > .runs-view {
    margin-bottom: 40px;
}

.btn {
    min-height: 44px;
    border-radius: 10px;
    padding: 10px 18px;
    font-size: 13px;
    box-shadow: 0 2px 4px rgba(18, 24, 33, 0.04);
    transition: transform 150ms ease, box-shadow 150ms ease, border-color 150ms ease, background 150ms ease;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(18, 24, 33, 0.10);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(215, 21, 42, 0.20);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, #e11d35, var(--red));
}

.btn-dark {
    background: linear-gradient(135deg, #2a2b2f, var(--black));
    color: #ffffff;
}

.btn-secondary {
    border-color: var(--line-strong);
}

.form-control,
.datatype-select,
.product-search {
    border-color: var(--line-strong);
    border-radius: 10px;
    box-shadow: 0 1px 2px rgba(18, 24, 33, 0.03);
}

.status-message,
.run-progress,
.data-processor-loading {
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
}

.data-processor-loading {
    padding: 16px 18px;
}

.lp-workspace {
    grid-template-columns: minmax(300px, 420px) minmax(520px, 1fr);
    gap: 24px;
}

.csv-pane,
.record-pane,
.runs-view {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: var(--shadow-soft);
}

.csv-pane,
.record-pane {
    padding: 22px;
}

.record-pane {
    box-shadow: var(--shadow-soft);
}

.pane-heading,
.selected-file-bar {
    padding-bottom: 16px;
}

.pane-heading h2,
.selected-file-bar h2,
.view-heading h1,
.modal-header h2 {
    font-size: 22px;
    font-weight: 750;
    letter-spacing: -0.02em;
}

.product-toggle,
.csv-item,
.record-card,
.prediction-table-panel,
.model-health-panel,
.insight-panel,
.runs-filter-grid,
.runs-table-wrap,
.options-modal,
.missing-preview-panel {
    border-color: var(--line);
    border-radius: 12px;
}

.product-toggle,
.csv-item {
    transition: border-color 150ms ease, background 150ms ease, transform 150ms ease, box-shadow 150ms ease;
}

.product-toggle:hover,
.csv-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(18, 24, 33, 0.06);
}

.product-toggle.active,
.csv-item.active {
    border-color: rgba(215, 21, 42, 0.55);
    background: #fff4f5;
}

.record-card {
    padding: 22px;
    background: linear-gradient(145deg, #ffffff, #fafbfc);
}

.record-card.has-record {
    border-color: var(--line-strong);
}

.expand-indicator,
.record-chip,
.band-summary,
.prediction-table-toggle-copy,
.synthetic-summary,
.anomaly-badge,
.missing-period-chip {
    border-radius: 999px;
}

.metric-card {
    border: 0;
    border-radius: 12px;
    background: linear-gradient(145deg, #272a30, #181a1e);
    box-shadow: 0 8px 20px rgba(18, 24, 33, 0.12);
}

.insight-panel {
    background: linear-gradient(145deg, #292c32, #181a1f);
    box-shadow: 0 12px 28px rgba(18, 24, 33, 0.14);
}

.chart-shell,
.missing-preview-chart-shell {
    border: 1px solid var(--line);
    border-radius: 14px;
}

.runs-view {
    padding: 26px;
}

.runs-filter-grid {
    padding: 16px;
    background: #fafbfc;
}

.runs-table-wrap {
    box-shadow: 0 4px 14px rgba(18, 24, 33, 0.04);
}

.runs-table th {
    background: #22252a;
    font-size: 10px;
    letter-spacing: 0.06em;
}

.runs-table tbody tr:last-child td {
    border-bottom: 0;
}

.options-modal {
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 28px 80px rgba(0, 0, 0, 0.24);
    padding: 24px;
}

.icon-button,
.confidence-option,
.model-option {
    border-color: var(--line-strong);
    border-radius: 10px;
}

@media (max-width: 1120px) {
    .lp-topbar {
        grid-template-columns: auto 1fr;
        gap: 10px 24px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .lp-brand {
        grid-column: 1;
        grid-row: 1;
    }

    .lp-nav {
        grid-column: 2;
        grid-row: 1;
    }

    .lp-topbar-actions {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-content: flex-start;
    }

    .lp-workspace {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    .lp-home {
        width: 100%;
        margin: 0;
        padding: 0;
    }

    .lp-topbar {
        position: relative;
        grid-template-columns: 1fr;
        gap: 10px;
        min-height: 0;
        margin-bottom: 20px;
        padding: 12px 16px;
    }

    .lp-brand,
    .lp-nav,
    .lp-topbar-actions {
        grid-column: 1;
    }

    .lp-brand {
        grid-row: 1;
    }

    .lp-nav {
        grid-row: 2;
    }

    .lp-topbar-actions {
        grid-row: 3;
    }

    .lp-product-title {
        display: none;
    }

    .lp-home > .lp-workspace,
    .lp-home > .runs-view,
    .lp-home > .status-message,
    .lp-home > .run-progress,
    .lp-home > .data-processor-loading {
        width: calc(100% - 24px);
    }

    .lp-topbar .batch-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
    }

    .lp-topbar .action-with-help {
        gap: 5px;
    }

    .lp-topbar .btn {
        min-height: 40px;
        padding: 8px 12px;
    }

    .lp-topbar-actions .action-with-help:first-child .mode-help[open] .insight-help-body {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }

    .lp-topbar-actions .action-with-help:last-child .mode-help[open] .insight-help-body {
        right: 0;
        left: auto;
        transform: none;
    }

    .csv-pane,
    .record-pane,
    .runs-view {
        border-radius: 14px;
        padding: 16px;
    }
}

/* Viewport-safe help panels for phones and portrait tablets */

@media (max-width: 900px) {
    .insight-help[open] .insight-help-body,
    .metric-help[open] .insight-help-body,
    .mode-help[open] .insight-help-body,
    .health-item .metric-help[open] .insight-help-body,
    .anomaly-header-label .anomaly-header-help[open] .insight-help-body {
        position: fixed !important;
        top: auto !important;
        right: 12px !important;
        bottom: max(12px, env(safe-area-inset-bottom)) !important;
        left: 12px !important;
        z-index: 2000 !important;
        width: auto !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: min(52vh, 420px);
        overflow-y: auto;
        border: 1px solid var(--line-strong);
        border-radius: 16px;
        background: #ffffff;
        color: var(--ink);
        box-shadow: 0 24px 70px rgba(18, 24, 33, 0.24);
        padding: 16px 52px 18px 18px;
        line-height: 1.5;
        text-align: left;
        transform: none !important;
    }

    .insight-help[open] > summary {
        position: fixed !important;
        right: 22px !important;
        bottom: max(22px, calc(env(safe-area-inset-bottom) + 10px)) !important;
        left: auto !important;
        z-index: 2001 !important;
        width: 32px !important;
        height: 32px !important;
        border: 0 !important;
        border-radius: 999px !important;
        background: var(--gray-900) !important;
        color: #ffffff !important;
        font-size: 0 !important;
        box-shadow: 0 6px 18px rgba(18, 24, 33, 0.20);
        transform: none !important;
    }

    .insight-help[open] > summary::after {
        color: #ffffff;
        content: "×";
        font-size: 20px;
        font-weight: 500;
        line-height: 1;
    }
}

@media (min-width: 901px) {
    .insight-help[open] .insight-help-body,
    .metric-help[open] .insight-help-body,
    .mode-help[open] .insight-help-body,
    .health-item .metric-help[open] .insight-help-body,
    .anomaly-header-label .anomaly-header-help[open] .insight-help-body {
        position: fixed !important;
        top: var(--help-popup-top, 12px) !important;
        right: auto !important;
        bottom: auto !important;
        left: var(--help-popup-left, 12px) !important;
        z-index: 2000 !important;
        width: min(360px, calc(100vw - 24px)) !important;
        min-width: 0 !important;
        max-width: calc(100vw - 24px) !important;
        max-height: min(60vh, 420px);
        overflow-y: auto;
        border-radius: 12px;
        box-shadow: 0 18px 50px rgba(18, 24, 33, 0.20);
        transform: none !important;
    }
}
