:root {
    color-scheme: dark;
    --bg: #0f172a;
    --panel: #111c32;
    --panel-soft: #17233b;
    --text: #e5edf7;
    --muted: #9fb0c8;
    --border: #263854;
    --green: #22c55e;
    --red: #ef4444;
    --blue: #38bdf8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: radial-gradient(circle at top left, #1d3b65 0, var(--bg) 36rem);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0;
}

.hero,
.section-title,
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin: 0;
}

h1 {
    font-size: clamp(2rem, 5vw, 4rem);
    line-height: 1;
}

.subtitle,
.resource-target,
#range-label,
.counts {
    color: var(--muted);
}

.panel,
.card,
.message {
    background: color-mix(in srgb, var(--panel) 92%, transparent);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 22px 60px rgb(0 0 0 / 0.22);
}

.panel,
.message {
    margin-top: 24px;
    padding: 20px;
}

.button {
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--panel-soft);
    color: var(--text);
    cursor: pointer;
    font-weight: 700;
    padding: 10px 16px;
}

.button:hover,
.button.active {
    border-color: var(--blue);
    color: white;
}

.button.primary {
    background: var(--blue);
    border-color: var(--blue);
    color: #06111f;
}

.controls {
    display: grid;
    gap: 18px;
    padding: 24px;
}

.controls-row {
    display: grid;
    gap: 16px;
}

.controls-row-top {
    grid-template-columns: 1fr;
}

.custom-range {
    grid-template-columns: minmax(220px, 1fr) minmax(210px, 260px) minmax(210px, 260px) auto;
    align-items: end;
}

.control-group,
.control-field {
    display: grid;
    gap: 8px;
}

.quick-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.quick-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.quick-filters .button {
    min-width: 96px;
    text-align: center;
}

.refresh-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: #0b1324;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
    padding: 0 12px;
    white-space: nowrap;
}

.refresh-chip:focus-within {
    border-color: var(--blue);
}

.refresh-chip input {
    width: 48px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text);
    font: inherit;
    padding: 0;
    text-align: center;
}

.control-label,
.control-field {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 800;
}

label {
    display: grid;
    gap: 6px;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 700;
}

label.control-field {
    gap: 8px;
    font-weight: 800;
}

input {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #0b1324;
    color: var(--text);
    padding: 10px;
    width: 100%;
}

.apply-button {
    min-height: 41px;
    padding-inline: 22px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr));
    gap: 18px;
    margin-top: 24px;
}

.card {
    padding: 20px;
}

.empty-card {
    display: grid;
    gap: 8px;
    min-height: 140px;
    place-content: center;
    text-align: center;
}

.card-header {
    align-items: flex-start;
}

.card-header > :first-child {
    min-width: 0;
}

.resource-name {
    font-size: 1.15rem;
}

.resource-target {
    margin-top: 4px;
    overflow-wrap: anywhere;
}

.resource-type {
    border-radius: 999px;
    background: #0b1324;
    color: var(--blue);
    font-size: 0.75rem;
    font-weight: 800;
    padding: 6px 10px;
}

.badges {
    display: flex;
    flex-direction: column;
    align-items: end;
    gap: 8px;
}

.status-badge {
    border-radius: 999px;
    color: #06111f;
    font-size: 0.75rem;
    font-weight: 900;
    padding: 6px 10px;
    text-transform: uppercase;
}

.status-badge.unknown {
    background: var(--border);
    color: var(--muted);
}

.card.status-online {
    border-color: color-mix(in srgb, var(--green) 70%, var(--border));
    box-shadow: 0 0 0 1px rgb(34 197 94 / 0.25), 0 22px 60px rgb(0 0 0 / 0.22);
}

.card.status-offline {
    border-color: color-mix(in srgb, var(--red) 70%, var(--border));
    box-shadow: 0 0 0 1px rgb(239 68 68 / 0.25), 0 22px 60px rgb(0 0 0 / 0.22);
}

.card.status-unknown {
    border-color: var(--border);
}

.availability {
    margin: 24px 0 4px;
    font-size: 3rem;
    font-weight: 900;
}

.checks-summary {
    display: grid;
    gap: 8px;
    margin-top: 18px;
}

.check-summary-row {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border-radius: 12px;
    background: #0b1324;
    padding: 10px;
}

.check-summary-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sparkline {
    position: relative;
    margin-top: 18px;
    overflow: hidden;
    height: 16px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #0b1324;
}

.sparkline-segment {
    position: absolute;
    top: 0;
    bottom: 0;
    border-radius: 0;
    min-width: 0;
}

.sparkline-segment.cap-left {
    border-top-left-radius: 999px;
    border-bottom-left-radius: 999px;
}

.sparkline-segment.cap-right {
    border-top-right-radius: 999px;
    border-bottom-right-radius: 999px;
}

.online,
.status-dot.online {
    background: var(--green);
}

.offline,
.status-dot.offline {
    background: var(--red);
}

.status-dot.unknown {
    background: var(--border);
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 800;
}

.timeline-meta {
    display: grid;
    justify-items: end;
    gap: 8px;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 4px;
}

.status-graph {
    display: grid;
    gap: 14px;
    margin-top: 22px;
}

.graph-axis,
.graph-row {
    display: grid;
    grid-template-columns: 220px minmax(260px, 1fr);
    gap: 16px;
}

.graph-axis {
    color: var(--muted);
    font-size: 0.82rem;
    grid-template-columns: 220px minmax(260px, 1fr);
}

.graph-axis::before {
    content: "";
}

.graph-axis span {
    grid-column: 2;
    grid-row: 1;
}

.axis-start {
    justify-self: start;
}

.axis-middle {
    justify-self: center;
}

.axis-end {
    justify-self: end;
}

.graph-label {
    display: grid;
    gap: 3px;
    min-width: 0;
}

.graph-label strong,
.graph-label span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.graph-label span {
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.graph-track {
    position: relative;
    min-height: 42px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background:
            linear-gradient(90deg, transparent 0 49.8%, rgb(255 255 255 / 0.08) 49.8% 50.2%, transparent 50.2% 100%),
            #0b1324;
}

.graph-segment {
    position: absolute;
    top: 50%;
    height: 18px;
    transform: translateY(-50%);
    border-radius: 0;
    min-width: 0;
}

.graph-segment.cap-left {
    border-top-left-radius: 999px;
    border-bottom-left-radius: 999px;
}

.graph-segment.cap-right {
    border-top-right-radius: 999px;
    border-bottom-right-radius: 999px;
}

.clickable {
    cursor: pointer;
}

.clickable:hover {
    filter: brightness(1.18);
}

.graph-empty {
    display: inline-block;
    color: var(--muted);
    padding: 11px 14px;
}

.panel-empty {
    grid-column: 1 / -1;
    color: var(--muted);
    padding: 8px 0;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 360px), 1fr));
    gap: 16px;
    margin-top: 18px;
}

.metric-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    background: #0b1324;
    padding: 16px;
}

.metric-card-header,
.metric-footer {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.metric-card h3 {
    font-size: 1rem;
    overflow-wrap: anywhere;
}

.metric-latest {
    color: var(--blue);
    font-size: 1.35rem;
    font-weight: 900;
    text-align: right;
    white-space: nowrap;
}

.metric-chart {
    position: relative;
    height: 190px;
    margin-top: 16px;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 16px;
    background:
            linear-gradient(90deg, transparent 0 49.8%, rgb(255 255 255 / 0.07) 49.8% 50.2%, transparent 50.2% 100%),
            linear-gradient(0deg, transparent 0 49.8%, rgb(255 255 255 / 0.07) 49.8% 50.2%, transparent 50.2% 100%),
            #081120;
}

.metric-line-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.metric-line {
    fill: none;
    stroke: var(--blue);
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.35;
    vector-effect: non-scaling-stroke;
}

.metric-axis-label {
    position: absolute;
    right: 10px;
    max-width: calc(100% - 20px);
    overflow: hidden;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-axis-label.top {
    top: 8px;
}

.metric-axis-label.bottom {
    bottom: 8px;
}

.metric-chart-empty {
    display: inline-block;
    color: var(--muted);
    padding: 14px;
}

.metric-footer {
    margin-top: 10px;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 800;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.failure-dialog {
    width: min(760px, calc(100% - 32px));
    max-height: min(760px, calc(100vh - 32px));
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: 22px;
    background: var(--panel);
    color: var(--text);
    padding: 22px;
    box-shadow: 0 30px 80px rgb(0 0 0 / 0.45);
}

.failure-dialog::backdrop {
    background: rgb(2 6 23 / 0.72);
    backdrop-filter: blur(3px);
}

.dialog-header,
.failure-item-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.failure-list {
    display: grid;
    gap: 12px;
    margin-top: 20px;
}

.failure-item {
    border: 1px solid color-mix(in srgb, var(--red) 55%, var(--border));
    border-radius: 16px;
    background: #0b1324;
    padding: 14px;
}

.failure-item-header {
    justify-content: flex-start;
    align-items: center;
    margin-bottom: 12px;
}

.failure-item dl {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px 14px;
    margin: 0;
}

.failure-item dt {
    color: var(--muted);
    font-weight: 800;
}

.failure-item dd {
    margin: 0;
    overflow-wrap: anywhere;
}

@media (max-width: 820px) {
    .hero,
    .section-title {
        align-items: stretch;
        flex-direction: column;
    }

    .controls-row-top,
    .custom-range {
        grid-template-columns: 1fr;
    }

    .quick-filters .button,
    .refresh-chip,
    .apply-button {
        width: 100%;
    }

    .quick-toolbar {
        align-items: stretch;
    }

    .card-header {
        flex-direction: column;
    }

    .badges {
        align-items: start;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .metric-card-header,
    .metric-footer {
        align-items: stretch;
        flex-direction: column;
    }

    .metric-latest {
        text-align: left;
    }

    .graph-axis,
    .graph-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .graph-axis::before {
        display: none;
    }

    .graph-axis span {
        grid-column: 1;
    }

    .timeline-meta {
        justify-items: start;
    }

    .dialog-header {
        flex-direction: column;
    }

    .failure-item dl {
        grid-template-columns: 1fr;
    }
}
