:root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #242422;
    --border: rgba(255, 255, 255, 0.10);
    --text: #ffffff;
    --text-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --accent: #3987e5;
    --good: #0ca30c;
    --warn: #fab219;
    --serious: #ec835a;
    --crit: #d03b3b;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --violet: #9085e9;
}
@media (prefers-color-scheme: light) {
    :root {
        color-scheme: light;
        --page: #f9f9f7;
        --surface: #fcfcfb;
        --surface-2: #f0efec;
        --border: rgba(11, 11, 11, 0.10);
        --text: #0b0b0b;
        --text-2: #52514e;
        --grid: #e1e0d9;
        --axis: #c3c2b7;
        --accent: #2a78d6;
        --series-1: #2a78d6;
        --series-2: #eb6834;
        --series-3: #1baf7a;
        --violet: #4a3aa7;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--page);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 48px; }
[hidden] { display: none !important; }

header.top {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 18px 0 14px;
}
header.top h1 { font-size: 18px; font-weight: 600; margin: 0 auto 0 0; }
.tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; }
.tabs button { background: none; color: var(--text-2); border: 0; padding: 7px 16px; border-radius: 7px; font: inherit; font-weight: 500; cursor: pointer; }
.tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px; margin-top: 14px; }
.card h2 { font-size: 14px; font-weight: 600; margin: 0 0 12px; }
.card h2 small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.note { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

button, .btn {
    font: inherit; font-weight: 500; cursor: pointer; text-decoration: none; display: inline-block;
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 14px;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button.primary { background: var(--accent); border-color: transparent; color: #fff; }
button.danger { color: var(--crit); }
button.small { padding: 5px 10px; font-size: 13px; }
button.link { background: none; border: 0; color: var(--text-2); padding: 7px 4px; }
input, select {
    font: inherit; color: var(--text); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px;
}
input[type="number"] { width: 76px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 10px; }
label { color: var(--text-2); }

/* status */
.state { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.up { background: var(--good); }
.dot.down { background: var(--crit); }
.dot.warn { background: var(--warn); }
.dot.k-internet { background: var(--crit); }
.dot.k-gateway { background: var(--serious); }
.dot.k-wifi { background: var(--accent); }
.dot.k-dns { background: var(--violet); }
.dot.k-degraded { background: var(--warn); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.kv div span { display: block; color: var(--muted); font-size: 13px; }
.kv div b { font-weight: 600; }

.live { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; margin-top: 14px; }
.live .card { margin: 0; padding: 14px 16px; }
.live .name { color: var(--muted); font-size: 13px; }
.live .state { font-size: 17px; margin: 3px 0; }
.live .sub { color: var(--text-2); font-size: 13px; }

.banner { margin-top: 14px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--warn); color: var(--text); background: var(--surface); }

/* filters */
.filters { display: flex; gap: 10px 14px; flex-wrap: wrap; align-items: center; margin-top: 22px; }
.seg { display: flex; background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 3px; }
.seg button { border: 0; background: none; color: var(--text-2); padding: 5px 11px; border-radius: 6px; }
.seg button[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.chip { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 5px 12px; color: var(--muted); background: none; }
.chip[aria-pressed="true"] { color: var(--text); background: var(--surface-2); }
.chip[aria-pressed="false"] .dot { opacity: 0.35; }
.custom { display: flex; gap: 6px; align-items: center; color: var(--muted); }

/* tiles */
.tiles { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 12px; margin-top: 14px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.2; margin-top: 4px; }
.tile.hero .value { font-size: 48px; }
.tile .sub { color: var(--text-2); font-size: 13px; margin-top: 2px; }
@media (max-width: 760px) { .tiles { grid-template-columns: 1fr 1fr; } .tile.hero { grid-column: 1 / -1; } }

/* timeline */
.strip { display: flex; gap: 2px; height: 40px; }
.strip.dense { gap: 1px; }
.strip i { flex: 1; min-width: 1px; border-radius: 2px; background: var(--good); opacity: 0.55; }
.strip i.down { background: var(--crit); }
.strip i.nodata { background: var(--surface-2); opacity: 1; }
.strip i:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.axis-row { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin-top: 6px; font-variant-numeric: tabular-nums; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; color: var(--text-2); font-size: 13px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend i.line { height: 2px; width: 16px; border-radius: 1px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.card-head h2 { margin: 0; }

/* heatmap */
.heat { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; font-size: 12px; color: var(--muted); }
.heat b { font-weight: 400; display: flex; align-items: center; }
.heat i { aspect-ratio: 1.5; min-height: 14px; border-radius: 2px; background: var(--surface-2); position: relative; overflow: hidden; }
.heat i s { position: absolute; inset: 0; background: var(--accent); }
.heat i:hover { outline: 2px solid var(--text); outline-offset: 1px; }
.heat .h { text-align: left; font-variant-numeric: tabular-nums; }

/* charts */
.chart { position: relative; }
.chart svg { display: block; width: 100%; }
.chart text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .base { stroke: var(--axis); stroke-width: 1; }
.chart .cross { stroke: var(--muted); stroke-width: 1; }
.chart-title { color: var(--text-2); font-size: 13px; margin: 14px 0 6px; }

.tip {
    position: fixed; z-index: 10; pointer-events: none; max-width: 260px;
    background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
    border-radius: 8px; padding: 8px 10px; font-size: 13px; box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.tip b { display: block; margin-bottom: 3px; }
.tip div { display: flex; align-items: center; gap: 6px; color: var(--text-2); white-space: nowrap; }
.tip div em { margin-left: auto; padding-left: 14px; color: var(--text); font-style: normal; font-variant-numeric: tabular-nums; }

/* tables */
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 500; font-size: 13px; padding: 6px 10px 8px 0; border-bottom: 1px solid var(--axis); white-space: nowrap; }
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--grid); vertical-align: top; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.detail { white-space: normal; color: var(--text-2); min-width: 160px; }
td .state { font-weight: 500; }
.empty { color: var(--muted); padding: 14px 0 4px; }

/* schedules */
.sched { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 0; border-bottom: 1px solid var(--grid); }
.sched .meta { color: var(--muted); font-size: 13px; }
.sched.off .title { color: var(--muted); }
.days label { margin-right: 10px; white-space: nowrap; }
form.add { margin-top: 16px; }

.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.toast.error { border-color: var(--crit); }

/* login */
.login { max-width: 340px; margin: 16vh auto 0; padding: 0 16px; }
.login h1 { font-size: 20px; font-weight: 600; margin: 0 0 16px; }
.login input { width: 100%; margin: 6px 0 12px; padding: 10px 12px; }
.login button { width: 100%; padding: 10px; }
.login .error { color: var(--crit); margin: 0 0 12px; }
