﻿:root {
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #eef0f4;
    --text: #151821;
    --muted: #5f6776;
    --border: #e0e4eb;
    --track: #e6e9ef;
    --dl: #2563eb;
    --ul: #7c3aed;
    --accent: #2563eb;
    --good: #15803d;
    --good-bg: #dcfce7;
    --bad: #b91c1c;
    --bad-bg: #fee2e2;
    --warn: #b45309;
    --shadow: 0 1px 2px rgba(16,24,40,.05),0 4px 16px rgba(16,24,40,.06);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0d1016;
        --surface: #161a23;
        --surface-2: #1e2430;
        --text: #e9ecf2;
        --muted: #9aa3b3;
        --border: #283040;
        --track: #252c39;
        --dl: #60a5fa;
        --ul: #a78bfa;
        --accent: #60a5fa;
        --good: #4ade80;
        --good-bg: #14301f;
        --bad: #f87171;
        --bad-bg: #3a1a1a;
        --warn: #fbbf24;
        --shadow: none;
    }
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.5 system-ui,-apple-system,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
    -webkit-font-smoothing: antialiased
}

.wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 32px 16px 48px
}

header h1 {
    font-size: 26px;
    margin: 0 0 4px;
    letter-spacing: -.01em
}

header p {
    margin: 0;
    color: var(--muted)
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px
}

.main {
    margin-top: 20px;
    display: grid;
    grid-template-columns: minmax(0,1.1fr) minmax(0,1fr);
    gap: 20px;
    align-items: center
}

@media (max-width:760px) {
    .main {
        grid-template-columns: minmax(0,1fr)
    }
}

.gauge {
    position: relative;
    width: 100%;
    max-width: 340px;
    margin: 0 auto
}

    .gauge svg {
        display: block;
        width: 100%;
        height: auto
    }

    .gauge .center {
        position: absolute;
        left: 0;
        right: 0;
        top: 40%;
        text-align: center;
        pointer-events: none
    }

    .gauge .val {
        font-size: 46px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        letter-spacing: -.02em;
        line-height: 1
    }

    .gauge .unit {
        color: var(--muted);
        font-size: 14px;
        margin-top: 4px
    }

    .gauge .phase {
        font-size: 13px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .06em;
        margin-top: 10px;
        color: var(--muted)
    }

.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 8px
}

button {
    font: inherit;
    cursor: pointer;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    padding: 8px 14px
}

    button:hover {
        border-color: var(--muted)
    }

    button.primary {
        background: var(--accent);
        border-color: var(--accent);
        color: #fff;
        font-weight: 600;
        padding: 12px 28px;
        font-size: 16px;
        min-width: 160px
    }

@media (prefers-color-scheme: dark) {
    button.primary {
        color: #0d1016
    }
}

button:disabled {
    opacity: .55;
    cursor: default
}

.opts {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 14px;
    font-size: 14px;
    color: var(--muted)
}

    .opts label {
        display: flex;
        align-items: center;
        gap: 6px
    }

select, input[type=text] {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 8px
}

input[type=text] {
    width: 150px
}

.metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px
}

.metric {
    background: var(--surface-2);
    border-radius: 12px;
    padding: 14px
}

    .metric .lbl {
        font-size: 13px;
        color: var(--muted);
        display: flex;
        align-items: center;
        gap: 6px
    }

    .metric .num {
        font-size: 28px;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        margin-top: 2px
    }

        .metric .num small {
            font-size: 13px;
            font-weight: 500;
            color: var(--muted);
            margin-left: 4px
        }

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block
}

.verdict {
    margin-top: 14px
}

    .verdict h3, .panel h2 {
        font-size: 14px;
        margin: 0 0 8px;
        color: var(--muted);
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .05em
    }

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px
}

.chip {
    font-size: 13px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--muted)
}

    .chip.ok {
        background: var(--good-bg);
        color: var(--good)
    }

    .chip.no {
        background: var(--bad-bg);
        color: var(--bad)
    }

.msg {
    margin-top: 10px;
    font-size: 14px;
    color: var(--bad);
    min-height: 1em;
    text-align: center
}

.row {
    margin-top: 20px;
    display: grid;
    grid-template-columns: minmax(0,1fr) minmax(0,1.4fr);
    gap: 20px
}

@media (max-width:760px) {
    .row {
        grid-template-columns: minmax(0,1fr)
    }
}

dl.info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 0;
    font-size: 14px
}

    dl.info dt {
        color: var(--muted)
    }

    dl.info dd {
        margin: 0;
        font-variant-numeric: tabular-nums;
        overflow-wrap: anywhere
    }

.tips {
    margin: 14px 0 0;
    padding-left: 18px;
    color: var(--muted);
    font-size: 13px
}

    .tips li {
        margin: 3px 0
    }

.hist-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px
}

    .hist-head button {
        font-size: 13px;
        padding: 4px 10px
    }

.legend {
    display: flex;
    gap: 14px;
    font-size: 13px;
    color: var(--muted);
    margin: 4px 0 6px
}

    .legend span {
        display: flex;
        align-items: center;
        gap: 6px
    }

#chart {
    width: 100%;
    height: 160px;
    display: block
}

.table-wrap {
    overflow-x: auto;
    margin-top: 8px
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-variant-numeric: tabular-nums
}

th, td {
    text-align: right;
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap
}

    th:first-child, td:first-child, th:nth-child(2), td:nth-child(2) {
        text-align: left
    }

th {
    color: var(--muted);
    font-weight: 600
}

.empty {
    color: var(--muted);
    font-size: 14px;
    padding: 20px 0;
    text-align: center
}

footer {
    margin-top: 24px;
    color: var(--muted);
    font-size: 12px;
    text-align: center
}

    footer a {
        color: inherit
    }

/* ---------- Live graph, package, bufferbloat, IP toggle ---------- */
.live-wrap { max-width: 340px; margin: 4px auto 0; }
#live { display: block; width: 100%; height: 64px; background: var(--surface-2); border-radius: 10px; }
.live-cap { font-size: 12px; color: var(--muted); text-align: center; margin-top: 4px; min-height: 1.2em; }
.metric .sub { font-size: 12px; margin-top: 2px; color: var(--muted); }
.metric .sub.good { color: var(--good); }
.metric .sub.warn { color: var(--warn); }
.metric .sub.bad { color: var(--bad); }
.bloat { display: flex; align-items: center; gap: 10px; margin-top: 12px; font-size: 13px; color: var(--muted); }
.bloat[hidden] { display: none; }
.grade { flex: none; min-width: 34px; text-align: center; font-weight: 700; font-size: 15px; padding: 4px 8px; border-radius: 8px; background: var(--surface-2); color: var(--text); }
.grade.good { background: var(--good-bg); color: var(--good); }
.grade.warn { background: var(--surface-2); color: var(--warn); }
.grade.bad { background: var(--bad-bg); color: var(--bad); }
.plan { max-width: 420px; margin: 14px auto 0; font-size: 14px; background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.plan summary { cursor: pointer; font-weight: 600; }
.plan summary span { font-weight: 400; color: var(--muted); margin-left: 4px; }
.plan-fields { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 10px; color: var(--muted); }
.plan-fields label { display: flex; align-items: center; gap: 6px; }
.plan input[type=number] { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; width: 90px; }
.plan .hint { margin: 8px 0 2px; font-size: 12px; color: var(--muted); }
button.link { background: none; border: none; padding: 0 2px; color: var(--accent); font-size: 13px; text-decoration: underline; cursor: pointer; }
button.link[hidden] { display: none; }

/* ---------- Server picker ---------- */
#server { max-width: 240px; }
td.srv { max-width: 130px; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Insights, sharing, FAQ ---------- */
.insights { margin-top: 20px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 24px; }
@media (max-width: 760px) { .insights { grid-template-columns: minmax(0, 1fr); } }
.insights[hidden], .shared-banner[hidden] { display: none; }
.insights h2, .faq h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.diag-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.diag-item { border-left: 4px solid var(--border); background: var(--surface-2); border-radius: 0 10px 10px 0; padding: 10px 12px; font-size: 14px; }
.diag-item strong { display: block; margin-bottom: 2px; }
.diag-item span { color: var(--muted); }
.diag-item.good { border-left-color: var(--good); }
.diag-item.warn { border-left-color: var(--warn); }
.diag-item.bad { border-left-color: var(--bad); }
.diag-item.info { border-left-color: var(--accent); }
.can-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.can { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.can-v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.can-k { font-size: 13px; color: var(--muted); }
.insights .note { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.shared-banner { margin-top: 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); font-size: 14px; }
button.primary.small { padding: 8px 16px; font-size: 14px; min-width: 0; }
.faq { margin-top: 20px; }
.faq details { border-top: 1px solid var(--border); padding: 12px 0; }
.faq details:last-of-type { border-bottom: 1px solid var(--border); }
.faq summary { cursor: pointer; font-weight: 600; font-size: 15px; }
.faq details p { margin: 8px 0 0; color: var(--muted); font-size: 14px; }

/* ---------- Guide links ---------- */
.diag-link { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 600; color: var(--accent); text-decoration: none; }
.diag-link:hover { text-decoration: underline; }
.guides { margin-top: 20px; }
.guides h2 { font-size: 14px; margin: 0 0 10px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.guide-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; }
.guide-cards a { display: block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--text); }
.guide-cards a:hover { border-color: var(--accent); }
.guide-cards strong { display: block; font-size: 15px; }
.guide-cards span { display: block; font-size: 13px; color: var(--muted); margin-top: 2px; }
/* footer note (the site layout strips <footer> from page bodies) */
.page-note { margin-top: 24px; color: var(--muted); font-size: 12px; text-align: center; }
.page-note a { color: inherit; }
