:root {
    color-scheme: light;
    --ink: #172120;
    --muted: #62706d;
    --line: #d7dcda;
    --line-dark: #aeb8b5;
    --paper: #f7f8f7;
    --surface: #ffffff;
    --header: #13201f;
    --header-text: #f4f6f5;
    --accent: #185e60;
    --accent-soft: #e7f1f0;
    --warning: #7c293c;
    --warning-soft: #f8ebee;
    --disabled: #736a45;
    --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 15px; }
body { margin: 0; min-width: 320px; }
a { color: var(--accent); text-underline-offset: 2px; }
code, pre, textarea { font-family: var(--mono); }
button, input, select, textarea { color: inherit; font: inherit; }
button, .button { border: 1px solid var(--line-dark); background: var(--surface); border-radius: 2px; color: var(--ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; min-height: 34px; padding: 6px 11px; text-decoration: none; }
button:hover, .button:hover { border-color: var(--accent); }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: white; }
button.danger { background: var(--warning); border-color: var(--warning); color: white; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line-dark); border-radius: 2px; min-height: 34px; padding: 6px 8px; }
textarea { line-height: 1.45; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus, button:focus, a:focus { outline: 2px solid #4f999b; outline-offset: 2px; }

.skip-link { background: white; left: 8px; padding: 8px; position: fixed; top: -50px; z-index: 10; }
.skip-link:focus { top: 8px; }
.topbar { align-items: center; background: var(--header); color: var(--header-text); display: grid; gap: 24px; grid-template-columns: 240px 1fr auto; min-height: 52px; padding: 0 20px; }
.product-name { color: inherit; font-weight: 700; text-decoration: none; }
.product-name span { color: #b7c3c0; font-weight: 500; margin-left: 5px; }
.main-nav { align-self: stretch; display: flex; overflow-x: auto; }
.main-nav a { align-items: center; border-bottom: 3px solid transparent; color: #dbe2e0; display: flex; padding: 0 12px; text-decoration: none; white-space: nowrap; }
.main-nav a[aria-current="page"] { border-bottom-color: #62b0b0; color: white; }
.actor { color: #bdc8c5; font-family: var(--mono); font-size: .8rem; }
.contextbar { align-items: center; background: #eef1f0; border-bottom: 1px solid var(--line); display: flex; gap: 14px; min-height: 44px; padding: 5px 20px; }
.target-switch { border: 1px solid var(--line-dark); display: inline-flex; }
.target-switch a, .target-tabs a { background: white; color: var(--ink); padding: 5px 10px; text-decoration: none; }
.target-switch a + a, .target-tabs a + a { border-left: 1px solid var(--line-dark); }
.target-switch a[aria-current="true"], .target-tabs a[aria-current="true"] { background: var(--header); color: white; }
.mode { border-left: 1px solid var(--line-dark); font-size: .78rem; padding-left: 14px; text-transform: uppercase; }
.mode-read { color: var(--accent); }
.mode-write { color: var(--accent); }
.mode-live { color: var(--warning); font-weight: 600; }
.mode-disabled { color: var(--disabled); }
.database-account { color: var(--muted); font-size: .78rem; }
.environment { color: var(--muted); font-size: .8rem; margin-left: auto; text-transform: uppercase; }

.app-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: calc(100vh - 96px); }
.object-sidebar { background: #f0f2f1; border-right: 1px solid var(--line); min-width: 0; padding: 14px 0; }
.sidebar-title { align-items: center; display: flex; justify-content: space-between; padding: 0 14px 10px; }
.sidebar-title span { color: var(--muted); font-family: var(--mono); font-size: .8rem; }
.object-sidebar nav { max-height: calc(100vh - 145px); overflow: auto; }
.object-sidebar nav a, .unsupported-object { align-items: center; color: var(--ink); display: grid; font-family: var(--mono); font-size: .78rem; gap: 7px; grid-template-columns: 18px minmax(0, 1fr) auto; min-height: 30px; padding: 5px 12px; text-decoration: none; }
.object-sidebar nav a:hover { background: #e1e6e4; }
.object-kind { color: var(--muted); font-family: var(--sans); font-size: .67rem; font-weight: 700; }
.locked { color: var(--warning); }
.unsupported-object { color: var(--muted); }
.content { min-width: 0; padding: 24px; }
.notice, .restriction { border: 1px solid #9dbebc; background: var(--accent-soft); margin: 0 0 18px; padding: 9px 11px; }
.restriction { background: var(--warning-soft); border-color: #d6aab4; color: #5d1c2c; }
.live-warning { background: var(--warning-soft); border: 1px solid #d6aab4; color: #5d1c2c; margin: 0 0 18px; padding: 9px 11px; }

.page-header { align-items: end; border-bottom: 1px solid var(--line); display: flex; gap: 24px; justify-content: space-between; margin-bottom: 18px; padding-bottom: 13px; }
.page-header h1 { font-size: 1.45rem; line-height: 1.2; margin: 2px 0 0; }
.page-header h1 code { font-size: 1.2rem; }
.eyebrow { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .07em; margin: 0; text-transform: uppercase; }
.page-actions, .target-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.target-tabs { border: 1px solid var(--line-dark); gap: 0; }
.summary-line { display: flex; gap: 22px; margin: 0; }
.summary-line div { min-width: 72px; }
.summary-line dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.summary-line dd { font-family: var(--mono); margin: 3px 0 0; }
.filterbar { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.filterbar label, .confirmation-grid label, .write-confirmation label, .danger-zone label { display: grid; font-size: .78rem; gap: 4px; }
.filterbar input { min-width: 220px; }
.table-wrap { border: 1px solid var(--line); max-width: 100%; overflow: auto; }
table { border-collapse: collapse; width: 100%; }
th, td { border-bottom: 1px solid var(--line); padding: 8px 9px; text-align: left; vertical-align: top; }
thead th { background: #edf0ef; color: #4f5c59; font-size: .72rem; font-weight: 700; position: sticky; text-transform: uppercase; top: 0; white-space: nowrap; z-index: 1; }
tbody th { font-weight: 500; }
tbody tr:last-child > * { border-bottom: 0; }
.actions { text-align: right; white-space: nowrap; }
.actions a, .actions span { margin-left: 10px; }
.actions span { color: var(--muted); font-size: .8rem; }
.footnote, .result-count { color: var(--muted); font-size: .78rem; margin: 8px 0 0; }
.result-count { margin: 0 0 7px; }
.section { margin-top: 26px; }
.section h2, .danger-zone h2 { font-size: .95rem; margin: 0 0 9px; }
.two-column { display: grid; gap: 18px; grid-template-columns: 1fr 1fr; }
.compact-table th, .compact-table td { padding: 6px 7px; }
details { border: 1px solid var(--line); margin-bottom: 7px; }
summary { cursor: pointer; padding: 8px; }
details pre { border-top: 1px solid var(--line); margin: 0; padding: 10px; }
.sql-block { background: #101918; color: #e7eceb; font-size: .78rem; line-height: 1.55; margin: 0; max-height: 520px; overflow: auto; padding: 14px; white-space: pre-wrap; }
.data-grid { max-height: calc(100vh - 280px); }
.data-grid td, .data-grid th { white-space: nowrap; }
.cell-value code { display: block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
.cell-display[hidden] { display: none; }
.is-null code { color: #7b8582; font-style: italic; }

/* The header stays put while the body scrolls, so column identity survives a
   long table the way it does in a spreadsheet. */
.data-grid thead th { background: var(--surface); position: sticky; top: 0; z-index: 1; }

.grid-toolbar { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 7px; }
.grid-toolbar .result-count { margin: 0; }
.grid-hint { color: var(--muted); font-size: .78rem; margin: 0; }
.grid-status { font-size: .78rem; min-height: 1em; }
.grid-status-ok { color: var(--accent); }
.grid-status-error { color: #8d2138; font-weight: 600; }

.grid-select { width: 1%; }
.grid-select input { cursor: pointer; margin: 0; }

.cell-value.is-editable { cursor: text; }
.cell-value.is-editable:hover { background: var(--accent-soft); }
.cell-value.is-editable:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.cell-value.is-editing { background: var(--surface); padding: 0; }
.cell-value.is-saving { opacity: .55; }
.cell-value.is-saved { background: var(--accent-soft); transition: background .6s ease-out; }

.grid-editor {
    border: 2px solid var(--accent);
    font: inherit;
    min-width: 160px;
    padding: 4px 6px;
    resize: vertical;
    width: 100%;
}

/* The highlight layer sits exactly under a transparent textarea, so every
   font and spacing property below must stay identical between the two. */
.sql-editor { position: relative; }
.sql-editor textarea,
.sql-highlight {
    border: 1px solid var(--line-dark);
    box-sizing: border-box;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .82rem;
    letter-spacing: normal;
    line-height: 1.55;
    margin: 0;
    padding: 10px 12px;
    tab-size: 4;
    white-space: pre-wrap;
    word-break: break-word;
    width: 100%;
}
.sql-editor textarea {
    background: transparent;
    caret-color: var(--ink);
    color: transparent;
    display: block;
    position: relative;
    resize: vertical;
    z-index: 1;
}
.sql-highlight {
    background: var(--surface);
    color: var(--ink);
    inset: 0;
    overflow: auto;
    pointer-events: none;
    position: absolute;
    z-index: 0;
}
.tok-keyword { color: var(--accent); font-weight: 600; }
.tok-string { color: #8d2138; }
.tok-comment { color: var(--muted); font-style: italic; }
.tok-number { color: #6a4b16; }

.sql-suggestions {
    background: var(--surface);
    border: 1px solid var(--line-dark);
    box-shadow: 0 4px 14px rgb(0 0 0 / .12);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .78rem;
    list-style: none;
    margin: 0;
    max-height: 200px;
    overflow: auto;
    padding: 0;
    position: absolute;
    right: 12px;
    top: 100%;
    width: 260px;
    z-index: 3;
}
.sql-suggestions li { cursor: pointer; padding: 5px 9px; }
.sql-suggestions li.is-active { background: var(--accent-soft); color: var(--accent); }

.sql-history { font-size: .78rem; margin-top: 14px; }
.sql-history ol { display: grid; gap: 4px; margin: 9px 0; padding-left: 18px; }
.sql-history-entry {
    background: none; border: 0; color: var(--ink); cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .76rem; overflow: hidden; padding: 2px 0; text-align: left;
    text-overflow: ellipsis; white-space: nowrap; width: 100%;
}
.sql-history-entry:hover { color: var(--accent); }

.sql-preview {
    background: var(--paper); border: 1px solid var(--line-dark);
    font-size: .8rem; line-height: 1.55; margin: 0 0 14px;
    overflow-x: auto; padding: 12px; white-space: pre-wrap;
}
.column-designer .field-row { grid-template-columns: 2fr 2fr 1fr auto auto auto; }
.column-chips code { background: var(--accent-soft); margin-right: 5px; padding: 2px 5px; }
.import-form { align-items: end; display: flex; flex-wrap: wrap; gap: 12px; }
.import-form label { display: grid; font-size: .78rem; gap: 4px; }
label.stacked { display: grid; font-size: .78rem; gap: 4px; margin-bottom: 14px; max-width: 320px; }

.operation-form { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.operation-form label { display: grid; font-size: .78rem; gap: 4px; }
.inline-form { align-items: center; display: inline-flex; gap: 6px; margin-right: 8px; }
.inline-confirm { align-items: center; display: inline-flex; font-size: .72rem; gap: 4px; }
.grant-line { display: block; font-size: .72rem; }
.is-expiring { color: var(--warning); font-weight: 600; }
.log-tabs { flex-wrap: wrap; }
.log-tabs .is-missing { color: var(--disabled); }
.log-view { max-height: 60vh; }

.deploy-actions { margin-top: 12px; }
.deploy-form { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; }
.deploy-form label { display: grid; font-size: .78rem; gap: 4px; }
/* Migrations a release adds, offered to go into the schema before the code. */
.deploy-migrations { border: 1px solid var(--line, #d9d9d9); border-radius: 8px; display: grid; flex-basis: 100%; gap: 6px; margin: 0; padding: 10px 12px; }
.deploy-migrations legend { font-size: .78rem; font-weight: 600; padding: 0 4px; }
.deploy-form .deploy-migrations label.checkbox { align-items: center; display: flex; gap: 8px; }
.deploy-state { font-weight: 600; text-transform: uppercase; font-size: .72rem; letter-spacing: .04em; }
.deploy-state-running, .deploy-state-queued { color: var(--warning); }
.deploy-state-succeeded { color: var(--accent); }
.deploy-state-failed { color: #8d2138; }
.deploy-log {
    background: var(--header); border: 1px solid var(--line-dark); color: var(--header-text);
    font-size: .76rem; line-height: 1.5; margin: 0; max-height: 420px; overflow: auto;
    padding: 12px; white-space: pre-wrap; word-break: break-word;
}

.fk-link { text-decoration: none; }
.fk-link code { border-bottom: 1px dotted var(--accent); color: var(--accent); }
.row-action { background: white; left: 0; position: sticky; z-index: 1; }
.pagination { align-items: center; display: flex; gap: 14px; justify-content: flex-end; margin-top: 12px; }

.field-table { border: 1px solid var(--line); }
.field-row { align-items: center; border-bottom: 1px solid var(--line); display: grid; gap: 9px; grid-template-columns: 62px minmax(130px, .7fr) minmax(140px, .7fr) 52px minmax(260px, 2fr); padding: 7px 9px; }
.field-row:last-child { border-bottom: 0; }
.field-head { background: #edf0ef; color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.field-row textarea { min-height: 48px; }
.field-disabled { background: #f2f3f2; color: var(--muted); }
.field-row small { color: var(--muted); }
.write-confirmation, .confirmation-grid { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; margin-top: 14px; }
.write-confirmation input, .confirmation-grid input { width: 190px; }
.danger-zone { border-top: 1px solid #c997a3; margin-top: 32px; padding-top: 16px; }
.danger-zone form { align-items: end; display: flex; flex-wrap: wrap; gap: 10px; }
.sql-form > label { display: block; font-size: .78rem; margin-bottom: 5px; }
.sql-form textarea { background: #101918; border-color: #101918; color: #e7eceb; font-size: .84rem; }
.form-actions { align-items: center; color: var(--muted); display: flex; font-size: .78rem; justify-content: space-between; margin-top: 9px; }
.status { border: 1px solid var(--line-dark); display: inline-block; font-size: .73rem; padding: 2px 6px; white-space: nowrap; }
.status-equal { background: #edf3f1; color: #24584f; }
.status-different, .status-source_only, .status-workspace_only { background: var(--warning-soft); border-color: #d6aab4; color: #6b2133; }
.hash { color: var(--muted); }
.error-page { max-width: 680px; }
.error-page h1 { font-size: 1.45rem; }

@media (max-width: 980px) {
    .topbar { gap: 10px; grid-template-columns: 1fr auto; padding: 8px 12px 0; }
    .main-nav { grid-column: 1 / -1; grid-row: 2; min-height: 40px; }
    .actor { grid-column: 2; grid-row: 1; }
    .contextbar { padding: 6px 12px; }
    .app-shell { display: block; }
    .object-sidebar { border-bottom: 1px solid var(--line); border-right: 0; padding: 8px 0; }
    .object-sidebar nav { display: flex; max-height: none; overflow-x: auto; }
    .object-sidebar nav a, .unsupported-object { flex: 0 0 auto; grid-template-columns: 18px auto; }
    .locked { display: none; }
    .content { padding: 18px 12px; }
    .two-column { grid-template-columns: 1fr; }
    .field-table { overflow-x: auto; }
    .field-row { min-width: 860px; }
}

@media (max-width: 640px) {
    .product-name span, .actor, .environment, .database-account { display: none; }
    .page-header { align-items: flex-start; flex-direction: column; gap: 10px; }
    .summary-line { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; width: 100%; }
    .filterbar { align-items: stretch; display: grid; grid-template-columns: 1fr; }
    .filterbar input, .filterbar select { min-width: 0; width: 100%; }
    .confirmation-grid, .write-confirmation, .danger-zone form { align-items: stretch; display: grid; }
    .confirmation-grid input, .write-confirmation input { width: 100%; }
    .form-actions { align-items: stretch; flex-direction: column; gap: 8px; }
}

.secret-marker { color: var(--muted); font-size: .74rem; font-style: italic; }
.redirect-designer .field-row { grid-template-columns: 2fr 2fr 2fr auto; }

/* Sign-in: one code per working session (SignIn.php, 1 October 2026). */
.signin-body { background: var(--paper); }
.signin-page { align-items: center; display: flex; justify-content: center; min-height: 100vh; padding: 24px 16px; }
.signin-card { background: var(--surface); border: 1px solid var(--line); max-width: 420px; padding: 28px; width: 100%; }
.signin-card h1 { margin: 4px 0 10px; }
.signin-form { display: grid; gap: 8px; margin: 18px 0 12px; }
.signin-form input { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .2em; }
.signout-form { display: inline; margin-left: 12px; }
.signout-form button { background: transparent; border-color: #44524f; color: var(--header-text); min-height: 28px; padding: 3px 9px; }
