:root {
    --bg: #f5f7fb;
    --bg-soft: #eef2f8;
    --surface: #ffffff;
    --surface-2: #fbfcfe;
    --line: #dde5f0;
    --line-strong: #c8d3e3;
    --text: #152033;
    --muted: #6d7b93;
    --blue: #1f6bff;
    --blue-soft: #e8f0ff;
    --green: #12a36d;
    --orange: #ff9f1a;
    --red: #dc4c64;
    --shadow: 0 14px 40px rgba(17, 28, 45, 0.08);
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 12px;
}

* { box-sizing: border-box; }

html,
body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(circle at top right, rgba(31, 107, 255, 0.08), transparent 22%),
        linear-gradient(180deg, #f8faff 0%, #f2f5fb 100%);
    color: var(--text);
    font: 14px/1.55 "Segoe UI", Tahoma, Arial, sans-serif;
}

button,
input { font: inherit; }

code,
pre { font-family: Consolas, "Courier New", monospace; }

.app-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    padding: 24px 18px;
    border-right: 1px solid var(--line);
    background: #101827;
    color: #f1f5fb;
}

.brand h1,
.topbar h2,
.panel h3 { margin: 0; }

.brand h1 {
    margin-top: 6px;
    font-size: 30px;
    line-height: 1.02;
}

.brand p {
    margin: 12px 0 0;
    color: #97a8c4;
}

.brand-kicker,
.eyebrow,
.sidebar-label,
.panel-meta,
.stat-label {
    display: inline-block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
}

.brand-kicker,
.sidebar-label { color: #8ca0bf; }

.nav-stack {
    display: grid;
    gap: 8px;
    margin: 28px 0;
}

.nav-link {
    padding: 13px 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    background: transparent;
    color: #eef4ff;
    text-align: left;
    cursor: pointer;
    transition: 160ms ease;
}

.nav-link:hover,
.nav-link.is-active {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.18);
}

.sidebar-card {
    margin-top: 12px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.04);
}

.sidebar code {
    color: #dce7ff;
    word-break: break-word;
}

.side-list {
    margin: 10px 0 0;
    padding-left: 18px;
    color: #d6e1f5;
}

.side-list li + li { margin-top: 6px; }

.workspace { padding: 22px; }

.topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(360px, 520px);
    gap: 20px;
    align-items: center;
    margin-bottom: 18px;
}

.topbar h2 {
    margin-top: 4px;
    font-size: 34px;
}

.topbar p {
    margin: 8px 0 0;
    color: var(--muted);
}

.search-shell {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.search-shell input,
.query-row input {
    min-width: 0;
    padding: 13px 14px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--text);
}

.search-shell input:focus,
.query-row input:focus {
    outline: none;
    border-color: #9dbafb;
    box-shadow: 0 0 0 4px rgba(31, 107, 255, 0.1);
}

.search-shell button,
.query-row button,
.mini-action {
    border: 0;
    border-radius: 12px;
    cursor: pointer;
    transition: 160ms ease;
}

.search-shell button,
.query-row button {
    padding: 13px 16px;
    background: var(--blue);
    color: #fff;
    font-weight: 600;
}

.search-shell button:hover,
.query-row button:hover,
.mini-action:hover { transform: translateY(-1px); }

.stats-grid,
.content-grid {
    display: grid;
    gap: 16px;
}

.stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin-bottom: 16px;
}

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

.stat-card { padding: 18px; }

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 24px;
    line-height: 1.1;
}

.stat-card p {
    margin: 6px 0 0;
    color: var(--muted);
}

.stat-card-accent { background: linear-gradient(135deg, #f8fbff, #eef4ff); }

.inline-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.mini-action {
    padding: 10px 12px;
    background: var(--blue-soft);
    color: var(--blue);
    font-weight: 600;
}

.view { display: none; }
.view.is-active { display: block; }

.content-grid {
    grid-template-columns: minmax(320px, 0.9fr) minmax(0, 1.5fr);
}

.panel { padding: 18px; }
.panel-wide { min-width: 0; }

.panel-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-bottom: 14px;
}

.panel-meta,
.eyebrow,
.stat-label { color: var(--muted); }

.status-pill {
    padding: 7px 10px;
    border-radius: 999px;
    background: #edf2fa;
    color: var(--muted);
    font-size: 12px;
}

.status-pill.is-ok {
    background: #e8f8f1;
    color: var(--green);
}

.status-pill.is-error {
    background: #fff0f3;
    color: var(--red);
}

.query-form + .query-form { margin-top: 16px; }

.query-form label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
}

.query-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.panel-spaced { margin-top: 16px; }

.result-box {
    min-height: 220px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-2);
    overflow: auto;
}

.result-box-compact { min-height: 120px; }

.placeholder,
.meta-strip { color: var(--muted); }

.meta-strip { margin-bottom: 12px; }

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.summary-card {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.summary-card span {
    display: block;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.summary-card strong {
    display: block;
    margin-top: 6px;
    font-size: 18px;
    word-break: break-word;
}

.explorer-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
}

.explorer-table th,
.explorer-table td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

.explorer-table th {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    background: #f8fbff;
}

.explorer-table tr:last-child td { border-bottom: 0; }

.mono {
    font-family: Consolas, "Courier New", monospace;
    word-break: break-word;
}

.keyval {
    display: grid;
    gap: 10px;
}

.keyval-row {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
}

.keyval-row:last-child { border-bottom: 0; }

.keyval-key {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.keyval-value { word-break: break-word; }

.history-list {
    display: grid;
    gap: 10px;
}

.history-item {
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
}

.json-tree {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.error-box {
    color: #b4233d;
    border-color: #f2c9d1;
    background: #fff5f7;
}

@media (max-width: 1180px) {
    .app-shell,
    .topbar,
    .stats-grid,
    .content-grid,
    .query-row {
        grid-template-columns: 1fr;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }
}

@media (max-width: 720px) {
    .workspace,
    .sidebar { padding: 16px; }

    .keyval-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }
}
