:root {
    --bg: #eef2f3;
    --panel: #ffffff;
    --ink: #15202b;
    --muted: #5d6d7c;
    --line: #d5dee4;
    --accent: #0c6b4d;
    --accent-strong: #084e38;
    --side: #13232e;
    --side-ink: #e6eef3;
    --side-muted: #93a7b5;
    --side-line: #2a4252;
    --danger: #9d2430;
    --shadow: 0 1px 2px rgba(20, 32, 43, 0.05), 0 10px 28px rgba(20, 32, 43, 0.05);
    --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background: var(--bg);
    font: 15px/1.5 var(--sans);
}

a { color: var(--accent-strong); }

img { display: block; }

code, pre, textarea, .data {
    font-family: var(--mono);
}

h1, h2, p { margin-top: 0; }

h1 { font-size: 1.7rem; letter-spacing: -0.03em; margin-bottom: 0.25rem; }

h2 { font-size: 1.05rem; margin-bottom: 0.75rem; }

.skip {
    position: absolute;
    left: 12px;
    top: -40px;
    background: white;
    padding: 8px 12px;
    z-index: 10;
}

.skip:focus { top: 12px; }

.top {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 60px;
    padding: 10px 18px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-right: auto;
    color: var(--ink);
    font-weight: 700;
    text-decoration: none;
}

.conn-pill {
    margin: 0;
    padding: 4px 10px;
    border-radius: 999px;
    background: #e7f4ee;
    color: var(--accent-strong);
    font-size: 0.85rem;
}

.conn-pill.is-empty {
    background: #eef2f4;
    color: var(--muted);
}

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

.shell.solo { grid-template-columns: minmax(0, 1fr); }

.side {
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow: auto;
    padding: 16px 12px 24px;
    background: var(--side);
    color: var(--side-ink);
}

.side-link, .table-list a {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    color: var(--side-ink);
    text-decoration: none;
}

.side-link.is-active, .table-list a.is-active, .side-link:hover, .table-list a:hover {
    background: #1d3646;
}

.side-block { margin-top: 18px; }

.side-label, .side-muted, .side-error {
    padding: 0 10px;
    color: var(--side-muted);
    font-size: 0.82rem;
}

.side-error { color: #ffb4bc; }

.side input[type="search"] {
    width: calc(100% - 20px);
    margin: 8px 10px 10px;
}

.table-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.table-list a span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.main { padding: 28px; min-width: 0; }

.connect-wrap { max-width: 560px; margin: 32px auto; }

.lede, .note, .hint, .fine-print, .empty {
    color: var(--muted);
}

.fine-print code, .lede code {
    font-family: var(--mono);
    font-size: 0.92em;
}

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

.card { padding: 18px; }

.panel { margin-top: 18px; padding: 16px; }

.panel-head, .page-head, .pager, .form-actions, .button-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.page-head { align-items: flex-start; margin-bottom: 16px; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr 140px;
    gap: 14px;
    margin-top: 16px;
}

.span-2 { grid-column: span 2; }

label, .stack { display: grid; gap: 6px; font-weight: 600; }

input, select, textarea, button, .button {
    font: inherit;
}

input, select, textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    color: var(--ink);
}

textarea { min-height: 180px; resize: vertical; }

.row-form textarea { min-height: 88px; }

button, .button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 8px 14px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button.ghost, .button.ghost {
    background: white;
    color: var(--ink);
    border-color: var(--line);
}

button.danger { background: var(--danger); }

button.link {
    width: auto;
    padding: 0;
    border: 0;
    background: none;
    color: var(--danger);
    font-weight: 700;
}

button.link.danger { color: var(--danger); }

.inline-form { display: inline; }

.check {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}

.check input { width: auto; }

details { display: grid; gap: 10px; }

summary { cursor: pointer; }

.banner {
    padding: 10px 12px;
    border-radius: 8px;
    white-space: pre-wrap;
    word-break: break-word;
}

.banner.ok { background: #e5f6ef; color: var(--accent-strong); }

.banner.error { background: #fdecee; color: var(--danger); }

.facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 10px;
    margin: 0 0 18px;
}

.facts div {
    padding: 12px;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.facts dt { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; }

.facts dd { margin: 4px 0 0; }

.filter-input { max-width: 320px; margin-bottom: 12px; }

.schema-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.schema-list a {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: #f7fbf9;
    text-decoration: none;
}

.schema-list a.is-current {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.schema-list a.is-system:not(.is-current) { color: var(--muted); }

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: end;
    margin-bottom: 14px;
}

.filters label { min-width: 140px; }

.filters button { margin-bottom: 1px; }

.data-wrap {
    overflow: auto;
    max-height: calc(100vh - 240px);
    border: 1px solid var(--line);
    border-radius: 10px;
}

.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.86rem;
}

.data th, .data td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
    max-width: 360px;
    white-space: pre-wrap;
    word-break: break-word;
}

.data th {
    position: sticky;
    top: 0;
    background: #f6faf8;
    font-family: var(--sans);
}

.data tbody tr:hover { background: #f3faf6; }

.data a.quiet {
    margin-left: 8px;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.85rem;
}

.actions-col, .row-actions { width: 110px; white-space: nowrap; }

.row-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.null { color: var(--muted); font-style: italic; }

.tag {
    display: inline-block;
    margin-left: 6px;
    padding: 0 6px;
    border-radius: 999px;
    background: #e7eef2;
    color: var(--muted);
    font-family: var(--sans);
    font-size: 0.72rem;
    font-weight: 700;
}

.side .tag { background: #243846; color: var(--side-muted); }

.sql {
    overflow: auto;
    margin: 0;
    padding: 12px;
    border-radius: 8px;
    background: #13232e;
    color: #e6eef3;
    white-space: pre-wrap;
}

.row-form { display: grid; gap: 14px; max-width: 760px; }

.row-form fieldset {
    margin: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.row-form legend { padding: 0 6px; font-weight: 700; }

.delete-form { margin-top: 12px; }

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

@media (max-width: 800px) {
    .shell { grid-template-columns: 1fr; }
    .side { position: static; height: auto; max-height: 280px; }
    .form-grid, .span-2 { grid-template-columns: 1fr; display: grid; }
    .span-2 { grid-column: auto; }
    .top { flex-wrap: wrap; }
}
