:root {
    color-scheme: dark;
    --bg: #061622;
    --panel: rgba(18, 43, 60, .86);
    --panel-2: rgba(28, 59, 80, .88);
    --border: rgba(146, 202, 235, .22);
    --text: #f4f8fb;
    --muted: #aab8c4;
    --accent: #85dcff;
    --green: #29d17d;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: radial-gradient(circle at 20% 10%, rgba(54, 117, 160, .26), transparent 34%), var(--bg);
    color: var(--text);
}
button, input, select { font: inherit; }
.shell { min-height: 100%; padding: 18px; }
.login {
    width: min(460px, calc(100vw - 32px));
    margin: 10vh auto;
    padding: 32px;
    border: 1px solid var(--border);
    border-radius: 30px;
    background: var(--panel);
    box-shadow: 0 24px 80px rgba(0, 0, 0, .35);
}
.brand span, .sidebar header span, label, .context small {
    display: block;
    text-transform: uppercase;
    letter-spacing: .14em;
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
}
.brand h1 { margin: 10px 0; font-size: clamp(40px, 7vw, 72px); line-height: .92; }
.brand p { color: var(--muted); }
form { display: grid; gap: 14px; }
input, select {
    width: 100%;
    margin-top: 7px;
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 13px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, .08);
    outline: none;
}
button {
    border: 1px solid rgba(133, 220, 255, .24);
    border-radius: 15px;
    padding: 12px 14px;
    color: var(--text);
    background: rgba(255, 255, 255, .08);
    cursor: pointer;
}
button:hover, button.active { background: rgba(133, 220, 255, .18); border-color: rgba(133, 220, 255, .55); }
form button[type="submit"] { background: linear-gradient(135deg, #2374ff, #29d17d); border: 0; font-weight: 800; }
.message { min-height: 20px; color: var(--accent); }
.workspace {
    display: grid;
    grid-template-columns: minmax(320px, 25vw) 1fr;
    gap: 14px;
    height: calc(100vh - 36px);
}
.sidebar, .viewer {
    border: 1px solid var(--border);
    border-radius: 28px;
    background: var(--panel);
    overflow: hidden;
}
.sidebar {
    display: grid;
    grid-template-rows: auto auto auto auto auto auto 1fr auto;
    min-height: 0;
}
.sidebar header {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
    padding: 18px;
    border-bottom: 1px solid var(--border);
}
.sidebar header span { grid-column: 1 / -1; }
.sidebar header strong { min-width: 0; color: var(--accent); }
.sidebar header button { padding: 8px 12px; }
.query, .context, .sync, .filters, .metrics { padding: 14px 18px; border-bottom: 1px solid var(--border); }
.context strong { display: block; margin-top: 8px; font-size: 22px; }
.context span { color: var(--muted); font-size: 12px; }
.sync {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.sync button {
    padding: 9px 11px;
    font-size: 12px;
    font-weight: 900;
}
.sync button.active {
    color: #9dffc9;
    border-color: rgba(41, 209, 125, .55);
    background: rgba(41, 209, 125, .16);
}
.sync span {
    min-width: 0;
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}
.sync.connected span { color: var(--accent); }
.filters { display: grid; gap: 8px; }
.filters button {
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: left;
}
.filters span {
    color: var(--accent);
    font-weight: 900;
}
.metrics { color: var(--muted); font-size: 12px; line-height: 1.6; }
.list {
    min-height: 0;
    overflow: auto;
    padding: 12px;
}
.item {
    width: 100%;
    text-align: left;
    display: grid;
    gap: 6px;
    margin-bottom: 10px;
    background: var(--panel-2);
}
.item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item small { color: var(--muted); }
.badge {
    width: max-content;
    padding: 3px 8px;
    border-radius: 999px;
    background: rgba(41, 209, 125, .18);
    color: #9dffc9;
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}
.empty { padding: 22px; color: var(--muted); text-align: center; }
.pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid var(--border);
}
.pager span { color: var(--muted); }
.viewer {
    position: relative;
    display: grid;
    place-items: center;
    background: rgba(3, 15, 24, .88);
}
.viewer iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #fff;
}
.viewer-empty { text-align: center; color: var(--muted); max-width: 520px; padding: 28px; }
.viewer-empty h2 { color: var(--text); margin: 0 0 8px; }

@media (max-width: 900px) {
    .shell { padding: 10px; }
    .workspace { grid-template-columns: 1fr; height: auto; }
    .sidebar { min-height: 70vh; }
    .viewer { min-height: 70vh; }
}
