:root {
    color-scheme: light;
    --risk-low: #16a34a;
    --risk-medium: #f59e0b;
    --risk-high: #dc2626;
}

* {
    box-sizing: border-box;
}

html {
    background: #f8fafc;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
select {
    font: inherit;
}

#nodeSelect option {
    background: #ffffff;
    color: #0f172a;
}

.hidden {
    display: none !important;
}

.panel {
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.06);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 800;
    line-height: 1.4;
    color: #0f172a;
}

.eyebrow {
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1.4;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #64748b;
}

.metric-card {
    position: relative;
    overflow: hidden;
    min-height: 164px;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 1rem;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
    transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.metric-card::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    content: "";
    background: #94a3b8;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.08);
}

.metric-temperature::before { background: #f97316; }
.metric-ph::before { background: #7c3aed; }
.metric-salinity::before { background: #2563eb; }
.metric-do::before { background: #0891b2; }
.metric-turbidity::before { background: #d97706; }

.metric-label {
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

.metric-value {
    font-size: clamp(1.9rem, 3vw, 2.35rem);
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.035em;
    color: #0f172a;
}

.metric-unit {
    margin-left: 0.2rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: #64748b;
}

.metric-icon {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 0.9rem;
    font-size: 0.7rem;
    font-weight: 900;
    letter-spacing: -0.02em;
}

.metric-status,
.status-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    border-radius: 999px;
    padding: 0.28rem 0.6rem;
    font-size: 0.6875rem;
    font-weight: 800;
    line-height: 1.2;
}

.status-neutral {
    background: #f1f5f9;
    color: #475569;
}

.status-ok,
.status-low {
    background: #dcfce7;
    color: #166534;
}

.status-warning,
.status-medium {
    background: #fef3c7;
    color: #92400e;
}

.status-danger,
.status-high {
    background: #fee2e2;
    color: #991b1b;
}

.status-info {
    background: #cffafe;
    color: #155e75;
}

.filter-button,
.range-button,
.segmented-button {
    border: 1px solid #e2e8f0;
    border-radius: 0.7rem;
    background: #ffffff;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 800;
    line-height: 1;
    transition: background 160ms ease, color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.filter-button,
.range-button {
    padding: 0.62rem 0.78rem;
}

.segmented-button {
    padding: 0.68rem 0.9rem;
}

.filter-button:hover,
.range-button:hover,
.segmented-button:hover {
    border-color: #6ee7b7;
    color: #047857;
}

.filter-button:focus-visible,
.range-button:focus-visible,
.segmented-button:focus-visible {
    outline: 3px solid rgba(16, 185, 129, 0.25);
    outline-offset: 2px;
}

.filter-button.active,
.range-button.active,
.segmented-button.active {
    border-color: #047857;
    background: #047857;
    color: #ffffff;
}

.chart-shell {
    position: relative;
    min-height: 370px;
}

.chart-shell canvas {
    width: 100% !important;
    height: 370px !important;
}

.empty-state {
    display: grid;
    min-height: 170px;
    place-content: center;
    padding: 1.5rem;
    text-align: center;
    border: 1px dashed #cbd5e1;
    border-radius: 1rem;
    background: #f8fafc;
}

.probability-track {
    height: 0.45rem;
    margin-top: 0.35rem;
    overflow: hidden;
    border-radius: 999px;
    background: #f1f5f9;
}

.probability-bar {
    width: 0;
    height: 100%;
    border-radius: inherit;
    transition: width 500ms ease;
}

.evaluation-card {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    background: linear-gradient(145deg, #ffffff, #f8fafc);
}

.evaluation-value {
    margin-top: 0.45rem;
    font-size: 1.75rem;
    font-weight: 900;
    line-height: 1;
    letter-spacing: -0.035em;
    color: #0f172a;
}

.model-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 0;
}

.model-row dt {
    color: #64748b;
}

.model-row dd {
    margin: 0;
    font-weight: 800;
    color: #334155;
}

.alert-item {
    display: flex;
    gap: 0.8rem;
    padding: 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    background: #ffffff;
}

.alert-item-high {
    border-color: #fecaca;
    background: #fff7f7;
}

.alert-item-medium {
    border-color: #fde68a;
    background: #fffbeb;
}

.alert-dot {
    width: 0.7rem;
    height: 0.7rem;
    margin-top: 0.3rem;
    flex: 0 0 auto;
    border-radius: 50%;
    background: #94a3b8;
}

.toast {
    pointer-events: auto;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    padding: 0.9rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 0.9rem;
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
    animation: toast-in 180ms ease-out;
}

.toast-error { border-color: #fecaca; }
.toast-success { border-color: #bbf7d0; }
.toast-warning { border-color: #fde68a; }

.loader {
    width: 2.2rem;
    height: 2.2rem;
    border: 3px solid #d1fae5;
    border-top-color: #047857;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

@keyframes toast-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
    .chart-shell,
    .chart-shell canvas {
        min-height: 310px;
        height: 310px !important;
    }

    .metric-card {
        min-height: 150px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

@media print {
    header,
    #refreshButton,
    #offlineBanner,
    #toastContainer {
        display: none !important;
    }

    body {
        background: #ffffff;
    }

    .panel,
    .metric-card {
        break-inside: avoid;
        box-shadow: none;
    }
}
