/* ==========================================================================
   HR · Payroll · Finance — Admin design system
   --------------------------------------------------------------------------
   Hand-written, no build step, no framework. One file.
   Sections:
     01. Tokens (light)            12. Feedback: alerts, toasts, empty, loaders
     02. Tokens (dark)             13. Tabs & pagination
     03. Base / reset              14. Overlays: dropdown, modal, drawer
     04. App layout                15. Data display: stat, kv, timeline, avatar…
     05. Sidebar & navigation      16. Permission matrix
     06. Topbar                    17. Notifications
     07. Page header & breadcrumbs 18. Auth pages
     08. Cards                     19. Utilities
     09. Buttons                   20. Responsive
     10. Badges, chips, dots       21. Motion preferences
     11. Tables, toolbar, forms    22. Print
   Spacing utilities use an 8px scale with a 4px half step:
     1 = 4px · 2 = 8px · 3 = 16px · 4 = 24px
   ========================================================================== */


/* ==========================================================================
   01. Tokens — light (default)
   ========================================================================== */
:root {
  color-scheme: light;
  /* Surfaces */
  --bg: #f6f7f9;
  --surface: #ffffff; --surface-2: #f9fafb; --surface-3: #f1f3f5; --surface-sunken: #eef0f3;
  --overlay: rgba(15, 23, 42, 0.45);
  /* Lines */
  --border: #e4e7ec; --border-strong: #d0d5dd;
  /* Text (all ≥ 4.5:1 on --surface and --bg) */
  --text: #111827; --text-2: #475467; --text-3: #667085; --text-inverse: #ffffff;
  /* Accent (single blue) */
  --accent: #2563eb; --accent-hover: #1d4ed8; --accent-text: #1d4ed8; --accent-soft: #eff4ff;
  --accent-border: #c7d7fe;
  --on-accent: #ffffff;
  --avatar-bg: #e3ebfd; --avatar-text: #1d4ed8;
  --focus: #2563eb; --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.28);
  /* Status */
  --success: #15803d; --success-soft: #ecfdf3; --success-border: #abefc6; --success-solid: #16a34a;
  --warning: #b54708; --warning-soft: #fffaeb; --warning-border: #fedf89; --warning-solid: #f59e0b;
  --danger: #b42318; --danger-soft: #fef3f2; --danger-border: #fecdca; --danger-solid: #d92d20;
  --danger-hover: #b42318;
  --info: #026aa2; --info-soft: #f0f9ff; --info-border: #b9e6fe; --info-solid: #0ba5ec;
  --neutral: #344054; --neutral-soft: #f2f4f7; --neutral-border: #e4e7ec; --neutral-solid: #98a2b3;
  /* Sidebar */
  --sidebar-bg: #fbfbfc; --sidebar-text: #344054; --sidebar-muted: #667085;
  --sidebar-hover: #f1f3f5; --sidebar-active-bg: #eef2fb; --sidebar-active-text: #1d4ed8;
  /* Type */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: 12px; --fs-sm: 13px; --fs-base: 14px; --fs-md: 15px; --fs-lg: 16px; --fs-xl: 18px;
  --fs-2xl: 22px; --fs-3xl: 26px;
  --lh: 1.45;
  --fw-medium: 500; --fw-semibold: 600;
  /* Spacing (8px scale + 4px half step) */
  --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px; --space-5: 20px;
  --space-6: 24px; --space-8: 32px; --space-10: 40px; --space-12: 48px;
  /* Radius */
  --radius-sm: 4px; --radius: 6px; --radius-lg: 8px; --radius-xl: 12px; --radius-full: 999px;
  /* Elevation — subtle, borders do most of the work */
  --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.10), 0 2px 4px -2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 16px 40px -8px rgba(16, 24, 40, 0.20), 0 4px 8px -4px rgba(16, 24, 40, 0.06);
  /* Sizes */
  --control-h: 34px; --control-h-sm: 28px; --control-h-lg: 40px;
  --sidebar-w: 248px; --sidebar-w-collapsed: 64px;
  --topbar-h: 56px;
  --content-max: 1440px;
  --z-sticky: 20; --z-sidebar: 60; --z-dropdown: 70; --z-overlay: 80; --z-toast: 90;
  --ease: cubic-bezier(0.2, 0, 0, 1);
}


/* ==========================================================================
   02. Tokens — dark
   Applied for html[data-theme="dark"], and for html[data-theme="system"]
   (or no data-theme) when the OS prefers dark.
   ========================================================================== */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c0e12;
  --surface: #13161c; --surface-2: #171b22; --surface-3: #1e232c; --surface-sunken: #0f1216;
  --overlay: rgba(0, 0, 0, 0.6);
  --border: #262c36; --border-strong: #363d4a;
  --text: #e8eaee; --text-2: #b3b9c4; --text-3: #8d95a3; --text-inverse: #0c0e12;
  --accent: #2563eb; --accent-hover: #3b74f0; --accent-text: #7aa7ff;
  --accent-soft: rgba(59, 130, 246, 0.14); --accent-border: rgba(96, 150, 255, 0.40);
  --avatar-bg: #1d2a44; --avatar-text: #9cbcff;
  --focus: #6b9cff; --focus-ring: 0 0 0 3px rgba(107, 156, 255, 0.35);
  --success: #4ade80; --success-soft: rgba(34, 197, 94, 0.12);
  --success-border: rgba(74, 222, 128, 0.30);
  --warning: #fbbf24; --warning-soft: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(251, 191, 36, 0.30);
  --danger: #f87171; --danger-soft: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(248, 113, 113, 0.32); --danger-solid: #dc2626; --danger-hover: #b91c1c;
  --info: #38bdf8; --info-soft: rgba(14, 165, 233, 0.12); --info-border: rgba(56, 189, 248, 0.30);
  --neutral: #c5cad3; --neutral-soft: rgba(255, 255, 255, 0.06);
  --neutral-border: rgba(255, 255, 255, 0.10); --neutral-solid: #6b7280;
  --sidebar-bg: #101318; --sidebar-text: #c5cad3; --sidebar-muted: #8d95a3;
  --sidebar-hover: #1a1f27; --sidebar-active-bg: rgba(59, 130, 246, 0.14);
  --sidebar-active-text: #9cbcff;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"], html:not([data-theme]) {
    color-scheme: dark;
    --bg: #0c0e12;
    --surface: #13161c; --surface-2: #171b22; --surface-3: #1e232c; --surface-sunken: #0f1216;
    --overlay: rgba(0, 0, 0, 0.6);
    --border: #262c36; --border-strong: #363d4a;
    --text: #e8eaee; --text-2: #b3b9c4; --text-3: #8d95a3; --text-inverse: #0c0e12;
    --accent: #2563eb; --accent-hover: #3b74f0; --accent-text: #7aa7ff;
    --accent-soft: rgba(59, 130, 246, 0.14); --accent-border: rgba(96, 150, 255, 0.40);
    --avatar-bg: #1d2a44; --avatar-text: #9cbcff;
    --focus: #6b9cff; --focus-ring: 0 0 0 3px rgba(107, 156, 255, 0.35);
    --success: #4ade80; --success-soft: rgba(34, 197, 94, 0.12);
    --success-border: rgba(74, 222, 128, 0.30);
    --warning: #fbbf24; --warning-soft: rgba(245, 158, 11, 0.12);
    --warning-border: rgba(251, 191, 36, 0.30);
    --danger: #f87171; --danger-soft: rgba(239, 68, 68, 0.12);
    --danger-border: rgba(248, 113, 113, 0.32); --danger-solid: #dc2626; --danger-hover: #b91c1c;
    --info: #38bdf8; --info-soft: rgba(14, 165, 233, 0.12); --info-border: rgba(56, 189, 248, 0.30);
    --neutral: #c5cad3; --neutral-soft: rgba(255, 255, 255, 0.06);
    --neutral-border: rgba(255, 255, 255, 0.10); --neutral-solid: #6b7280;
    --sidebar-bg: #101318; --sidebar-text: #c5cad3; --sidebar-muted: #8d95a3;
    --sidebar-hover: #1a1f27; --sidebar-active-bg: rgba(59, 130, 246, 0.14);
    --sidebar-active-text: #9cbcff;
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3); --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 8px 20px -4px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.03);
    --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  }
}


/* ==========================================================================
   03. Base / reset
   ========================================================================== */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }

body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--fs-base); line-height: var(--lh);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

body.has-overlay { overflow: hidden; }

h1, h2, h3, h4, h5, h6 { margin: 0; font-weight: var(--fw-semibold); line-height: 1.3; color: var(--text); }
p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; }
img, svg, video { max-width: 100%; }
svg { flex-shrink: 0; }
hr { border: 0; height: 1px; background: var(--border); margin: var(--space-4) 0; }
small { font-size: var(--fs-xs); }
strong, b { font-weight: var(--fw-semibold); }
code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
:not(pre) > code {
  padding: 1px 5px; border-radius: var(--radius-sm); background: var(--surface-3);
  color: var(--text);
}
kbd {
  padding: 1px 6px; border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--radius-sm); background: var(--surface); font-size: var(--fs-xs);
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: var(--radius-sm); }

::selection { background: rgba(37, 99, 235, 0.22); }

.icon { display: inline-block; vertical-align: middle; flex: none; }

/* Theme-toggle icon swap (CSS-only, so no inline script is needed) */
[data-theme-icon] { display: none; }
html:not([data-theme]) [data-theme-icon="system"],
html[data-theme="system"] [data-theme-icon="system"],
html[data-theme="light"] [data-theme-icon="light"],
html[data-theme="dark"] [data-theme-icon="dark"] { display: inline-block; }


/* ==========================================================================
   04. App layout
   ========================================================================== */
.app {
  --sb: var(--sidebar-w); display: grid; grid-template-columns: var(--sb) minmax(0, 1fr);
  min-height: 100vh;
  /* Paint the rail behind the sticky sidebar so it reads as one column on long pages */
  background: linear-gradient(90deg, var(--sidebar-bg) calc(var(--sb) - 1px), var(--border) calc(var(--sb) - 1px) var(--sb), var(--bg) var(--sb));
  transition: grid-template-columns 0.2s var(--ease);
}
.main { display: flex; flex-direction: column; min-width: 0; min-height: 100vh; }

.content {
  width: 100%; max-width: var(--content-max); margin: 0 auto;
  padding: var(--space-6) var(--space-8) var(--space-12); flex: 1 0 auto;
}

.sidebar-backdrop { display: none; }


/* ==========================================================================
   05. Sidebar & navigation
   ========================================================================== */
.sidebar {
  position: sticky; top: 0; z-index: var(--z-sidebar); display: flex; flex-direction: column;
  height: 100vh; background: var(--sidebar-bg); border-right: 1px solid var(--border);
  color: var(--sidebar-text);
}

.sidebar__brand {
  display: flex; align-items: center; gap: var(--space-3); height: var(--topbar-h);
  padding: 0 var(--space-4); border-bottom: 1px solid var(--border); flex: none; min-width: 0;
}

.sidebar__logo {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  flex: none; border-radius: var(--radius); background: var(--accent); color: var(--on-accent);
  font-size: var(--fs-sm); font-weight: 700; letter-spacing: -0.02em; text-decoration: none;
}
.sidebar__logo:hover { text-decoration: none; }

.sidebar__brand > .dropdown { flex: 1 1 auto; min-width: 0; }
.sidebar__brand > .dropdown > .dropdown__menu { left: -6px; right: auto; min-width: 220px; }

/* Company switcher: name / meta on the left, chevron on the right */
.sidebar__company {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center;
  column-gap: var(--space-2); flex: 1 1 auto; width: 100%; min-width: 0; margin: 0 -6px;
  padding: 4px 6px; border: 0; border-radius: var(--radius); background: none; color: var(--text);
  font-size: var(--fs-base); font-weight: var(--fw-semibold); line-height: 1.25; text-align: left;
  white-space: nowrap;
}
.sidebar__company > * { grid-column: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.sidebar__company > :nth-child(2):not(svg) { color: var(--sidebar-muted); font-size: var(--fs-xs); font-weight: 400; }
.sidebar__company > svg { grid-column: 2; grid-row: 1 / span 2; width: 16px; height: 16px; color: var(--sidebar-muted); }
button.sidebar__company:hover,
a.sidebar__company:hover { background: var(--sidebar-hover); text-decoration: none; }

.sidebar__nav {
  position: relative; flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: var(--space-3) var(--space-3) var(--space-6); scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.sidebar__footer { flex: none; padding: var(--space-3); border-top: 1px solid var(--border); }

.nav-group + .nav-group { margin-top: var(--space-4); }

.nav-group__title {
  display: block; margin: 0 0 var(--space-1); padding: 0 var(--space-3);
  color: var(--sidebar-muted); font-size: 11px; font-weight: var(--fw-semibold);
  letter-spacing: 0.06em; text-transform: uppercase; white-space: nowrap; line-height: 24px;
}

.nav-item {
  position: relative; display: flex; align-items: center; gap: 10px; min-height: 32px;
  padding: 0 var(--space-3); border-radius: var(--radius); color: var(--sidebar-text);
  font-weight: var(--fw-medium); font-size: var(--fs-base); text-decoration: none;
  white-space: nowrap; transition: background-color 0.12s, color 0.12s;
}
.nav-item + .nav-item { margin-top: 1px; }
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
.nav-item:focus-visible { outline-offset: -2px; }
.nav-item.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); }
.nav-item.is-active .nav-item__icon { color: var(--sidebar-active-text); }

.nav-item__icon { width: 18px; height: 18px; flex: none; color: var(--sidebar-muted); }
.nav-item:hover .nav-item__icon { color: var(--text); }
.nav-item__label { overflow: hidden; text-overflow: ellipsis; }

.nav-item__badge {
  margin-left: auto; min-width: 20px; height: 18px; padding: 0 6px;
  border-radius: var(--radius-full); background: var(--surface-3); color: var(--text-2);
  font-size: 11px; font-weight: var(--fw-semibold); line-height: 18px; text-align: center;
  font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-item__badge { background: var(--accent); color: var(--on-accent); }

/* Desktop collapsed rail (icons only). Scoped to ≥1024px so it never
   affects the off-canvas drawer used on smaller screens. */
@media (min-width: 1024px) {
  .app.is-sidebar-collapsed { --sb: var(--sidebar-w-collapsed); }
  .app.is-sidebar-collapsed .sidebar__brand { justify-content: center; padding: 0; }
  .app.is-sidebar-collapsed .sidebar__brand > .dropdown,
  .app.is-sidebar-collapsed .sidebar__company,
  .app.is-sidebar-collapsed .nav-group__title,
  .app.is-sidebar-collapsed .nav-item__badge,
  .app.is-sidebar-collapsed .nav-item__label,
  .app.is-sidebar-collapsed .sidebar__footer { display: none; }
  .app.is-sidebar-collapsed .sidebar__nav { padding-left: var(--space-2); padding-right: var(--space-2); }
  .app.is-sidebar-collapsed .nav-group + .nav-group {
    margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border);
  }
  .app.is-sidebar-collapsed .nav-item {
    justify-content: center; height: 36px; padding: 0; gap: 0;
    font-size: 0;           /* hides bare text nodes inside the link */
  }
}


/* ==========================================================================
   06. Topbar
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: var(--z-sticky); display: flex; align-items: center;
  gap: var(--space-3); height: var(--topbar-h); padding: 0 var(--space-6);
  background: var(--surface); border-bottom: 1px solid var(--border);
}

.topbar__left { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }

.topbar__search { position: relative; flex: 1 1 auto; min-width: 0; max-width: 420px; margin: 0; }
.topbar__search > svg, .topbar__search .icon {
  position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.topbar__search input {
  width: 100%; height: var(--control-h); padding: 0 var(--space-3) 0 34px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2);
  color: var(--text); font-size: var(--fs-base);
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}
.topbar__search input::placeholder { color: var(--text-3); }
.topbar__search input:hover { border-color: var(--border-strong); }
.topbar__search input:focus { background: var(--surface); border-color: var(--focus); box-shadow: var(--focus-ring); outline: none; }
.topbar__search kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: var(--text-3);
  pointer-events: none;
}

.topbar__actions { display: flex; align-items: center; gap: var(--space-1); margin-left: auto; flex: none; }

.topbar__user {
  display: inline-flex; align-items: center; gap: var(--space-2); padding: 2px; border: 0;
  border-radius: var(--radius-full); background: none;
}
.topbar__user:hover { background: var(--surface-3); }

.has-dot { position: relative; }
.has-dot::after {
  content: ""; position: absolute; top: 6px; right: 6px; width: 8px; height: 8px;
  border: 2px solid var(--surface); border-radius: 50%; background: var(--danger-solid);
}


/* ==========================================================================
   07. Page header & breadcrumbs
   ========================================================================== */
.page-header {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-6);
}
.page-header__titles { min-width: 0; flex: 1 1 320px; }
.page-title {
  font-size: var(--fs-2xl); font-weight: var(--fw-semibold); letter-spacing: -0.015em;
  line-height: 1.25; overflow-wrap: anywhere;
}
.page-subtitle { margin: var(--space-1) 0 0; color: var(--text-2); font-size: var(--fs-base); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }

.breadcrumbs ol, ol.breadcrumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px 0; margin: 0 0 var(--space-2);
  padding: 0; list-style: none; font-size: var(--fs-sm); color: var(--text-3);
}
.breadcrumbs li { display: inline-flex; align-items: center; min-width: 0; }
.breadcrumbs li + li::before { content: "/"; margin: 0 var(--space-2); color: var(--border-strong); }
.breadcrumbs a { color: var(--text-2); }
.breadcrumbs a:hover { color: var(--text); }
.breadcrumbs [aria-current="page"] { color: var(--text); font-weight: var(--fw-medium); }
.topbar .breadcrumbs ol, .topbar ol.breadcrumbs { margin: 0; }


/* ==========================================================================
   08. Cards
   ========================================================================== */
.card {
  min-width: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-xs);
}
.card + .card { margin-top: var(--space-4); }

.card__header {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4);
  padding: 14px var(--space-5); border-bottom: 1px solid var(--border); min-height: 54px;
}
.card__header > :first-child:not(.card__actions) { flex: 1 1 auto; min-width: 0; }
.card__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); line-height: 1.35; }
.card__subtitle { margin: 2px 0 0; color: var(--text-3); font-size: var(--fs-sm); }
.card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-left: auto; }

.card__body { padding: var(--space-5); }
.card__body.card__body--flush { padding: 0; }
.card__body--flush > .table-wrap { border-radius: 0; }

.card__footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--border);
  background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.card > :last-child:not(.card__footer) { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }


/* ==========================================================================
   09. Buttons
   ========================================================================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: var(--control-h); padding: 0 14px; border: 1px solid var(--border-strong);
  border-radius: var(--radius); background: var(--surface); color: var(--text);
  font-size: var(--fs-base); font-weight: var(--fw-medium); line-height: 1; white-space: nowrap;
  text-decoration: none; vertical-align: middle; box-shadow: var(--shadow-xs); cursor: pointer;
  user-select: none;
  transition: background-color 0.12s, border-color 0.12s, color 0.12s, box-shadow 0.12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; color: var(--text); }
.btn:active { background: var(--surface-sunken); }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn > svg { width: 16px; height: 16px; }

.btn--secondary { /* explicit alias of the default bordered button */ }

.btn--primary {
  background: var(--accent); border-color: var(--accent); color: var(--on-accent);
  box-shadow: var(--shadow-xs), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn--primary:active { background: var(--accent-hover); }

.btn--danger { background: var(--danger-solid); border-color: var(--danger-solid); color: #ffffff; }
.btn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); color: #ffffff; }
.btn--danger:active { background: var(--danger-hover); }

.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--link {
  height: auto; padding: 0; border: 0; background: none; box-shadow: none;
  color: var(--accent-text);
}
.btn--link:hover, .btn--link:active { background: none; color: var(--accent-text); text-decoration: underline; text-underline-offset: 2px; }

.btn--sm { height: var(--control-h-sm); padding: 0 10px; font-size: var(--fs-sm); gap: 6px; }
.btn--sm > svg { width: 14px; height: 14px; }
.btn--lg { height: var(--control-h-lg); padding: 0 18px; font-size: var(--fs-md); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn--icon.btn--lg { width: var(--control-h-lg); }
.btn--icon > svg { width: 18px; height: 18px; }
.btn--icon.btn--sm > svg { width: 16px; height: 16px; }
.btn--block { display: flex; width: 100%; }

.btn[disabled], .btn.is-disabled, .btn[aria-disabled="true"] {
  opacity: 0.5; cursor: not-allowed; pointer-events: none; box-shadow: none;
}

.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 14px; height: 14px; border: 2px solid currentColor;
  border-color: var(--text-3) var(--text-3) var(--text-3) transparent; border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.btn-group { display: inline-flex; vertical-align: middle; }
.btn-group > .btn { border-radius: 0; box-shadow: none; }
.btn-group > .btn + .btn { margin-left: -1px; }
.btn-group > .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.btn-group > .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group > .btn:hover, .btn-group > .btn:focus-visible { position: relative; z-index: 1; }
.btn-group > .btn.is-active { background: var(--surface-3); color: var(--text); }


/* ==========================================================================
   10. Badges, chips, dots
   ========================================================================== */
.badge {
  display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px;
  border: 1px solid var(--neutral-border); border-radius: var(--radius-full);
  background: var(--neutral-soft); color: var(--neutral); font-size: var(--fs-xs);
  font-weight: var(--fw-medium); line-height: 1; white-space: nowrap; vertical-align: middle;
}
.badge > svg { width: 12px; height: 12px; }
.badge .dot { width: 6px; height: 6px; }
.badge--success { background: var(--success-soft); border-color: var(--success-border); color: var(--success); }
.badge--warning { background: var(--warning-soft); border-color: var(--warning-border); color: var(--warning); }
.badge--danger  { background: var(--danger-soft);  border-color: var(--danger-border);  color: var(--danger); }
.badge--info    { background: var(--info-soft);    border-color: var(--info-border);    color: var(--info); }
.badge--neutral { background: var(--neutral-soft); border-color: var(--neutral-border); color: var(--neutral); }
.badge--accent  { background: var(--accent-soft);  border-color: var(--accent-border);  color: var(--accent-text); }

.chip {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius-full);
  background: var(--surface); color: var(--text-2); font-size: var(--fs-sm); white-space: nowrap;
}
.chip button, .chip .chip__remove {
  display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  margin-right: -6px; padding: 0; border: 0; border-radius: 50%; background: none;
  color: var(--text-3);
}
.chip button:hover { background: var(--surface-3); color: var(--text); }
.chip svg { width: 12px; height: 12px; }

.dot {
  display: inline-block; width: 8px; height: 8px; flex: none; border-radius: 50%;
  background: var(--neutral-solid); vertical-align: middle;
}
.dot--success { background: var(--success-solid); }
.dot--warning { background: var(--warning-solid); }
.dot--danger  { background: var(--danger-solid); }
.dot--info    { background: var(--info-solid); }
.dot--neutral { background: var(--neutral-solid); }
.dot--accent  { background: var(--accent); }


/* ==========================================================================
   11a. Tables
   ========================================================================== */
.table-wrap {
  position: relative;     /* contains absolutely-positioned children (e.g. .sr-only) */
  width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
}
.table-wrap--scroll,
.table-wrap:has(> .matrix) { max-height: min(70vh, 720px); overflow: auto; }

.table {
  width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base);
  font-variant-numeric: lining-nums;
}
.table th, .table td {
  padding: 10px var(--space-4); border-bottom: 1px solid var(--border); text-align: left;
  vertical-align: middle;
}
.table th {
  height: 38px; padding-top: 8px; padding-bottom: 8px; background: var(--surface-2);
  color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  letter-spacing: 0.02em; text-transform: uppercase; white-space: nowrap;
}
.table th:first-child, .table td:first-child { padding-left: var(--space-5); }
.table th:last-child, .table td:last-child { padding-right: var(--space-5); }
.table tbody tr:last-child td { border-bottom: 0; }
.table th a { color: inherit; text-decoration: none; }
.table td .badge { vertical-align: middle; }
.table input[type="checkbox"] { width: 16px; height: 16px; margin: 0; vertical-align: middle; accent-color: var(--accent); }
.table .col-check { width: 1%; padding-right: 0; }

.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text); }
.table th.is-sortable::after, .table th.is-sorted-asc::after, .table th.is-sorted-desc::after {
  content: ""; display: inline-block; width: 5px; height: 5px; margin-left: 7px;
  border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor;
  vertical-align: 2px; opacity: 0; transform: rotate(45deg); transition: opacity 0.12s;
}
.table th.is-sortable:hover::after { opacity: 0.45; }
.table th.is-sorted-asc,
.table th.is-sorted-desc { color: var(--text); }
.table th.is-sorted-asc::after { opacity: 1; transform: rotate(-135deg); vertical-align: -1px; }
.table th.is-sorted-desc::after { opacity: 1; transform: rotate(45deg); }

.table tbody tr { transition: background-color 0.1s; }
.table tr.is-clickable { cursor: pointer; }
.table tr.is-clickable:hover td,
.table tr[data-row-href]:hover td { background: var(--surface-2); }
.table tr.is-selected td { background: var(--accent-soft); }
.table tr[data-row-href]:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }

.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .table__actions { text-align: right; white-space: nowrap; width: 1%; }
.table .table__actions > * + * { margin-left: var(--space-1); }
.table .is-muted-row td { color: var(--text-3); }
.table .is-muted-row td .badge, .table .is-muted-row td .avatar { opacity: 0.75; }

.table tfoot td, .table tfoot th {
  border-top: 1px solid var(--border-strong); border-bottom: 0; background: var(--surface-2);
  color: var(--text); font-weight: var(--fw-semibold); font-size: var(--fs-base);
  text-transform: none; letter-spacing: 0;
}

.table--compact { font-size: var(--fs-sm); }
.table--compact th, .table--compact td { padding: 6px var(--space-3); }
.table--compact th { height: 32px; }
.table--compact th:first-child, .table--compact td:first-child { padding-left: var(--space-4); }
.table--compact th:last-child, .table--compact td:last-child { padding-right: var(--space-4); }

/* Rich cell: avatar + two-line label */
.cell-user { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-user__name { color: var(--text); font-weight: var(--fw-medium); white-space: nowrap; }
.cell-user__meta { color: var(--text-3); font-size: var(--fs-xs); white-space: nowrap; }


/* ==========================================================================
   11b. Toolbar & filters
   ========================================================================== */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2);
  margin-bottom: var(--space-4);
}
.card > .toolbar, .card__body--flush > .toolbar {
  margin: 0; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
}
.toolbar__group { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.toolbar__spacer { flex: 1 1 auto; }
.toolbar .input, .toolbar .select { width: auto; height: var(--control-h-sm); font-size: var(--fs-sm); }
.toolbar .input-group { width: auto; }
.toolbar .input-group .input { min-width: 0; width: 220px; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px; height: var(--control-h-sm); padding: 0 10px;
  border: 1px dashed var(--border-strong); border-radius: var(--radius-full);
  background: transparent; color: var(--text-2); font-size: var(--fs-sm);
  font-weight: var(--fw-medium); white-space: nowrap; text-decoration: none;
}
.filter-chip:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.filter-chip > svg { width: 14px; height: 14px; }
.filter-chip.is-active {
  border-style: solid; border-color: var(--accent-border); background: var(--accent-soft);
  color: var(--accent-text);
}
.filter-chip__value { color: var(--text); font-weight: var(--fw-semibold); }
.filter-chip.is-active .filter-chip__value { color: inherit; }


/* ==========================================================================
   11c. Forms
   ========================================================================== */
.form { display: block; min-width: 0; }

.form-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4) var(--space-6);
}
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.form-section { padding-bottom: var(--space-6); }
.form-section + .form-section { padding-top: var(--space-6); border-top: 1px solid var(--border); }
.form-section__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
.form-section__desc { margin: 2px 0 var(--space-4); color: var(--text-3); font-size: var(--fs-sm); max-width: 640px; }
.form-section__title + .form-grid,
.form-section__title + .field { margin-top: var(--space-4); }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--full { grid-column: 1 / -1; }
.field + .field { margin-top: 0; }
.form > .field + .field, .auth-card .field + .field { margin-top: var(--space-4); }

.field__label { color: var(--text); font-size: var(--fs-sm); font-weight: var(--fw-medium); line-height: 1.35; }
.field__label .req { margin-left: 1px; color: var(--danger); font-weight: var(--fw-semibold); }
.field__label .optional { margin-left: 4px; color: var(--text-3); font-weight: 400; }
.field__hint { color: var(--text-3); font-size: var(--fs-xs); line-height: 1.4; }
.field__error {
  display: flex; align-items: flex-start; gap: 5px; color: var(--danger); font-size: var(--fs-xs);
  font-weight: var(--fw-medium); line-height: 1.4;
}
.field__error > svg { width: 14px; height: 14px; margin-top: 1px; }
.field__row { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); padding-top: 6px; }

.input, .select, .textarea {
  display: block; width: 100%; min-width: 0; height: var(--control-h); padding: 0 10px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background-color: var(--surface); color: var(--text); font-size: var(--fs-base); line-height: 1.4;
  box-shadow: var(--shadow-xs); transition: border-color 0.12s, box-shadow 0.12s;
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--focus); box-shadow: var(--focus-ring); outline: none;
}
.input:disabled, .select:disabled, .textarea:disabled, .input[readonly], .textarea[readonly] {
  background-color: var(--surface-2); color: var(--text-2); box-shadow: none;
}
.input:disabled, .select:disabled, .textarea:disabled { cursor: not-allowed; border-color: var(--border); }
.input[type="date"], .input[type="time"], .input[type="month"] { min-width: 0; }
.input[type="number"] { font-variant-numeric: tabular-nums; }
.input--sm, .select--sm { height: var(--control-h-sm); font-size: var(--fs-sm); }

/* Native select with a CSS-gradient caret (no data: URI → CSP-safe for img-src) */
.select {
  padding-right: 32px; appearance: none; -webkit-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% - 16px) 52%, calc(100% - 11px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; text-overflow: ellipsis;
}
.select[multiple], .select[size] { height: auto; padding: 4px; background-image: none; }

.textarea { height: auto; min-height: 88px; padding: 8px 10px; resize: vertical; line-height: 1.5; }

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea,
.input.is-invalid, .select.is-invalid, .textarea.is-invalid { border-color: var(--danger); }
.field.has-error .input:focus,
.field.has-error .select:focus,
.field.has-error .textarea:focus { box-shadow: 0 0 0 3px rgba(217, 45, 32, 0.22); }
.field.has-error .field__label { color: var(--danger); }

.input-group { display: flex; align-items: stretch; width: 100%; min-width: 0; }
.input-group > .input, .input-group > .select { flex: 1 1 auto; width: 1%; }
.input-group > * { border-radius: 0; }
.input-group > * + * { margin-left: -1px; }
.input-group > :first-child { border-radius: var(--radius) 0 0 var(--radius); }
.input-group > :last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.input-group > :only-child { border-radius: var(--radius); }
.input-group > .input:focus, .input-group > .select:focus { position: relative; z-index: 1; }
.input-group > .btn { height: auto; min-height: var(--control-h); box-shadow: none; }
.input-addon {
  display: inline-flex; align-items: center; flex: none; padding: 0 10px;
  border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-3);
  font-size: var(--fs-sm); white-space: nowrap;
}
.input-addon > svg { width: 16px; height: 16px; }
.field.has-error .input-group > .input-addon { border-color: var(--danger); }

.checkbox, .radio {
  display: inline-flex; align-items: flex-start; gap: var(--space-2); color: var(--text);
  font-size: var(--fs-base); line-height: 20px; cursor: pointer;
}
.checkbox input, .radio input {
  flex: none; width: 16px; height: 16px; margin: 2px 0 0; accent-color: var(--accent);
  cursor: pointer;
}
.checkbox input:disabled + *, .radio input:disabled + * { color: var(--text-3); cursor: not-allowed; }
.checkbox small, .radio small { display: block; color: var(--text-3); font-size: var(--fs-xs); line-height: 1.4; }

.switch {
  position: relative; display: inline-flex; align-items: center; gap: 10px; color: var(--text);
  line-height: 20px; cursor: pointer;
}
.switch input { position: absolute; width: 32px; height: 18px; margin: 0; opacity: 0; cursor: pointer; }
.switch__track {
  position: relative; flex: none; width: 32px; height: 18px; border-radius: var(--radius-full);
  background: var(--border-strong); transition: background-color 0.15s var(--ease);
}
.switch__track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: #ffffff; box-shadow: 0 1px 2px rgba(16, 24, 40, 0.25);
  transition: transform 0.15s var(--ease);
}
.switch input:checked + .switch__track { background: var(--accent); }
.switch input:checked + .switch__track::after { transform: translateX(14px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--focus); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: 0.5; }
.switch input:disabled ~ span:last-child { color: var(--text-3); }

.form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center;
  justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-6);
  padding: var(--space-4) 0; border-top: 1px solid var(--border);
  background: var(--form-actions-bg, var(--bg));
}
.card .form-actions { --form-actions-bg: var(--surface); }
.card__body > .form-actions:last-child, .card__body > .form > .form-actions:last-child {
  margin: var(--space-6) calc(var(--space-5) * -1) calc(var(--space-5) * -1);
  padding: var(--space-3) var(--space-5); border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.form-actions__start { margin-right: auto; display: flex; align-items: center; gap: var(--space-2); }

.readonly-value {
  display: flex; align-items: center; min-height: var(--control-h); color: var(--text);
  font-size: var(--fs-base); overflow-wrap: anywhere;
}
.readonly-value:empty::before { content: "—"; color: var(--text-3); }


/* ==========================================================================
   12. Feedback: alerts, toasts, empty state, spinner, skeleton
   ========================================================================== */
.alert {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border: 1px solid var(--info-border);
  border-radius: var(--radius-lg); background: var(--info-soft); color: var(--text);
  font-size: var(--fs-base);
}
.alert + .alert { margin-top: var(--space-2); }
.alert > svg { width: 18px; height: 18px; margin-top: 1px; color: var(--info); }
.alert__body { flex: 1; min-width: 0; }
.alert__title { display: block; font-weight: var(--fw-semibold); }
.alert__close {
  display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px;
  margin: -2px -6px -2px auto; padding: 0; border: 0; border-radius: var(--radius-sm);
  background: none; color: var(--text-3); flex: none;
}
.alert__close:hover { background: rgba(127, 127, 127, 0.14); color: var(--text); }
.alert__close svg { width: 16px; height: 16px; }
.alert--success { border-color: var(--success-border); background: var(--success-soft); }
.alert--success > svg { color: var(--success); }
.alert--error { border-color: var(--danger-border); background: var(--danger-soft); }
.alert--error > svg { color: var(--danger); }
.alert--warning { border-color: var(--warning-border); background: var(--warning-soft); }
.alert--warning > svg { color: var(--warning); }
.alert--info > svg { color: var(--info); }

.flash-stack {
  position: fixed;
  top: calc(var(--topbar-h) + var(--space-3));   /* below the topbar so its actions stay usable */
  right: var(--space-4); z-index: var(--z-toast); display: flex; flex-direction: column;
  gap: var(--space-2); width: min(380px, calc(100vw - 32px)); pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
  border: 1px solid var(--border); border-left: 3px solid var(--info-solid);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); pointer-events: auto; animation: toast-in 0.2s var(--ease);
}
.toast > svg { width: 18px; height: 18px; margin-top: 1px; color: var(--info); }
.toast__body { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast .alert__close { margin: -2px 0 -2px auto; }
.toast--success { border-left-color: var(--success-solid); }
.toast--success > svg { color: var(--success); }
.toast--error, .toast--danger { border-left-color: var(--danger-solid); }
.toast--error > svg, .toast--danger > svg { color: var(--danger); }
.toast--warning { border-left-color: var(--warning-solid); }
.toast--warning > svg { color: var(--warning); }
.toast.is-leaving, .alert.is-leaving { opacity: 0; transform: translateY(-4px); transition: opacity 0.18s, transform 0.18s; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.empty-state {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-12) var(--space-6); text-align: center;
}
.empty-state__icon {
  display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 48px;
  margin-bottom: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-xl);
  background: var(--surface-2); color: var(--text-3);
}
.empty-state__icon svg { width: 22px; height: 22px; }
.empty-state__title { font-size: var(--fs-md); font-weight: var(--fw-semibold); color: var(--text); }
.empty-state__text { max-width: 420px; margin: var(--space-1) 0 0; color: var(--text-3); font-size: var(--fs-sm); }
.empty-state__action { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); margin-top: var(--space-5); }

.spinner {
  display: inline-block; width: 16px; height: 16px; flex: none;
  border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%;
  vertical-align: middle; animation: spin 0.7s linear infinite;
}
.spinner--sm { width: 12px; height: 12px; }
.spinner--lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  display: block; height: 12px; border-radius: var(--radius-sm);
  background: linear-gradient(90deg, var(--border) 25%, var(--surface-3) 37%, var(--border) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease infinite;
}
.skeleton + .skeleton { margin-top: var(--space-2); }
.skeleton--title { height: 18px; width: 40%; }
.skeleton--circle { width: 32px; height: 32px; border-radius: 50%; }
@keyframes shimmer { from { background-position: 100% 50%; } to { background-position: 0 50%; } }


/* ==========================================================================
   13. Tabs & pagination
   ========================================================================== */
.tabs {
  position: relative; display: flex; gap: var(--space-1); margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border); overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.card__header + .tabs, .card > .tabs { margin-bottom: 0; padding: 0 var(--space-4); }

.tab {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 40px;
  margin-bottom: -1px; padding: 0 var(--space-3); border: 0; border-bottom: 2px solid transparent;
  background: none; color: var(--text-2); font-size: var(--fs-base); font-weight: var(--fw-medium);
  white-space: nowrap; text-decoration: none; transition: color 0.12s, border-color 0.12s;
}
.tab:hover { color: var(--text); border-bottom-color: var(--border-strong); text-decoration: none; }
.tab.is-active, .tab[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.tab:focus-visible { outline-offset: -2px; }
.tab > svg { width: 16px; height: 16px; }
.tab .badge { height: 18px; padding: 0 6px; font-size: 11px; }
.tab-panel { min-width: 0; }
.tab-panel[hidden] { display: none !important; }

.pagination {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); margin: 0; padding: 0;
  list-style: none;
}
.pagination li { display: flex; }
.pagination a, .pagination span {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-width: 32px;
  height: 32px; padding: 0 var(--space-2); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums;
  text-decoration: none;
}
.pagination a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.pagination svg { width: 14px; height: 14px; }
.pagination .is-active > a, .pagination .is-active > span, .pagination a.is-active {
  border-color: var(--accent); background: var(--accent); color: var(--on-accent);
}
.pagination .is-disabled > a,
.pagination .is-disabled > span { opacity: 0.5; pointer-events: none; }
.pagination .pagination__gap > span { border-color: transparent; background: none; }
.pagination-info { color: var(--text-3); font-size: var(--fs-sm); font-variant-numeric: tabular-nums; }


/* ==========================================================================
   14. Overlays: dropdown, modal, drawer
   ========================================================================== */
.dropdown { position: relative; display: inline-flex; }

.dropdown__menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: var(--z-dropdown); display: none;
  min-width: 200px; max-width: min(320px, calc(100vw - 24px)); max-height: min(420px, 70vh);
  overflow-y: auto; padding: var(--space-1); border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-md);
  text-align: left;
}
.dropdown__menu--left { right: auto; left: 0; }
.dropdown__menu--up { top: auto; bottom: calc(100% + 4px); }
.dropdown__menu--wide { min-width: 320px; padding: 0; }
.dropdown.is-open > .dropdown__menu { display: block; animation: pop-in 0.12s var(--ease); }

.dropdown__item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 32px; padding: 0 10px;
  border: 0; border-radius: var(--radius-sm); background: none; color: var(--text);
  font-size: var(--fs-base); text-align: left; text-decoration: none; white-space: nowrap;
  cursor: pointer;
}
.dropdown__item:hover, .dropdown__item:focus-visible { background: var(--surface-3); text-decoration: none; color: var(--text); outline: none; }
.dropdown__item > svg { width: 16px; height: 16px; color: var(--text-3); }
.dropdown__item.is-active { color: var(--accent-text); }
.dropdown__item.is-active > svg { color: var(--accent-text); }
.dropdown__item--danger, .dropdown__item--danger > svg { color: var(--danger); }
.dropdown__item--danger:hover { background: var(--danger-soft); color: var(--danger); }
.dropdown__item kbd, .dropdown__item .badge { margin-left: auto; }
.dropdown__divider { height: 1px; margin: var(--space-1) calc(var(--space-1) * -1); background: var(--border); border: 0; }
.dropdown__header {
  padding: 6px 10px 4px; color: var(--text-3); font-size: var(--fs-xs);
  font-weight: var(--fw-semibold); line-height: 1.4;
}
.dropdown__header strong { display: block; color: var(--text); font-size: var(--fs-base); }
.dropdown__header--bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border);
}
.dropdown__header--bar strong { display: inline; }
.dropdown form { margin: 0; }

@keyframes pop-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

.modal, .drawer {
  position: fixed; inset: 0; z-index: var(--z-overlay); display: none; background: var(--overlay);
}
.modal { align-items: center; justify-content: center; padding: var(--space-4); overflow-y: auto; }
.modal.is-open { display: flex; animation: fade-in 0.15s ease; }
.drawer.is-open { display: block; animation: fade-in 0.15s ease; }

.modal__dialog {
  display: flex; flex-direction: column; width: 100%; max-width: 520px;
  max-height: calc(100vh - 32px); margin: auto; border: 1px solid var(--border);
  border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-lg);
  overflow: hidden; animation: dialog-in 0.18s var(--ease);
}
.modal__dialog--sm { max-width: 420px; }
.modal__dialog--lg { max-width: 760px; }
.modal__dialog--xl { max-width: 1040px; }

.drawer__dialog, .drawer__panel {
  position: absolute; top: 0; right: 0; bottom: 0; display: flex; flex-direction: column;
  width: min(480px, 100%); border-left: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow-lg); animation: drawer-in 0.22s var(--ease);
}
.drawer__dialog--lg { width: min(720px, 100%); }

.modal__header, .drawer__header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  flex: none; padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--border);
}
.modal__title, .drawer__title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); line-height: 1.35; }
.modal__body, .drawer__body { position: relative; flex: 1 1 auto; padding: var(--space-5); overflow-y: auto; }
.modal__footer, .drawer__footer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: var(--space-2); flex: none; padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border); background: var(--surface-2);
}
.modal__header .btn--icon, .drawer__header .btn--icon { margin-right: -8px; }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }


/* ==========================================================================
   15. Data display: stat, kv, timeline, avatar, progress, code
   ========================================================================== */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: var(--space-4);
  margin-bottom: var(--space-6);
}
.stat {
  min-width: 0; padding: var(--space-4) var(--space-5); border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-xs);
}
.stat__label {
  display: flex; align-items: center; gap: var(--space-2); color: var(--text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
}
.stat__label > svg { width: 16px; height: 16px; color: var(--text-3); }
.stat__value {
  margin-top: var(--space-2); color: var(--text); font-size: var(--fs-3xl);
  font-weight: var(--fw-semibold); letter-spacing: -0.02em; line-height: 1.15;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere;
}
.stat__value small { margin-right: 4px; color: var(--text-3); font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: 0; }
.stat__delta {
  display: inline-flex; align-items: center; gap: 4px; margin-top: var(--space-2);
  color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-medium);
  font-variant-numeric: tabular-nums;
}
.stat__delta--up { color: var(--success); }
.stat__delta--down { color: var(--danger); }
.stat__delta--up::before { content: "\2191"; }
.stat__delta--down::before { content: "\2193"; }
.stat__delta .muted { font-weight: 400; }

.kv {
  display: grid; grid-template-columns: minmax(120px, 200px) minmax(0, 1fr);
  gap: var(--space-3) var(--space-6); margin: 0;
}
.kv dt { color: var(--text-3); font-size: var(--fs-sm); line-height: 20px; }
.kv dd { margin: 0; color: var(--text); line-height: 20px; overflow-wrap: anywhere; }

.timeline { position: relative; margin: 0; padding: 0 0 0 var(--space-6); list-style: none; }
.timeline::before {
  content: ""; position: absolute; top: 6px; bottom: 6px; left: 7px; width: 2px; border-radius: 1px;
  background: var(--border);
}
.timeline__item { position: relative; padding-bottom: var(--space-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__item::before {
  content: ""; position: absolute; top: 4px; left: -21px; width: 12px; height: 12px;
  border: 2px solid var(--surface); border-radius: 50%; background: var(--neutral-solid);
  box-shadow: 0 0 0 1px var(--border-strong);
}
.timeline__item--success::before { background: var(--success-solid); box-shadow: 0 0 0 1px var(--success-border); }
.timeline__item--warning::before { background: var(--warning-solid); box-shadow: 0 0 0 1px var(--warning-border); }
.timeline__item--danger::before { background: var(--danger-solid); box-shadow: 0 0 0 1px var(--danger-border); }
.timeline__item--accent::before { background: var(--accent); box-shadow: 0 0 0 1px var(--accent-border); }
.timeline__meta { color: var(--text-3); font-size: var(--fs-xs); }
.timeline__body { margin-top: 2px; color: var(--text); }
.timeline__body p { margin: 2px 0 0; color: var(--text-2); font-size: var(--fs-sm); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 32px;
  height: 32px; border-radius: 50%; background: var(--avatar-bg); color: var(--avatar-text);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: 0.02em;
  text-transform: uppercase; overflow: hidden; user-select: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.avatar--lg { width: 48px; height: 48px; font-size: var(--fs-lg); }
.avatar--neutral { background: var(--surface-3); color: var(--text-2); }
.avatar-stack { display: inline-flex; }
.avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.avatar-stack .avatar + .avatar { margin-left: -6px; }

.progress {
  width: 100%; height: 8px; border-radius: var(--radius-full); background: var(--surface-3);
  overflow: hidden;
}
.progress__bar {
  height: 100%; max-width: 100%; border-radius: inherit; background: var(--accent);
  transition: width 0.3s var(--ease);
}
.progress--sm { height: 4px; }
.progress--success .progress__bar { background: var(--success-solid); }
.progress--warning .progress__bar { background: var(--warning-solid); }
.progress--danger .progress__bar { background: var(--danger-solid); }

.code-block {
  margin: 0; padding: var(--space-3) var(--space-4); border: 1px solid var(--border);
  border-radius: var(--radius); background: var(--surface-2); color: var(--text);
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.6; white-space: pre;
  overflow-x: auto; tab-size: 2;
}

.key-value-inline {
  display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-5);
  margin: 0; color: var(--text-2); font-size: var(--fs-sm);
}
.key-value-inline > * { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.key-value-inline dt, .key-value-inline .key { color: var(--text-3); }
.key-value-inline dd { margin: 0 var(--space-3) 0 -14px; color: var(--text); font-weight: var(--fw-medium); }
.key-value-inline strong { color: var(--text); font-weight: var(--fw-medium); }

.qr {
  display: inline-block; align-self: flex-start; width: 176px; max-width: 100%; padding: 8px;
  border: 1px solid var(--border); border-radius: var(--radius-lg); background: #ffffff;
  line-height: 0;
}
.qr svg { width: 100%; height: auto; }


/* ==========================================================================
   16. Permission matrix
   ========================================================================== */
.matrix { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-sm); }
.matrix th, .matrix td {
  padding: 6px var(--space-3); border-bottom: 1px solid var(--border); background: var(--surface);
  text-align: center; vertical-align: middle; white-space: nowrap;
}
.matrix thead th {
  position: sticky; top: 0; z-index: 2; height: 40px; background: var(--surface-2);
  color: var(--text-3); font-size: var(--fs-xs); font-weight: var(--fw-semibold);
  letter-spacing: 0.02em; text-transform: uppercase;
}
.matrix th:first-child, .matrix td:first-child {
  position: sticky; left: 0; z-index: 1; min-width: 220px; padding-left: var(--space-5);
  border-right: 1px solid var(--border); text-align: left;
}
.matrix thead th:first-child { z-index: 3; }
.matrix tbody tr:nth-child(even) td { background: var(--surface-2); }
.matrix tbody tr:hover td { background: var(--accent-soft); }
.matrix tbody tr:hover td:first-child { background: color-mix(in srgb, var(--surface) 88%, var(--accent)); }
.matrix input[type="checkbox"] { width: 15px; height: 15px; margin: 0; vertical-align: middle; accent-color: var(--accent); cursor: pointer; }
.matrix thead label { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; cursor: pointer; }
.matrix td:first-child label { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; }
.matrix .matrix__module td, .matrix .matrix__module th, .matrix tbody tr.matrix__module:nth-child(even) td {
  padding-top: 8px; padding-bottom: 8px; background: var(--surface-3); color: var(--text);
  font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: 0.04em;
  text-align: left; text-transform: uppercase;
}
.matrix .matrix__module label { display: inline-flex; align-items: center; gap: var(--space-2); }
.matrix tbody tr:last-child td { border-bottom: 0; }


/* ==========================================================================
   17. Notifications
   ========================================================================== */
.notif-list { margin: 0; padding: 0; list-style: none; }
.notif-item {
  position: relative; display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none;
}
.notif-list > li:last-child > .notif-item,
.notif-list > .notif-item:last-child { border-bottom: 0; }
a.notif-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.notif-item__icon {
  display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px;
  flex: none; border-radius: 50%; background: var(--surface-3); color: var(--text-2);
}
.notif-item__icon svg { width: 16px; height: 16px; }
.notif-item__body { flex: 1; min-width: 0; font-size: var(--fs-sm); line-height: 1.45; }
.notif-item__title { color: var(--text); font-weight: var(--fw-medium); }
.notif-item__text { color: var(--text-2); }
.notif-item__time { display: block; margin-top: 2px; color: var(--text-3); font-size: var(--fs-xs); }
.notif-item.is-unread { background: color-mix(in srgb, var(--accent-soft) 60%, transparent); }
.notif-item.is-unread::before {
  content: ""; position: absolute; top: 50%; left: 8px; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--accent);
}
.notif-item.is-unread .notif-item__title { font-weight: var(--fw-semibold); }


/* ==========================================================================
   18. Auth pages
   ========================================================================== */
.auth-layout {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: var(--space-8) var(--space-4);
  background: radial-gradient(1200px 500px at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px; padding: var(--space-8); border: 1px solid var(--border);
  border-radius: var(--radius-xl); background: var(--surface); box-shadow: var(--shadow-sm);
}
.auth-card__brand {
  display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-6);
  color: var(--text); font-weight: var(--fw-semibold); font-size: var(--fs-md);
}
.auth-card__title { margin-bottom: var(--space-1); font-size: var(--fs-xl); font-weight: var(--fw-semibold); letter-spacing: -0.01em; }
.auth-card__title + p { margin-bottom: var(--space-6); color: var(--text-3); }
.auth-card .form-actions { position: static; margin-top: var(--space-6); padding: 0; border: 0; background: none; }
.auth-footer { margin-top: var(--space-6); color: var(--text-3); font-size: var(--fs-xs); text-align: center; }
.auth-footer a { color: var(--text-2); }


/* ==========================================================================
   19. Utilities
   ========================================================================== */
.muted { color: var(--text-3) !important; }
.small { font-size: var(--fs-sm) !important; }
.strong { font-weight: var(--fw-semibold) !important; }
.mono { font-family: var(--font-mono) !important; font-size: 0.93em; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right !important; }
.text-center { text-align: center !important; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.nowrap { white-space: nowrap !important; }
.truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.hidden { display: none !important; }

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-4); }
.gap-4 { gap: var(--space-6); }

.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: var(--space-1) !important; }
.mt-2 { margin-top: var(--space-2) !important; }
.mt-3 { margin-top: var(--space-4) !important; }
.mt-4 { margin-top: var(--space-6) !important; }
.mb-0 { margin-bottom: 0 !important; }
.mb-1 { margin-bottom: var(--space-1) !important; }
.mb-2 { margin-bottom: var(--space-2) !important; }
.mb-3 { margin-bottom: var(--space-4) !important; }
.mb-4 { margin-bottom: var(--space-6) !important; }

.grid-2, .grid-3, .grid-4 { display: grid; gap: var(--space-4); align-items: start; }
.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-2 > .card + .card, .grid-3 > .card + .card, .grid-4 > .card + .card { margin-top: 0; }
.w-full { width: 100% !important; }
.divider { height: 1px; margin: var(--space-4) 0; border: 0; background: var(--border); }


/* ==========================================================================
   20. Responsive
   ========================================================================== */
@media (max-width: 1279.98px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Sidebar becomes an off-canvas drawer */
@media (max-width: 1023.98px) {
  .app { grid-template-columns: minmax(0, 1fr); background: var(--bg); }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(280px, 86vw); height: auto;
    box-shadow: var(--shadow-lg); transform: translateX(-100%); visibility: hidden;
    transition: transform 0.22s var(--ease), visibility 0s linear 0.22s;
  }
  .app.is-sidebar-open .sidebar {
    transform: none; visibility: visible; transition: transform 0.22s var(--ease), visibility 0s;
  }
  .sidebar-backdrop {
    position: fixed; inset: 0; z-index: calc(var(--z-sidebar) - 1); display: block;
    background: var(--overlay); opacity: 0; pointer-events: none; transition: opacity 0.2s;
  }
  .app.is-sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }

  .topbar { padding: 0 var(--space-4); }
  .content { padding: var(--space-5) var(--space-5) var(--space-10); }
}

@media (max-width: 899.98px) {
  .form-grid--3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Forms single-column */
@media (max-width: 719.98px) {
  .form-grid,
  .form-grid--3,
  .grid-2,
  .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .form-actions { position: static; justify-content: stretch; }
  .form-actions > .btn { flex: 1 1 auto; }
  .form-actions__start { width: 100%; margin-right: 0; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .kv dd + dt { margin-top: var(--space-3); }
  .page-header { align-items: stretch; }
  .page-actions { width: 100%; }
  .page-actions > .btn { flex: 1 1 auto; }
  .topbar__search kbd { display: none; }
  .modal { padding: var(--space-2); }
  .modal__dialog { max-height: calc(100vh - 16px); }
}

@media (max-width: 559.98px) {
  :root { --fs-2xl: 20px; --fs-3xl: 22px; }
  .grid-4 { grid-template-columns: minmax(0, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
  .stat { padding: var(--space-3) var(--space-4); }
  .content { padding: var(--space-4) var(--space-4) var(--space-8); }
  .topbar { gap: var(--space-2); padding: 0 var(--space-3); }
  .card__header { padding: var(--space-3) var(--space-4); }
  .card__body { padding: var(--space-4); }
  .card__footer { padding: var(--space-3) var(--space-4); }
  .card__body > .form-actions:last-child, .card__body > .form > .form-actions:last-child {
    margin: var(--space-6) calc(var(--space-4) * -1) calc(var(--space-4) * -1);
    padding: var(--space-3) var(--space-4);
  }
  .table th:first-child, .table td:first-child { padding-left: var(--space-4); }
  .table th:last-child, .table td:last-child { padding-right: var(--space-4); }
  .toolbar .input-group .input { width: 100%; }
  .toolbar .input-group, .toolbar__group { flex: 1 1 100%; }
  .toolbar__spacer { display: none; }
  .auth-card { padding: var(--space-6) var(--space-5); }
  .matrix th:first-child, .matrix td:first-child { min-width: 150px; padding-left: var(--space-3); }
  .dropdown__menu--wide { min-width: min(320px, calc(100vw - 24px)); }
}

@media (max-width: 359.98px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
  .topbar__actions .btn--icon { width: 32px; }
}


/* ==========================================================================
   21. Motion preferences
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important; scroll-behavior: auto !important;
  }
  .spinner, .btn.is-loading::after { animation-duration: 1.2s !important; animation-iteration-count: infinite !important; }
}


/* ==========================================================================
   22. Print
   ========================================================================== */
@media print {
  :root, html[data-theme] {
    color-scheme: light;
    --bg: #ffffff;
    --surface: #ffffff; --surface-2: #f7f7f7; --surface-3: #efefef;
    --border: #d0d0d0; --border-strong: #b0b0b0;
    --text: #000000; --text-2: #222222; --text-3: #555555;
    --shadow-xs: none; --shadow-sm: none; --shadow-md: none; --shadow-lg: none;
  }
  @page { margin: 14mm; }
  body { background: #ffffff; font-size: 11pt; }
  .sidebar, .sidebar-backdrop, .topbar, .btn, .btn-group, .page-actions, .card__actions,
  .toolbar, .pagination, .flash-stack, .form-actions, .tabs, .dropdown, .modal, .drawer,
  .alert__close, .no-print { display: none !important; }
  .app, .app.is-sidebar-collapsed { display: block; }
  .main { min-height: 0; }
  .content { max-width: none; padding: 0; }
  .card, .stat { box-shadow: none; break-inside: avoid; }
  .table-wrap { overflow: visible; max-height: none; }
  .table th { background: #f2f2f2 !important; }
  .table tr { break-inside: avoid; }
  .badge { border-color: #999 !important; background: none !important; color: #000 !important; }
  .tab-panel[hidden] { display: none !important; }
  a { color: inherit; text-decoration: none; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ==========================================================================
   App additions (PHP views): installer checklists, wide auth card, misc
   ========================================================================== */
.auth-card--wide { max-width: 680px; width: 100%; }
.check-list { list-style: none; margin: 16px 0; padding: 0; display: grid; gap: 8px; }
.check-list__item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.check-list__item > .icon { flex: none; margin-top: 2px; color: var(--text-3); }
.check-list__item.is-ok > .icon { color: var(--success); }
.check-list__item.is-fail { border-color: var(--danger); }
.check-list__item.is-fail > .icon { color: var(--danger); }
.check-list__item.is-warn > .icon { color: var(--warning); }
.justify-center { justify-content: center; }
.secret-box { font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace); letter-spacing: .08em; padding: 10px 12px; border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface-2); word-break: break-all; }
.recovery-codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius); }
.qr-box { width: 180px; height: 180px; padding: 8px; background: #fff; border-radius: var(--radius); border: 1px solid var(--border); }
.qr-box svg { width: 100%; height: 100%; }
.step-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; background: var(--surface); }
.step-card__head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.setup-list { list-style: none; margin: 0; padding: 0; }
.setup-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.setup-list li:last-child { border-bottom: 0; }
.setup-list .icon { flex: none; }
.setup-list .is-done { color: var(--success); }
.setup-list .is-todo { color: var(--text-3); }
.log-view { max-height: 560px; overflow: auto; font-size: 12px; white-space: pre-wrap; }
