* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #f8fafc;
    --text: #0f172a;
    --muted: #64748b;
    --muted-2: #94a3b8;
    --surface: #ffffff;
    --surface-border: #e2e8f0;
    --panel-bg: #ffffff;
    --panel-border: #e2e8f0;
    --table-bg: #ffffff;
    --table-border: #e2e8f0;
    --table-row-alt: #f8fafc;
    --table-hover: #eef2f7;
    --table-header-bg: #f1f5f9;
    --table-header-text: #0f172a;
    --accent: #16a34a;
    --accent-contrast: #ffffff;
    --pill-bg: rgba(22, 163, 74, 0.12);
    --pill-border: rgba(22, 163, 74, 0.3);
    --error: #dc2626;
    --tooltip-bg: rgba(15, 23, 42, 0.92);
    --tooltip-text: #f8fafc;
}

html[data-theme="dark"] {
    --bg: #0b0f14;
    --text: #f8fafc;
    --muted: #94a3b8;
    --muted-2: #64748b;
    --surface: #111827;
    --surface-border: rgba(255, 255, 255, 0.08);
    --panel-bg: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(15, 23, 42, 0.85));
    --panel-border: rgba(148, 163, 184, 0.18);
    --table-bg: rgba(15, 23, 42, 0.65);
    --table-border: rgba(148, 163, 184, 0.12);
    --table-row-alt: rgba(15, 23, 42, 0.35);
    --table-hover: rgba(148, 163, 184, 0.08);
    --table-header-bg: rgba(15, 23, 42, 0.92);
    --table-header-text: #cbd5f5;
    --accent: #22c55e;
    --accent-contrast: #0b0f14;
    --pill-bg: rgba(34, 197, 94, 0.1);
    --pill-border: rgba(34, 197, 94, 0.35);
    --error: #f87171;
    --tooltip-bg: rgba(15, 23, 42, 0.92);
    --tooltip-text: #f8fafc;
}

@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --bg: #0b0f14;
        --text: #f8fafc;
        --muted: #94a3b8;
        --muted-2: #64748b;
        --surface: #111827;
        --surface-border: rgba(255, 255, 255, 0.08);
        --panel-bg: linear-gradient(135deg, rgba(17, 24, 39, 0.95), rgba(15, 23, 42, 0.85));
        --panel-border: rgba(148, 163, 184, 0.18);
        --table-bg: rgba(15, 23, 42, 0.65);
        --table-border: rgba(148, 163, 184, 0.12);
        --table-row-alt: rgba(15, 23, 42, 0.35);
        --table-hover: rgba(148, 163, 184, 0.08);
        --table-header-bg: rgba(15, 23, 42, 0.92);
        --table-header-text: #cbd5f5;
        --accent: #22c55e;
        --accent-contrast: #0b0f14;
        --pill-bg: rgba(34, 197, 94, 0.1);
        --pill-border: rgba(34, 197, 94, 0.35);
        --error: #f87171;
    }
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

.container {
    width: min(1100px, 92vw);
    margin: 0 auto;
}

.site-header {
    background: var(--surface);
    border-bottom: 1px solid var(--surface-border);
    padding: 18px 0;
    margin-bottom: 28px;
}

.header-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.brand-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.brand {
    font-size: 20px;
    font-weight: 600;
}

.subtitle {
    font-size: 13px;
    color: var(--muted);
}

.theme-toggle {
    border: 1px solid var(--panel-border);
    background: transparent;
    color: var(--text);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
}

.theme-toggle:hover {
    background: var(--table-hover);
}

.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: 28px;
    margin-bottom: 6px;
}

.hero p {
    color: var(--muted);
    font-size: 14px;
}

.status-line {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 20px;
    font-weight: 700;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--accent);
}

.status-ok {
    background: #22c55e;
}

.status-warn {
    background: #f59e0b;
}

.status-bad {
    background: #ef4444;
}

.btn {
    background: var(--accent);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    color: var(--accent-contrast);
    font-weight: 600;
    cursor: pointer;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.table-section {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 6px 12px rgba(15, 23, 42, 0.04);
}

.status-card {
    margin-top: 8px;
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: var(--table-bg);
}

.table-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.table-controls {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--muted);
}

.search-input {
    width: 200px;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: transparent;
    color: var(--text);
    outline: none;
}

.search-input:focus {
    border-color: var(--accent);
}

.table-title {
    font-size: 15px;
    font-weight: 600;
}

.table-meta {
    font-size: 12px;
    color: var(--muted);
}

.table-info {
    font-size: 12px;
    color: var(--text);
    padding: 6px 12px;
    background: var(--pill-bg);
    border: 1px solid var(--pill-border);
    border-radius: 999px;
    white-space: nowrap;
}

.table-wrap {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid var(--panel-border);
    background: var(--table-bg);
}

.group-section {
    margin-top: 16px;
}

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

.group-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.group-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.monitor-item {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--table-bg);
}

.monitor-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.sla-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(22, 163, 74, 0.12);
    color: #16a34a;
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
}

.monitor-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.monitor-right {
    min-width: 0;
}

.sla-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 620px;
}

.sla-table th,
.sla-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--table-border);
    text-align: left;
    font-size: 14px;
}

.sla-table th {
    color: var(--table-header-text);
    font-weight: 600;
    background: var(--table-header-bg);
    position: sticky;
    top: 0;
    z-index: 1;
}

.sla-table tbody tr:hover {
    background: var(--table-hover);
}

.sla-table tbody tr:nth-child(even) {
    background: var(--table-row-alt);
}

.col-name {
    min-width: 220px;
}

.col-num {
    text-align: right;
    min-width: 110px;
}

.monitor-name {
    font-weight: 600;
    color: var(--text);
    font-size: 14px;
}

.monitor-row {
    cursor: pointer;
}

.monitor-toggle {
    display: inline-flex;
    margin-right: 6px;
    color: var(--muted);
    transition: transform 0.2s ease;
}

.monitor-row.is-open .monitor-toggle {
    transform: rotate(90deg);
}

.history-row {
    display: none;
}

.history-row.is-open {
    display: table-row;
}

.history-cell {
    padding: 10px 14px;
}

.history-wrap {
    overflow-x: auto;
    padding: 6px 4px;
}

.history-grid {
    display: grid;
    gap: 2px;
    width: 100%;
}

.history-day {
    width: 6px;
    height: 10px;
    border-radius: 999px;
    background: var(--table-border);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
    transform-origin: center;
    justify-self: center;
}

.history-day:hover {
    transform: scale(1.4);
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.08);
}

.history-tooltip {
    position: fixed;
    z-index: 9999;
    max-width: 240px;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--tooltip-bg);
    color: var(--tooltip-text);
    font-size: 12px;
    line-height: 1.4;
    white-space: pre-line;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.18);
    pointer-events: none;
}

.history-ok {
    background: #22c55e;
}

.history-warn {
    background: #f59e0b;
}

.history-bad {
    background: #ef4444;
}

.history-na {
    background: #cbd5f5;
}

.cell-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.cell-error {
    color: var(--error);
}

.empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 24px;
    width: 100%;
}

.footer {
    margin-top: 24px;
    font-size: 12px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source {
    color: var(--muted-2);
}

.errors {
    color: var(--error);
}

.empty-state {
    text-align: center;
    padding: 80px 0;
}

.empty-state h1 {
    font-size: 28px;
    margin-bottom: 12px;
}

.empty-state p {
    color: var(--muted);
}
