/* Pagesmith admin — design system.
   Light content area, dark sidebar, dense tables and forms. No external fonts or images.
   Component classes mirror the macros in views/_macros.njk; see src/web/README.md. */

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #dfe3ea;
  --border-strong: #c7cdd8;
  --text: #1b2230;
  --muted: #667085;
  --faint: #98a2b3;
  --primary: #2b5fd9;
  --primary-hover: #214cb3;
  --primary-soft: #e8eefc;
  --danger: #c4352b;
  --danger-hover: #a32a22;
  --danger-soft: #fdecea;
  --success: #1a7f4b;
  --success-soft: #e4f5ec;
  --warning: #a8650c;
  --warning-soft: #fdf3dc;
  --info: #23629e;
  --info-soft: #e5f1fb;
  --sidebar-bg: #151a24;
  --sidebar-hover: #1f2634;
  --sidebar-active: #2a3447;
  --sidebar-text: #a9b3c4;
  --sidebar-title: #66728a;
  --radius: 6px;
  --radius-lg: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.18);
  --sidebar-w: 224px;
  --topbar-h: 52px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "Cascadia Mono", Consolas, "Liberation Mono", Menlo, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { font-size: 14px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 1rem; line-height: 1.45; color: var(--text); background: var(--bg); }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; }
h1 { font-size: 1.43rem; }
h2 { font-size: 1.14rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 0.75rem; }
p:last-child { margin-bottom: 0; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
small, .small { font-size: 0.86rem; }
code, kbd, .mono { font-family: var(--mono); font-size: 0.93em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
img { max-width: 100%; }
[x-cloak] { display: none !important; }
[hidden] { display: none !important; }
.icon { flex: none; vertical-align: -0.18em; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }

/* ───────────── shell ───────────── */
.app { min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  display: flex; flex-direction: column; background: var(--sidebar-bg); color: var(--sidebar-text);
  overflow-y: auto; scrollbar-width: thin;
}
.brand { display: flex; align-items: center; gap: 9px; height: var(--topbar-h); padding: 0 16px; color: #fff; font-weight: 650; font-size: 1.07rem; letter-spacing: 0.01em; flex: none; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; background: var(--primary); display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; }
.nav { padding: 4px 8px 12px; flex: 1; }
.nav-section + .nav-section { margin-top: 14px; }
.nav-title { padding: 6px 10px 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.07em; color: var(--sidebar-title); }
.nav-link { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: var(--radius); color: var(--sidebar-text); line-height: 1.3; }
.nav-link:hover { background: var(--sidebar-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sidebar-active); color: #fff; font-weight: 550; box-shadow: inset 2px 0 0 var(--primary); }
.nav-link .icon { opacity: 0.85; }
.nav-empty { padding: 8px 10px; color: var(--sidebar-title); font-size: 0.86rem; }
.sidebar-foot { padding: 10px 18px 14px; font-size: 0.82rem; color: var(--sidebar-title); border-top: 1px solid #222a39; }
.sidebar-foot a { color: #e2a8a3; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--topbar-h); flex: none;
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-title { font-size: 1.07rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex: none; }
.topbar-user { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.nav-toggle { display: none; }
.content { padding: 20px; flex: 1; min-width: 0; max-width: 1480px; width: 100%; }
.sidebar-scrim { display: none; }

.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 26px 26px 22px; }
.auth-brand { display: flex; align-items: center; gap: 9px; font-weight: 650; font-size: 1.2rem; margin-bottom: 4px; }
.auth-sub { color: var(--muted); margin-bottom: 18px; }

/* ───────────── page header ───────────── */
.page-header { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-header-text { min-width: 0; flex: 1 1 260px; }
.page-header h1 { overflow-wrap: anywhere; }
.page-sub { color: var(--muted); margin-top: 3px; }
.page-back { display: inline-flex; align-items: center; gap: 4px; font-size: 0.86rem; color: var(--muted); margin-bottom: 4px; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-left: auto; }

/* ───────────── cards and layout ───────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; }
.card-sub { color: var(--muted); font-size: 0.86rem; }
.card-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.card-body { padding: 16px; }
.card-flush > .card-body { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.card-flush .table-wrap { border: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.grid { display: grid; gap: 16px; }
.grid > .card { margin-bottom: 0; }
.grid + .grid, .grid + .card, .card + .grid { margin-top: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); align-items: start; }
.stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { justify-content: space-between; }
.spacer { flex: 1; }

.stat { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; color: inherit; box-shadow: var(--shadow); min-width: 0; }
a.stat:hover { border-color: var(--border-strong); text-decoration: none; }
.stat-label { color: var(--muted); font-size: 0.82rem; }
.stat-value { font-size: 1.57rem; font-weight: 650; line-height: 1.2; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-hint { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
.stat-running .stat-value { color: var(--primary); }
.stat-failed .stat-value { color: var(--danger); }
.stat-succeeded .stat-value { color: var(--success); }
.stat-warning .stat-value { color: var(--warning); }

/* ───────────── buttons ───────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 550; line-height: 1; white-space: nowrap;
  cursor: pointer; user-select: none; transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled, .btn.disabled, .btn.is-busy { opacity: 0.55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--surface); border-color: #e3b1ad; color: var(--danger); }
.btn-danger:hover { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(16, 24, 40, 0.06); color: var(--text); }
.btn-sm { height: 26px; padding: 0 8px; font-size: 0.86rem; gap: 4px; }
.btn-block { width: 100%; }
.btn-icon { width: 32px; padding: 0; }
.btn-sm.btn-icon { width: 26px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border: 0; border-radius: var(--radius); background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: rgba(16, 24, 40, 0.07); color: var(--text); }
.inline-form { display: inline-flex; margin: 0; }
.btn-group { display: inline-flex; }
.btn-group > .btn { border-radius: 0; margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { display: inline-block; }
.spinner { width: 14px; height: 14px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.7s linear infinite; vertical-align: -2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.htmx-request.btn, .htmx-request > .btn { opacity: 0.6; pointer-events: none; }

/* ───────────── forms ───────────── */
.form { max-width: 760px; }
.form-wide { max-width: none; }
.field { margin-bottom: 14px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field-label { display: block; font-weight: 550; margin-bottom: 4px; }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-hint { color: var(--muted); font-size: 0.86rem; margin-top: 4px; }
.field-error { color: var(--danger); font-size: 0.86rem; margin-top: 4px; font-weight: 500; }
.input, .select, .textarea {
  display: block; width: 100%; min-width: 0; padding: 6px 9px; border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; line-height: 1.35;
}
.input, .select { height: 32px; }
.textarea { resize: vertical; min-height: 64px; }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 0.9rem; }
.input:focus, .select:focus, .textarea:focus { outline: 0; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(43, 95, 217, 0.16); }
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly], .textarea[readonly] { background: var(--surface-2); color: var(--muted); }
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input-sm, .select-sm { height: 26px; padding: 2px 7px; font-size: 0.86rem; }
.input-narrow { max-width: 140px; }
.has-error .input, .has-error .select, .has-error .textarea { border-color: var(--danger); }
.select { appearance: none; padding-right: 26px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 13px) 50%, calc(100% - 8px) 50%; background-size: 5px 5px; background-repeat: no-repeat; }
.select[multiple] { height: auto; background-image: none; padding-right: 9px; }
input[type="file"].input { height: auto; padding: 4px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-row-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.form-section { font-size: 0.82rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.form-section:first-child { margin-top: 0; }
.input-group { display: flex; gap: 6px; align-items: center; }
.input-group > .input { flex: 1; }

.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; line-height: 1.35; }
.check input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--primary); flex: none; }
.check-list { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.check-list-col { flex-direction: column; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; line-height: 1.3; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { position: relative; width: 32px; height: 18px; border-radius: 9px; background: var(--border-strong); transition: background 0.15s; flex: none; }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.15s; }
.switch input:checked + .switch-track { background: var(--primary); }
.switch input:checked + .switch-track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

.secret-current { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 0.9rem; padding: 3px 8px; border-radius: var(--radius); background: var(--surface-2); border: 1px solid var(--border); margin-bottom: 6px; }
.secret-empty { color: var(--warning); font-family: var(--font); }

.ordered { border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.ordered-item { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border-bottom: 1px solid var(--border); }
.ordered-item:last-of-type { border-bottom: 0; }
.ordered-num { color: var(--faint); font-variant-numeric: tabular-nums; width: 16px; }
.ordered-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ordered-empty { padding: 8px 10px; color: var(--muted); }
.ordered-add { display: flex; gap: 6px; padding: 6px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

/* ───────────── tables ───────────── */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); }
.table-sticky { max-height: calc(100vh - 190px); overflow-y: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 0.93rem; }
.table th, .table td { padding: 7px 10px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.table th { position: sticky; top: 0; z-index: 2; background: var(--surface-2); color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fafbfd; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table td.top { vertical-align: top; }
.table .row-actions { text-align: right; white-space: nowrap; width: 1%; }
.table .row-actions > * { vertical-align: middle; }
.table .row-actions > * + * { margin-left: 4px; }
.table tr.is-off td { color: var(--muted); }
.table tr.row-detail td { background: var(--surface-2); padding: 0; }
.table tr.row-detail td > div { padding: 8px 12px; }
.table-compact th, .table-compact td { padding: 5px 8px; }
.cell-main { font-weight: 550; color: var(--text); }
.cell-sub { color: var(--muted); font-size: 0.84rem; }
/* min-width: with overflow-wrap:anywhere a cell in a crowded table would otherwise shrink to one letter per line */
.cell-wrap { white-space: normal; overflow-wrap: anywhere; min-width: 200px; max-width: 340px; }
.cell-wrap.small { min-width: 160px; }

/* ───────────── badges ───────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px; font-size: 0.8rem; font-weight: 550; line-height: 1; white-space: nowrap; background: #eef0f4; color: #475467; }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge-queued { background: #eef0f4; color: #475467; }
.badge-running { background: var(--primary-soft); color: var(--primary); }
.badge-running .badge-dot { animation: pulse 1.2s ease-in-out infinite; }
.badge-succeeded, .badge-success { background: var(--success-soft); color: var(--success); }
.badge-failed, .badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-cancelled, .badge-neutral { background: #f0f1f4; color: #7a8394; }
.badge-paused, .badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
.tag { display: inline-block; padding: 1px 6px; border-radius: 4px; background: var(--surface-2); border: 1px solid var(--border); font-size: 0.82rem; color: var(--muted); white-space: nowrap; }

.queue-badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2); color: var(--muted); font-size: 0.86rem; font-weight: 550; white-space: nowrap; }
.queue-badge:hover { text-decoration: none; border-color: var(--border-strong); }
.queue-badge b { color: var(--text); font-variant-numeric: tabular-nums; }
.queue-badge.is-active { background: var(--primary-soft); border-color: #c5d4f7; color: var(--primary); }
.queue-badge.is-active b { color: var(--primary); }
.queue-badge.is-paused { background: var(--danger-soft); border-color: #f1c2be; color: var(--danger); }
.queue-badge.is-paused b { color: var(--danger); }

/* ───────────── tabs ───────────── */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; color: var(--muted); font-weight: 550; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; background: none; border-top: 0; border-left: 0; border-right: 0; font: inherit; cursor: pointer; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count { font-size: 0.78rem; background: #eef0f4; color: var(--muted); border-radius: 9px; padding: 1px 6px; }

/* ───────────── alerts, empty state, toasts ───────────── */
.alert { display: flex; gap: 9px; align-items: flex-start; padding: 9px 12px; border-radius: var(--radius); border: 1px solid #c9dcf0; background: var(--info-soft); color: #1d4f80; margin-bottom: 14px; overflow-wrap: anywhere; }
.alert:last-child { margin-bottom: 0; }
.alert .icon { margin-top: 2px; }
.alert-success { background: var(--success-soft); border-color: #bfe3cf; color: #14633a; }
.alert-error { background: var(--danger-soft); border-color: #f1c2be; color: #96281f; }
.alert-warning { background: var(--warning-soft); border-color: #f0dba8; color: #7d4a07; }
.alert a:not(.btn) { color: inherit; text-decoration: underline; }
.alert .btn { flex: none; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }
.empty-icon { width: 44px; height: 44px; margin: 0 auto 10px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--faint); }
.empty-title { color: var(--text); font-weight: 600; font-size: 1.07rem; }
.empty-text { margin-top: 4px; max-width: 460px; margin-left: auto; margin-right: auto; }
.empty-actions { margin-top: 14px; display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

.toasts { position: fixed; top: 12px; right: 12px; z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 24px)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius); background: #1f2633; color: #fff; box-shadow: var(--shadow-lg); border-left: 4px solid var(--info); overflow-wrap: anywhere; animation: toast-in 0.18s ease-out; }
.toast-success { border-left-color: #35b877; }
.toast-error { border-left-color: #f0645a; }
.toast-warning { border-left-color: #e9a93a; }
.toast-text { flex: 1; min-width: 0; }
.toast-close { border: 0; background: none; color: #aab3c4; cursor: pointer; font-size: 18px; line-height: 1; padding: 0 2px; }
.toast-close:hover { color: #fff; }
.toast.is-leaving { opacity: 0; transform: translateX(12px); transition: opacity 0.2s, transform 0.2s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ───────────── modal ───────────── */
.modal { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 20, 30, 0.5); }
.modal-dialog { position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); }
.modal-lg .modal-dialog { max-width: 860px; }
.modal-sm .modal-dialog { max-width: 400px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.modal-head h3 { flex: 1; font-size: 1.07rem; }
.modal-body { padding: 16px; overflow-y: auto; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ───────────── progress, code, key-value, pagination ───────────── */
.progress { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-bar { flex: 1; height: 6px; border-radius: 3px; background: #e6e9ef; overflow: hidden; min-width: 60px; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.progress-done .progress-fill { background: var(--success); }
.progress-failed .progress-fill { background: var(--danger); }
.progress-text { font-size: 0.82rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.progress-label { font-size: 0.82rem; color: var(--muted); margin-top: 2px; }

.code-wrap { position: relative; }
/* A block with a copy button gets a toolbar strip of its own, so the button never covers the text (also while it scrolls). */
.code-wrap.has-copy { padding-top: 32px; border-radius: var(--radius); background: #171c26; }
.code-wrap.has-copy > .code { padding-top: 2px; border-radius: 0 0 var(--radius) var(--radius); }
.code-wrap.has-copy.is-light { background: var(--surface-2); border: 1px solid var(--border); }
.code-wrap.has-copy.is-light > .code { border: 0; }
.code { margin: 0; padding: 10px 12px; border-radius: var(--radius); background: #171c26; color: #dfe5ef; font-family: var(--mono); font-size: 0.88rem; line-height: 1.5; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; }
.code-nowrap { white-space: pre; overflow-wrap: normal; }
.code-light { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.code-copy { position: absolute; top: 6px; right: 6px; height: 24px; padding: 0 8px; border-radius: 4px; border: 1px solid #39435a; background: #232b3a; color: #c8d0de; font: inherit; font-size: 0.8rem; cursor: pointer; opacity: 0.85; }
.code-copy:hover { opacity: 1; color: #fff; }
.code-wrap.is-light .code-copy { top: 4px; right: 4px; border-color: var(--border-strong); background: var(--surface); color: var(--muted); }
.code-wrap.is-light .code-copy:hover { color: var(--text); }

.kv { display: grid; grid-template-columns: minmax(120px, max-content) minmax(0, 1fr); gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.pagination { display: flex; align-items: center; gap: 4px; margin-top: 14px; flex-wrap: wrap; }
.page-link { display: inline-grid; place-items: center; min-width: 30px; height: 30px; padding: 0 8px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); color: var(--text); font-variant-numeric: tabular-nums; }
.page-link:hover { background: var(--surface-2); text-decoration: none; }
.page-link.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-link.disabled { color: var(--faint); pointer-events: none; }
.page-gap { color: var(--faint); padding: 0 4px; }
.pagination-info { margin-left: 8px; color: var(--muted); font-size: 0.86rem; }

/* ───────────── health checklist ───────────── */
.checklist { list-style: none; margin: 0; padding: 0; }
.check-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.check-item:last-child { border-bottom: 0; padding-bottom: 0; }
.check-item:first-child { padding-top: 0; }
.check-mark { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: none; margin-top: 1px; color: #fff; background: var(--faint); }
.check-ok .check-mark { background: var(--success); }
.check-warn .check-mark { background: #d99a1c; }
.check-fail .check-mark { background: var(--danger); }
.check-off .check-mark, .check-load .check-mark { background: #c3c9d4; }
.check-body { min-width: 0; flex: 1; }
.check-label { font-weight: 550; }
.check-hint { color: var(--muted); font-size: 0.86rem; overflow-wrap: anywhere; }
.check-link { white-space: nowrap; font-size: 0.86rem; }

/* ───────────── misc ───────────── */
.thumb { width: 40px; height: 40px; object-fit: contain; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 1px solid var(--border); }
.preview-frame { width: 100%; height: 70vh; border: 1px solid var(--border); border-radius: var(--radius-lg); background: #fff; }
.divider-text { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 0.82rem; margin: 14px 0; }
.divider-text::before, .divider-text::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.error-page { text-align: center; padding: 56px 16px; }
.error-code { font-size: 3.4rem; font-weight: 700; color: var(--border-strong); line-height: 1; }
.error-message { font-size: 1.14rem; margin: 10px auto 18px; max-width: 560px; overflow-wrap: anywhere; }

/* ───────────── settings → models ───────────── */
.model-toolbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 12px; }
.model-list { display: flex; flex-direction: column; gap: 10px; }
.model { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); padding: 12px 14px; min-width: 0; scroll-margin-top: 64px; }
.model:target { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.model.is-off { background: var(--surface-2); }
.model.is-off .model-name { color: var(--muted); }
.model-head { display: flex; align-items: center; gap: 10px 12px; flex-wrap: wrap; }
.model-title { flex: 1 1 260px; min-width: 0; }
.model-name { font-weight: 600; font-size: 1.02rem; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.model-id { color: var(--muted); font-size: 0.84rem; overflow-wrap: anywhere; }
.model-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.model-test:empty { display: none; }
.model-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1.35fr); gap: 12px 28px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.model-col-title { font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--faint); margin-bottom: 6px; }
.model-kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 12px; margin: 0; font-size: 0.92rem; }
.model-kv dt { color: var(--muted); }
.model-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.model-warn { color: var(--warning); font-size: 0.84rem; margin-top: 1px; }
.model-addons { display: flex; flex-direction: column; gap: 8px; }
.model-addon-desc { display: block; color: var(--muted); font-size: 0.84rem; line-height: 1.4; margin-top: 1px; }
.model-notes { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); color: var(--muted); font-size: 0.86rem; line-height: 1.45; overflow-wrap: anywhere; }
.model-notes summary { cursor: pointer; }
.model-notes[open] .model-notes-short { display: none; }
.model-notes-full { margin-top: 4px; }
.sync-block { margin-top: 14px; }
.list-tight { margin: 4px 0 0; padding-left: 18px; }
@media (max-width: 1180px) { .model-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .model-grid > :last-child { grid-column: 1 / -1; } }
@media (max-width: 700px) { .model-grid { grid-template-columns: minmax(0, 1fr); } }

/* ───────────── responsive (down to tablet) ───────────── */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
  .form-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 920px) {
  .sidebar { transform: translateX(-100%); transition: transform 0.18s ease-out; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(15, 20, 30, 0.45); }
  .main { margin-left: 0; }
  .nav-toggle { display: inline-grid; }
  .topbar { padding: 0 12px; }
  .content { padding: 14px 12px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-user span { display: none; }
}
@media (max-width: 680px) {
  .grid-2, .grid-3, .grid-4, .form-row, .form-row-3, .form-row-4 { grid-template-columns: minmax(0, 1fr); }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 8px; }
  .page-actions { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
