:root {
    --bg: #0f1419;
    --panel: #171d24;
    --panel-2: #1e262f;
    --line: #2b3644;
    --fg: #e6edf3;
    --muted: #8b98a5;
    --ok: #3fb950;
    --down: #f85149;
    --warn: #d29922;
    --accent: #1f6feb;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.5 "Pretendard", "Malgun Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

header {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 12px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

header h2 { margin: 0; font-size: 16px; font-weight: 600; }

nav { display: flex; gap: 4px; }

nav a {
    color: var(--muted);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 6px;
}

nav a:hover { background: var(--panel-2); color: var(--fg); }
nav a.active { background: var(--accent); color: #fff; }

main { padding: 20px; width: 100%; }

h1 { font-size: 20px; margin: 0 0 16px; }

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--muted); }

/* Label beside the control instead of above it, to keep the toolbar one row tall. */
.field.inline { flex-direction: row; align-items: center; gap: 8px; }

input, select, button {
    font: inherit;
    color: var(--fg);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 6px 10px;
}

button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }

a.btn {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel-2);
    color: var(--fg);
    text-decoration: none;
}

label.check { display: flex; align-items: center; gap: 6px; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 12px;
}

.card {
    min-width: 0;
    background: var(--panel);
    border: 1px solid var(--line);
    border-left: 4px solid var(--ok);
    border-radius: 8px;
    padding: 14px 16px;
}

.card.bad { border-left-color: var(--down); }
.card.warn { border-left-color: var(--warn); }

.card h3 { margin: 0 0 2px; font-size: 15px; overflow-wrap: anywhere; }
.card .sub { color: var(--muted); font-size: 12px; margin-bottom: 10px; overflow-wrap: anywhere; }

.wan {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    padding: 6px 0;
    border-top: 1px solid var(--line);
    min-width: 0;
}

.wan .tag {
    min-width: 42px;
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--panel-2);
    color: var(--muted);
}

.wan .isp { flex: 1 1 120px; min-width: 0; display: flex; gap: 4px 8px; align-items: baseline; flex-wrap: wrap; overflow-wrap: anywhere; }
.wan .meta { color: var(--muted); font-size: 12px; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: 0 0 auto; }

/* A live "still online" heartbeat - only the healthy dot pulses, so a red or grey one stands out. */
.dot.up { background: var(--ok); animation: heartbeat 2.4s ease-out infinite; }
.dot.down { background: var(--down); }
.dot.unknown { background: var(--muted); }

@keyframes heartbeat {
    0%   { box-shadow: 0 0 0 0 rgba(63, 185, 80, .55); }
    70%  { box-shadow: 0 0 0 6px rgba(63, 185, 80, 0); }
    100% { box-shadow: 0 0 0 0 rgba(63, 185, 80, 0); }
}

@media (prefers-reduced-motion: reduce) {
    .dot.up { animation: none; }
}

.pill {
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 999px;
    background: rgba(63, 185, 80, .15);
    color: var(--ok);
}

.pill.bad { background: rgba(248, 81, 73, .15); color: var(--down); }
.pill.warn { background: rgba(210, 153, 34, .15); color: var(--warn); }

table { width: 100%; border-collapse: collapse; background: var(--panel); border-radius: 8px; overflow: hidden; }
th, td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--line); }
th { background: var(--panel-2); color: var(--muted); font-size: 12px; font-weight: 600; }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.down-val { color: var(--down); font-weight: 600; }

.status { color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.error { color: var(--down); background: rgba(248, 81, 73, .1); padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; }
.empty { color: var(--muted); padding: 24px; text-align: center; }

/* auth */
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; }

main.bare { display: flex; justify-content: center; padding: 60px 20px; }

.login-wrap { width: 100%; max-width: 360px; }

.login-box {
    display: flex;
    flex-direction: column;
    gap: 14px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 24px;
}

.login-box h1 { font-size: 17px; margin: 0 0 4px; }
.login-box .field { gap: 6px; }
.login-box input { width: 100%; }
.login-box .btn { text-align: center; }

/* dashboard: pinned problem panel + paged healthy list */
.dash {
    display: grid;
    grid-template-columns: 310px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.pinned {
    position: sticky;
    top: 12px;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 10px;
    padding: 12px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 8px;
}

/* No scrollbar here on purpose: problem sites must all stay visible at once. */
.pinned.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.dash.pin-wide { grid-template-columns: 600px minmax(0, 1fr); }

.pinned-head {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

/* Compact tiles so more fit without scrolling. */
.pinned .card { background: var(--panel); padding: 10px 12px; }
.pinned .card h3 { font-size: 14px; }
.pinned .card .sub { margin-bottom: 6px; }
.pinned .card .wan { padding: 4px 0; }
.pinned .empty { grid-column: 1 / -1; padding: 12px; }

.page-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.page-bar .status { margin: 0 auto 0 0; }

@media (max-width: 1200px) {
    .dash, .dash.pin-wide { grid-template-columns: 1fr; }
    .pinned { position: static; }
}

.countdown {
    min-width: 34px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: var(--muted);
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 6px;
}

/* Blazor circuit reconnect / error UI */
#components-reconnect-modal,
#blazor-error-ui { display: none; }

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .6);
}

.reconnect-dialog {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    padding: 24px 28px;
    text-align: center;
    color: var(--fg);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .5);
}

.reconnect-dialog p { margin: 0; }
.reconnect-dialog .meta { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; }

/* Show only the message matching the current state. */
.reconnect-dialog .on-reconnecting,
.reconnect-dialog .on-failed,
.reconnect-dialog .on-rejected,
.reconnect-dialog button { display: none; }

.components-reconnect-show .on-reconnecting,
.components-reconnect-show .reconnect-spinner { display: block; }

.components-reconnect-failed .on-failed,
.components-reconnect-rejected .on-rejected,
.components-reconnect-failed button,
.components-reconnect-rejected button { display: block; }

.reconnect-spinner {
    display: none;
    width: 26px;
    height: 26px;
    border: 3px solid var(--line);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#blazor-error-ui.show,
#blazor-error-ui[style*="block"] {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    padding: 12px 20px;
    color: #fff;
    background: var(--down);
}

#blazor-error-ui .reload { color: #fff; text-decoration: underline; margin-left: 10px; }

/* headline counters - readable across the room, not buried in 12px grey */
/* Sits inside the toolbar, pushed to the right of the controls. */
.stats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-left: auto;
}

.stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 96px;
    padding: 6px 14px;
    background: var(--panel-2);
    border: 1px solid var(--line);
    border-left: 4px solid var(--line);
    border-radius: 8px;
}

.stat .v { font-size: 24px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--muted); }

.stat.bad { border-left-color: var(--down); }
.stat.bad .v { color: var(--down); }
.stat.ok { border-left-color: var(--ok); }
.stat.ok .v { color: var(--ok); }
.stat.time { border-left-color: var(--accent); }
.stat.time .v { font-size: 16px; padding-top: 5px; }
