* {
    box-sizing: border-box;
}

:root {
    --ink: #102039;
    --muted: #66758d;
    --navy: #0a1628;
    --navy-soft: #13233c;
    --mint: #37d8b0;
    --mint-dark: #087f68;
    --surface: #ffffff;
    --canvas: #f3f6f8;
    --line: #dfe6eb;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background-color: var(--canvas);
    margin: 0;
    color: var(--ink);
    min-height: 100vh;
}

.page-header,
.dashboard-grid {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
}

/* Site shell */
.site-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    padding: 28px 18px 22px;
    background: var(--navy);
    color: white;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: transform .22s ease;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
    padding: 52px 8px 34px;
}

.brand-logo { width: 194px; height: auto; display: block; }

.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--mint);
    color: var(--navy);
    display: grid;
    place-items: center;
    font-weight: 900;
    letter-spacing: -1px;
}

.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { font-size: 17px; letter-spacing: -.02em; }
.brand-copy small { color: #91a1b9; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }

.site-nav { display: grid; gap: 7px; }
.site-nav-link {
    display: flex;
    align-items: center;
    gap: 13px;
    min-height: 48px;
    padding: 0 14px;
    border-radius: 11px;
    color: #aebbd0;
    text-decoration: none;
    font-size: 15px;
    font-weight: 600;
    transition: background .18s ease, color .18s ease, transform .18s ease;
}
.site-nav-link:hover { background: var(--navy-soft); color: white; transform: translateX(2px); }
.site-nav-link.active { background: var(--mint); color: var(--navy); }
.nav-icon { width: 22px; text-align: center; font-size: 20px; font-weight: 700; }

.sidebar-footer {
    margin-top: auto;
    padding: 18px 10px 0;
    border-top: 1px solid rgba(255,255,255,.09);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-footer > span { display: grid; gap: 2px; }
.sidebar-footer strong { font-size: 12px; }
.sidebar-footer small { color: #8393aa; font-size: 11px; }
.sidebar-sign-in {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 8px;
    background: var(--mint);
    color: var(--navy);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}
.sidebar-sign-in:hover { background: #66e4c6; }

.theme-toggle {
    width: 100%;
    min-height: 48px;
    margin: auto 0 14px;
    padding: 0 14px;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 11px;
    background: rgba(255,255,255,.06);
    color: #dbe5f2;
    display: flex;
    align-items: center;
    gap: 13px;
    font-size: 14px;
    font-weight: 650;
}
.theme-toggle:hover { background: rgba(255,255,255,.12); }
.theme-toggle:focus-visible { outline: 2px solid var(--mint); outline-offset: 2px; }
.theme-icon { width: 22px; font-size: 20px; line-height: 1; text-align: center; }
.theme-toggle + .sidebar-footer { margin-top: 0; }

.site-main { margin-left: 250px; min-height: 100vh; transition: margin-left .22s ease, border-radius .22s ease; }
.app-main { padding: 26px clamp(20px, 4vw, 54px) 48px; }
.mobile-menu-toggle {
    display: grid;
    align-content: center;
    gap: 4px;
    position: fixed;
    z-index: 1200;
    top: 18px;
    left: 18px;
    width: 42px;
    height: 42px;
    padding: 0 11px;
    border-radius: 10px;
    background: #0d1a2d;
    color: white;
    border: 1px solid #29374a;
    box-shadow: 0 4px 14px rgba(5,13,24,.22);
}
.mobile-menu-toggle:hover { background: #15263f; }
.mobile-menu-toggle span { display: block; height: 2px; width: 100%; border-radius: 999px; background: white; }

@media (min-width: 921px) {
    body.menu-collapsed .site-sidebar { transform: translateX(-100%); }
    body.menu-collapsed .site-main { margin-left: 0; }
    body.menu-collapsed.marketing-page .site-main { border-radius: 0; }
}

.app-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 28px;
    margin-bottom: 24px;
}
.app-toolbar > div:first-child { flex: 0 0 225px; }
.app-toolbar h1 { margin: 4px 0 0; font-size: clamp(25px, 3vw, 34px); letter-spacing: -.04em; }
.eyebrow { color: var(--mint-dark); font-size: 12px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }

/* App navigation */
.top-nav {
    display: flex;
    flex: 1 1 auto;
    width: auto;
    align-items: center;
    gap: 6px;
    background: #e4eaee;
    border: 1px solid #d7e0e6;
    border-radius: 16px;
    padding: 7px;
    min-height: 64px;
    overflow-x: auto;
}

.nav-link {
    text-decoration: none;
    color: var(--ink);
    min-height: 48px;
    padding: 0 20px;
    border: 1px solid transparent;
    border-radius: 11px;
    display: inline-flex;
    flex: 1 1 0;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}

.nav-link:hover {
    background: #f5f8f9;
    border-color: #cbd6dd;
    transform: translateY(-1px);
}

.nav-link.active {
    background: white;
    border-color: #d6e0e6;
    font-weight: 750;
    box-shadow: 0 3px 9px rgba(16,32,57,.12);
}

.nav-link:focus-visible {
    outline: 3px solid rgba(8,127,104,.28);
    outline-offset: 2px;
}

.upload-data-menu {
    position: relative;
}

.upload-data-menu > summary {
    cursor: pointer;
}

.upload-data-menu-options {
    position: absolute;
    z-index: 1000;
    min-width: 190px;
    overflow: hidden;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
}

.upload-data-menu-options .nav-link {
    display: flex;
    min-height: 0;
    padding: 12px 20px;
    border: 0;
    border-radius: 0;
    color: #203347;
    justify-content: flex-start;
}

/* Header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}

.buttons {
    display: flex;
    gap: 0.5rem;
}

button {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background-color: white;
    padding: 8px 12px;
    font-size: 13px;
    cursor: pointer;
}

button:hover {
    background-color: #ebeced;
}

.feature-details p {
    margin: 0;
}

.feature-description {
    color: gray;
    font-size: 14px;
    margin-top: 0.25rem;
}

/* Main split layout */
.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: stretch;
}

.dashboard-box {
    background: white;
    border: 1px solid #dcdfe4;
    border-radius: 16px;
    padding: 1rem;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
}

.chart-box {
    gap: 0.75rem;
}

/* Live stacked-area charts */
.stacked-area-panel { margin-top: 1rem; gap: .9rem; }
.stacked-area-empty-state {
    min-height: 260px;
    display: grid;
    place-items: center;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: color-mix(in srgb, var(--canvas) 65%, transparent);
}
.live-stacked-area-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 430px), 1fr));
    gap: 1rem;
}
.stacked-area-card {
    --stacked-card-bg: var(--surface);
    --stacked-card-text: var(--ink);
    --stacked-muted: var(--muted);
    --stacked-grid: var(--line);
    --stacked-plot-bg: var(--canvas);
    --stacked-gb-h2: #147fa8;
    --stacked-gb-o2: #17976f;
    --stacked-gb-co2: #7454b8;
    --stacked-gb-co: #d52d2d;
    --stacked-hidden: #c8d1d7;
    --stacked-gradient-top-opacity: .96;
    --stacked-gradient-bottom-opacity: .52;
    min-width: 0;
    padding: .9rem;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--stacked-card-text);
    background: var(--stacked-card-bg);
}
.stacked-area-card-header { display: flex; align-items: start; justify-content: space-between; gap: .75rem; }
.stacked-area-card h4 { margin: 0; font-size: 14px; }
.stacked-area-card-header p { margin: .2rem 0 0; color: var(--stacked-muted); }
.stacked-live-indicator { color: var(--mint-dark); font-size: 11px; font-weight: 800; letter-spacing: .08em; }
.stacked-remove-chart { padding: .25rem .5rem; line-height: 1; font-size: 18px; }
.stacked-area-wrap { position: relative; height: 270px; margin-top: .7rem; background: var(--stacked-plot-bg); border-radius: 9px; overflow: hidden; }
.stacked-area-wrap svg { display: block; width: 100%; height: 100%; }
.stacked-area-wrap .grid line { stroke: var(--stacked-grid); }
.stacked-area-wrap .grid path { display: none; }
.stacked-area-wrap .axis text, .stacked-area-wrap .axis-label { fill: var(--stacked-muted); font-size: 10px; }
.stacked-area-wrap .axis path, .stacked-area-wrap .axis line { stroke: var(--stacked-grid); }
.stacked-chart-status { min-height: 17px; margin: .45rem 0 0; color: var(--stacked-muted); font-size: 11px; }
.stacked-chart-status.error { color: #b42318; }
.stacked-area-legend { display: flex; flex-wrap: wrap; gap: .4rem .7rem; margin-top: .35rem; font-size: 11px; color: var(--stacked-card-text); }
.stacked-area-legend span { display: inline-flex; gap: .3rem; align-items: center; }
.stacked-area-swatch { width: 10px; height: 10px; border-radius: 50%; background: var(--swatch); }
.stacked-area-tooltip { position: absolute; z-index: 2; pointer-events: none; max-width: 200px; padding: .45rem .55rem; border: 1px solid var(--line); border-radius: 7px; background: var(--stacked-card-bg); color: var(--stacked-card-text); box-shadow: 0 4px 12px rgba(0,0,0,.14); font-size: 11px; }
.stacked-area-tooltip p { margin: 0 0 .25rem; color: var(--stacked-muted); }
.stacked-area-tooltip div { display: flex; justify-content: space-between; gap: .8rem; }
.stacked-area-modal { max-height: min(90vh, 720px); display: flex; flex-direction: column; }
.stacked-area-sensor-list { overflow-y: auto; display: grid; gap: .65rem; }
.stacked-area-sensor { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .7rem; align-items: center; padding: .7rem; border: 1px solid var(--line); border-radius: 9px; }
.stacked-area-sensor label { font-size: 13px; font-weight: 650; }
.stacked-area-sensor small { display: block; margin-top: .15rem; color: var(--muted); }
.stacked-area-visibility { display: inline-flex; gap: .4rem; }
.stacked-area-visibility label { font-size: 12px; font-weight: 500; }
.stacked-area-visibility input { margin-right: .18rem; }
.stacked-area-reminder { padding: .8rem; border-radius: 8px; border: 1px solid #9acac1; background: #effbf8; margin-top: 1rem}
.stacked-area-reminder h4, .stacked-area-reminder p { margin: 0; }
.stacked-area-reminder p { margin-top: .3rem; }
.stacked-area-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: .9rem; }

html.dark-mode .stacked-area-card {
    --stacked-card-bg: #101a29;
    --stacked-card-text: #eef7ff;
    --stacked-muted: #8fa2b7;
    --stacked-grid: #27384c;
    --stacked-plot-bg: #0b1320;
    --stacked-gb-h2: #40d4ff;
    --stacked-gb-o2: #6cefaa;
    --stacked-gb-co2: #ae80ff;
    --stacked-gb-co: #ff7070;
    --stacked-hidden: #31465d;
    --stacked-gradient-top-opacity: 1;
    --stacked-gradient-bottom-opacity: .48;
}
html.dark-mode .stacked-area-empty-state { border-color: var(--line); }
html.dark-mode .stacked-area-reminder { background: #123331; border-color: #267a70; }
html.dark-mode .stacked-chart-status.error { color: #ffb4ab; }

.trend-canvas-wrap {
    width: 100%;
    height: clamp(260px, 38vh, 360px);
    position: relative;
}

.live-charts {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 0.75rem;
}

.trend-graph {
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 0.75rem;
    min-width: 0;
    cursor: pointer;
}

.trend-graph.active {
    border-color: #86a7ef;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

.trend-graph-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.trend-graph-header h4 {
    margin: 0;
    font-size: 13px;
}

.trend-running {
    color: #15803d;
    font-size: 11px;
    font-weight: 600;
}

.box-header h3 {
    margin: 0;
    font-size: 18px;
}

.box-header p {
    margin: 0.3rem 0 1rem 0;
    color: gray;
    font-size: 14px;
}

.header-order {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.chart-header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: .5rem;
}

.chart-header-actions select {
    min-width: 10rem;
    max-width: 16rem;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: white;
    color: var(--ink);
    font-size: 13px;
    cursor: pointer;
}

.chart-header-actions select:hover { background: #ebeced; }

.dark-mode .chart-header-actions select {
    background: #1c2a3d;
    border-color: #3a4b61;
    color: #e8eef7;
}

.dark-mode .chart-header-actions select:hover { background: #27374d; }

@media (max-width: 700px) {
    .chart-box > .header-order,
    .stacked-area-panel > .header-order {
        flex-direction: column;
    }
}

.upload-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.upload-panel {
    padding: 0;
    border: 0;
    background: transparent;
}

.upload-calendar-panel {
    width: 100%;
    gap: 0.8rem;
}

.upload-calendar-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.upload-calendar-header .box-header p {
    margin-bottom: 0;
}

.upload-calendar-controls {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.upload-calendar-controls button {
    display: grid;
    width: 2rem;
    height: 2rem;
    padding: 0;
    place-items: center;
    border-color: var(--line);
    border-radius: 50%;
    color: var(--navy);
    font-size: 1.3rem;
    line-height: 1;
}

.upload-calendar-controls select {
    height: 2rem;
    padding: 0 0.45rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--navy);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
}

#upload-calendar-month-select {
    min-width: 6.8rem;
}

#upload-calendar-year-select {
    min-width: 4.7rem;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.upload-calendar-weekdays,
.upload-calendar-days {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.3rem;
}

.upload-calendar-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(13rem, 0.55fr);
    align-items: stretch;
    gap: 1rem;
}

.upload-calendar-grid-area {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.upload-calendar-weekdays {
    color: var(--muted);
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    text-transform: uppercase;
}

.upload-calendar-day,
.upload-calendar-empty-day {
    aspect-ratio: 1;
    min-height: 1.8rem;
}

.upload-calendar-day {
    position: relative;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font-size: 0.82rem;
}

.upload-calendar-day:hover,
.upload-calendar-day:focus-visible {
    border-color: var(--mint-dark);
    background: #effcf8;
    outline: none;
}

.upload-calendar-day.has-upload {
    border-color: #b8eade;
    background: #e7faf4;
    color: #075c4d;
    font-weight: 800;
}

.upload-calendar-day.has-upload::after {
    position: absolute;
    right: 50%;
    bottom: 0.24rem;
    width: 0.28rem;
    height: 0.28rem;
    border-radius: 50%;
    background: var(--mint-dark);
    content: "";
    transform: translateX(50%);
}

.upload-calendar-day.selected {
    border-color: var(--mint-dark);
    background: var(--mint);
    color: var(--navy);
}

.upload-calendar-day.selected::after {
    background: var(--navy);
}

.upload-calendar-details {
    min-height: 100%;
    padding: 0.75rem 0.9rem;
    border-left: 3px solid var(--mint-dark);
    border-radius: 0 9px 9px 0;
    background: #f4fbfa;
    color: var(--muted);
    font-size: 0.84rem;
}

.upload-calendar-details strong {
    color: var(--ink);
}

.upload-calendar-details ul {
    display: grid;
    gap: 0.45rem;
    margin: 0.45rem 0 0;
    padding-left: 1.15rem;
    color: var(--ink);
}

.upload-calendar-details li {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

@media (max-width: 620px) {
    .upload-calendar-header {
        flex-direction: column;
    }

    .upload-calendar-content {
        grid-template-columns: 1fr;
    }

    .upload-calendar-details {
        min-height: 3.5rem;
    }
}

.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    border: 1px solid #dcdfe4;
    border-radius: 16px;
    background: white;
}

.upload-section-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.sensor-rules-trigger {
    flex: 0 0 auto;
    padding: 0.6rem 1rem;
    border: 1px solid var(--mint-dark);
    border-radius: 8px;
    background: var(--mint);
    color: var(--navy);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.sensor-rules-trigger:hover {
    background: #66e4c6;
}

.sensor-rule-limit-group {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.run-details-modal.sensor-rules-modal {
    width: min(1040px, calc(100% - 2rem));
}

.sensor-rules-modal .modal-header {
    background: linear-gradient(120deg, #effcf8 0%, #edf6ff 100%);
}

.sensor-rules-modal .modal-header h3 {
    color: #0f4c5c;
}

.sensor-rules-layout {
    display: grid;
    grid-template-columns: minmax(210px, 0.7fr) minmax(0, 1.7fr);
    min-height: 390px;
}

.sensor-rules-list-panel {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 1.25rem;
    border-right: 1px solid var(--line);
    background: #f4fbfa;
}

.sensor-rules-search-label {
    color: var(--navy);
    font-size: 0.85rem;
    font-weight: 700;
}

.sensor-rules-list-panel input {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    box-sizing: border-box;
    font: inherit;
}

.sensor-rules-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 0.25rem;
    max-height: 390px;
    overflow-y: auto;
}

.sensor-rules-list-item {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    width: 100%;
    padding: 0.45rem 0.6rem;
    border: 1px solid transparent;
    border-radius: 8px;
    background: transparent;
    color: var(--ink);
    cursor: pointer;
    font: inherit;
    font-size: 0.85rem;
    text-align: left;
}

.sensor-rules-list-item:hover,
.sensor-rules-list-item.selected {
    border-color: var(--mint-dark);
    background: #dff8f0;
    color: #0b4a42;
}

.sensor-rules-list-item small,
.sensor-rules-empty,
.sensor-rules-selection {
    color: var(--muted);
    font-size: 0.72rem;
}

.sensor-rules-empty,
.sensor-rules-selection {
    margin: 0;
}

.sensor-rules-editor .modal-form-section {
    padding: 1.25rem 1.5rem 0;
}

.sensor-rules-selection {
    margin: 1.25rem 1.5rem 0;
    padding: 0.55rem 0.75rem;
    border-left: 3px solid var(--mint-dark);
    border-radius: 0 6px 6px 0;
    background: #effcf8;
}

@media (max-width: 640px) {
    .sensor-rules-layout {
        grid-template-columns: 1fr;
    }

    .sensor-rules-list-panel {
        max-height: 270px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

.run-details-modal .modal-header {
    padding-bottom: 0.75rem;
    border-bottom: 2px dashed #9ca3af;
}

.upload-form {
    margin: 0;
}

.upload-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 1rem;
    border: 2px dashed #9ca3af;
    border-radius: 8px;
    color: #434445;
    cursor: pointer;
    text-align: center;
}

.upload-dropzone:hover {
    background: #f5f7fa;
    border-color: #6b7280;
}

.dark-mode .upload-section {
    border-color: #29374a;
    background: var(--navy);
    color: white;
}

.dark-mode .upload-calendar-day.has-upload,
.dark-mode .upload-calendar-details {
    background: #153b3a;
    border-color: var(--mint-dark);
}

.dark-mode .upload-calendar-day,
.dark-mode .upload-calendar-details strong,
.dark-mode .upload-calendar-details ul {
    color: #e8eef7;
}

.dark-mode .upload-calendar-controls select {
    border-color: #3b4c62;
    background: #101c2c;
    color: #e8eef7;
}

.dark-mode .upload-section .box-header h3 {
    color: white;
}

.dark-mode .upload-section .box-header p,
.dark-mode .upload-section .upload-dropzone-copy {
    color: #b7c5d8;
}

.dark-mode .upload-section .upload-dropzone {
    border-color: #60738d;
    background: var(--navy-soft);
    color: white;
}

.dark-mode .upload-section .upload-dropzone:hover {
    background: #1b3150;
    border-color: var(--mint);
}

.upload-dropzone-title {
    font-weight: 600;
}

.upload-dropzone-copy {
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 0.85rem;
}


.upload-submit {
    display: inline-flex;
    align-items: center;
    padding: 0.55rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #f5f7fa;
    cursor: pointer;
    white-space: nowrap;
    font-size: 12px;
}

.upload-submit:hover {
    background: #e9edf3;
}

.upload-file-input {
    display: none;
}

.run-details-modal {
    width: min(520px, calc(100% - 2rem));
    border: 0;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.run-details-modal::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.site-message-modal {
    width: min(520px, calc(100% - 2rem));
    border: 0;
    border-radius: 12px;
    padding: 1.25rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.site-message-modal::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.site-message-list {
    margin: 1rem 0;
}

.site-message {
    margin: 0.5rem 0;
}

.site-message-warning,
.site-message-error {
    color: #9a3412;
}

.site-message-success {
    color: #166534;
}

.sensor-resolution-modal {
    width: min(900px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 0;
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.sensor-resolution-modal::backdrop {
    background: rgba(15, 23, 42, 0.55);
}

.sensor-resolution-modal .modal-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px dashed var(--line);
}

.sensor-resolution-modal .modal-header h3 {
    margin: 0;
    color: var(--navy);
}

.sensor-resolution-modal .modal-header p {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.sensor-resolution-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin: 1.25rem 1.5rem 0;
    padding: 1.25rem;
    border: 1px solid var(--line);
    border-radius: 12px;
}

.sensor-resolution-row legend {
    padding: 0 0.35rem;
    font-weight: 600;
    color: var(--navy);
}

.sensor-resolution-row label,
.sensor-resolution-row .modal-field label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sensor-resolution-help {
    grid-column: 1 / -1;
    margin: 0;
    color: var(--muted);
    font-size: 0.85rem;
}

.sensor-resolution-modal input,
.sensor-resolution-modal select,
.sensor-resolution-modal textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
    box-sizing: border-box;
}

.sensor-resolution-modal textarea {
    min-height: 88px;
    resize: vertical;
}

.sensor-resolution-modal input:focus,
.sensor-resolution-modal select:focus,
.sensor-resolution-modal textarea:focus {
    outline: 3px solid rgba(55, 216, 176, 0.22);
    border-color: var(--mint-dark);
}

.sensor-resolution-modal .sensor-new-fields {
    grid-column: 1 / -1;
    margin-top: 0;
}

.sensor-resolution-row.is-creating {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.sensor-resolution-row.is-creating .sensor-action-field {
    width: min(100%, 420px);
    margin-inline: auto;
}

.sensor-resolution-row.is-creating .sensor-new-fields {
    width: min(100%, 720px);
    margin-inline: auto;
}

.sensor-resolution-modal .sensor-new-fields[hidden] {
    display: none;
}

.sensor-resolution-modal .modal-actions {
    position: sticky;
    bottom: 0;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--canvas);
}

#column-selection-modal {
    width: min(760px, calc(100% - 2rem));
}

#column-selection-modal .modal-header {
    background: linear-gradient(120deg, #effcf8 0%, #edf6ff 100%);
}

#column-selection-modal .column-selection-guidance {
    margin: 1rem 1.5rem 0;
    padding: 0.85rem 1rem;
    border-left: 3px solid var(--mint-dark);
    border-radius: 0 8px 8px 0;
    background: #f3fbf9;
    color: var(--muted);
    font-size: 0.88rem;
    line-height: 1.5;
}

#column-selection-modal .column-selection-guidance p {
    margin: 0;
}

#column-selection-modal .column-selection-guidance p + p {
    margin-top: 0.45rem;
}

#column-selection-modal > .errorlist {
    margin: 1rem 1.5rem 0;
}

#column-selection-modal .column-selection-form {
    padding: 0 1.5rem;
}

#column-selection-modal .modal-field-grid {
    margin-top: 1rem;
}

#column-selection-modal .column-selection-tools {
    position: static;
    justify-content: flex-start;
    flex-wrap: wrap;
    margin: 0.25rem 0 0;
    padding: 0;
    border: 0;
    background: transparent;
}

#column-selection-modal .column-selection-tools button {
    padding: 0.45rem 0.7rem;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 0.78rem;
    font-weight: 650;
    cursor: pointer;
}

#column-selection-modal .column-selection-tools button:hover {
    border-color: var(--mint-dark);
    background: #effcf8;
}

#column-selection-modal .column-selection-count {
    margin: 0.85rem 0 0.5rem;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 700;
}

#column-selection-modal .column-selection-list {
    max-height: 42vh;
    overflow-y: auto;
    padding: 0.65rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--canvas);
}

#column-selection-modal .column-group-heading {
    margin: 0.35rem 0 0.5rem;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

#column-selection-modal .column-group-heading:not(:first-child) {
    margin-top: 1rem;
}

#column-selection-modal .column-choice {
    margin: 0;
    border-bottom: 1px solid var(--line);
}

#column-selection-modal .column-choice:last-child {
    border-bottom: 0;
}

#column-selection-modal .column-choice label {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    column-gap: 0.7rem;
    align-items: start;
    padding: 0.65rem 0.45rem;
    border-radius: 7px;
    cursor: pointer;
}

#column-selection-modal .column-choice label:hover {
    background: var(--surface);
}

#column-selection-modal .column-choice input[type="checkbox"] {
    grid-column: 1;
    grid-row: 1 / span 3;
    width: 16px;
    height: 16px;
    margin: 0.15rem 0 0;
    padding: 0;
    border-radius: 4px;
    accent-color: var(--mint-dark);
}

#column-selection-modal .column-choice strong {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 0.88rem;
}

#column-selection-modal .column-choice span,
#column-selection-modal .column-choice small {
    grid-column: 2;
    color: var(--muted);
    font-size: 0.76rem;
}

#column-selection-modal .column-choice small {
    margin-top: 0.2rem;
    color: var(--mint-dark);
    font-weight: 650;
}

#column-selection-modal .column-selection-form > p:not(.column-selection-count) {
    margin: 0.85rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
}

#column-selection-modal .modal-actions:not(.column-selection-tools) {
    margin-inline: -1.5rem;
}

#column-selection-modal .modal-save:disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

.productive-window-form {
    padding: 1.25rem 1.5rem 0;
}

.productive-window-guidance {
    padding: 0.85rem 1rem;
    border: 1px solid #ccefe7;
    border-radius: 10px;
    background: #effcf8;
    color: var(--ink);
    font-size: 0.88rem;
    line-height: 1.5;
}

.productive-window-guidance p {
    margin: 0;
}

.productive-window-guidance p + p {
    margin-top: 0.45rem;
}

.productive-window-status {
    margin: 0.85rem 0 0;
    padding: 0.7rem 0.85rem;
    border: 1px solid #f1d59a;
    border-radius: 8px;
    background: #fff8e8;
    color: #79500b;
    font-size: 0.85rem;
}

.productive-window-timezone,
.productive-window-note {
    margin: 0.85rem 0 0;
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.5;
}

.productive-window-fields {
    margin-top: 0.75rem;
}

.productive-window-form .modal-actions {
    margin-inline: -1.5rem;
}

@media (max-width: 640px) {
    .sensor-resolution-row {
        grid-template-columns: 1fr;
    }

    .modal-field-grid {
        grid-template-columns: 1fr;
    }

    .upload-file-summary {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.25rem;
    }

    #column-selection-modal .column-selection-form,
    .productive-window-form {
        padding-inline: 1rem;
    }

    #column-selection-modal .column-selection-guidance {
        margin-inline: 1rem;
    }

    #column-selection-modal .column-selection-tools {
        gap: 0.45rem;
    }

    #column-selection-modal .modal-actions:not(.column-selection-tools),
    .productive-window-form .modal-actions {
        margin-inline: -1rem;
    }
}

.modal-header,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.modal-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.run-details-modal {
    width: min(680px, calc(100% - 2rem));
    max-height: calc(100vh - 2rem);
    padding: 0;
    overflow: auto;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.run-details-modal .modal-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px dashed var(--line);
}

.run-details-modal .modal-header h3,
.modal-form-section h4 {
    margin: 0;
    color: var(--navy);
}

.run-details-modal .modal-header p {
    margin: 0.3rem 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.upload-file-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 1.25rem 1.5rem 0;
    padding: 0.75rem 1rem;
    border: 1px solid #ccefe7;
    border-radius: 10px;
    background: #effcf8;
    color: var(--ink);
    font-size: 0.85rem;
}

.upload-file-summary span {
    color: var(--mint-dark);
    font-weight: 700;
}

.modal-form-section {
    padding: 1.25rem 1.5rem 0;
}

.modal-form-section h4 {
    font-size: 0.85rem;
}

.modal-field-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.modal-field {
    margin: 0;
}

.modal-field-full {
    grid-column: 1 / -1;
}

.run-details-modal input,
.run-details-modal select,
.run-details-modal textarea {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

.run-details-modal textarea {
    min-height: 88px;
    resize: vertical;
}

.run-details-modal input:focus,
.run-details-modal select:focus,
.run-details-modal textarea:focus {
    outline: 3px solid rgba(55, 216, 176, 0.22);
    border-color: var(--mint-dark);
}

.run-details-modal .modal-actions {
    position: sticky;
    bottom: 0;
    justify-content: flex-end;
    margin-top: 1.5rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--line);
    background: var(--canvas);
}

.modal-cancel,
.modal-save {
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

.modal-cancel {
    border: 0;
    background: transparent;
    color: var(--muted);
}

.modal-save {
    border: 1px solid var(--mint-dark);
    background: var(--mint);
    color: var(--navy);
}

.modal-save:hover {
    background: #66e4c6;
}

.modal-close {
    border: 0;
    background: transparent;
    font-size: 1.5rem;
    cursor: pointer;
}

.upload-empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    padding: 5rem;

}

.upload-empty-state h4 {
    margin: 0;
    font-size: 18px;
}

.upload-empty-state p {
    margin: 0.4rem 0 0 0;
    color: gray;
    font-size: 14px;
}

.uploaded-file-list {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 0.5rem;
    padding: 0.5rem;
    list-style: none;
    box-sizing: border-box;
}

.uploaded-file-table-header {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) minmax(9rem, 1fr) minmax(8rem, 1fr) 7rem minmax(8rem, 1fr);
    gap: 1rem;
    width: 100%;
    padding: 0 1.5rem;
    color: #6b7280;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.recent-uploads-panel .upload-header-row,
.recent-uploads-panel .box-header {
    width: 100%;
}

.recent-uploads-panel .box-header p {
    margin-bottom: 0.5rem;
}

.uploaded-file-card {
    display: grid;
    grid-template-columns: minmax(12rem, 2fr) minmax(9rem, 1fr) minmax(8rem, 1fr) 7rem minmax(8rem, 1fr);
    align-items: start;
    gap: 1rem;
    width: 100%;
    padding: 0.8rem 1rem;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #f9fafb;
    box-sizing: border-box;
}

.uploaded-file-card[hidden] {
    display: none;
}

.recent-runs-more {
    display: flex;
    justify-content: center;
    padding: 0.35rem 0 0.75rem;
}

.recent-runs-more button {
    border-color: var(--mint-dark);
    background: #effcf8;
    color: #075c4d;
    font-weight: 700;
}

.recent-runs-more button:hover {
    background: #dff8f0;
}

.upload-calendar-note-button { padding: 0.25rem 0.5rem; border-color: var(--mint-dark); background: #effcf8; color: #075c4d; font-size: 0.72rem; font-weight: 700; }
.run-notes-modal { width: min(42rem, calc(100% - 2rem)); }
.run-notes-list { max-height: 18rem; overflow-y: auto; padding: 1rem 1.5rem; }
.run-note { padding: 0.75rem; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.run-note + .run-note { margin-top: 0.65rem; }
.run-note small { color: var(--muted); font-weight: 700; }
.run-note p { margin: 0.4rem 0 0; white-space: pre-wrap; }
.run-notes-form { border-top: 1px solid var(--line); }
.run-notes-form > label, .run-notes-form > textarea, .run-notes-error { display: block; margin: 1rem 1.5rem 0; }
.run-notes-form > label { color: var(--navy); font-size: 0.85rem; font-weight: 700; }
.run-notes-form > textarea { width: calc(100% - 3rem); min-height: 5rem; resize: vertical; }
.run-notes-error { min-height: 1.1rem; color: #b42318; font-size: 0.85rem; }

/* Keep the workflow controls at the far right of the Recent Runs grid. */
.uploaded-file-card > .uploaded-file-field:nth-child(1) { order: 1; }
.uploaded-file-card > .uploaded-file-field:nth-child(4) { order: 2; }
.uploaded-file-card > .uploaded-file-field:nth-child(5) { order: 3; }
.uploaded-file-card > .uploaded-file-field:nth-child(2) { order: 4; }
.uploaded-file-card > .uploaded-file-field:nth-child(3) { order: 5; }

.uploaded-file-card a,
.uploaded-file-card span {
    font-weight: 600;
    color: #434445;
    text-decoration: none;
}

.uploaded-file-card small {
    display: block;
    margin-top: 0.25rem;
    color: #6b7280;
    font-size: 12px;
}

.uploaded-file-run small {
    display: none;
}

.uploaded-file-field {
    display: flex;
    flex-direction: column;
    min-width: 0;
    gap: 0.35rem;
    color: #434445;
    font-size: 0.9rem;
}

.owner-profile {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.uploaded-file-card .owner-initials {
    display: inline-grid;
    width: 1.9rem;
    height: 1.9rem;
    place-items: center;
    border-radius: 50%;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.uploaded-file-card .owner-initials.owner-color-0 { background: #dbeafe; color: #1d4ed8; }
.uploaded-file-card .owner-initials.owner-color-1 { background: #ede9fe; color: #6d28d9; }
.uploaded-file-card .owner-initials.owner-color-2 { background: #ccfbf1; color: #0f766e; }
.uploaded-file-card .owner-initials.owner-color-3 { background: #ffe4e6; color: #be123c; }
.uploaded-file-card .owner-initials.owner-color-4 { background: #fef3c7; color: #a16207; }
.uploaded-file-card .owner-initials.owner-color-5 { background: #e0e7ff; color: #4338ca; }

.uploaded-file-status-form {
    width: 7rem;
    margin: 0;
    transform: translateX(-0.5rem);
}

.uploaded-file-status-form label {
    color: #6b7280;
    font-size: 0.72rem;
}

.uploaded-file-status-form select {
    padding: 0.35rem 0.25rem;
    border: 1px solid #cbd5e1;
    border-radius: 0.35rem;
    background: #fff;
    color: #1f2937;
    font-size: 0.75rem;
}

.uploaded-file-status-form select.status-bubble {
    border: 0;
    border-radius: 999px;
    font-weight: 700;
    text-align: center;
}

.uploaded-file-status-form select.status-raw {
    background: #dbeafe;
    color: #1d4ed8;
}

.uploaded-file-status-form select.status-cleaned {
    background: #dcfce7;
    color: #15803d;
}

.uploaded-file-status-form select.status-reviewed {
    background: #fef3c7;
    color: #a16207;
}

.status-bubble {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 0.35rem 0.65rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.status-dot {
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    flex: 0 0 auto;
    margin-right: 0.35rem;
}

.status-review { background: #fef3c7; color: #a16207; }
.status-raw { background: #dbeafe; color: #1d4ed8; }
.status-cleaned { background: #dcfce7; color: #15803d; }
.status-review .status-dot { background: #eab308; }
.status-raw .status-dot { background: #2563eb; }
.status-cleaned .status-dot { background: #16a34a; }
.sensor-rules-list-item > span { display: flex; align-items: center; gap: 0.4rem; }
.sensor-rule-set, .sensor-rule-unset { font-size: 0.65rem; font-style: normal; font-weight: 700; padding: 0.12rem 0.35rem; border-radius: 999px; }
.sensor-rule-set { background: #dcfce7; color: #15803d; }
.sensor-rule-unset { background: #f3f4f6; color: #6b7280; }
.file-action-button { padding: 0.4rem 0.7rem; border: 0; border-radius: 0.35rem; background: #2563eb; color: #fff; font-weight: 700; cursor: pointer; }
.run-actions-menu { position: relative; width: fit-content; }
.run-actions-trigger { display: inline-flex; align-items: center; gap: 0.45rem; list-style: none; }
.run-actions-trigger::-webkit-details-marker { display: none; }
.run-actions-trigger::marker { content: ""; }
.run-actions-trigger::after {
    width: 0.38rem;
    height: 0.38rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    content: "";
    transform: translateY(-1px) rotate(45deg);
}
.run-actions-menu-list {
    position: absolute;
    z-index: 10;
    right: 0;
    min-width: 13.75rem;
    margin-top: 0.35rem;
    padding: 0.35rem;
    border: 1px solid #d7e0e6;
    border-radius: 0.5rem;
    background: #fff;
    box-shadow: 0 10px 24px rgba(16, 32, 57, 0.16);
}
.run-actions-menu-list form { margin: 0; }
.run-actions-menu-item {
    display: block;
    width: 100%;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 0.3rem;
    background: transparent;
    color: #203347;
    font: inherit;
    font-weight: 600;
    text-align: left;
    text-decoration: none;
    cursor: pointer;
}
.run-actions-menu-item:hover,
.run-actions-menu-item:focus-visible { background: #edf5f8; outline: none; }
.run-actions-delete { color: #b42318; }
.run-actions-delete:hover,
.run-actions-delete:focus-visible { background: #fef2f2; }
.cleaning-review-modal { width: min(48rem, calc(100vw - 2rem)); }
.cleaning-review-table-wrap { max-height: 22rem; overflow: auto; }
.cleaning-review-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.cleaning-review-table th, .cleaning-review-table td { padding: 0.6rem; border-bottom: 1px solid #e5e7eb; text-align: left; }
.cleaning-review-note { color: #6b7280; font-size: 0.85rem; }

.uploaded-file-status-form select.status-bubble option {
    background: #fff;
    color: #1f2937;
}

@media (max-width: 760px) {
    .uploaded-file-table-header {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .uploaded-file-table-header span:first-child {
        grid-column: 1 / -1;
    }

    .uploaded-file-card {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .uploaded-file-run {
        grid-column: 1 / -1;
    }
}

@media (max-width: 480px) {
    .uploaded-file-table-header {
        display: none;
    }

    .uploaded-file-card {
        grid-template-columns: 1fr;
    }

    .uploaded-file-run {
        grid-column: auto;
    }
}

/* Metrics */
.metrics-box {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
}

.metrics-box .box-header h3 {
    font-size: 14px;
}

.metrics-box .box-header p {
    margin: 0.15rem 0 0;
    font-size: 11px;
}

.metrics-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.4rem;
}

.metric-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.5rem;
    min-width: 0;
}

.metric-label {
    margin: 0;
    color: #6b7280;
    font-size: 10px;
}

.metric-card h2 {
    margin: 0.2rem 0 0 0;
    font-size: 14px;
}

#sensor-value {
    font-size: 16px;
}

#o2-feed-ratio {
    font-size: 16px;
}

#sensor-rate-of-change {
    font-size: 16px;
}
/* Hidden by default */
.hidden {
  display: none;
}

/* Dark overlay */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* dark fade */
  z-index: 999;
}

/* Modal box */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 10px;
    width: 60%;
    max-width: 700px;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

#sensorModal modal {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    z-index: 1000;

    overflow: hidden; 
}

.sensor-list {
    max-height: 400px;
    overflow-y: auto; 
    flex: 1 1 auto; 
    min-height: 0; 
}

#window-feedback {
    display: none;
}

.logo {
    width: 120px;
    height: auto;
}

.sensor-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    border: #d1d5db 2px solid;
    border-radius: 8px;
    font-size: 12px;
    padding: 1rem;
    cursor: pointer;
    position: relative;
}

.sensor-card.selected {
    background: #eff6ff;
    border-color: #2563eb;
    color: #1e3a8a;
}

.sensor-card.running {
    box-shadow: inset 4px 0 0 #22c55e;
}

.sensor-statuses {
    display: inline-flex;
    gap: 0.35rem;
    margin-left: auto;
}

.sensor-status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.18rem 0.45rem;
    font-size: 10px;
    font-weight: 700;
}

.sensor-status.selected-status {
    color: #1d4ed8;
    background: #dbeafe;
}

.sensor-status.running-status {
    color: #166534;
    background: #dcfce7;
}

/* X button (hidden by default) */
.sensor-card .remove-btn {
    margin-left: auto;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    display: none;
}

/* show X only when selected */
.sensor-card.selected .remove-btn {
  display: block;
  display: none;
}

.sensor-card:hover {
    background-color: #ebeced;
}

.sensor-card.suppress-hover:hover {
    background-color: transparent;
}

.sensor-card.selected.suppress-hover:hover {
    background: #ebeced;
}

.stacked-sensor-cards {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

p {
    font-size: 12px;
}

.window {
    margin: 0;
    color: gray;
    font-size: 14px;
}

#window-input {
    width: 10%;
}

.window-controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#current-window-display {
    margin: 0;
    font-size: 14px;
}

#current-window-value {
    font-weight: 600;
    color: #111827;
}

.box-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border: dashed gray 2px;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    min-height: 200px;
}

.recent-uploads-content {
    align-items: stretch;
    justify-content: flex-start;
    border: 0;
    min-height: 0;
}

/* Public pages */
.marketing-page { background: var(--navy); }
.marketing-page .site-main {
    background: #f7fafb;
    border-radius: 28px 0 0 28px;
    overflow: hidden;
}

.home-main {
    padding: clamp(34px, 6vw, 86px) clamp(28px, 7vw, 100px) 42px;
    display: flex;
    flex-direction: column;
}

.home-hero {
    width: min(1180px, 100%);
    margin: auto;
    display: grid;
    grid-template-columns: minmax(0, .88fr) minmax(430px, 1.12fr);
    align-items: center;
    gap: clamp(46px, 7vw, 105px);
}

.hero-copy h1 {
    margin: 18px 0 24px;
    max-width: 680px;
    font-size: clamp(48px, 6vw, 82px);
    line-height: .98;
    letter-spacing: -.065em;
    font-weight: 800;
}
.hero-copy h1 span { color: var(--mint-dark); }
.hero-copy > p { max-width: 590px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.75; }
.hero-actions { display: flex; align-items: center; gap: 24px; margin-top: 34px; flex-wrap: wrap; }
.primary-action {
    appearance: none;
    border: 0;
    background: var(--navy);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 50px;
    padding: 0 20px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 14px;
    font-weight: 750;
    cursor: pointer;
    transition: transform .18s ease, background .18s ease;
}
.primary-action:hover { background: #142a49; transform: translateY(-2px); }
.primary-action span { color: var(--mint); font-size: 20px; }
.text-action, .text-button { color: var(--ink); font-weight: 700; font-size: 14px; text-underline-offset: 5px; }
.text-button { background: none; border: 0; padding: 10px; text-decoration: underline; }

.hero-visual {
    position: relative;
    background: var(--navy);
    color: white;
    padding: 26px;
    border-radius: 24px;
    box-shadow: 0 32px 70px rgba(10,22,40,.22);
    overflow: hidden;
}
.hero-visual::after { content: ""; position: absolute; width: 190px; height: 190px; right: -70px; top: -80px; border: 40px solid rgba(55,216,176,.08); border-radius: 50%; }
.visual-header { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 1; color: #aebbd0; font-size: 13px; }
.live-pill { display: inline-flex; align-items: center; gap: 7px; background: rgba(55,216,176,.12); color: #78e6ca; border-radius: 20px; padding: 6px 10px; font-size: 11px; font-weight: 700; }
.live-pill i { width: 6px; height: 6px; border-radius: 50%; background: var(--mint); }
.visual-metric { display: grid; grid-template-columns: 1fr auto; align-items: end; margin-top: 28px; position: relative; z-index: 1; }
.visual-metric small { grid-column: 1 / -1; color: #8293ac; font-size: 12px; }
.visual-metric strong { font-size: 48px; letter-spacing: -.05em; line-height: 1; margin-top: 8px; }
.visual-metric > span { color: var(--mint); font-size: 11px; font-weight: 700; padding-bottom: 5px; }
.hero-chart { width: 100%; margin-top: 18px; overflow: visible; }
.chart-grid { fill: none; stroke: rgba(255,255,255,.07); stroke-width: 1; }
.chart-area { fill: url(#area); }
.chart-line { fill: none; stroke: var(--mint); stroke-width: 4; stroke-linecap: round; }
.visual-stats { display: grid; grid-template-columns: repeat(3,1fr); border-top: 1px solid rgba(255,255,255,.1); padding-top: 20px; gap: 14px; }
.visual-stats span { display: grid; gap: 5px; }
.visual-stats small { color: #8293ac; font-size: 10px; text-transform: uppercase; letter-spacing: .08em; }
.visual-stats strong { font-size: 15px; }

.home-proof {
    width: min(1180px, 100%);
    margin: clamp(50px, 7vh, 80px) auto 0;
    padding-top: 25px;
    border-top: 1px solid var(--line);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 28px;
}
.home-proof article { display: flex; gap: 15px; }
.home-proof article > span { color: var(--mint-dark); font-size: 12px; font-weight: 800; padding-top: 4px; }
.home-proof h2 { margin: 0 0 5px; font-size: 15px; }
.home-proof p { margin: 0; color: var(--muted); line-height: 1.5; }

.quick-start {
    display: grid;
    grid-template-columns: minmax(16rem, 0.75fr) minmax(0, 1.25fr);
    gap: clamp(28px, 5vw, 72px);
    width: min(1180px, 100%);
    margin: clamp(60px, 9vh, 105px) auto 0;
    padding: clamp(28px, 4vw, 48px);
    border: 1px solid #cfe4e0;
    border-radius: 22px;
    background: linear-gradient(125deg, #effcf8 0%, #f5f9ff 100%);
}
.quick-start-intro h2 { margin: 14px 0; font-size: clamp(28px, 3.5vw, 42px); line-height: 1.1; letter-spacing: -.045em; }
.quick-start-intro > p { margin: 0; color: var(--muted); line-height: 1.7; }
.quick-start-video {
    display: inline-flex;
    gap: 0.45rem;
    align-items: center;
    margin-top: 1.5rem;
    color: #075c4d;
    font-size: 0.9rem;
    font-weight: 800;
    text-underline-offset: 4px;
}
.quick-start-video[aria-disabled="true"] { cursor: default; }
.quick-start-steps { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; }
.quick-start-steps li { display: flex; gap: 0.8rem; padding: 1rem; border: 1px solid #dce9e7; border-radius: 12px; background: rgba(255, 255, 255, 0.8); }
.quick-start-steps > li > span { display: grid; width: 1.85rem; height: 1.85rem; flex: 0 0 auto; place-items: center; border-radius: 50%; background: var(--mint); color: var(--navy); font-size: 0.8rem; font-weight: 800; }
.quick-start-steps h3 { margin: 0 0 0.35rem; font-size: 0.95rem; }
.quick-start-steps p { margin: 0; color: var(--muted); font-size: 0.82rem; line-height: 1.55; }

.research-story {
    width: min(1180px, 100%);
    margin: clamp(62px, 9vw, 120px) auto 40px;
    padding: clamp(32px, 5vw, 64px);
    border-radius: 22px;
    background: #e8f7f2;
    display: grid;
    grid-template-columns: minmax(260px, .8fr) minmax(320px, 1.2fr);
    gap: clamp(35px, 7vw, 100px);
    align-items: start;
}
.research-story h2 { margin: 14px 0 0; max-width: 520px; font-size: clamp(32px, 4.5vw, 55px); line-height: 1.08; letter-spacing: -.05em; }
.research-story-copy { display: grid; gap: 18px; }
.research-story-copy p { color: #42566b; font-size: 16px; line-height: 1.72; margin: 0; }

.centered-main { display: grid; place-items: center; padding: 30px; }
.auth-card { width: min(460px, 100%); background: white; border: 1px solid var(--line); border-radius: 20px; padding: clamp(28px, 5vw, 48px); box-shadow: 0 25px 70px rgba(16,32,57,.1); }
.auth-card h1 { margin: 12px 0 10px; font-size: 34px; letter-spacing: -.04em; }
.auth-card > p { color: var(--muted); font-size: 15px; line-height: 1.6; }
.auth-form { display: grid; gap: 9px; margin-top: 28px; }
.auth-form label { font-size: 13px; font-weight: 700; margin-top: 8px; }
.auth-form input { width: 100%; min-height: 48px; border: 1px solid #ccd6de; border-radius: 8px; padding: 0 13px; font: inherit; outline: none; }
.auth-form input:focus { border-color: var(--mint-dark); box-shadow: 0 0 0 3px rgba(55,216,176,.18); }
.auth-form .primary-action { margin-top: 14px; }
.form-error { background: #fff1f2; color: #a32336; border-radius: 7px; padding: 10px 12px; margin: 0; }
.auth-actions { display: flex; align-items: center; gap: 18px; margin-top: 25px; }
.auth-actions form { margin: 0; }

.about-main { padding: clamp(55px, 9vw, 125px) clamp(30px, 9vw, 130px); }
.about-intro { max-width: 820px; }
.about-intro h1 { margin: 18px 0 24px; font-size: clamp(48px, 7vw, 84px); line-height: 1; letter-spacing: -.06em; }
.about-intro p { max-width: 700px; color: var(--muted); font-size: 19px; line-height: 1.7; }
.team-story { display: grid; grid-template-columns: minmax(420px, 1.25fr) minmax(320px, .75fr); gap: clamp(35px, 6vw, 80px); align-items: center; margin: 70px 0; max-width: 1180px; }
.team-photo { margin: 0; }
.team-photo img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 20px; display: block; box-shadow: 0 24px 60px rgba(10,22,40,.16); }
.team-photo figcaption { color: var(--muted); font-size: 12px; margin-top: 10px; }
.team-story-copy h2 { margin: 14px 0 20px; font-size: clamp(30px, 4vw, 48px); line-height: 1.1; letter-spacing: -.045em; }
.team-story-copy p { color: var(--muted); font-size: 16px; line-height: 1.7; }
.about-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; max-width: 1180px; margin: 0 0 36px; }
.about-grid article { padding: 28px; background: white; border: 1px solid var(--line); border-radius: 16px; }
.about-grid article > span { color: var(--mint-dark); font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; }
.about-grid h2 { margin: 12px 0 10px; font-size: 22px; }
.about-grid p { color: var(--muted); font-size: 14px; line-height: 1.65; margin: 0; }
.team-members { max-width: 1180px; margin-top: 80px; }
.team-members-header { max-width: 650px; margin-bottom: 28px; }
.team-members-header h2 { margin: 12px 0; font-size: clamp(30px, 4vw, 48px); letter-spacing: -.045em; }
.team-members-header p { color: var(--muted); font-size: 16px; line-height: 1.65; }
.team-members-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.team-member-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: #fff; }
.team-member-headshot {
    display: grid;
    min-height: 240px;
    place-items: center;
    background: linear-gradient(135deg, #dff8f0, #dcecff);
    color: #315266;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.team-member-headshot span { padding: 0.5rem 0.7rem; border: 1px dashed currentColor; border-radius: 999px; }
.team-member-card img.team-member-headshot {
    display: block;
    width: 100%;
    height: 320px;
    min-height: 0;
    object-fit: cover;
    object-position: center top;
}
.team-member-card img.team-member-headshot-brandy { object-position: center 48%; }
.team-member-content { padding: 24px; }
.team-member-role { margin: 0; color: var(--mint-dark); font-size: 0.7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.team-member-content h3 { margin: 0.45rem 0 0.85rem; font-size: 1.35rem; }
.team-member-bio { margin: 0; color: var(--muted); font-size: 0.9rem; line-height: 1.7; }
.team-member-contact { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; margin-top: 1.2rem; font-size: 0.84rem; font-style: normal; }
.team-member-contact a { color: var(--mint-dark); font-weight: 700; text-underline-offset: 3px; }
.empty-workspace { min-height: 360px; align-items: center; justify-content: center; text-align: center; }
.empty-workspace h2 { margin: 10px 0 5px; }
.empty-workspace p { color: var(--muted); font-size: 14px; }

/* Analysis */
.analysis-layout {
    width: min(100%, 1200px);
    margin: 0 auto;
}

.analysis-box {
    gap: 1rem;
}

.analysis-run-prompt {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.analysis-run-prompt h3,
.analysis-prompt-label,
.analysis-selection-status {
    margin: 0;
}

.analysis-prompt-label {
    color: var(--muted);
}

.analysis-run-select {
    width: min(100%, 28rem);
    min-height: 2.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.analysis-run-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
}

.analysis-run-actions button:first-child {
    min-height: 48px;
    padding: 0.7rem 1.1rem;
    border: 1px solid #d1dce3;
    border-radius: 11px;
    background: #f5f8f9;
    color: var(--ink);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.analysis-run-actions button:first-child:hover {
    background: #ffffff;
    border-color: #b9cbd4;
    transform: translateY(-1px);
}

.analysis-run-actions button:first-child:focus-visible,
.analysis-run-actions button:last-child:focus-visible {
    outline: 3px solid rgba(8, 127, 104, 0.28);
    outline-offset: 2px;
}

.analysis-run-actions button:last-child {
    width: fit-content;
    padding: 0.55rem 0.9rem;
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.analysis-run-actions button:last-child:hover {
    color: var(--ink);
    text-decoration: underline;
}

.analysis-selection-status {
    color: var(--muted);
    font-size: 0.875rem;
    line-height: 1.4;
}

.analysis-chart-area {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    gap: 1.5rem;
    min-height: clamp(360px, 60vh, 620px);
}

.analysis-canvas-wrap {
    position: relative;
    min-width: 0;
    min-height: 360px;
}

#analysis-chart {
    width: 100%;
    height: 100%;
}

.chart-status {
    position: absolute;
    inset: 50% auto auto 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    color: #6b7280;
    text-align: center;
}

.noise-threshold-control {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem;
    border-left: 1px solid #e5e7eb;
    text-align: center;
}

.analysis-slider-control {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
}

.analysis-slider-control + .analysis-slider-control {
    padding-top: 1.5rem;
    border-top: 1px solid #e5e7eb;
}

.noise-threshold-control label {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.35;
}

.noise-threshold-control output {
    font-size: 26px;
}

#noise-threshold,
#max-nan-gap {
    width: 220px;
    margin: 0.5rem 0;
    writing-mode: vertical-lr;
    direction: rtl;
}

.noise-threshold-control p {
    margin: 0;
    color: #6b7280;
    line-height: 1.4;
}

.analysis-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.historical-query-heading,
.historical-results-heading,
.historical-comparison-header,
.historical-run-header,
.historical-query-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}


.historical-query-box {
    position: relative;
    overflow: hidden;
    padding: 0;
    border-color: #d7e2eb;
    box-shadow: 0 14px 35px rgba(27, 55, 78, 0.07);
}

.historical-query-box::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 4px;
    background: linear-gradient(90deg, #37d8b0, #1479b8 65%, #8a5cf5);
}

.historical-query-heading {
    padding: 1.35rem 1.4rem 1.1rem;
    background: linear-gradient(120deg, rgba(55, 216, 176, 0.09), rgba(20, 121, 184, 0.035) 55%, transparent);
}

.historical-query-title-group {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.historical-query-title-group h3 {
    margin: 0;
    font-size: 21px;
    letter-spacing: -0.02em;
}

.historical-query-title-group p {
    margin: 0.3rem 0 0;
    color: #64748b;
    font-size: 13px;
}

.historical-add-button {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    white-space: nowrap;
}

.historical-add-button span {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    border-radius: 50%;
    background: #e8f5fb;
    color: #1479b8;
    font-size: 17px;
    line-height: 1;
}

.historical-query-form {
    padding: 1rem 1.4rem 1.3rem;
    border-top: 1px solid #e4ebf0;
}

.historical-builder-labels {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: #64748b;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.historical-query-heading .box-header p,
.historical-results-heading p,
.historical-comparison-header p,
.historical-run-header p {
    margin: 0.3rem 0 0;
    color: #6b7280;
    font-size: 13px;
}

.historical-query-box h4,
.historical-query-box h5 {
    margin: 0;
}

.historical-conditions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin: 0.75rem 0;
}

.historical-condition {
    display: grid;
    grid-template-columns: 36px minmax(220px, 1fr) minmax(120px, 0.35fr) minmax(120px, 0.35fr) 40px;
    gap: 0.75rem;
    align-items: end;
    padding: 0.9rem;
    border: 1px solid #e5e7eb;
    border-radius: 13px;
    background: #f8fafc;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.historical-condition:focus-within {
    border-color: #91c9e8;
    box-shadow: 0 0 0 3px rgba(20, 121, 184, 0.08);
}

.historical-condition.has-error {
    border-color: #fda4af;
    background: #fff7f8;
}

.historical-condition.has-error .historical-condition-summary {
    color: #be123c;
    font-weight: 700;
}

.historical-condition-number {
    align-self: center;
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 9px;
    background: #e8f5fb;
    color: #126b9f;
    font-size: 12px;
    font-weight: 800;
}

.historical-condition label,
.historical-results-heading label {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    color: #4b5563;
    font-size: 12px;
    font-weight: 700;
}

.historical-condition input,
.historical-condition select,
.historical-results-heading select {
    min-height: 40px;
    border: 1px solid #ccd6de;
    border-radius: 8px;
    padding: 0 0.65rem;
    background: white;
    color: #111827;
    font: inherit;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

.historical-condition input:focus,
.historical-condition select:focus,
.historical-results-heading select:focus {
    border-color: #1479b8;
    box-shadow: 0 0 0 3px rgba(20, 121, 184, 0.1);
}

.historical-condition label > span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.35rem;
}

.historical-condition label small {
    color: #94a3b8;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.remove-historical-condition {
    display: grid;
    width: 40px;
    height: 40px;
    padding: 0;
    place-items: center;
    border-radius: 10px;
    color: #64748b;
    font-size: 22px;
    line-height: 1;
}

.remove-historical-condition:not(:disabled):hover {
    border-color: #fecaca;
    background: #fff1f2;
    color: #be123c;
}

.historical-condition-summary {
    grid-column: 2 / -1;
    margin: -0.1rem 0 0;
    color: #64748b;
    font-size: 11px;
}

.historical-query-actions {
    justify-content: flex-start;
    flex-wrap: wrap;
    padding-top: 0.15rem;
}

#search-historical-runs {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 132px;
    justify-content: center;
}

.historical-search-icon {
    font-size: 19px;
    line-height: 0;
}

#search-historical-runs.is-loading .historical-search-icon {
    animation: historical-pulse 900ms ease-in-out infinite alternate;
}

@keyframes historical-pulse {
    to { opacity: 0.35; transform: scale(0.88); }
}

#historical-query-status {
    margin: 0 0 0 auto;
    color: #4b5563;
    font-size: 13px;
}

#historical-query-status.error,
#historical-comparison-status.error {
    color: #b42318;
}

.historical-results {
    margin-top: 0;
    padding: 1.35rem 1.4rem 1.4rem;
    border-top: 1px solid #e5e7eb;
    background: #fbfdfe;
}

.historical-results-heading {
    align-items: flex-end;
    margin-bottom: 0.75rem;
}

.historical-results-title,
.historical-comparison-title-row,
.historical-run-title-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.historical-count-badge,
.historical-selection-count,
.historical-run-status {
    display: inline-flex;
    align-items: center;
    width: max-content;
    border-radius: 999px;
    font-weight: 750;
    white-space: nowrap;
}

.historical-count-badge {
    padding: 0.33rem 0.58rem;
    background: #e8f5fb;
    color: #126b9f;
    font-size: 11px;
}

.historical-selection-count {
    padding: 0.25rem 0.5rem;
    background: #eef2f6;
    color: #64748b;
    font-size: 10px;
}

.historical-run-list {
    display: grid;
    gap: 0.75rem;
}

.historical-aggregate-summary {
    margin-bottom: 1rem;
    padding: 1rem;
    border: 1px solid #dce7ee;
    border-radius: 13px;
    background: white;
}

.historical-aggregate-summary > p {
    margin: 0.25rem 0 0;
    color: #64748b;
    font-size: 12px;
}

.historical-run-chart-wrap {
    position: relative;
    height: 230px;
    padding: 0.75rem 0.9rem 0.9rem;
    border-top: 1px solid #edf1f4;
    background: #fcfdff;
}

.historical-run-chart-title {
    margin: 0 0 0.35rem;
    color: #475569;
    font-size: 11px;
    font-weight: 750;
}

.historical-run-chart-wrap canvas {
    width: 100% !important;
    height: calc(100% - 22px) !important;
}

.historical-run-warning {
    margin: 0.65rem 0.9rem 0;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    background: #fff7ed;
    color: #9a3412;
    font-size: 11px;
}

.historical-response-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.45rem 1.25rem;
    padding: 0.75rem 0.9rem;
    border-top: 1px solid #e5e7eb;
    background: #f8fbfd;
    font-size: 12px;
}

.historical-response-heading {
    grid-column: 1 / -1;
    color: #334155;
}

.historical-response-summary p {
    margin: 0;
}

.historical-run-card {
    min-width: 0;
    overflow: hidden;
    border: 1px solid #dce3ea;
    border-radius: 13px;
    background: white;
    transition: border-color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.historical-run-card:hover {
    border-color: #b9cfdd;
    box-shadow: 0 8px 20px rgba(27, 55, 78, 0.06);
}

.historical-run-card.is-selected {
    border-color: #55a7d2;
    box-shadow: 0 0 0 2px rgba(20, 121, 184, 0.1), 0 10px 24px rgba(27, 55, 78, 0.08);
}

.historical-run-header {
    padding: 0.75rem 0.9rem;
    background: #f8fafc;
}

.historical-run-status {
    padding: 0.2rem 0.45rem;
    background: #dcfce7;
    color: #15803d;
    font-size: 9px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.historical-run-selection {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.historical-run-selection input {
    width: 17px;
    height: 17px;
}

.historical-summary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.historical-summary-table th,
.historical-summary-table td {
    padding: 0.65rem 0.9rem;
    border-top: 1px solid #e5e7eb;
    text-align: right;
    white-space: nowrap;
}

.historical-summary-table th:first-child,
.historical-summary-table td:first-child {
    text-align: left;
}

.historical-summary-table th {
    color: #4b5563;
    font-weight: 700;
}

.historical-comparison {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid #dce7ee;
    border-radius: 13px;
    background: white;
}

.historical-comparison-chart-wrap {
    position: relative;
    height: clamp(300px, 45vh, 460px);
    margin-top: 0.75rem;
    border: 1px solid #edf1f4;
    border-radius: 10px;
    background: #fcfdff;
    padding: 0.6rem;
}

#historical-comparison-chart {
    width: 100%;
    height: 100%;
}

.historical-empty {
    margin: 1rem 1.4rem 1.4rem;
    padding: 1.5rem;
    border: 1px dashed #cbd5e1;
    border-radius: 12px;
    color: #64748b;
    text-align: center;
}

.historical-empty p,
.historical-no-results p {
    margin: 0.35rem 0 0;
}

.historical-no-results {
    display: flex;
    min-height: 180px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.25rem;
    border: 1px dashed #cbd5e1;
    border-radius: 13px;
    color: #64748b;
    text-align: center;
}

.historical-no-results-icon {
    display: grid;
    width: 42px;
    height: 42px;
    margin-bottom: 0.6rem;
    place-items: center;
    border-radius: 50%;
    background: #eef6fa;
    color: #1479b8;
    font-size: 26px;
}

/* Dark mode */
html.dark-mode { color-scheme: dark; }
html.dark-mode body {
    --ink: #e8eef7;
    --muted: #a9b6c8;
    --canvas: #0d1726;
    --surface: #162235;
    --line: #2b3b51;
    background: var(--canvas);
    color: var(--ink);
}
.dark-mode .marketing-page { background: #081321; }
.dark-mode .marketing-page .site-main,
.dark-mode .app-main { background: var(--canvas); }
.dark-mode .site-sidebar { background: #07111f; }
.dark-mode .top-nav { background: #172438; border-color: #2d3d52; }
.dark-mode .nav-link { color: #d5deea; }
.dark-mode .nav-link:hover { background: #213149; border-color: #3b4d65; }
.dark-mode .nav-link.active { background: #2a3b53; border-color: #43566f; color: #fff; box-shadow: 0 2px 8px rgba(0,0,0,.28); }
.dark-mode button:not(.mobile-menu-toggle):not(.theme-toggle),
.dark-mode .upload-submit {
    background: #1c2a3d;
    border-color: #3a4b61;
    color: #e8eef7;
}
.dark-mode button:not(.mobile-menu-toggle):not(.theme-toggle):hover,
.dark-mode .upload-submit:hover { background: #27374d; }
.dark-mode .run-details-modal { background: #101c2c; border-color: #2b3b51; color: #e8eef7; }
.dark-mode .run-details-modal .modal-header h3,
.dark-mode .sensor-resolution-modal .modal-header h3,
.dark-mode .sensor-resolution-row legend,
.dark-mode .modal-form-section h4 { color: #fff; }
.dark-mode .run-details-modal .modal-header p { color: #aebed1; }
.dark-mode .sensor-resolution-modal { background: #101c2c; border-color: #2b3b51; color: #e8eef7; }
.dark-mode .sensor-resolution-modal .modal-header p,
.dark-mode .sensor-resolution-help { color: #aebed1; }
.dark-mode #column-selection-modal .modal-header { background: linear-gradient(120deg, #102d2c 0%, #172438 100%); }
.dark-mode #column-selection-modal .column-selection-guidance,
.dark-mode .productive-window-guidance {
    border-color: #285c56;
    background: #102d2c;
    color: #e8eef7;
}
.dark-mode #column-selection-modal .column-selection-tools button {
    border-color: #3a4b61;
    background: #1c2a3d;
    color: #e8eef7;
}
.dark-mode #column-selection-modal .column-selection-tools button:hover,
.dark-mode #column-selection-modal .column-choice label:hover { background: #27374d; }
.dark-mode .productive-window-status {
    border-color: #66532b;
    background: #30291b;
    color: #f0d99e;
}
.dark-mode .upload-file-summary { background: #102d2c; border-color: #285c56; color: #e8eef7; }
.dark-mode .upload-file-summary span { color: #81ead2; }
.dark-mode .run-details-modal input,
.dark-mode .run-details-modal select,
.dark-mode .run-details-modal textarea,
.dark-mode .sensor-resolution-modal input,
.dark-mode .sensor-resolution-modal select,
.dark-mode .sensor-resolution-modal textarea { background: #0e1929; border-color: #3b4c62; color: #e8eef7; }
.dark-mode .run-details-modal .modal-actions { background: #101c2c; border-color: #2b3b51; }
.dark-mode .sensor-resolution-modal .modal-actions { background: #101c2c; border-color: #2b3b51; }
.dark-mode .modal-cancel { background: transparent; color: #aebed1; }
.dark-mode .modal-save { background: var(--mint); border-color: var(--mint); color: var(--navy); }
.dark-mode .dashboard-box,
.dark-mode .auth-card,
.dark-mode .about-grid article,
.dark-mode .team-member-card,
.dark-mode .modal { background: var(--surface); border-color: var(--line); color: var(--ink); }
.dark-mode .team-member-headshot { background: linear-gradient(135deg, #17394a, #26365b); color: #c8d8e9; }
.dark-mode .team-member-contact a { color: #81ead2; }
.dark-mode .trend-graph { background: #121e30; border-color: #2e4057; }
.dark-mode .trend-graph.active { border-color: #6f93c7; box-shadow: 0 0 0 2px rgba(111,147,199,.15); }
.dark-mode .trend-canvas-wrap { background: #111d2e; border-radius: 10px; }
.dark-mode .metric-card { background: #101c2c; border-color: #2a3b51; }
.dark-mode .uploaded-file-card {
    background: #101c2c;
    border-color: #2b3b51;
}
.dark-mode .uploaded-file-card a,
.dark-mode .uploaded-file-card span,
.dark-mode .uploaded-file-status-form label {
    color: var(--ink);
}
.dark-mode .uploaded-file-card small {
    color: var(--muted);
}
.dark-mode .run-actions-menu-list { border-color: #3b4c62; background: #101c2c; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35); }
.dark-mode .uploaded-file-card .run-actions-menu-item { color: #e8eef7; }
.dark-mode .uploaded-file-card .run-actions-menu-item:hover,
.dark-mode .uploaded-file-card .run-actions-menu-item:focus-visible { background: #213149; }
.dark-mode .uploaded-file-card .run-actions-delete { color: #fca5a5; }
.dark-mode .uploaded-file-card .run-actions-delete:hover,
.dark-mode .uploaded-file-card .run-actions-delete:focus-visible { background: #4a202b; }
.dark-mode .uploaded-file-card .status-bubble.status-raw { background: #1e3a5f; color: #bfdbfe; }
.dark-mode .uploaded-file-card .status-bubble.status-review { background: #5c450e; color: #fef3c7; }
.dark-mode .uploaded-file-card .status-bubble.status-cleaned { background: #164e36; color: #bbf7d0; }
.dark-mode .uploaded-file-card .status-raw .status-dot { background: #60a5fa; }
.dark-mode .uploaded-file-card .status-review .status-dot { background: #facc15; }
.dark-mode .uploaded-file-card .status-cleaned .status-dot { background: #4ade80; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-0 { background: #1e3a5f; color: #bfdbfe; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-1 { background: #3b2469; color: #ddd6fe; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-2 { background: #134e4a; color: #99f6e4; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-3 { background: #641d36; color: #fecdd3; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-4 { background: #5c450e; color: #fef3c7; }
.dark-mode .uploaded-file-card .owner-initials.owner-color-5 { background: #312e81; color: #c7d2fe; }
.dark-mode .uploaded-file-status-form select {
    background: #0e1929;
    border-color: #3b4c62;
    color: var(--ink);
}
.dark-mode .uploaded-file-status-form select.status-raw { background: #1e3a5f; color: #bfdbfe; }
.dark-mode .uploaded-file-status-form select.status-cleaned { background: #164e36; color: #bbf7d0; }
.dark-mode .uploaded-file-status-form select.status-reviewed { background: #5c450e; color: #fef3c7; }
.dark-mode .metric-label,
.dark-mode .box-header p,
.dark-mode .feature-description,
.dark-mode .window,
.dark-mode .upload-empty-state p,
.dark-mode .empty-workspace p,
.dark-mode .noise-threshold-control p { color: var(--muted); }
.dark-mode #current-window-value { color: var(--ink); }
.dark-mode input:not([type="range"]) {
    background: #0e1929;
    border-color: #3b4c62;
    color: var(--ink);
}
.dark-mode input:not([type="range"])::placeholder { color: #7f90a7; }
.dark-mode .sensor-card { background: #121f31; border-color: #3a4c64; }
.dark-mode .sensor-card:hover { background: #1b2b40; }
.dark-mode .sensor-card.selected { background: #183052; border-color: #5b8fda; color: #d9e9ff; }
.dark-mode .box-content { border-color: #526178; }
.dark-mode .research-story { background: #102d2c; }
.dark-mode .research-story-copy p { color: #b5c9ca; }
.dark-mode .text-action,
.dark-mode .text-button { color: var(--ink); }
.dark-mode .primary-action,
.dark-mode button.primary-action { background: var(--mint); border-color: var(--mint); color: #071622; }
.dark-mode .primary-action:hover,
.dark-mode button.primary-action:hover { background: #68e4c6; }
.dark-mode .primary-action span { color: #071622; }
.dark-mode .quick-start { border-color: #31515a; background: linear-gradient(125deg, #102b31 0%, #14263e 100%); }
.dark-mode .quick-start-video { color: #81ead2; }
.dark-mode .quick-start-steps li { border-color: #30455a; background: rgba(16, 28, 44, 0.72); }
.dark-mode .form-error { background: #4a1f2a; color: #ffbec7; }
.dark-mode .noise-threshold-control { border-color: var(--line); }
.dark-mode .analysis-slider-control + .analysis-slider-control { border-color: var(--line); }
/* Analysis visualization follows the selected theme. */
.dark-mode .analysis-canvas-wrap {
    background: #101c2c;
    border: 1px solid #2b3b51;
    border-radius: 12px;
    padding: 12px;
    color: var(--ink);
}
.dark-mode .analysis-canvas-wrap .chart-status { color: var(--muted); }
.dark-mode .historical-condition,
.dark-mode .historical-run-header {
    background: #101c2c;
    border-color: var(--line);
}
.dark-mode .historical-condition.has-error {
    background: #351d29;
    border-color: #a84a64;
}
.dark-mode .historical-condition.has-error .historical-condition-summary { color: #ff9bad; }
.dark-mode .historical-query-box {
    background: var(--surface);
    border-color: var(--line);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.2);
}
.dark-mode .historical-query-heading {
    background: linear-gradient(120deg, rgba(55, 216, 176, 0.09), rgba(20, 121, 184, 0.05) 55%, transparent);
}
.dark-mode .historical-query-form,
.dark-mode .historical-results { border-color: var(--line); }
.dark-mode .historical-results { background: #111d2e; }
.dark-mode .historical-run-card,
.dark-mode .historical-comparison,
.dark-mode .historical-aggregate-summary,
.dark-mode .historical-comparison-chart-wrap { background: #101c2c; }
.dark-mode .historical-run-chart-wrap { border-color: var(--line); background: #101c2c; }
.dark-mode .historical-run-chart-title { color: var(--muted); }
.dark-mode .historical-run-warning { background: #3b2516; color: #fdba74; }
.dark-mode .historical-response-summary { border-color: var(--line); background: #132033; }
.dark-mode .historical-response-heading { color: var(--ink); }
.dark-mode .historical-comparison-chart-wrap { border-color: #26384e; }
.dark-mode .historical-run-card.is-selected {
    border-color: #5ca8d4;
    box-shadow: 0 0 0 2px rgba(92, 168, 212, 0.14);
}
.dark-mode .historical-condition-number,
.dark-mode .historical-count-badge {
    background: #17334a;
    color: #8bd0f3;
}
.dark-mode .historical-selection-count {
    background: #26364a;
    color: var(--muted);
}
.dark-mode .historical-run-status {
    background: #153b31;
    color: #75dfbb;
}
.dark-mode .historical-no-results,
.dark-mode .historical-empty { border-color: #3a4c62; color: var(--muted); }
.dark-mode .historical-no-results-icon { background: #17334a; color: #8bd0f3; }
.dark-mode .historical-query-title-group p,
.dark-mode .historical-builder-labels,
.dark-mode .historical-condition-summary { color: var(--muted); }
.dark-mode .historical-condition,
.dark-mode .historical-run-card,
.dark-mode .historical-results,
.dark-mode .historical-comparison,
.dark-mode .historical-summary-table th,
.dark-mode .historical-summary-table td { border-color: var(--line); }
.dark-mode .historical-condition label,
.dark-mode .historical-results-heading label,
.dark-mode .historical-summary-table th,
.dark-mode #historical-query-status { color: var(--muted); }
.dark-mode .historical-condition input,
.dark-mode .historical-condition select,
.dark-mode .historical-results-heading select {
    background: #0e1929;
    border-color: #3b4c62;
    color: var(--ink);
}
.dark-mode #historical-query-status.error,
.dark-mode #historical-comparison-status.error { color: #ff9b91; }

@media (max-width: 640px) {
    .upload-header-row {
        flex-direction: column;
        align-items: stretch;
    }

    .upload-submit {
        align-self: flex-start;
    }

    .analysis-chart-area {
        grid-template-columns: 1fr;
    }

    .noise-threshold-control {
        border-top: 1px solid #e5e7eb;
        border-left: 0;
    }

    #noise-threshold,
    #max-nan-gap {
        width: min(100%, 320px);
        writing-mode: horizontal-tb;
        direction: ltr;
    }

    .historical-query-heading,
    .historical-results-heading,
    .historical-comparison-header {
        align-items: stretch;
        flex-direction: column;
    }

    .historical-condition {
        grid-template-columns: 32px minmax(0, 1fr) minmax(0, 1fr) 40px;
    }

    .historical-condition-number {
        grid-column: 1;
        grid-row: 1;
    }

    .historical-sensor-field {
        grid-column: 2 / 4;
    }

    .remove-historical-condition {
        grid-column: 4;
        grid-row: 1;
    }

    .historical-minimum-field {
        grid-column: 2;
    }

    .historical-maximum-field {
        grid-column: 3;
    }

    .historical-condition-summary {
        grid-column: 2 / -1;
    }

    #historical-query-status {
        width: 100%;
        margin-left: 0;
    }

    .historical-run-card {
        overflow-x: auto;
    }

    .historical-query-title-group {
        align-items: flex-start;
        flex-direction: column;
    }

    .historical-results-title,
    .historical-comparison-title-row {
        align-items: flex-start;
        flex-direction: column;
        gap: 0.35rem;
    }
}

@media (max-width: 920px) {
    .site-sidebar { transform: translateX(-100%); box-shadow: 12px 0 40px rgba(0,0,0,.2); }
    body.menu-open .site-sidebar { transform: translateX(0); }
    .site-main { margin-left: 0; }
    .marketing-page .site-main { border-radius: 0; }
    .mobile-menu-toggle { top: 14px; left: 14px; }
    .home-main { padding-top: 90px; }
    .home-hero { grid-template-columns: 1fr; }
    .hero-copy h1 { font-size: clamp(46px, 10vw, 72px); }
    .app-toolbar { align-items: flex-start; flex-direction: column; padding-left: 48px; }
    .app-toolbar > div:first-child { flex: 0 0 auto; }
    .top-nav { width: 100%; }
    .top-nav .nav-link { flex: 0 0 auto; }
    .home-proof { grid-template-columns: repeat(2, 1fr); }
    .quick-start { grid-template-columns: 1fr; }
    .research-story { grid-template-columns: 1fr; }
    .team-story { grid-template-columns: 1fr; }
    .about-grid { grid-template-columns: 1fr; }
    .team-members-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
    .home-main { padding-left: 22px; padding-right: 22px; }
    .home-hero { gap: 42px; }
    .hero-visual { padding: 20px; border-radius: 18px; }
    .visual-stats { grid-template-columns: 1fr; }
    .home-proof { grid-template-columns: 1fr; }
    .home-proof { grid-template-columns: 1fr; }
    .quick-start { padding: 24px; }
    .quick-start-steps { grid-template-columns: 1fr; }
    .about-main { padding-top: 90px; }
    .about-intro h1 { font-size: 48px; }
    .team-members { margin-top: 56px; }
    .team-members-grid { grid-template-columns: 1fr; }
    .team-member-headshot { min-height: 210px; }
    .team-member-card img.team-member-headshot { height: 280px; }
    .app-main { padding: 18px 14px 36px; }
    .stacked-area-wrap { height: 235px; }
    .stacked-area-sensor { grid-template-columns: 1fr; }
    .stacked-area-actions { flex-wrap: wrap; }
}

@media (min-width: 960px) {
    .dashboard-grid {
        display: flex;
        flex-direction: column;
     
    }

    .dashboard-grid > .dashboard-box:only-child {
        flex: 1 1 100%;
    }

    .chart-box {
        flex: 2 1 0;
    }

    .metrics-box {
        flex: 0 1 250px;
        position: sticky;
        top: 1rem;
    }

    .metrics-row {
        grid-template-columns: 1fr;
    }

    .metric-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.5rem;
    }
}

@media (min-width: 1180px) {
    .live-charts {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

/* Historical deviation review */
.analysis-subnav {
    display: flex;
    gap: 8px;
    margin: -8px 0 22px;
    padding: 5px;
    width: fit-content;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
}

.analysis-subnav-link {
    padding: 9px 14px;
    border-radius: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 750;
    text-decoration: none;
}

.analysis-subnav-link:hover { color: var(--ink); background: var(--canvas); }
.analysis-subnav-link.active { color: var(--navy); background: var(--mint); }

.deviation-workspace { margin-bottom: 20px; }
.deviation-page-heading { margin-bottom: 22px; }
.deviation-page-heading h2 { margin: 5px 0 7px; font-size: clamp(25px, 3vw, 34px); }

.deviation-analysis-form {
    display: grid;
    grid-template-columns: minmax(180px, 1.4fr) minmax(180px, 1.4fr) minmax(145px, .7fr) minmax(145px, .7fr);
    gap: 14px;
    align-items: end;
}

.deviation-analysis-form label:not(.deviation-checkbox-field) {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 750;
}

.deviation-analysis-form select,
.deviation-analysis-form input[type="number"] {
    width: 100%;
    min-height: 44px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
}

.deviation-checkbox-field {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 44px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
}

.deviation-checkbox-field input { width: 18px; height: 18px; accent-color: var(--mint-dark); }
.deviation-analysis-form .primary-action { min-height: 44px; }
.deviation-request-status { margin: 15px 0 0; color: var(--muted); font-size: 13px; }

.deviation-results { display: grid; gap: 20px; }
.deviation-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.deviation-summary-card {
    display: grid;
    gap: 5px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: var(--surface);
}
.deviation-summary-card span { color: var(--muted); font-size: 12px; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.deviation-summary-card strong { font-size: 28px; line-height: 1; }
.deviation-summary-card small { color: var(--muted); line-height: 1.4; }
.deviation-summary-card-priority { border-color: #efc4c4; }
.deviation-summary-card-priority strong { color: #b42318; }

.deviation-chart-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.deviation-legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 16px; max-width: 520px; color: var(--muted); font-size: 12px; }
.deviation-legend span { display: inline-flex; align-items: center; gap: 6px; }
.deviation-legend i { width: 19px; height: 4px; border-radius: 999px; display: inline-block; }
.legend-current { background: #1479b8; }
.legend-envelope { height: 10px !important; background: rgba(20,121,184,.18); border: 1px solid rgba(20,121,184,.42); }
.legend-brief { background: #d5a000; }
.legend-unusual { background: #d98200; }
.legend-priority { background: #c62828; }
.deviation-chart-wrap { position: relative; height: 430px; margin-top: 18px; }

.deviation-table-wrap { overflow-x: auto; }
.deviation-events-table { width: 100%; border-collapse: collapse; margin-top: 16px; font-size: 13px; }
.deviation-events-table th,
.deviation-events-table td { padding: 12px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.deviation-events-table th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.deviation-event-row { cursor: pointer; }
.deviation-event-row:hover,
.deviation-event-row:focus { background: rgba(20,121,184,.06); outline: none; }
.deviation-event-row:focus-visible { box-shadow: inset 0 0 0 2px var(--mint-dark); }
.deviation-classification { display: inline-flex; padding: 5px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.deviation-classification.brief_deviation { color: #765b00; background: #fff2b8; }
.deviation-classification.unusual_behavior { color: #8a4800; background: #ffdfb3; }
.deviation-classification.high_priority_review { color: #9b1c1c; background: #fee2e2; }
.deviation-events-empty { margin: 18px 0 2px; padding: 18px; border: 1px dashed var(--line); border-radius: 10px; color: var(--muted); text-align: center; }

.dark-mode .analysis-subnav,
.dark-mode .deviation-summary-card { background: var(--surface); border-color: var(--line); }
.dark-mode .analysis-subnav-link.active { color: #071622; }
.dark-mode .deviation-analysis-form select,
.dark-mode .deviation-analysis-form input[type="number"] { background: #101c2c; border-color: var(--line); color: var(--ink); }
.dark-mode .deviation-summary-card-priority { border-color: #7f3f45; }
.dark-mode .deviation-summary-card-priority strong { color: #ff9b91; }
.dark-mode .deviation-event-row:hover,
.dark-mode .deviation-event-row:focus { background: rgba(111,147,199,.1); }
.dark-mode .deviation-classification.brief_deviation { color: #f7d774; background: #433813; }
.dark-mode .deviation-classification.unusual_behavior { color: #fdba74; background: #4a2b12; }
.dark-mode .deviation-classification.high_priority_review { color: #ffb4ab; background: #4a1f2a; }

@media (max-width: 1100px) {
    .deviation-analysis-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .deviation-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .deviation-chart-heading { flex-direction: column; }
    .deviation-legend { justify-content: flex-start; }
}

@media (max-width: 650px) {
    .analysis-subnav { width: 100%; }
    .analysis-subnav-link { flex: 1; text-align: center; }
    .deviation-analysis-form,
    .deviation-summary-grid { grid-template-columns: 1fr; }
    .deviation-chart-wrap { height: 310px; }
}

.boundary-run-picker {
    border: 1px solid var(--border-color, #cbd5e1);
    border-radius: 8px;
    margin: 16px 0;
    padding: 12px 16px;
}
.boundary-run-picker legend { font-weight: 600; padding: 0 6px; }
.boundary-run-options { display: flex; flex-wrap: wrap; gap: 10px 20px; max-height: 180px; overflow-y: auto; }
.boundary-run-options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Standby Review: independent sensor matches within a shared run list. */
.standby-run-field { display: flex; flex-direction: column; gap: 8px; max-width: 480px; margin-bottom: 8px; font-weight: 600; }
.standby-run-field select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit; }
.standby-results { margin-top: 24px; }
.standby-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr)); gap: 14px; margin: 18px 0 24px; }
.standby-summary-card { padding: 20px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.standby-summary-card h4 { margin: 0 0 10px; }
.standby-summary-card p { margin: 8px 0; }
.standby-help { color: var(--muted); font-size: 13px; line-height: 1.6; }
.standby-applied { color: var(--ink); font-size: 14px; }
.standby-notice { padding: 14px 18px; border: 1px solid var(--line); border-left: 4px solid #d98200; border-radius: 8px; background: var(--surface); }
.standby-match { border-top: 1px solid var(--line); }
.standby-match summary { cursor: pointer; padding: 20px; }
.standby-match summary strong { margin-right: 18px; }
.standby-match-count { display: inline-block; margin-left: 18px; color: var(--muted); font-size: 13px; }
.standby-match-content { padding: 0 20px 20px; }
.standby-match-content > p { margin-bottom: 14px; }
.standby-chart-wrap { position: relative; height: 270px; margin: 18px 0; }
.standby-table-wrap { overflow-x: auto; margin-top: 18px; }
.standby-table-wrap table { min-width: 680px; }
.standby-table-wrap caption { text-align: left; caption-side: bottom; padding: 12px 0; }
.standby-workspace [hidden] { display: none !important; }
.standby-workspace .error { color: #b42318; }
.dark-mode .standby-workspace .error { color: #ff9b91; }
@media (max-width: 700px) {
    .analysis-subnav { flex-wrap: wrap; }
    .standby-match summary .standby-applied, .standby-match-count { display: block; margin: 8px 0 0; }
    .standby-workspace .historical-builder-labels { flex-wrap: wrap; gap: 8px; }
}
@media (max-width: 600px) {
    .standby-workspace .historical-condition { grid-template-columns: minmax(0, 1fr) 40px; }
    .standby-workspace .historical-condition-number { grid-column: 1; grid-row: 1; }
    .standby-workspace .remove-historical-condition { grid-column: 2; grid-row: 1; }
    .standby-workspace .historical-sensor-field { grid-column: 1 / -1; grid-row: 2; }
    .standby-workspace .historical-minimum-field { grid-column: 1 / -1; grid-row: 3; }
    .standby-workspace .historical-maximum-field { grid-column: 1 / -1; grid-row: 4; }
    .standby-workspace .historical-condition-summary { grid-column: 1 / -1; grid-row: 5; }
}

.app-toolbar .top-nav {
    overflow: visible;
    flex-wrap: wrap;
}

    .app-toolbar .top-nav > details {
        flex: 1 1 0;
    }

        .app-toolbar .top-nav > details > summary {
            display: flex;
        }
