:root {
    --bg: #f1f5f9;
    --surface: #ffffff;
    --border: #e5e7eb;
    --border-soft: #eef2f6;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --success: #059669;
    --success-bg: #ecfdf5;
    --success-fg: #065f46;
    --warning: #d97706;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --data-1: #4f46e5;
    --data-2: #059669;
    --data-3: #d97706;
    --data-4: #7c3aed;
    --shadow: 0 1px 3px rgba(15, 23, 42, .04), 0 4px 12px rgba(15, 23, 42, .04);
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    font-size: 15px;
    line-height: 1.5;
    letter-spacing: 0;
    -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.mono { font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace; }
.muted { color: var(--text-3); }
.block { display: block; }
.full { width: 100%; }

.status-board {
    min-height: 100dvh;
    padding: 32px 20px;
}

.status-container {
    width: min(960px, 100%);
    margin: 0 auto;
}

.status-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 22px;
    padding: 4px;
}

.status-titlebar h1 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
    font-size: 22px;
    line-height: 1.25;
    font-weight: 700;
    letter-spacing: 0;
}

.status-titlebar span {
    color: var(--text-3);
    font-size: 14px;
    font-weight: 600;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.summary {
    height: 103px;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: center;
    margin-bottom: 18px;
    overflow: hidden;
}

.summary div {
    min-width: 0;
    height: 58px;
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    position: relative;
    text-align: center;
}

.summary div + div::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 1px;
    background: var(--border);
}

.summary span {
    color: var(--text-3);
    font-size: 14px;
    line-height: 1.2;
}

.summary strong {
    font-size: 30px;
    line-height: 1;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.metric-purple { color: var(--data-1); }
.metric-green { color: var(--data-2); }
.metric-orange { color: var(--data-3); }
.metric-violet { color: var(--data-4); }

.monitor-list {
    display: grid;
    gap: 12px;
}

.monitor-card {
    height: 175px;
    position: relative;
    padding: 0;
    overflow: hidden;
}

.monitor-head,
.monitor-title,
.monitor-live,
.monitor-foot {
    display: flex;
    align-items: center;
}

.monitor-head {
    position: absolute;
    left: 32px;
    right: 32px;
    top: 28px;
    justify-content: space-between;
    gap: 18px;
}

.monitor-title {
    min-width: 0;
    gap: 10px;
}

.status-dot {
    width: 14px;
    height: 14px;
    flex: 0 0 auto;
    border-radius: 999px;
    background: #cbd5e1;
    box-shadow: 0 0 0 4px #e2e8f0;
}

.status-dot.ok,
.status-dot.slow {
    background: #10b981;
    box-shadow: 0 0 0 4px #d1fae5;
}

.status-dot.error {
    background: var(--danger);
    box-shadow: 0 0 0 4px #fee2e2;
}

.monitor-title h2 {
    margin: 0;
    color: var(--text);
    font-size: 20px;
    line-height: 1.2;
    font-weight: 700;
    letter-spacing: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-live {
    flex: 0 0 auto;
    gap: 12px;
    color: var(--text-2);
    font-size: 17px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.availability-pill {
    min-width: 78px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 12px;
    border: 1px solid #86efac;
    border-radius: 8px;
    background: var(--success-bg);
    color: var(--success-fg);
    font-size: 15px;
    font-weight: 700;
}

.monitor-chart {
    position: absolute;
    left: 32px;
    right: 32px;
    top: 67px;
    height: 44px;
    margin: 0;
}

.monitor-chart svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.latency-line {
    fill: none;
    stroke: var(--warning);
    stroke-width: 4;
    stroke-linecap: round;
    stroke-linejoin: round;
    vector-effect: non-scaling-stroke;
}

.latency-line.ok { stroke: #10b981; }
.latency-line.slow { stroke: #f59e0b; }
.latency-line.error { stroke: var(--danger); }

.check-strip {
    position: absolute;
    left: 32px;
    right: 32px;
    top: 110px;
    height: 31px;
    display: grid;
    grid-template-columns: repeat(100, minmax(3px, 1fr));
    gap: 4px;
    margin: 0;
}

.check-bar {
    min-width: 0;
    border-radius: 4px;
    background: #cbd5e1;
}

.check-bar.ok,
.check-bar.slow {
    background: var(--success);
}

.check-bar.error {
    background: var(--danger);
}

.monitor-foot {
    position: absolute;
    left: 32px;
    right: 32px;
    bottom: 12px;
    justify-content: space-between;
    gap: 12px;
    margin: 0;
    color: #8aa0bc;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.monitor-foot span {
    text-align: center;
}

.row-error {
    margin: 10px 0 0;
    padding: 8px 10px;
    border: 1px solid #fecaca;
    border-radius: 8px;
    background: var(--danger-bg);
    color: #991b1b;
    font-size: 13px;
}

.public-empty {
    padding: 28px;
    color: var(--text-3);
    text-align: center;
}

.button,
.icon-button {
    min-height: 42px;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    transition: background .18s ease, border-color .18s ease, color .18s ease;
}
.button-primary { background: #2563eb; color: #fff; }
.button-primary:hover { background: #1d4ed8; }
.button-secondary { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }
.button-ghost { background: transparent; border-color: rgba(255,255,255,.18); color: #f8fafc; }
.button-danger { background: #fff1f0; border-color: #fecaca; color: var(--danger); }
.icon-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    background: #f8fafc;
    border-color: var(--border);
}
.danger-text { color: var(--danger); }

.auth-page {
    min-height: 100dvh;
    display: grid;
    place-items: center;
    padding: 24px;
}
.auth-panel {
    width: min(420px, 100%);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.auth-panel h1 { margin: 12px 0 8px; line-height: 1.15; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    background: #2563eb;
    color: #fff;
    font-weight: 800;
}
.brand small { display: block; color: var(--text-3); }

.form-stack,
.form-grid,
.mini-form {
    display: grid;
    gap: 16px;
}
.form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
}
.quick-monitor-form {
    grid-template-columns: 1.1fr 1.1fr 1fr auto;
}
label span {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-weight: 700;
    font-size: 14px;
}
input,
select {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 9px 12px;
    background: #fff;
    color: var(--text);
}
input:focus,
select:focus,
button:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, .22);
    outline-offset: 2px;
}

.notice {
    border-radius: 10px;
    padding: 12px 14px;
    margin: 16px 0;
    border: 1px solid var(--border);
}
.notice-success { background: #ecfdf5; color: #065f46; border-color: #bbf7d0; }
.notice-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.admin-shell {
    min-height: 100dvh;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
}
.sidebar {
    position: sticky;
    top: 0;
    height: 100dvh;
    background: #0f172a;
    color: #f8fafc;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}
.side-nav { display: grid; gap: 8px; }
.side-nav a {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 8px;
    color: #cbd5e1;
}
.side-nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-main {
    padding: 32px;
    max-width: 1280px;
    width: 100%;
    min-width: 0;
}
.admin-header,
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.admin-header h1,
.section-head h2 {
    margin: 0;
}
.eyebrow {
    margin: 0 0 6px;
    color: #2563eb;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 24px 0;
}
.metric,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}
.metric { padding: 18px; }
.metric span { color: var(--text-3); }
.metric strong {
    display: block;
    margin-top: 4px;
    font-size: 30px;
    line-height: 1.1;
}
.panel {
    padding: 22px;
    margin-bottom: 22px;
}

.table-wrap { overflow-x: auto; }
table {
    width: 100%;
    min-width: 900px;
    border-collapse: collapse;
}
th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    vertical-align: top;
}
th {
    color: var(--text-2);
    font-size: 13px;
    background: #f8fafc;
}
.empty {
    text-align: center;
    color: var(--text-3);
    padding: 28px;
}
.error-cell {
    max-width: 260px;
    color: var(--danger);
    word-break: break-word;
}
.actions {
    display: flex;
    gap: 8px;
}
.actions form { margin: 0; }
.pill {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border-radius: 999px;
    padding: 0 10px;
    font-size: 13px;
    font-weight: 800;
}
.pill.ok,
.pill.slow {
    background: var(--success-bg);
    color: var(--success-fg);
}
.pill.error {
    background: var(--danger-bg);
    color: #991b1b;
}
.pill.unknown,
.muted-pill {
    background: #f1f5f9;
    color: #64748b;
}

@media (max-width: 900px) {
    .status-board { padding: 20px 12px; }
    .status-titlebar {
        align-items: center;
        margin-bottom: 16px;
    }
    .status-titlebar h1 { font-size: 20px; }
    .summary {
        height: auto;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        margin-bottom: 12px;
    }
    .summary div {
        height: 82px;
        gap: 5px;
    }
    .summary strong { font-size: 26px; }
    .summary span { font-size: 13px; }
    .summary div + div::before { display: none; }
    .summary div:nth-child(2n + 1)::after {
        content: "";
        position: absolute;
        right: 0;
        top: 16px;
        bottom: 16px;
        width: 1px;
        background: var(--border);
    }
    .summary div:nth-child(n + 3) { border-top: 1px solid var(--border); }
    .monitor-card {
        height: auto;
        min-height: 186px;
        padding: 0;
    }
    .monitor-head {
        left: 18px;
        right: 18px;
        top: 22px;
        align-items: flex-start;
        flex-direction: column;
    }
    .monitor-live {
        width: 100%;
        justify-content: space-between;
    }
    .check-strip { gap: 2px; }
    .monitor-chart {
        left: 18px;
        right: 18px;
        top: 88px;
    }
    .check-strip {
        left: 18px;
        right: 18px;
        top: 130px;
    }
    .monitor-foot {
        left: 18px;
        right: 18px;
        bottom: 14px;
    }
    .admin-shell {
        display: block;
        min-height: 100dvh;
    }
    .sidebar {
        position: static;
        height: auto;
        padding: 16px;
        gap: 14px;
    }
    .sidebar .brand-mark {
        width: 36px;
        height: 36px;
        border-radius: 8px;
    }
    .side-nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 8px;
    }
    .side-nav a {
        justify-content: center;
        padding: 0 8px;
        text-align: center;
        font-size: 13px;
    }
    .sidebar form { margin: 0; }
    .quick-monitor-form,
    .form-grid {
        grid-template-columns: 1fr;
    }
    .metrics-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
        margin: 16px 0;
    }
    .admin-main {
        padding: 18px 12px 24px;
    }
    .admin-header,
    .section-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }
    .admin-header .button {
        width: 100%;
    }
    .metric {
        padding: 14px;
    }
    .metric strong {
        font-size: 26px;
    }
    .panel {
        padding: 16px;
        margin-bottom: 16px;
    }
    .table-wrap {
        overflow: visible;
    }
    table,
    thead,
    tbody,
    tr,
    td {
        display: block;
        width: 100%;
        min-width: 0;
    }
    thead { display: none; }
    tr {
        padding: 14px;
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        background: #fff;
    }
    td {
        display: flex;
        justify-content: space-between;
        gap: 14px;
        padding: 8px 0;
        border: 0;
        text-align: right;
        word-break: break-word;
    }
    td::before {
        content: attr(data-label);
        flex: 0 0 82px;
        color: var(--text-3);
        font-weight: 700;
        text-align: left;
    }
    td:first-child {
        padding-top: 0;
    }
    td:last-child {
        padding-bottom: 0;
    }
    .actions {
        justify-content: flex-end;
        flex-wrap: wrap;
    }
    .error-cell {
        max-width: none;
    }
}

@media (max-width: 520px) {
    .status-board { padding: 16px 10px; }
    .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .summary div::after { display: block; }
    .summary div:nth-child(2n)::after { display: none; }
    .summary div + div { border-top: 0; }
    .summary div:nth-child(n + 3) { border-top: 1px solid var(--border); }
    .monitor-title h2 { font-size: 18px; }
    .monitor-live { font-size: 15px; }
    .check-strip {
        grid-template-columns: repeat(100, minmax(1px, 1fr));
        gap: 1px;
        height: 28px;
    }
}
