* {
    box-sizing: border-box
}

:root {
    --bg: #0b1020;
    --panel: #161f3d;
    --panel2: #1d2950;
    --text: #ebf0ff;
    --muted: #9eb0db;
    --line: #2c3a69;
    --accent: #72a8ff
}

body {
    margin: 0;
    font-family: Inter, system-ui, Arial, sans-serif;
    background: linear-gradient(180deg, var(--bg), #09111f);
    color: var(--text)
}

.shell {
    display: grid;
    grid-template-columns: 310px 1fr;
    min-height: 100vh
}

.side {
    padding: 18px;
    border-right: 1px solid var(--line);
    background: rgba(13, 19, 39, .92);
    height: 100vh;
    position: sticky;
    top: 0;
    overflow: auto
}

main {
    padding: 18px
}

.panel,
.card {
    background: linear-gradient(180deg, var(--panel), var(--panel2));
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .18)
}

.panel {
    padding: 14px;
    margin: 14px 0
}

.card {
    padding: 14px
}

h1,
h2,
h3 {
    margin: 0 0 10px
}

.muted {
    color: var(--muted)
}

.small,
.status {
    font-size: .88rem;
    color: var(--muted)
}

label {
    display: block;
    margin: 10px 0;
    font-size: .92rem
}

input,
select,
button {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0f1731;
    color: var(--text)
}

button {
    cursor: pointer;
    font-weight: 700
}

button.primary,
.nav.active {
    border: none;
    background: linear-gradient(180deg, #5d92ff, #4075e1)
}

button+button {
    margin-top: 8px
}

.nav {
    text-align: left;
    margin-bottom: 8px
}

.tab {
    display: none
}

.tab.active {
    display: block
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px
}

.pill {
    padding: 8px 12px;
    border-radius: 999px;
    background: #101937;
    border: 1px solid var(--line);
    color: var(--muted);
    font-size: .88rem
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 16px
}

.wide {
    grid-column: span 2
}

.controls {
    min-width: 260px
}

canvas {
    width: 100%;
    height: auto;
    background: #0d1530;
    border: 1px solid var(--line);
    border-radius: 12px
}

.legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 10px
}

.legendItem {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: .88rem
}

.swatch {
    width: 12px;
    height: 12px;
    border-radius: 999px
}

.det {
    padding: 10px 0;
    border-bottom: 1px solid var(--line)
}

.det:last-child {
    border-bottom: none
}

.detTitle {
    font-weight: 700
}

.detText {
    color: var(--muted);
    font-size: .86rem
}

.hm {
    display: grid;
    gap: 8px
}

.hmRow {
    display: grid;
    grid-template-columns: 62px repeat(8, minmax(48px, 1fr));
    gap: 6px
}

.hmHead,
.hmBed,
.hmCell {
    padding: 8px 6px;
    border-radius: 10px;
    text-align: center;
    font-size: .8rem
}

.hmHead,
.hmBed {
    background: #0f1731;
    border: 1px solid var(--line)
}

.hmCell {
    font-weight: 700
}

.good {
    background: rgba(45, 178, 125, .22)
}

.warn {
    background: rgba(216, 160, 49, .25)
}

.bad {
    background: rgba(214, 92, 92, .3)
}

.tableWrap {
    overflow: auto;
    max-height: 360px
}

table {
    width: 100%;
    border-collapse: collapse
}

th,
td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    text-align: left;
    font-size: .86rem
}

th {
    color: var(--muted);
    position: sticky;
    top: 0;
    background: #16203d
}

.workCard {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937;
    margin: 8px 0
}

code {
    background: #101937;
    padding: 2px 6px;
    border-radius: 8px
}

@media(max-width:1150px) {
    .shell {
        grid-template-columns: 1fr
    }

    .side {
        height: auto;
        position: relative
    }

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

    .wide {
        grid-column: auto
    }
}

.codebox {
    white-space: pre-wrap;
    overflow: auto;
    max-height: 260px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0f1731;
    color: var(--muted)
}

.sectionTitleRow {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center
}

.sectionTitleRow>div {
    display: flex;
    gap: 8px
}

.sectionTitleRow button {
    width: auto;
    margin: 0
}

.healthBadge {
    display: inline-block;
    min-width: 46px;
    padding: 4px 8px;
    border-radius: 999px;
    text-align: center;
    font-weight: 700
}

.healthGood {
    background: rgba(45, 178, 125, .22)
}

.healthWatch {
    background: rgba(216, 160, 49, .22)
}

.healthBad {
    background: rgba(214, 92, 92, .28)
}

.checkline {
    display: flex;
    align-items: center;
    gap: 8px
}

.checkline input {
    width: auto;
    margin: 0
}

.sev-normal {
    color: #8dd9b3
}

.sev-watch {
    color: #e1bd69
}

.sev-warn {
    color: #f0a85e
}

.sev-alarm {
    color: #ff7d7d;
    font-weight: 700
}

.confBar {
    height: 8px;
    border-radius: 999px;
    background: #0f1731;
    overflow: hidden;
    margin-top: 5px
}

.confFill {
    height: 100%;
    background: linear-gradient(90deg, #5d92ff, #d65c5c)
}

.trend-degrading {
    color: #ff7d7d;
    font-weight: 700
}

.trend-stable {
    color: #e1bd69
}

.trend-improving {
    color: #8dd9b3;
    font-weight: 700
}

textarea {
    width: 100%;
    margin-top: 6px;
    padding: 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #0f1731;
    color: var(--text);
    resize: vertical
}

.kpiGrid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px
}

.kpiBox {
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937
}

.kpiValue {
    font-size: 1.3rem;
    font-weight: 800
}

.effect-strong_improvement {
    color: #75e6a8;
    font-weight: 800
}

.effect-improved {
    color: #9dd9b7;
    font-weight: 700
}

.effect-no_material_change {
    color: #e1bd69
}

.effect-worse {
    color: #f0a85e;
    font-weight: 700
}

.effect-strongly_worse {
    color: #ff7d7d;
    font-weight: 800
}

.effectScore {
    font-size: 2rem;
    font-weight: 900;
    margin-bottom: 6px
}

.crosshairReadout {
    margin-top: 8px;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #0f1731;
    color: var(--muted);
    font-size: .84rem;
    min-height: 34px
}

.reviewJson {
    max-height: 420px
}

.chartHint {
    color: var(--muted);
    font-size: .78rem;
    margin-top: 5px
}

.timelineLegend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px
}

.timelineKey {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    color: var(--muted)
}

.timelineChip {
    width: 18px;
    height: 10px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, .18)
}

.timelineAlertChip {
    width: 18px;
    height: 10px;
    border-radius: 3px;
    border: 2px solid #ff6b6b;
    background: transparent
}

.chartSubnote {
    font-size: .78rem;
    color: var(--muted);
    margin-top: 5px
}

.buttonRow {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px
}

.anomalyItem {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px;
    margin-bottom: 8px;
    background: #101937;
    cursor: pointer
}

.anomalyItem:hover {
    border-color: #5d92ff
}

.anomalyItem.active {
    outline: 2px solid #5d92ff
}

.anomalyAlarm {
    color: #ff7d7d;
    font-weight: 800
}

.anomalyWarn {
    color: #f0a85e;
    font-weight: 700
}

.anomalyWatch {
    color: #e1bd69;
    font-weight: 700
}

.piMarkerLabel {
    font-size: .72rem
}

#evidence textarea {
    width: 100%;
    box-sizing: border-box;
    background: #0d1530;
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 9px
}

.evidenceAssessment {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937;
}

.evidenceAssessmentValue {
    margin-top: 3px;
    font-size: 1.15rem;
    font-weight: 900;
    letter-spacing: .03em;
}

.evidenceDetailGrid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.evidenceDetailSection {
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937;
}

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

.evidenceMetric {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 7px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
    font-size: .88rem;
}

.evidenceMetric:last-child {
    border-bottom: none;
}

.evidenceMetric span {
    color: var(--muted);
}

.evidenceMetric b {
    text-align: right;
}

.evidenceSubtext {
    margin: 8px 0 10px;
}

.evidenceCoverageRow {
    padding: 9px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.evidenceCoverageRow:last-child {
    border-bottom: none;
}

.evidenceCoverageHeading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 3px;
}

.evidenceCoverageBadge {
    display: inline-block;
    flex-shrink: 0;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .035em;
    border: 1px solid currentColor;
}

.evidenceYes {
    color: #75e6a8;
}

.evidenceNeutral {
    color: #e1bd69;
}

.evidenceNA {
    color: var(--muted);
}

.evidenceInterpretation {
    margin-top: 14px;
    padding: 13px 14px;
    border-left: 3px solid #5d92ff;
    border-radius: 8px;
    background: #101937;
}

@media(max-width:900px) {
    .evidenceDetailGrid {
        grid-template-columns: 1fr;
    }

    .evidenceAssessment {
        align-items: flex-start;
        flex-direction: column;
    }
}

.savedInvestigationCard {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}

.savedInvestigationCard:last-child {
    border-bottom: none;
}

.savedInvestigationOpen {
    width: auto;
    min-width: 190px;
    margin: 0;
}

.savedSnapshotHeader {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    padding: 13px 14px;
    margin-bottom: 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937;
}

.savedSnapshotMeta {
    text-align: right;
    color: var(--muted);
    font-size: .78rem;
    line-height: 1.5;
}

.savedSnapshotNotes {
    margin-top: 14px;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #101937;
}

@media(max-width:900px) {
    .savedInvestigationCard {
        grid-template-columns: 1fr;
    }

    .savedInvestigationOpen {
        width: 100%;
    }

    .savedSnapshotHeader {
        flex-direction: column;
    }

    .savedSnapshotMeta {
        text-align: left;
    }
}

.savedInvestigationSummary {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: .86rem;
}

.investigationHistoryTable .savedInvestigationOpen {
    width: auto;
    min-width: 88px;
    margin: 0;
    padding: 7px 12px;
}

.investigationStatus {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
    border: 1px solid currentColor;
}

.investigationStatus-open {
    color: #72a8ff;
}

.investigationStatus-closed {
    color: #75e6a8;
}

.investigationViewButton {
    width: auto;
    margin: 0;
    padding: 7px 11px;
    font-size: .78rem;
}

.investigationViewButton.active {
    border-color: #72a8ff;
    background: #17264d;
}

.savedInvestigationSummary {
    margin-bottom: 10px;
    color: var(--muted);
    font-size: .86rem;
}

.investigationHistoryTable .savedInvestigationOpen {
    width: auto;
    min-width: 78px;
    margin: 0;
    padding: 7px 11px;
}

.investigationStatus {
    display: inline-block;
    padding: 3px 7px;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
    border: 1px solid currentColor;
}

.investigationStatus-open {
    color: #72a8ff;
}

.investigationStatus-closed {
    color: #75e6a8;
}