:root {
    color-scheme: dark;
    --bg: #0b0e11;
    --surface: #181a20;
    --surface-strong: #1e2329;
    --line: #2b3139;
    --text: #eaecef;
    --muted: #848e9c;
    --green: #0ecb81;
    --amber: #f0b90b;
    --red: #f6465d;
    --blue: #1e80ff;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

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

button, input { font: inherit; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 68px;
    padding: 12px clamp(16px, 3vw, 40px);
    border-bottom: 1px solid var(--line);
    background: rgba(11, 14, 17, .9);
    backdrop-filter: saturate(160%) blur(24px);
}

.brand, .topbar-right, .hero-row, .panel-heading {
    display: flex;
    align-items: center;
}

.brand { gap: 11px; }
.brand strong, .brand span { display: block; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.topbar-right { gap: 15px; }

.brand-mark {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: var(--amber);
    color: var(--bg);
    font-weight: 800;
    box-shadow: 0 12px 36px rgba(240, 185, 11, .18);
}

.brand-mark.small {
    width: 35px;
    height: 35px;
    border-radius: 11px;
    font-size: 13px;
}

.dashboard {
    width: min(1440px, 100%);
    margin: 0 auto;
    padding: 34px clamp(16px, 3vw, 40px) 60px;
}

.hero-row {
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 27px;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(28px, 4vw, 44px); letter-spacing: -.045em; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -.025em; }
.eyebrow { margin-bottom: 7px; color: var(--amber); font-size: 10px; font-weight: 700; letter-spacing: .16em; }
.muted { color: var(--muted); font-size: 12px; }

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 9px 13px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    font-size: 11px;
    letter-spacing: .08em;
}

.status-pill span, .feed-status::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
}

.status-healthy span, .feed-online::before { background: var(--green); box-shadow: 0 0 12px rgba(14, 203, 129, .45); }
.status-degraded span, .feed-reconnecting::before, .feed-degraded::before { background: var(--amber); }
.feed-offline::before { background: var(--red); }
.feed-connecting::before { background: var(--blue); }

.metric-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(130px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.metric-card, .panel {
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}

.metric-card {
    min-height: 117px;
    padding: 17px;
    border-radius: 17px;
}

.metric-card span, .metric-card small { display: block; color: var(--muted); font-size: 11px; }
.metric-card strong { display: block; margin: 14px 0 8px; font-size: 24px; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }

.panel {
    margin-top: 12px;
    border-radius: 19px;
    overflow: hidden;
}

.panel-heading {
    justify-content: space-between;
    gap: 20px;
    min-height: 80px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--line);
}

.connections-panel > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
}

.connections-panel > summary::-webkit-details-marker { display: none; }
.connections-panel:not([open]) > summary { border-bottom-color: transparent; }
.connections-panel > summary:hover { background: rgba(240, 185, 11, .035); }
.connections-panel > summary:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

.panel-heading-meta {
    display: flex;
    align-items: center;
    gap: 14px;
}

.collapse-icon {
    width: 9px;
    height: 9px;
    border-right: 2px solid var(--muted);
    border-bottom: 2px solid var(--muted);
    transform: rotate(45deg);
    transition: transform .18s ease;
}

.connections-panel[open] .collapse-icon { transform: rotate(225deg); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 13px 20px; text-align: left; white-space: nowrap; border-bottom: 1px solid rgba(255, 255, 255, .055); }
th { color: var(--muted); font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
.source-name { display: block; font-weight: 600; }
.source-meta { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.feed-status { display: inline-flex; align-items: center; gap: 8px; text-transform: uppercase; font-size: 10px; font-weight: 700; letter-spacing: .05em; }
.empty-state { padding: 30px; color: var(--muted); text-align: center; }
.numeric { font-variant-numeric: tabular-nums; }

.queue-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    padding: 16px;
}

.queue-item { padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-strong); }
.queue-row { display: flex; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; }
.queue-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.queue-track { height: 4px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: rgba(255, 255, 255, .07); }
.queue-fill { height: 100%; width: 0; border-radius: inherit; background: var(--green); transition: width .25s ease; }
.queue-fill.warn { background: var(--amber); }
.queue-fill.danger { background: var(--red); }

.ghost-button, .restart-button, .dialog-button, .login-form button, .button-link {
    border: 1px solid var(--line);
    border-radius: 10px;
    color: var(--text);
    background: var(--surface-strong);
    cursor: pointer;
}

.ghost-button { padding: 7px 10px; font-size: 11px; }
.ghost-button:hover { border-color: var(--amber); color: var(--amber); }

.restart-button {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    color: var(--amber);
    font-size: 20px;
    line-height: 1;
}

.restart-button:hover { border-color: var(--amber); background: rgba(240, 185, 11, .09); }
.restart-button:focus-visible, .dialog-button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.confirm-dialog {
    width: min(420px, calc(100% - 28px));
    max-height: calc(100dvh - 28px);
    padding: 0;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 20px;
    color: var(--text);
    background: var(--surface);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .65);
}

.confirm-dialog::backdrop {
    background: rgba(0, 0, 0, .72);
    backdrop-filter: blur(8px);
}

.confirm-dialog form { padding: 25px; }

.dialog-icon {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin-bottom: 22px;
    border: 1px solid rgba(240, 185, 11, .28);
    border-radius: 50%;
    color: var(--amber);
    background: rgba(240, 185, 11, .08);
    font-size: 25px;
}

.confirm-dialog h2 { font-size: 23px; }
.dialog-copy { margin: 12px 0 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.dialog-progress { min-height: 18px; margin: 14px 0 0; color: var(--amber); font-size: 11px; line-height: 1.45; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 22px; }
.dialog-button { min-height: 42px; padding: 10px 14px; font-size: 12px; font-weight: 700; }
.dialog-button.secondary:hover { border-color: var(--muted); }
.dialog-button.primary { border-color: var(--amber); color: var(--bg); background: var(--amber); }
.dialog-button:disabled { cursor: wait; opacity: .58; }

.login-body {
    display: grid;
    place-items: center;
    padding: 20px;
}

.login-card {
    width: min(390px, 100%);
    padding: 34px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: 0 35px 100px rgba(0, 0, 0, .5);
    backdrop-filter: blur(30px);
}

.login-card .brand-mark { margin-bottom: 30px; }
.login-card h1 { font-size: 30px; }
.login-form { margin-top: 26px; }
.login-form label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.login-form input {
    width: 100%;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    outline: none;
    color: var(--text);
    background: rgba(0, 0, 0, .3);
}
.login-form input:focus { border-color: var(--amber); box-shadow: 0 0 0 3px rgba(240, 185, 11, .13); }
.login-form button, .button-link { display: block; width: 100%; margin-top: 17px; padding: 13px; text-align: center; text-decoration: none; background: var(--amber); color: var(--bg); font-weight: 700; }
.validation { display: block; margin-top: 8px; color: #ff6961; font-size: 11px; }

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .queue-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
    .topbar { min-height: 60px; padding: 10px 14px; }
    .brand span { display: none; }
    .topbar-right { gap: 8px; }
    .dashboard { padding: 22px 12px 36px; }
    .hero-row { align-items: flex-start; gap: 12px; margin-bottom: 20px; }
    .hero-row .muted { max-width: 210px; }
    h1 { font-size: 30px; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); }
    .metric-card { min-width: 0; min-height: 102px; padding: 14px; border-radius: 14px; }
    .metric-card strong { font-size: 20px; }
    .queue-grid { grid-template-columns: 1fr 1fr; }
    .topbar .muted { display: none; }
    .panel { border-radius: 15px; }
    .panel-heading { align-items: center; min-height: 72px; padding: 15px 16px; }
    .panel-heading .muted { display: none; }
    .table-wrap { overflow: visible; padding: 10px; }
    table, tbody { display: block; }
    thead { display: none; }
    tbody { display: grid; gap: 8px; }
    tbody tr {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        padding: 12px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: var(--surface-strong);
    }
    tbody tr:hover { background: var(--surface-strong); }
    tbody td {
        min-width: 0;
        padding: 0;
        border: 0;
        white-space: normal;
    }
    tbody td:first-child { grid-column: 1; }
    tbody td:nth-child(2) { display: flex; grid-column: 2; align-items: flex-start; justify-content: flex-end; }
    tbody td:nth-child(n+3) {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 9px;
        border-radius: 8px;
        background: rgba(11, 14, 17, .72);
    }
    tbody td:nth-child(3) { grid-column: 1 / -1; }
    tbody td:nth-child(n+3)::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 9px;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
    }
    tbody .empty-state {
        display: block;
        grid-column: 1 / -1;
        padding: 20px;
        background: transparent;
        text-align: center;
    }
}

@media (max-width: 380px) {
    .hero-row { flex-direction: column; }
    .status-pill { align-self: flex-start; }
    .queue-grid { grid-template-columns: 1fr; }
    .confirm-dialog form { padding: 21px; }
    .dialog-actions { grid-template-columns: 1fr; }
}
