/* ==========================================================================
   Design system — tokens, reset, layout, components.
   Every project overrides the token block in tokens.css; nothing else needs
   to change for a different brand.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* The UA [hidden] rule loses to .card/.grid/.stack display values, so any
   element toggled via the hidden property must win explicitly. */
[hidden] { display: none !important; }

:root {
  /* Colour — light theme. Override these five and the whole UI follows. */
  --accent: #4f46e5;
  --accent-hover: color-mix(in srgb, var(--accent) 88%, black);
  --accent-soft: color-mix(in srgb, var(--accent) 12%, white);
  --accent-contrast: #ffffff;

  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f3f8;
  --surface-3: #e9ebf3;
  --border: #e3e6ef;
  --border-strong: #cfd4e2;
  --text: #101322;
  --text-soft: #45506b;
  --muted: #6b7590;

  --success: #0f9d68;
  --success-soft: #e4f7ee;
  --warning: #b7791f;
  --warning-soft: #fdf3e2;
  --danger: #d4443c;
  --danger-soft: #fdeceb;
  --info: #2563eb;
  --info-soft: #e8f0fe;

  /* Type */
  --font-sans: "Inter", "SF Pro Text", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, "Cascadia Code", Menlo, Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.8125rem;
  --fs-base: 0.9375rem;
  --fs-md: 1.0625rem;
  --fs-lg: 1.3125rem;
  --fs-xl: 1.75rem;
  --fs-2xl: 2.25rem;
  --fs-3xl: 3rem;
  --lh-tight: 1.2;
  --lh-base: 1.6;

  /* Space — 4px scale */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-8: 32px; --s-10: 40px;
  --s-12: 48px; --s-16: 64px;

  /* Shape + depth */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;
  --shadow-sm: 0 1px 2px rgb(16 19 34 / 6%), 0 1px 3px rgb(16 19 34 / 4%);
  --shadow-md: 0 4px 12px rgb(16 19 34 / 8%), 0 2px 4px rgb(16 19 34 / 4%);
  --shadow-lg: 0 16px 40px rgb(16 19 34 / 12%), 0 4px 12px rgb(16 19 34 / 5%);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
  --sidebar-w: 248px;
  --topbar-h: 60px;
  --ease: cubic-bezier(0.2, 0, 0.13, 1);
}

[data-theme="dark"] {
  --accent-soft: color-mix(in srgb, var(--accent) 22%, #0b0e17);
  --bg: #0b0e17;
  --surface: #121724;
  --surface-2: #171d2c;
  --surface-3: #1e2536;
  --border: #232b3d;
  --border-strong: #313a50;
  --text: #eef1f8;
  --text-soft: #c2c9da;
  --muted: #8b95ac;
  --success: #34d399; --success-soft: #10301f;
  --warning: #fbbf24; --warning-soft: #33260c;
  --danger: #f87171; --danger-soft: #3a1618;
  --info: #60a5fa; --info-soft: #12233d;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 40%);
  --shadow-md: 0 6px 18px rgb(0 0 0 / 45%);
  --shadow-lg: 0 20px 48px rgb(0 0 0 / 55%);
  color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: color-mix(in srgb, var(--accent) 22%, #0b0e17);
    --bg: #0b0e17; --surface: #121724; --surface-2: #171d2c; --surface-3: #1e2536;
    --border: #232b3d; --border-strong: #313a50;
    --text: #eef1f8; --text-soft: #c2c9da; --muted: #8b95ac;
    --success: #34d399; --success-soft: #10301f;
    --warning: #fbbf24; --warning-soft: #33260c;
    --danger: #f87171; --danger-soft: #3a1618;
    --info: #60a5fa; --info-soft: #12233d;
    color-scheme: dark;
  }
}

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 { margin: 0 0 var(--s-3); line-height: var(--lh-tight); letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--s-4); color: var(--text-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
small { font-size: var(--fs-sm); }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--s-6) 0; }
img, svg { max-width: 100%; }
code, pre, kbd { font-family: var(--font-mono); font-size: 0.875em; }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 5px; }
pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); overflow: auto; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--r-sm); }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--accent); color: var(--accent-contrast); padding: var(--s-2) var(--s-4);
}
.skip-link:focus { left: var(--s-2); top: var(--s-2); }

/* ---------------------------------------------------------------- shell -- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: var(--s-4) var(--s-3);
  gap: var(--s-2);
}
.brand { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3) var(--s-4); font-weight: 700; font-size: var(--fs-md); color: var(--text); letter-spacing: -0.02em; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  display: grid; place-items: center; color: var(--accent-contrast); font-size: var(--fs-sm); font-weight: 800;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #7c3aed));
  box-shadow: var(--shadow-sm);
}
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); padding: var(--s-3) var(--s-3) var(--s-1); font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-md); color: var(--text-soft); font-weight: 500; font-size: var(--fs-base);
  transition: background 120ms var(--ease), color 120ms var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .icon { width: 18px; height: 18px; flex: none; opacity: 0.85; }
.sidebar-footer { margin-top: auto; padding-top: var(--s-4); border-top: 1px solid var(--border); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: var(--s-4);
  padding: 0 var(--s-6); border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20;
}
.topbar .spacer { flex: 1; }
.page { padding: var(--s-8) var(--s-6) var(--s-16); max-width: 1240px; width: 100%; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page-header .grow { flex: 1; min-width: 240px; }
.page-header h1 { font-size: var(--fs-xl); margin-bottom: var(--s-1); }
.page-header p { margin: 0; color: var(--muted); font-size: var(--fs-sm); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(84vw, var(--sidebar-w)); z-index: 60;
    transform: translateX(-102%); transition: transform 220ms var(--ease); box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  .nav-scrim { position: fixed; inset: 0; background: rgb(6 9 16 / 48%); z-index: 55; opacity: 0; pointer-events: none; transition: opacity 200ms var(--ease); }
  body.nav-open .nav-scrim { opacity: 1; pointer-events: auto; }
  .page { padding: var(--s-6) var(--s-4) var(--s-12); }
  .topbar { padding: 0 var(--s-4); }
}

/* --------------------------------------------------------------- pieces -- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); padding: var(--s-5);
}
.card + .card { margin-top: var(--s-4); }
.card-header { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); }
.card-header h3, .card-header h2 { margin: 0; font-size: var(--fs-md); }
.card-header .actions { margin-left: auto; display: flex; gap: var(--s-2); }
.card-flush { padding: 0; overflow: hidden; }

.grid { display: grid; gap: var(--s-4); }
.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(240px, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-2 { margin-top: var(--s-2); } .mt-4 { margin-top: var(--s-4); } .mt-6 { margin-top: var(--s-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--s-2); } .mb-4 { margin-bottom: var(--s-4); }
.muted { color: var(--muted); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mono { font-family: var(--font-mono); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* stats */
.stat { display: flex; flex-direction: column; gap: var(--s-1); }
.stat-label { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.stat-value { font-size: var(--fs-xl); font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-delta { font-size: var(--fs-xs); font-weight: 600; }
.stat-delta.up { color: var(--success); }
.stat-delta.down { color: var(--danger); }

/* -------------------------------------------------------------- buttons -- */
.btn {
  --btn-bg: var(--surface); --btn-fg: var(--text); --btn-border: var(--border-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  min-height: 38px; padding: 0 var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--btn-border); background: var(--btn-bg); color: var(--btn-fg);
  font: inherit; font-weight: 600; font-size: var(--fs-sm); cursor: pointer;
  transition: transform 100ms var(--ease), background 120ms var(--ease), border-color 120ms var(--ease), box-shadow 120ms var(--ease);
  text-decoration: none; white-space: nowrap; user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-disabled { opacity: 0.55; pointer-events: none; }
.btn-primary { --btn-bg: var(--accent); --btn-fg: var(--accent-contrast); --btn-border: var(--accent); box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-soft { --btn-bg: var(--accent-soft); --btn-fg: var(--accent); --btn-border: transparent; }
.btn-soft:hover { background: color-mix(in srgb, var(--accent) 18%, var(--surface)); }
.btn-ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { --btn-bg: var(--danger); --btn-fg: #fff; --btn-border: var(--danger); }
.btn-danger:hover { background: color-mix(in srgb, var(--danger) 88%, black); }
.btn-sm { min-height: 30px; padding: 0 var(--s-3); font-size: var(--fs-xs); border-radius: var(--r-sm); }
.btn-lg { min-height: 46px; padding: 0 var(--s-6); font-size: var(--fs-base); border-radius: var(--r-lg); }
.btn-icon { width: 36px; padding: 0; }
.btn-block { width: 100%; }

.icon-btn {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* --------------------------------------------------------------- forms -- */
.field { display: flex; flex-direction: column; gap: var(--s-2); margin-bottom: var(--s-4); }
.field > label, .label { font-size: var(--fs-sm); font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: var(--fs-xs); color: var(--muted); }
.field .field-errors { margin: 0; padding-left: var(--s-4); color: var(--danger); font-size: var(--fs-xs); }

.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); font: inherit; font-size: var(--fs-base);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
.textarea { min-height: 110px; resize: vertical; line-height: 1.55; }
.input::placeholder, .textarea::placeholder { color: var(--muted); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }
.input.has-error, .textarea.has-error { border-color: var(--danger); }
.input-sm { min-height: 32px; font-size: var(--fs-sm); }

.input-group { display: flex; gap: var(--s-2); align-items: center; }
.input-group .input { flex: 1; }

.checkbox, .radio { display: flex; align-items: flex-start; gap: var(--s-2); font-size: var(--fs-sm); color: var(--text-soft); }
.checkbox input, .radio input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

.switch { position: relative; display: inline-flex; align-items: center; gap: var(--s-3); cursor: pointer; font-size: var(--fs-sm); }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track { width: 38px; height: 22px; border-radius: var(--r-full); background: var(--surface-3); border: 1px solid var(--border-strong); position: relative; transition: background 160ms var(--ease); }
.switch-track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); box-shadow: var(--shadow-sm); transition: transform 160ms var(--ease); }
.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

.search-input { position: relative; }
.search-input .input { padding-left: 34px; }
.search-input svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--muted); pointer-events: none; }

/* --------------------------------------------------------------- table -- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table th {
  text-align: left; font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted); padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap;
}
.table td { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.table .num { font-variant-numeric: tabular-nums; text-align: right; }
.table-actions { display: flex; gap: var(--s-1); justify-content: flex-end; }

/* --------------------------------------------------------------- badges -- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.7; border: 1px solid transparent;
  background: var(--surface-2); color: var(--text-soft); white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }

/* --------------------------------------------------------------- alerts -- */
.flash {
  display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface);
  font-size: var(--fs-sm); margin-bottom: var(--s-4); animation: slide-in 260ms var(--ease);
}
.flash-success { background: var(--success-soft); border-color: color-mix(in srgb, var(--success) 28%, transparent); color: var(--success); }
.flash-error { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); color: var(--danger); }
.flash-info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); color: var(--info); }

.alert { padding: var(--s-4); border-radius: var(--r-md); border: 1px solid var(--border); background: var(--surface-2); font-size: var(--fs-sm); }
.alert-warning { background: var(--warning-soft); border-color: color-mix(in srgb, var(--warning) 30%, transparent); }

/* ---------------------------------------------------------------- empty -- */
.empty { text-align: center; padding: var(--s-12) var(--s-4); color: var(--muted); }
.empty-mark {
  width: 52px; height: 52px; border-radius: var(--r-lg); margin: 0 auto var(--s-4);
  display: grid; place-items: center; background: var(--surface-2); border: 1px dashed var(--border-strong); color: var(--muted);
}
.empty h3 { font-size: var(--fs-md); color: var(--text); margin-bottom: var(--s-1); }
.empty p { margin: 0 auto var(--s-4); max-width: 42ch; font-size: var(--fs-sm); }

/* ------------------------------------------------------------ pagination -- */
.pagination { display: flex; align-items: center; gap: var(--s-2); justify-content: space-between; flex-wrap: wrap; margin-top: var(--s-4); }
.pagination .pages { display: flex; gap: var(--s-1); }
.page-link {
  min-width: 34px; height: 34px; display: inline-grid; place-items: center; padding: 0 var(--s-2);
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); font-size: var(--fs-sm); font-weight: 500;
}
.page-link:hover { background: var(--surface-2); text-decoration: none; }
.page-link.is-current { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); font-weight: 700; }

/* ---------------------------------------------------------------- modal -- */
.modal { position: fixed; inset: 0; z-index: 80; display: none; align-items: center; justify-content: center; padding: var(--s-4); }
.modal.is-open { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(6 9 16 / 52%); backdrop-filter: blur(2px); }
.modal-panel {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg); width: min(560px, 100%); max-height: 88vh; overflow: auto;
  padding: var(--s-6); animation: pop-in 200ms var(--ease);
}
.modal-panel h2 { font-size: var(--fs-lg); }
.modal-close { position: absolute; top: var(--s-3); right: var(--s-3); }

/* -------------------------------------------------------------- dropdown -- */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 190px; z-index: 40;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); padding: var(--s-1); display: none;
}
.dropdown.is-open .dropdown-menu { display: block; animation: pop-in 140ms var(--ease); }
.dropdown-item {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-sm); color: var(--text-soft); font-size: var(--fs-sm); width: 100%;
  background: none; border: 0; text-align: left; cursor: pointer; font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.dropdown-sep { height: 1px; background: var(--border); margin: var(--s-1); }

/* ---------------------------------------------------------------- toast -- */
.toasts { position: fixed; right: var(--s-4); bottom: var(--s-4); z-index: 90; display: flex; flex-direction: column; gap: var(--s-2); }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent);
  border-radius: var(--r-md); box-shadow: var(--shadow-md); padding: var(--s-3) var(--s-4);
  font-size: var(--fs-sm); min-width: 240px; animation: slide-in 200ms var(--ease);
}
.toast-success { border-left-color: var(--success); }
.toast-error { border-left-color: var(--danger); }

/* ---------------------------------------------------------------- tabs -- */
.tabs { display: flex; gap: var(--s-1); border-bottom: 1px solid var(--border); margin-bottom: var(--s-5); overflow-x: auto; }
.tab {
  padding: var(--s-2) var(--s-4); border: 0; background: none; color: var(--muted);
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer; border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------- progress -- */
.progress { height: 8px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.progress-bar { height: 100%; background: var(--accent); border-radius: inherit; transition: width 400ms var(--ease); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: var(--fs-sm); overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 56px; height: 56px; font-size: var(--fs-md); }

/* ---------------------------------------------------------------- auth -- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-aside {
  background:
    radial-gradient(1200px 600px at 10% 0%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 60%),
    linear-gradient(160deg, #0c1020, #131a2f 55%, #0a0d17);
  color: #fff; padding: var(--s-12); display: flex; flex-direction: column; justify-content: space-between;
}
.auth-aside h1 { font-size: var(--fs-3xl); letter-spacing: -0.03em; line-height: 1.1; max-width: 22ch; }
.auth-aside p { color: rgb(255 255 255 / 72%); max-width: 44ch; }
.auth-points { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-8); }
.auth-point { display: flex; gap: var(--s-3); align-items: flex-start; font-size: var(--fs-sm); color: rgb(255 255 255 / 82%); }
.auth-point .dot { width: 22px; height: 22px; border-radius: 50%; background: rgb(255 255 255 / 12%); display: grid; place-items: center; flex: none; font-size: 11px; }
.auth-main { display: grid; place-items: center; padding: var(--s-8) var(--s-4); background: var(--bg); }
.auth-card { width: min(400px, 100%); }
.auth-card h2 { font-size: var(--fs-xl); margin-bottom: var(--s-1); }
.auth-card .sub { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--s-6); }
@media (max-width: 900px) { .auth-shell { grid-template-columns: 1fr; } .auth-aside { display: none; } }

/* ------------------------------------------------------------ installer -- */
.install-shell { min-height: 100vh; display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.install-panel { width: min(760px, 100%); }
.install-steps { display: flex; gap: var(--s-2); margin-bottom: var(--s-6); flex-wrap: wrap; }
.install-step {
  display: flex; align-items: center; gap: var(--s-2); padding: var(--s-2) var(--s-3);
  border-radius: var(--r-full); font-size: var(--fs-xs); font-weight: 600;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.install-step.is-done { background: var(--success-soft); color: var(--success); border-color: transparent; }
.install-step.is-current { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.check-row { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--border); font-size: var(--fs-sm); }
.check-row:last-child { border-bottom: 0; }
.check-row .ok { color: var(--success); }
.check-row .bad { color: var(--danger); }
.check-row .detail { margin-left: auto; color: var(--muted); font-size: var(--fs-xs); }

/* ------------------------------------------------------------ animation -- */
@keyframes slide-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop-in { from { opacity: 0; transform: scale(0.97); } to { opacity: 1; transform: none; } }
@keyframes skeleton { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
.skeleton {
  border-radius: var(--r-sm); height: 14px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%; animation: skeleton 1.4s ease infinite;
}
.reveal { animation: slide-in 320ms var(--ease) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------------------------------------------------------------- print -- */
@media print {
  .sidebar, .topbar, .no-print, .toasts { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  .page { padding: 0; max-width: none; }
  body { background: #fff; color: #000; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
}

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --------------------------------------------------------------- prose -- */
.prose { font-size: var(--fs-md); line-height: 1.7; color: var(--text-soft); }
.prose > *:first-child { margin-top: 0; }
.prose h1, .prose h2, .prose h3, .prose h4 { color: var(--text); margin: var(--s-8) 0 var(--s-3); }
.prose h2 { font-size: var(--fs-xl); padding-bottom: var(--s-2); border-bottom: 1px solid var(--border); }
.prose h3 { font-size: var(--fs-lg); }
.prose p { margin: 0 0 var(--s-4); }
.prose ul, .prose ol { margin: 0 0 var(--s-4); padding-left: var(--s-6); }
.prose li { margin-bottom: var(--s-1); }
.prose li::marker { color: var(--muted); }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose code { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 5px; font-size: 0.875em; }
.prose pre { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--s-4); overflow-x: auto; margin: 0 0 var(--s-4); }
.prose pre code { background: none; border: 0; padding: 0; font-size: var(--fs-sm); }
.prose blockquote { margin: 0 0 var(--s-4); padding: var(--s-2) var(--s-4); border-left: 3px solid var(--accent); background: var(--accent-soft); border-radius: 0 var(--r-md) var(--r-md) 0; }
.prose blockquote p:last-child { margin-bottom: 0; }
.prose hr { margin: var(--s-6) 0; }
.prose img { border-radius: var(--r-md); border: 1px solid var(--border); }
.prose table { width: 100%; border-collapse: collapse; margin-bottom: var(--s-4); font-size: var(--fs-sm); }
.prose th, .prose td { border: 1px solid var(--border); padding: var(--s-2) var(--s-3); text-align: left; }
.prose th { background: var(--surface-2); }
