:root {
    color-scheme: light;
    font: 16px / 1.5 "Aptos", "Segoe UI", system-ui, -apple-system, sans-serif;
    color: #17283e;
    background: #f3f6fa;
    --ink: #17283e;
    --muted: #52657d;
    --line: #d7e2ee;
    --navy: #102640;
    --blue: #204eab;
    --blue-dark: #14377b;
    --soft-blue: #ecf3ff;
    --light: #f6f9fc;
    --mono: ui-monospace, "SFMono-Regular", Consolas, monospace;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; }
h1, h2, p { margin: 0 0 .75rem; overflow-wrap: anywhere; }
h1 { font-size: clamp(2rem, 4vw, 3.2rem); line-height: 1.06; letter-spacing: -.05em; }
h2 { font-size: 1.2rem; letter-spacing: -.022em; }
a { color: var(--blue); text-underline-offset: .2em; }
code { font: .9em var(--mono); overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.sr-only, .skip-link:not(:focus) {
    position: absolute; width: 1px; height: 1px; clip-path: inset(50%); overflow: hidden; white-space: nowrap;
}
.skip-link:focus { position: absolute; z-index: 4; left: 1rem; top: .7rem; background: white; padding: .7rem; }
:focus-visible { outline: 3px solid #2783ca; outline-offset: 3px; }

.topbar { background: var(--navy); color: white; border-bottom: 1px solid #28435f; }
.topbar-inner {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem 1.5rem;
    width: min(96rem, 100%); margin: auto; min-height: 4.65rem; padding: .7rem clamp(1rem, 3vw, 2rem);
}
.brand { font-weight: 750; text-decoration: none; color: white; display: flex; gap: .7rem; align-items: center; white-space: nowrap; }
.brand-mark {
    display: block; width: auto; height: 2.5rem; flex: 0 0 auto;
}
.brand small { color: #cddef1; padding-left: .7rem; border-left: 1px solid #69829f; font-size: .88rem; font-weight: 500; }
.topbar nav { display: flex; gap: .6rem 1.15rem; align-items: center; flex-wrap: wrap; }
.topbar nav a, .topbar nav button.quiet { color: #e2ebf8; font-size: .92rem; }
.topbar nav a { padding-block: .35rem; text-decoration: none; }
.topbar nav a[aria-current] { color: white; font-weight: 700; border-bottom: 2px solid #6fdfce; }

.content, .access, .app-content { margin: 0 auto; padding: clamp(1.05rem, 3vw, 2.5rem) clamp(1rem, 3vw, 2rem) 4rem; }
.access { max-width: 35rem; padding-top: clamp(2.4rem, 7vw, 6.75rem); }
.access .card { border-top: 4px solid #3166c8; }
.access h1 { font-size: clamp(1.82rem, 5vw, 2.6rem); }
.content { max-width: 80rem; }
.app-content { max-width: 96rem; }
.card {
    min-width: 0; background: white; border: 1px solid var(--line); border-radius: .9rem;
    padding: clamp(1rem, 3vw, 1.75rem); box-shadow: 0 2px 6px #19345209;
}
.fields { margin-top: 1.5rem; display: grid; gap: 1rem; }
label { display: grid; gap: .33rem; font-weight: 670; font-size: .88rem; }
input, select, button { font: inherit; }
input:not([type=checkbox]), select {
    border: 1px solid #aebdd0; border-radius: .48rem; padding: .56rem .7rem;
    width: 100%; min-width: 0; min-height: 2.55rem; background: white; color: var(--ink);
}
select {
    appearance: none; padding-right: 1.9rem;
    background: white linear-gradient(45deg, transparent 47%, #425873 51%) right .76rem center / .25rem .25rem no-repeat;
    background-image: linear-gradient(45deg, transparent 49%, #425873 51%), linear-gradient(135deg, #425873 49%, transparent 51%);
    background-position: right .95rem center, right .7rem center;
    background-repeat: no-repeat;
}
button, .button {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.55rem;
    border: 1px solid var(--blue); background: var(--blue); color: white; border-radius: .48rem;
    padding: .52rem .9rem; font-size: .9rem; font-weight: 700; cursor: pointer; text-decoration: none;
}
button:hover, .button:hover { background: var(--blue-dark); }
button:disabled { background: #dce5f1; color: #4a5b71; border-color: #b6c4d6; cursor: not-allowed; }
button.quiet { border: 0; background: transparent; padding-left: 0; padding-right: 0; color: var(--blue); text-decoration: underline; }
.secondary { background: white; color: #254571; border-color: #b9c9de; }
.secondary:hover { background: var(--soft-blue); border-color: #87a7d6; }
.feedback { background: #e8f0fc; border: 1px solid #bdd2ef; border-radius: .55rem; padding: .8rem 1rem; margin-bottom: 1rem; }
.feedback.error { background: #fff3ef; border-color: #e3b2a1; color: #762f1a; }
.section-head { display: flex; align-items: end; justify-content: space-between; margin-bottom: 1.25rem; }
.user-list { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); }
.inline, .permission-form { display: flex; gap: .8rem; align-items: end; flex-wrap: wrap; }
.inline label { flex: 1 1 17rem; }
.invitation { margin-bottom: 1rem; }
.permission-form { align-items: stretch; flex-direction: column; }
.check { display: flex; align-items: center; gap: .45rem; }

.workbench { display: grid; grid-template-columns: minmax(12.5rem, 15.75rem) minmax(0, 1fr); gap: clamp(1rem, 2vw, 1.65rem); align-items: start; }
.workspace-sidebar {
    min-width: 0; background: white; border: 1px solid var(--line); border-radius: .85rem;
    display: grid; gap: .8rem; padding: .85rem;
}
.switcher { display: grid; gap: .35rem; }
.switcher label { color: var(--muted); }
.select-line { display: flex; gap: .35rem; min-width: 0; }
.select-line select { font-family: var(--mono); font-weight: 700; }
.overview-link, .table-entry {
    display: flex; align-items: center; gap: .6rem; padding: .56rem .57rem; border-radius: .42rem;
    min-height: 2.45rem; color: #304762; text-decoration: none; font-size: .9rem;
}
.overview-link { font-weight: 700; }
.overview-link:hover, .table-entry:hover { background: var(--light); }
.overview-link.current, .table-entry.current {
    background: var(--soft-blue); box-shadow: inset 3px 0 #3473d3; color: #164394; font-weight: 700;
}
.sidebar-tables { min-width: 0; border-top: 1px solid var(--line); padding-top: .6rem; }
.sidebar-section { font-size: .87rem; font-weight: 720; margin-bottom: .6rem; cursor: pointer; padding: .2rem .15rem; }
.sidebar-count { margin-left: .3rem; padding: .1rem .35rem; border-radius: 1rem; color: var(--muted); background: var(--light); }
.table-nav { list-style: none; margin: .45rem 0 0; padding: .08rem .14rem .25rem 0; max-height: min(30rem, 54vh); overflow: auto; }
.table-entry span:last-child { min-width: 0; overflow-wrap: anywhere; }
.table-icon {
    width: .83rem; height: .78rem; display: inline-block; flex: 0 0 auto; color: #456b9e;
    border: 1px solid currentColor; border-radius: .16rem;
    background: linear-gradient(to bottom, #dce8f8 0 43%, currentColor 43% 53%, transparent 53%);
}
.advanced-form { margin-top: .1rem; }
.advanced-form button { width: 100%; white-space: normal; }
.filter-empty { margin: .6rem .25rem 0; font-size: .9rem; color: var(--muted); }
.workspace-main { min-width: 0; display: grid; gap: 1rem; }
.workspace-hero {
    position: relative; overflow: hidden; isolation: isolate; display: flex; gap: 1rem 2rem; justify-content: space-between; align-items: center;
    min-height: 10.75rem; background: linear-gradient(115deg, #142c4a, #174b81); color: white;
    padding: clamp(1.25rem, 4vw, 2.75rem); border-radius: 1rem;
}
.workspace-hero::after {
    content: ""; position: absolute; z-index: -1; aspect-ratio: 1; width: min(35%, 21rem);
    right: -3%; top: -60%; transform: rotate(28deg); border: 1px solid #90e7e84d; border-radius: 2.5rem;
    box-shadow: 0 0 0 1.4rem #9ce8f010, 0 0 0 2.8rem #9ce8f00b, 0 0 0 4.2rem #9ce8f007;
}
.workspace-hero h1 { margin: .7rem 0 0; }
.hero-database { color: #e3edfa; margin: .35rem 0 0; overflow-wrap: anywhere; }
.role-badge {
    display: inline-block; width: fit-content; color: #234b80; background: #e5eefc; border-radius: 1rem;
    padding: .25rem .65rem; white-space: nowrap; font-size: .83rem; font-weight: 740;
}
.workspace-hero .role-badge { color: #d0fbf3; background: #164858; border: 1px solid #6fdfce68; }
.hero-stat { flex: 0 0 auto; display: flex; flex-direction: column; min-width: 8rem; padding-left: 1.2rem; border-left: 1px solid #82a7ce; color: #e3edfa; }
.hero-stat strong { font-size: 2.75rem; line-height: 1; color: white; font-variant-numeric: tabular-nums; letter-spacing: -.04em; }
.empty-workspace { max-width: 40rem; }
.inventory-panel, .records-panel { padding: 0; }
.panel-heading {
    display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex-wrap: wrap;
    padding: 1rem clamp(.8rem, 2vw, 1.35rem);
}
.panel-heading h2 { margin: 0; }
.inventory-search { width: min(100%, 19rem); }

.data-scroll { overflow: auto; border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.records-scroll { max-height: 64vh; }
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .91rem; }
.data-table th, .data-table td { text-align: left; vertical-align: middle; padding: .69rem clamp(.68rem, 1.6vw, 1.3rem); border-bottom: 1px solid #e3eaf3; }
.data-table thead th { white-space: nowrap; color: #3a526f; background: #edf3fa; border-block: 1px solid #dbe6f2; font-size: .83rem; }
.records-table thead th { font-family: var(--mono); position: sticky; top: 0; z-index: 1; }
.data-table tbody tr:nth-child(even) { background: #f8fafd; }
.data-table tbody tr:hover { background: #edf5ff; }
.data-table tbody tr:last-child > * { border-bottom-color: transparent; }
.data-table .number { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.records-table td { min-width: 7rem; max-width: 24rem; overflow-wrap: anywhere; vertical-align: top; }
.inventory-link { display: inline-flex; gap: .63rem; align-items: center; font-weight: 740; text-decoration: none; overflow-wrap: anywhere; }
.inventory-link:hover { text-decoration: underline; }
.subtle-link { font-size: .89rem; white-space: nowrap; font-weight: 650; }
.null-value { color: #526987; font: .82rem var(--mono); }
.crumbs { display: flex; align-items: center; gap: .55rem; font-size: .89rem; min-width: 0; color: #536884; }
.crumbs span:last-child { overflow-wrap: anywhere; }
.table-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: .7rem; }
.table-heading h1 { font-size: clamp(1.6rem, 4vw, 2.7rem); margin-bottom: .25rem; }
.table-heading p { margin: 0; }
.view-tabs { display: flex; gap: 1.35rem; border-bottom: 1px solid #c9d9eb; }
.view-tabs a { text-decoration: none; color: #3c587c; padding: .5rem .3rem .6rem; font-weight: 700; }
.view-tabs a[aria-current] { color: #1b4eac; border-bottom: 3px solid #2e6bd0; }
.record-tools, .record-footer { display: flex; align-items: end; justify-content: space-between; flex-wrap: wrap; gap: .75rem; padding: .8rem clamp(.75rem, 2vw, 1.3rem); }
.record-filter { display: flex; flex-wrap: wrap; flex: 1 1 26rem; align-items: end; gap: .55rem; }
.record-filter label { flex: 1 1 8rem; max-width: 13.5rem; }
.record-filter .subtle-link { padding: .6rem .2rem; }
.record-footer { align-items: center; border-top: 1px solid var(--line); min-height: 3.75rem; color: #455e7f; font-size: .88rem; }
.order-note { display: block; font-size: .83rem; margin-top: .15rem; }
.pagination { display: flex; gap: .45rem; }
.panel-message { padding: 1.35rem; }
.panel-message p { margin-bottom: 0; }

@media (max-width: 760px) {
    .workbench { grid-template-columns: minmax(0, 1fr); }
    .workspace-sidebar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .45rem .7rem; align-items: end; }
    .sidebar-tables, .advanced-form { grid-column: 1 / -1; }
    .sidebar-tables .table-nav { max-height: 12rem; }
    .advanced-form button { width: auto; }
    .topbar-inner { flex-wrap: wrap; }
    .records-scroll { max-height: 56vh; }
}
@media (max-width: 450px) {
    .workspace-hero { flex-wrap: wrap; gap: 1.15rem; }
    .hero-stat { display: flex; flex-direction: row; align-items: baseline; gap: .5rem; border-left: 0; padding: 0; }
    .hero-stat strong { font-size: 1.9rem; }
    .table-heading { flex-wrap: wrap; }
    .brand { gap: .52rem; }
    .brand small { padding-left: .5rem; }
    .inventory-table .number { white-space: normal; }
}

.catalog-page { max-width: 77rem; margin-inline: auto; }
.catalog-header {
    padding: .6rem 0 1.1rem; margin-bottom: 1.2rem;
    border-bottom: 1px solid var(--line);
}
.catalog-header h1 { margin-bottom: .45rem; }
.catalog-header p { margin-bottom: 0; max-width: 61ch; }
.catalog-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 22rem), 1fr));
    column-gap: clamp(.85rem, 2vw, 1.35rem);
}
.catalog-card {
    display: grid; grid-row: span 3; grid-template-rows: subgrid;
    margin-bottom: clamp(.85rem, 2vw, 1.35rem);
    padding: 1.25rem; border-top: 3px solid #3475b9; scroll-margin-top: 1rem;
}
.catalog-card:target { box-shadow: 0 0 0 2px #377ac879; }
.catalog-card-heading { grid-row: 1; display: flex; align-items: flex-start; gap: .85rem; margin-bottom: .65rem; }
.catalog-card-heading h2 { font-size: 1.35rem; margin: 0; overflow-wrap: anywhere; }
.catalog-card-heading h2 a { color: #184581; }
.catalog-card-heading code { display: block; color: var(--muted); line-height: 1.65; }
.database-mark {
    flex: 0 0 auto; display: inline-grid; place-items: center; color: #21558a;
    width: 3rem; height: 3rem; border-radius: .72rem; background: #e7f2fe; border: 1px solid #d5e6f8;
}
.database-mark::before {
    content: ""; height: 1rem; width: 1.25rem; border: 1.5px solid currentColor; border-radius: .23rem;
    background: linear-gradient(0deg, transparent 26%, currentColor 26% 36%, transparent 36% 61%, currentColor 61% 71%, transparent 71%);
}
.catalog-description { grid-row: 2; font-size: .94rem; margin: .55rem 0 1rem; }
.catalog-card-body { grid-row: 3; }
.catalog-disclosure { border: 1px solid var(--line); background: var(--light); border-radius: .52rem; }
.catalog-disclosure summary {
    display: flex; align-items: center; gap: .6rem; list-style: none; padding: .65rem .83rem;
    cursor: pointer; color: #234771; font-weight: 720; font-size: .92rem;
}
.catalog-disclosure summary::-webkit-details-marker { display: none; }
.catalog-disclosure summary::after {
    content: ""; width: .43rem; height: .43rem; margin-left: .15rem; flex: 0 0 auto;
    border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.catalog-disclosure[open] summary::after { transform: rotate(225deg); }
.catalog-disclosure summary span:first-child { margin-right: auto; }
.catalog-count {
    min-width: 1.7rem; text-align: center; padding: .02rem .35rem; border-radius: 1rem;
    background: #e4edf8; color: #355a84; font-size: .82rem; font-variant-numeric: tabular-nums;
}
.catalog-table-list, .comment-list { margin: 0; padding: 0; list-style: none; }
.catalog-table-list { max-height: 15rem; overflow: auto; border-top: 1px solid var(--line); }
.catalog-table-list a {
    display: flex; gap: .53rem; align-items: center; padding: .46rem .83rem; min-height: 2.25rem;
    font-size: .9rem; text-decoration: none; overflow-wrap: anywhere;
}
.catalog-table-list a:hover { background: #e7f1ff; text-decoration: underline; }
.catalog-table-list a:focus-visible { outline-offset: -3px; }
.catalog-comments { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .8rem; }
.catalog-comments h3 { margin: 0 0 .45rem; font-size: .95rem; }
.catalog-hint { font-size: .88rem; margin: 0; }
.catalog-disclosure .catalog-hint { padding: 0 .8rem .7rem; }
.comment-list { display: grid; gap: .6rem; }
.comment-list li { background: #f5f8fc; border: 1px solid #e1e9f2; border-radius: .5rem; padding: .57rem .7rem; min-width: 0; }
.comment-heading { display: flex; justify-content: space-between; align-items: baseline; gap: .4rem; flex-wrap: wrap; font-size: .83rem; }
.comment-heading strong { color: #264365; overflow-wrap: anywhere; min-width: 0; }
.comment-heading time { color: var(--muted); white-space: nowrap; }
.comment-list p { margin: .23rem 0 0; white-space: pre-wrap; font-size: .92rem; }
.catalog-success { color: #175f4c; font-size: .9rem; margin: .4rem 0; }
.comment-editor { margin-top: .6rem; }
.comment-editor summary {
    width: fit-content; color: var(--blue); cursor: pointer; font-size: .9rem;
    font-weight: 680; padding: .26rem .08rem;
}
.comment-form { display: grid; gap: .45rem; margin-top: .4rem; }
.comment-form textarea {
    font: inherit; color: var(--ink); width: 100%; resize: vertical; padding: .57rem .7rem;
    min-height: 5rem; border: 1px solid #aebdd0; border-radius: .48rem;
}
.comment-form button { justify-self: start; }
.catalog-editor, .account-recovery { border-top: 1px solid var(--line); margin-top: .9rem; padding-top: .65rem; }
.account-recovery summary, .comment-delete summary { color: var(--blue); cursor: pointer; font-size: .9rem; font-weight: 680; }
.comment-delete { margin-top: .5rem; }
.comment-delete .danger { background: #9c2c26; border-color: #9c2c26; }
.comment-delete .danger:hover { background: #792018; }
.account-recovery .comment-form p, .recovery-link { margin: .55rem 0 0; }

.view-tabs { flex-wrap: wrap; column-gap: 1.2rem; row-gap: 0; }
.advanced-actions summary { color: #254571; cursor: pointer; font-weight: 700; font-size: .9rem; padding: .5rem; }
.advanced-actions > div { display: grid; gap: .35rem; padding-top: .35rem; }
.query-form { display: grid; gap: .55rem; margin-block: 1rem; }
.query-form textarea {
    font: inherit; color: var(--ink); width: 100%; resize: vertical; padding: .65rem .75rem;
    border: 1px solid #aebdd0; border-radius: .48rem; background: #f9fbfe;
}
.query-form textarea#sql-input { font: .9rem/1.6 var(--mono); }
.query-form button { justify-self: start; }
.query-panel h3 { font-size: .95rem; margin-bottom: .35rem; }
.query-code { background: #edf3fa; border: 1px solid var(--line); padding: .8rem; border-radius: .48rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.query-explanation { white-space: pre-wrap; }

.column-alias {
    display: block; margin-top: .13rem; color: var(--muted);
    font: .78rem / 1.3 "Aptos", "Segoe UI", system-ui, sans-serif;
    overflow-wrap: anywhere; white-space: normal; max-width: 24rem;
}
.table-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 12.5rem), 1fr)); gap: .7rem; }
