/* ==========================================================================
   zerynix Admin - one stylesheet for the database setup page.

   Tokens: the platform's shared set (deployments/shared-ui/tokens.css, 2026-10-28): "Ink" dark and "Paper" light
   themes selected by <html data-theme>, IBM Plex Sans/Mono and Bricolage Grotesque self-hosted. Flat surfaces separated
   by hairlines; shadows only on the dialog. No inline styles or scripts (CSP: style-src 'self', script-src 'self').
   ========================================================================== */

@font-face { font-family: "Bricolage Grotesque"; src: url("/static/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Sans"; src: url("/static/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("/static/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-style: normal; font-display: swap; }

/* ---- Tokens ---------------------------------------------------------------- */
:root {
    --font-display: "Bricolage Grotesque", "IBM Plex Sans", system-ui, sans-serif;
    --font-body: "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
    --font-mono: "IBM Plex Mono", "Cascadia Mono", ui-monospace, Consolas, monospace;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --gutter: 16px;
    --wrap: 60rem;
    --dur-1: 120ms;
    --dur-2: 180ms;

    color-scheme: dark;
    --bg: #0b1220;
    --surface: #101a2c;
    --surface-2: #16223a;
    --hover: #1c2a45;
    --sunken: #0a101c;
    --line: #24324f;
    --line-strong: #34456b;
    --control-line: #6a7a99;
    --text: #e7ecf5;
    --text-2: #a9b4ca;
    --text-3: #8693ad;
    --accent: #7db3ff;
    --accent-hover: #a2c8ff;
    --accent-soft: rgb(125 179 255 / 0.14);
    --on-accent: #07101e;
    --focus: #a2c8ff;
    --success: #74d3a4; --success-bg: rgb(116 211 164 / 0.13);
    --warning: #f0c562; --warning-bg: rgb(240 197 98 / 0.13);
    --danger: #ff9d9d; --danger-bg: rgb(255 157 157 / 0.12);
    --code-bg: #0a101c; --code-text: #d8e2f2;
    --scrim: rgb(3 7 15 / 0.62);
    --shadow-float: 0 14px 36px rgb(2 6 15 / 0.55), 0 2px 6px rgb(2 6 15 / 0.4);
}
:root[data-theme="light"] {
    color-scheme: light;
    --bg: #eef1f6;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --hover: #e9eef6;
    --sunken: #f2f4f8;
    --line: #d6dce7;
    --line-strong: #b6c0d2;
    --control-line: #6b7891;
    --text: #0f1728;
    --text-2: #434e66;
    --text-3: #5f6a82;
    --accent: #1f4fd8;
    --accent-hover: #173fb0;
    --accent-soft: rgb(31 79 216 / 0.09);
    --on-accent: #ffffff;
    --focus: #1f4fd8;
    --success: #17663f; --success-bg: #e5f4ec;
    --warning: #845400; --warning-bg: #fbf1d9;
    --danger: #b42318; --danger-bg: #fdecea;
    --code-bg: #f3f5f9; --code-text: #1b2436;
    --scrim: rgb(15 23 40 / 0.42);
    --shadow-float: 0 14px 36px rgb(15 23 40 / 0.16), 0 2px 6px rgb(15 23 40 / 0.1);
}

/* ---- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); color: var(--text); font: 400 1rem/1.55 var(--font-body); -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; }
h1, h2 { font-family: var(--font-display); font-weight: 650; letter-spacing: -0.02em; }
h3 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
code { font-family: var(--font-mono); font-size: 0.9em; padding: 0.05em 0.35em; border-radius: 4px; background: var(--code-bg); color: var(--code-text); }
a { color: var(--accent); text-underline-offset: 0.18em; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--gutter); top: -4rem; z-index: 20; background: var(--accent); color: var(--on-accent); padding: 0.6rem 1rem; border-radius: var(--radius-md); font-weight: 600; }
.skip-link:focus { top: var(--gutter); color: var(--on-accent); }
.wrap { width: 100%; max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }
main { flex: 1 0 auto; padding-bottom: 4rem; }
[hidden] { display: none !important; }

/* ---- Header ----------------------------------------------------------------- */
.bar { border-bottom: 1px solid var(--line); background: var(--surface); }
.bar-inner { max-width: var(--wrap); margin: 0 auto; padding: 0.6rem var(--gutter); display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 1.5rem; min-height: 56px; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: var(--text); text-decoration: none; font-family: var(--font-display); font-weight: 700; font-size: 1.35rem; letter-spacing: -0.03em; line-height: 1; }
.brand:hover { color: var(--text); }
.brand-mark { width: 1.8rem; height: 1.8rem; flex: none; color: var(--accent); }
.brand-product { font-family: var(--font-body); font-weight: 500; font-size: 1rem; letter-spacing: 0; color: var(--text-2); }
.bar-tools { margin-left: auto; display: flex; align-items: center; gap: 1rem; }
.bar-note { color: var(--text-3); font-size: 0.875rem; }
.theme-form { display: inline-flex; gap: 0.2rem; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; }
.theme-form button { font: 500 0.875rem var(--font-body); min-height: 2.25rem; padding: 0 0.85rem; border: 0; border-radius: 999px; background: transparent; color: var(--text-2); cursor: pointer; }
.theme-form button:hover { color: var(--text); }
.theme-form button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* ---- Page head, panels -------------------------------------------------------- */
.page-head { padding: clamp(1.75rem, 5vw, 3rem) 0 1.5rem; }
.page-head h1 { font-size: clamp(1.9rem, 1.3rem + 2.4vw, 2.75rem); }
.lede { margin-top: 0.75rem; color: var(--text-2); font-size: 1.0625rem; max-width: 64ch; }
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.panel { padding: 1.25rem clamp(1rem, 3vw, 1.5rem) 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.panel-title { display: flex; align-items: center; gap: 0.7rem; font-size: 1.25rem; }
.step-no { display: inline-grid; place-items: center; width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font: 600 0.9375rem var(--font-body); flex: none; }
.panel-lede { margin-top: 0.5rem; color: var(--text-2); font-size: 0.9688rem; max-width: 64ch; }
.note { margin-top: 1rem; padding: 0.7rem 0.9rem; border-left: 3px solid var(--warning); background: var(--warning-bg); border-radius: 0 var(--radius-md) var(--radius-md) 0; color: var(--text); font-size: 0.9375rem; }

/* ---- Forms -------------------------------------------------------------------- */
.field { margin: 1.25rem 0 0; max-width: 28rem; }
.field > label, .select-label { display: block; font-weight: 500; font-size: 0.9688rem; margin: 0 0 0.35rem; }
.input { display: block; width: 100%; min-height: 2.75rem; padding: 0.5rem 0.85rem; background: var(--surface-2); color: var(--text); border: 1.5px solid var(--control-line); border-radius: var(--radius-md); font: 400 1rem/1.4 var(--font-body); }
.input:hover { border-color: var(--text); }
.input:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; border-color: var(--text); border-radius: var(--radius-md); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input--select { width: auto; min-width: 16rem; padding-right: 2.2rem; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%), linear-gradient(135deg, var(--text-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.input-affix { position: relative; }
.input-affix .input { padding-right: 4.75rem; }
.affix-btn { position: absolute; right: 0.35rem; top: 50%; transform: translateY(-50%); min-height: 2.25rem; padding: 0 0.7rem; background: transparent; border: 0; border-radius: var(--radius-sm); color: var(--accent); font: 600 0.9062rem var(--font-body); cursor: pointer; }
.affix-btn:hover { color: var(--accent-hover); }
.field-error { display: block; color: var(--danger); font-size: 0.9062rem; font-weight: 500; margin: 0.4rem 0 0; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1rem; margin-top: 1.25rem; }
.actions--run { align-items: end; }
.actions--run .select-label { margin: 0 0 0.35rem; }
.busy-text { color: var(--text-2); font-size: 0.9375rem; min-height: 1.4em; }
.busy-text:empty { display: none; }
.spinner { display: inline-block; width: 0.9rem; height: 0.9rem; margin-right: 0.4rem; vertical-align: -0.15em; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Buttons ------------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-height: 2.75rem; padding: 0.55rem 1.15rem; border: 1.5px solid transparent; border-radius: var(--radius-md); background: var(--surface-2); color: var(--text); font: 600 0.9688rem/1.2 var(--font-body); text-decoration: none; cursor: pointer; transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); color: var(--on-accent); }
.btn-quiet { background: transparent; color: var(--text); border-color: var(--control-line); }
.btn-quiet:hover { border-color: var(--text); }
.btn-small { min-height: 2.25rem; padding: 0.3rem 0.85rem; font-size: 0.9062rem; }
.btn[aria-disabled="true"], .btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn[data-busy="true"] { cursor: progress; opacity: 0.85; }

/* ---- Facts, tables -------------------------------------------------------------- */
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr)); gap: 0.75rem 1.5rem; margin: 1rem 0 0; }
.facts > div { padding: 0.75rem 0.9rem; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-2); }
.facts dt { color: var(--text-3); font-size: 0.8438rem; font-weight: 500; }
.facts dd { margin: 0.15rem 0 0; font-family: var(--font-mono); font-size: 0.9375rem; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; }
.table-wrap { margin-top: 1rem; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: 0.9375rem; }
.table th, .table td { padding: 0.65rem 0.9rem; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table thead th { font-size: 0.8125rem; font-weight: 600; color: var(--text-3); white-space: nowrap; }
.table .num { text-align: right; white-space: nowrap; }
.table .schema-name { font-weight: 600; }
.table .schema-detail { display: block; color: var(--text-3); font-size: 0.8438rem; font-weight: 400; }
.table .schema-file { display: block; color: var(--text-3); font-family: var(--font-mono); font-size: 0.8125rem; }
.outcome { display: inline-flex; align-items: center; gap: 0.35rem; font-weight: 600; font-size: 0.875rem; }
.outcome::before { content: ""; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: currentColor; flex: none; }
.outcome-done { color: var(--success); }
.outcome-failed { color: var(--danger); }
.outcome-skipped { color: var(--text-3); }
.outcome-error { color: var(--danger); font-weight: 400; font-size: 0.875rem; display: block; margin-top: 0.25rem; overflow-wrap: anywhere; }

/* ---- Result, log ---------------------------------------------------------------- */
.alert { margin-top: 1rem; padding: 0.8rem 1rem; border-left: 4px solid var(--text-3); background: var(--surface-2); border-radius: 0 var(--radius-md) var(--radius-md) 0; font-size: 0.9688rem; }
.alert:empty { display: none; }
.alert strong { display: block; font-weight: 600; }
.alert-success { border-color: var(--success); background: var(--success-bg); }
.alert-error { border-color: var(--danger); background: var(--danger-bg); }
.alert-info { border-color: var(--accent); background: var(--accent-soft); }
.alert .btn { margin-top: 0.6rem; }
.log-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1rem; margin-top: 1.5rem; }
.log-tools { display: flex; align-items: center; gap: 0.75rem; }
.copy-status { color: var(--success); font-size: 0.875rem; font-weight: 500; }
.log { margin: 0.5rem 0 0; padding: 0.85rem 1rem; max-height: 24rem; overflow: auto; background: var(--code-bg); color: var(--code-text); border: 1px solid var(--line); border-radius: var(--radius-md); font: 500 0.8125rem/1.55 var(--font-mono); white-space: pre-wrap; overflow-wrap: anywhere; direction: ltr; unicode-bidi: isolate; }
.log:empty::before { content: "No run yet."; color: var(--text-3); }

/* ---- Dialog --------------------------------------------------------------------- */
dialog.confirm { max-width: min(28rem, calc(100vw - 2 * var(--gutter))); padding: 1.5rem; background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: var(--radius-lg); box-shadow: var(--shadow-float); }
dialog.confirm::backdrop { background: var(--scrim); }
dialog.confirm h2 { font-size: 1.35rem; margin-bottom: 0.5rem; }
dialog.confirm p { color: var(--text-2); }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.6rem; margin-top: 1.5rem; }

/* ---- Footer --------------------------------------------------------------------- */
.foot { border-top: 1px solid var(--line); }
.foot .wrap { padding-top: 1.25rem; padding-bottom: 1.5rem; display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; justify-content: space-between; color: var(--text-3); font-size: 0.875rem; }

/* ---- Small screens --------------------------------------------------------------- */
@media (max-width: 640px) {
    .bar-note { display: none; }
    .field { max-width: none; }
    .input--select { width: 100%; }
    .actions--run { flex-direction: column; align-items: stretch; }
    .actions--run .btn { width: 100%; }
    .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
    .table tr { display: block; padding: 0.5rem 0; border-bottom: 1px solid var(--line); }
    .table tbody tr:last-child { border-bottom: 0; }
    .table td { display: flex; justify-content: space-between; gap: 1rem; padding: 0.3rem 0.9rem; border: 0; text-align: left; }
    .table td.num { text-align: right; }
    .table td::before { content: attr(data-label); color: var(--text-3); font-size: 0.8125rem; font-weight: 500; flex: none; }
    .table td:first-child { display: block; padding-top: 0.5rem; }
    .table td:first-child::before { display: none; }
}
@media (pointer: coarse) { .btn, .input, .theme-form button { min-height: 2.75rem; } }

/* ---- Motion and forced colours --------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
@media (forced-colors: active) {
    .btn, .input, .theme-form button { border: 2px solid ButtonText; }
    .theme-form button[aria-pressed="true"] { border: 3px solid Highlight; }
    .outcome::before { background: CanvasText; }
}
