:root {
    color-scheme: light dark;
    --bg: #f4f7f8;
    --surface: #ffffff;
    --text: #1f2933;
    --muted: #5f6b76;
    --line: #d8e0e6;
    --accent: #0f766e;
    --accent-soft: #ccfbf1;
    --danger: #b42318;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    font-family: "Segoe UI", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1419;
        --surface: #171d24;
        --text: #e7edf2;
        --muted: #9aa7b3;
        --line: #2a3440;
        --accent: #2dd4bf;
        --accent-soft: rgba(45, 212, 191, 0.12);
        --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    }
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
}

.shell {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
    padding: 2rem 0 3rem;
}

.gate {
    max-width: 720px;
    margin: 8vh auto 0;
    padding: 2.5rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.gate-code {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    user-select: none;
}

.gate h1 {
    margin: 0 0 1rem;
    font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.gate-copy {
    margin: 0 0 0.75rem;
    line-height: 1.6;
    color: var(--muted);
}

.gate-copy.subtle {
    font-size: 0.95rem;
}

.gate-form {
    margin-top: 1.75rem;
    display: grid;
    gap: 0.75rem;
}

.gate-form label {
    font-size: 0.85rem;
    color: var(--muted);
}

.gate-form input,
.dash-actions select,
.dash-actions button {
    font: inherit;
}

.gate-form input {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
}

.gate-form button,
.dash-actions button {
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    background: var(--accent);
    color: #fff;
    cursor: pointer;
}

.gate-form button:hover,
.dash-actions button:hover {
    filter: brightness(1.05);
}

.gate-error {
    margin: 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.dashboard .dash-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.82rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.dash-header h1 {
    margin: 0;
    font-size: clamp(1.8rem, 4vw, 2.5rem);
}

.dash-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
}

.dash-actions select {
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
}

.dash-actions .ghost {
    background: transparent;
    color: var(--text);
    border: 1px solid var(--line);
}

.setup-banner {
    margin-bottom: 1rem;
    padding: 1rem 1.1rem;
    border-radius: 12px;
    background: var(--accent-soft);
    border: 1px solid var(--line);
    line-height: 1.5;
}

.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.metric-card,
.panel-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.metric-card {
    padding: 1.1rem 1.2rem;
}

.metric-label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    color: var(--muted);
}

.metric-value {
    font-size: clamp(1.5rem, 3vw, 2rem);
}

.panel-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.panel-card {
    overflow: hidden;
}

.panel-card.wide {
    grid-column: 1 / -1;
}

.panel-head {
    padding: 1.1rem 1.2rem 0.75rem;
    border-bottom: 1px solid var(--line);
}

.panel-head h2 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

.panel-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.table-wrap {
    overflow: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

th,
td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th:last-child,
td:last-child {
    text-align: right;
    white-space: nowrap;
}

tbody tr:last-child td {
    border-bottom: none;
}

.empty {
    color: var(--muted);
    text-align: center !important;
}

.status-line {
    margin: 1rem 0 0;
    color: var(--muted);
    font-size: 0.88rem;
}

@media (max-width: 900px) {
    .metric-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .dashboard .dash-header {
        flex-direction: column;
    }
}

@media (max-width: 560px) {
    .metric-grid {
        grid-template-columns: 1fr;
    }
}
