:root {
    color-scheme: light;
    --ink: #172033;
    --muted: #687386;
    --line: #e4e8ef;
    --surface: #ffffff;
    --canvas: #f5f7fb;
    --navy: #18243b;
    --blue: #315fba;
    --blue-dark: #254c98;
    --green: #147a56;
    --red: #b42335;
    --shadow: 0 8px 26px rgba(20, 32, 55, .055);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--canvas);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

.topbar { height: 64px; background: var(--navy); color: #fff; }
.topbar-inner {
    width: min(1440px, calc(100% - 48px));
    height: 100%; margin: 0 auto; display: flex; align-items: center;
    justify-content: space-between;
}
.brand, .topbar-right { display: flex; align-items: center; gap: 12px; }
.brand { font-size: 15px; font-weight: 650; letter-spacing: .1px; }
.brand-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; border-radius: 12px; background: #dce8ff;
    color: #214b9b; font-size: 13px; font-weight: 800; letter-spacing: -.7px;
}
.brand-mark.small { width: 31px; height: 31px; border-radius: 9px; font-size: 10px; }
.signed-in { color: #d4dbea; font-size: 12px; }
.logout-link { color: #fff; text-decoration: none; font-weight: 600; padding: 7px 11px; border: 1px solid #536078; border-radius: 7px; }
.logout-link:hover { background: #293852; }

.page-shell { width: min(1440px, calc(100% - 48px)); margin: 30px auto 48px; }
.page-heading { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin: 0 0 22px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 4px; font-size: 26px; letter-spacing: -.7px; line-height: 1.25; }
h2 { font-size: 16px; margin-bottom: 3px; letter-spacing: -.15px; }
.muted { color: var(--muted); margin-bottom: 0; font-size: 12px; }
.security-pill, .language-tag {
    white-space: nowrap; display: inline-flex; align-items: center; gap: 8px;
    color: #536174; background: #fff; border: 1px solid var(--line);
    padding: 7px 11px; border-radius: 20px; font-size: 11px; font-weight: 650;
}
.security-dot { width: 7px; height: 7px; background: #1b9c71; border-radius: 50%; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 11px; box-shadow: var(--shadow); margin-bottom: 16px; padding: 18px 20px; }
.panel-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 14px; }
.browser-controls { display: flex; gap: 9px; align-items: center; }
.input {
    border: 1px solid #d6dce6; background: #fff; color: var(--ink);
    border-radius: 7px; padding: 9px 11px; min-height: 38px; font: inherit;
    outline: none; width: 100%;
}
.input:focus { border-color: #6b91d5; box-shadow: 0 0 0 3px rgba(49, 95, 186, .1); }
.select-input { max-width: 520px; flex: 1; }
.button {
    display: inline-flex; justify-content: center; align-items: center; min-height: 38px;
    border: 1px solid transparent; border-radius: 7px; padding: 8px 14px;
    cursor: pointer; font: inherit; font-size: 12px; font-weight: 650; white-space: nowrap;
    transition: background .15s ease, border-color .15s ease;
}
.button-primary { color: #fff; background: var(--blue); border-color: var(--blue); }
.button-primary:hover { background: var(--blue-dark); }
.button-secondary { color: #254c98; background: #edf3ff; border-color: #d8e4fb; }
.button-secondary:hover { background: #e2ecff; }
.button-quiet { color: #465369; background: #fff; border-color: #dfe4ec; }
.button-quiet:hover { background: #f7f9fc; }

.query-panel { padding-bottom: 15px; }
.query-heading { margin-bottom: 12px; }
.query-editor {
    display: block; width: 100%; min-height: 300px; resize: vertical; overflow: auto;
    border: 1px solid #27354d; border-radius: 8px; background: #111c2e; color: #e8eef8;
    padding: 17px 18px; font-family: Consolas, "SFMono-Regular", Menlo, monospace;
    font-size: 13px; line-height: 1.65; tab-size: 4; outline: none; white-space: pre;
}
.query-editor:focus { border-color: #7195d5; box-shadow: 0 0 0 3px rgba(49, 95, 186, .12); }
.editor-footer { display: flex; justify-content: space-between; align-items: center; gap: 15px; margin-top: 12px; }
.editor-hint { color: var(--muted); font-size: 11px; }
.editor-hint code { background: #edf0f5; border-radius: 4px; padding: 2px 4px; color: #36455d; }

.results-section { margin-top: 23px; }
.results-title-row { margin-bottom: 12px; }
.results-title-row h2 { font-size: 17px; }
.execution-summary {
    display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 13px;
    color: #426151; background: #f0f8f4; border: 1px solid #d8ece0;
    border-radius: 8px; font-size: 11px; margin-bottom: 12px;
}
.summary-check { font-weight: 800; color: var(--green); font-size: 15px; }
.summary-separator { color: #a1b7aa; }
.result-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 13px; overflow: hidden; box-shadow: 0 3px 13px rgba(20, 32, 55, .035); }
.result-card-heading { padding: 10px 14px; display: flex; justify-content: space-between; gap: 14px; align-items: center; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.result-card-heading strong { font-size: 12px; }
.result-card-heading span { color: var(--muted); font-size: 11px; }
.table-scroll { width: 100%; overflow: auto; max-height: 560px; }
.data-table { width: 100%; border-collapse: collapse; white-space: nowrap; font-size: 11px; }
.data-table th { background: #f7f9fc; color: #566276; text-align: left; font-weight: 700; position: sticky; top: 0; z-index: 1; }
.data-table th, .data-table td { padding: 8px 11px; border-bottom: 1px solid #edf0f4; max-width: 360px; overflow: hidden; text-overflow: ellipsis; }
.data-table td { color: #263348; }
.data-table tr:hover td { background: #f9fbfe; }
.data-table .row-number { width: 42px; min-width: 42px; text-align: right; color: #95a0b0; background: #fbfcfe; }
.result-footnote { padding: 0 14px; color: #7a5d20; font-size: 11px; }
.empty-state { color: var(--muted); background: #fff; border: 1px dashed #d7dde7; border-radius: 9px; padding: 22px; font-size: 12px; }
.alert { display: block; padding: 10px 13px; border-radius: 8px; margin: 0 0 15px; font-size: 12px; }
.alert:empty { display: none; }
.alert-success { color: #176344; background: #edf8f2; border: 1px solid #cdebd9; }
.alert-error { color: #982637; background: #fff1f2; border: 1px solid #f4d1d6; }
.footer-note { margin-top: 24px; padding: 13px 15px; border-left: 3px solid #d5a64b; background: #fffaf0; color: #77623b; font-size: 11px; border-radius: 0 7px 7px 0; }

.login-page { display: flex; min-height: 100vh; align-items: center; justify-content: center; padding: 24px; background: #f3f6fb; }
.login-card { width: min(410px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 30px; box-shadow: 0 16px 45px rgba(20, 32, 55, .09); }
.login-card .brand-mark { margin-bottom: 18px; }
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-card > .muted { margin-bottom: 22px; }
.login-card label { display: block; font-size: 12px; font-weight: 650; color: #3c485c; margin: 14px 0 6px; }
.login-card .input { min-height: 42px; }
.button-full { width: 100%; margin-top: 20px; min-height: 42px; }
.security-note { margin: 18px 0 0; color: #8791a0; font-size: 10px; text-align: center; }

@media (max-width: 760px) {
    .topbar-inner, .page-shell { width: calc(100% - 28px); }
    .page-shell { margin-top: 20px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .browser-controls, .editor-footer { align-items: stretch; flex-direction: column; }
    .select-input { max-width: none; }
    .button { width: 100%; }
    .topbar { height: auto; min-height: 60px; }
    .topbar-inner { padding: 10px 0; gap: 12px; }
    .signed-in { display: none; }
    .panel { padding: 15px; }
    .query-editor { min-height: 250px; }
}
