:root {
    /* Light theme (default) */
    --page: #f9f9f7;
    --surface: #fcfcfb;
    --ink: #0b0b0b;
    --ink-2: #52514e;
    --muted: #898781;
    --border: rgba(11, 11, 11, 0.10);
    --good: #0ca30c;
    --warn: #fab219;
    --critical: #d03b3b;
    --accent: #2a78d6;
    --accent-light: #86b6ef;
    --seg-off: #d03b3b;
    --seg-empty: rgba(11, 11, 11, 0.10);
}

@media (prefers-color-scheme: dark) {
    :root {
        --page: #0d0d0d;
        --surface: #1a1a19;
        --ink: #ffffff;
        --ink-2: #c3c2b7;
        --muted: #898781;
        --border: rgba(255, 255, 255, 0.10);
        --good: #0ca30c;
        --warn: #fab219;
        --critical: #d03b3b;
        --accent: #3987e5;
        --accent-light: #184f95;
        --seg-off: #d03b3b;
        --seg-empty: rgba(255, 255, 255, 0.10);
    }
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background-color: var(--page);
    color: var(--ink);
    line-height: 1.5;
}

/* Header bar */
.header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
}

.page-intro {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--ink-2);
    max-width: 72ch;
}

.header-status {
    display: flex;
    gap: 12px;
    align-items: center;
    font-size: 14px;
    color: var(--ink-2);
}

.live-clock {
    font-variant-numeric: tabular-nums;
}

.updated-ago {
    color: var(--muted);
}

/* Connection indicator */
.conn-indicator {
    font-size: 13px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.conn-indicator.live {
    color: var(--good);
}

.conn-indicator.polling {
    color: var(--warn);
}

.conn-indicator.down {
    color: var(--critical);
}

/* Main container */
.main-container {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
}

/* Status banner */
.status-banner {
    width: 100%;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.status-banner.good {
    background: linear-gradient(135deg, rgba(12, 163, 12, 0.08) 0%, rgba(12, 163, 12, 0.04) 100%);
}

.status-banner.warn {
    background: linear-gradient(135deg, rgba(250, 178, 25, 0.08) 0%, rgba(250, 178, 25, 0.04) 100%);
}

.status-banner.critical {
    background: linear-gradient(135deg, rgba(208, 59, 59, 0.08) 0%, rgba(208, 59, 59, 0.04) 100%);
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.banner-icon {
    font-size: 32px;
    font-weight: 600;
    line-height: 1;
}

.banner-text {
    font-size: 24px;
    font-weight: 600;
    color: var(--ink);
}

/* Stat tiles */
.stat-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-tile {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.stat-label {
    font-size: 13px;
    color: var(--ink-2);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 28px;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
}

/* Sites grid */
.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.grid-empty {
    text-align: center;
    grid-column: 1 / -1;
    color: var(--muted);
}

.site-card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.site-card.offline {
    border-color: var(--critical);
}

.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.site-id {
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
}

.status-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--ink);
}

.status-pill.online {
    background-color: rgba(12, 163, 12, 0.12);
}

.status-pill.offline {
    background-color: rgba(208, 59, 59, 0.12);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.online {
    background-color: var(--good);
    animation: pulse-dot 2s ease-in-out infinite;
}

.status-dot.offline {
    background-color: var(--critical);
}

@keyframes pulse-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.2);
    }
}

.site-row {
    font-size: 13px;
    color: var(--ink);
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
}

.site-row-label {
    color: var(--ink-2);
    margin-bottom: 2px;
}

.site-row-value {
    color: var(--ink);
}

.site-row-value.monospace {
    font-family: "Courier New", monospace;
    font-size: 12px;
}

/* Per-site uptime bar (Kuma-style) */
.uptime-block {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.uptime-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 6px;
}

.uptime-caption {
    font-size: 12px;
    color: var(--ink-2);
}

.uptime-pct {
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    font-variant-numeric: tabular-nums;
}

.uptime-bar {
    display: flex;
    gap: 2px;
    height: 22px;
    align-items: stretch;
}

.uptime-seg {
    flex: 1 1 0;
    border-radius: 3px;
    background-color: var(--seg-empty);
    min-width: 0;
}

.uptime-seg.online {
    background-color: var(--good);
}

.uptime-seg.offline {
    background-color: var(--seg-off);
}

/* Activity panel */
.activity-panel {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    margin-bottom: 24px;
}

.activity-panel h2 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
}

.activity-chart {
    width: 100%;
    overflow-x: auto;
}

.activity-placeholder {
    text-align: center;
    color: var(--muted);
    padding: 32px 16px;
    font-size: 14px;
}

.activity-svg {
    display: block;
    margin: 0 auto;
    min-width: 100%;
}

.axis-label {
    fill: var(--muted);
}

.bar {
    fill: var(--accent);
}

.bar.current {
    fill: var(--accent-light);
}

/* Footer */
.footer {
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 640px) {
    .header-status {
        flex-direction: column;
        gap: 4px;
        align-items: flex-end;
        font-size: 12px;
    }

    .banner-text {
        font-size: 18px;
    }

    .stat-tiles {
        grid-template-columns: repeat(2, 1fr);
    }

    .stat-value {
        font-size: 24px;
    }

    .sites-grid {
        grid-template-columns: 1fr;
    }
}
