/* =============================================================================
   authd.acyber.xyz — Admin Console
   Design system: "Technical Atelier"
   - Warm neutral ground, deep ink chrome, a single verdigris accent.
   - Editorial serif display for the wordmark/titles, humanist sans for UI,
     monospace for identifiers and machine values.
   - Static, dependency-free. No external fonts, no framework.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Palette — light (default) */
  --bg:            #f4f3ef;
  --bg-grid:       #eceae4;
  --surface:       #ffffff;
  --surface-2:     #faf9f6;
  --surface-3:     #f3f1ec;

  --ink:           #17181c;
  --ink-2:         #43464e;
  --ink-3:         #5c606a;
  --ink-4:         #5a5e66;

  --line:          #e5e2db;
  --line-strong:   #d6d3ca;

  --accent:        #0f6e5c;
  --accent-hover:  #0b5748;
  --accent-ink:    #ffffff;
  --accent-soft:   #e2f0ec;
  --accent-ring:   rgba(15, 110, 92, .35);

  --danger:        #b02a32;
  --danger-hover:  #952027;
  --danger-soft:   #fbeaea;
  --warn:          #8a5800;
  --warn-soft:     #fbf1dd;
  --ok:            #1f7a3d;
  --ok-soft:       #e7f3ea;
  --info:          #2b5f9e;
  --info-soft:     #e8f0fa;

  /* Chrome (sidebar) stays dark in both themes for a stable identity */
  --chrome:        #14161a;
  --chrome-2:      #1c1f25;
  --chrome-line:   #2a2e36;
  --chrome-ink:    #d3d6dc;
  --chrome-ink-2:  #8d929b;

  /* Typography */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", "JetBrains Mono", "Cascadia Code", Menlo, Consolas, monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 15px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 28px;

  /* Space scale (4px base) */
  --s-1: 4px;  --s-2: 8px;  --s-3: 12px; --s-4: 16px;
  --s-5: 20px; --s-6: 24px; --s-7: 32px; --s-8: 40px; --s-9: 56px;

  /* Radius */
  --r-xs: 4px; --r-sm: 6px; --r-md: 9px; --r-lg: 13px; --r-full: 999px;

  /* Depth */
  --sh-1: 0 1px 2px rgba(20, 22, 25, .05), 0 1px 3px rgba(20, 22, 25, .04);
  --sh-2: 0 10px 28px -12px rgba(20, 22, 25, .22), 0 2px 8px rgba(20, 22, 25, .06);
  --sh-3: 0 24px 60px -20px rgba(15, 18, 22, .40), 0 6px 18px rgba(15, 18, 22, .12);

  --sidebar-w: 246px;
  --topbar-h: 60px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: 160ms;
}

/* Dark theme — automatic, plus manual override via [data-theme="dark"] */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:          #0f1114;
    --bg-grid:     #15181d;
    --surface:     #181b20;
    --surface-2:   #1d2127;
    --surface-3:   #232830;

    --ink:         #eceef1;
    --ink-2:       #b9bec6;
    --ink-3:       #8b919b;
    --ink-4:       #8b919b;

    --line:        #2a2f37;
    --line-strong: #363c46;

    --accent:      #35b39a;
    --accent-hover:#4cc4ab;
    --accent-ink:  #062019;
    --accent-soft: #12312b;
    --accent-ring: rgba(53, 179, 154, .40);

    --danger:      #e26a6f;
    --danger-hover:#ec8186;
    --danger-soft: #3a1c1e;
    --warn:        #d8a94a;
    --warn-soft:   #332813;
    --ok:          #56b678;
    --ok-soft:     #14301f;
    --info:        #7aaae0;
    --info-soft:   #14283f;

    --chrome:      #101215;
    --chrome-2:    #191c21;
    --chrome-line: #272b32;

    --sh-1: 0 1px 2px rgba(0,0,0,.4);
    --sh-2: 0 10px 30px -12px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.4);
    --sh-3: 0 24px 60px -20px rgba(0,0,0,.75), 0 6px 18px rgba(0,0,0,.5);
  }
}
[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

/* -----------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
/* The `hidden` attribute is authoritative: many views/banners/popovers use it,
   and their authored `display` declarations would otherwise override its UA
   `display: none` (e.g. the login/app views were both always visible). Shown
   state removes the attribute; nothing needs to override this with `display`. */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 32px 32px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button { font: inherit; color: inherit; }
a { color: var(--accent); text-underline-offset: 2px; }
::selection { background: var(--accent-ring); }

.mono { font-family: var(--font-mono); font-size: .92em; letter-spacing: -.01em; }
.muted { color: var(--ink-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Focus visibility — consistent, high-contrast ring everywhere */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

.skip-link {
  position: fixed; top: -60px; left: var(--s-4); z-index: 100;
  background: var(--accent); color: var(--accent-ink);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-sm);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus { top: var(--s-3); }

.noscript {
  max-width: 560px; margin: 12vh auto; padding: var(--s-6);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-2);
}
.noscript h1 { font-family: var(--font-display); font-size: var(--text-2xl); margin-bottom: var(--s-3); }

/* -----------------------------------------------------------------------------
   3. Brand
   -------------------------------------------------------------------------- */
.brand { display: flex; align-items: center; gap: var(--s-3); text-align: left; }
.brand--button {
  background: none; border: 0; cursor: pointer; padding: var(--s-1);
  border-radius: var(--r-md); width: 100%;
}
.brand--stack { gap: var(--s-3); }
.brand__mark {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: grid; place-items: center;
  font-family: var(--font-display); font-size: 24px; font-weight: 700;
  color: var(--accent-ink);
  background: linear-gradient(150deg, var(--accent), var(--accent-hover));
  border-radius: 11px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 6px var(--accent-ring);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand__name {
  font-family: var(--font-display); font-size: 19px; letter-spacing: -.01em;
  color: var(--ink);
}
.brand__domain { color: var(--ink-3); font-weight: 400; }
.brand__sub { font-size: var(--text-xs); color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }
/* Inside dark chrome, override ink colors */
.sidebar .brand__name { color: var(--chrome-ink); }
.sidebar .brand__domain { color: var(--chrome-ink-2); }
.sidebar .brand__sub { color: var(--chrome-ink-2); }

/* -----------------------------------------------------------------------------
   4. Login view
   -------------------------------------------------------------------------- */
.login-view { min-height: 100dvh; display: grid; }
.login-shell { display: grid; place-items: center; padding: var(--s-6) var(--s-4); }
.login-card {
  width: 100%; max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-3);
  padding: var(--s-7);
  animation: rise .5s var(--ease) both;
}
.login-title {
  font-family: var(--font-display); font-size: var(--text-2xl);
  margin-top: var(--s-6); letter-spacing: -.01em;
}
.login-lede { color: var(--ink-3); margin-top: var(--s-2); }
.login-foot { margin-top: var(--s-5); font-size: var(--text-xs); color: var(--ink-4); }

/* Public email-link pages (#/reset-password, #/verify-email) */
.public-status { display: flex; flex-direction: column; align-items: center; gap: var(--s-2); margin: var(--s-2) 0 var(--s-5); }
.public-status .login-lede { margin: 0; }
.public-icon { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; font-family: var(--font-display); font-size: 26px; }
.public-icon--ok { background: var(--ok-soft); color: var(--ok); }
.public-icon--err { background: var(--warn-soft); color: var(--warn); }
.spinner { width: 22px; height: 22px; display: inline-block; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .7s linear infinite; }
.login-card .brand { margin-bottom: var(--s-1); }

/* Federated/passkey sign-in ("Sign in with …") */
.login-alt { margin-top: var(--s-5); }
.login-providers { margin-top: var(--s-2); }
.login-passkey-hint { font-size: var(--text-xs); color: var(--ink-4); margin: 0 0 var(--s-3); }
.login-divider {
  display: flex; align-items: center; gap: var(--s-3);
  color: var(--ink-4); font-size: var(--text-xs);
  text-transform: uppercase; letter-spacing: .08em;
  margin-bottom: var(--s-4);
}
.login-divider::before, .login-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.provider-grid { display: flex; flex-direction: column; gap: var(--s-2); }
.provider-btn {
  display: flex; align-items: center; gap: var(--s-3); width: 100%;
  padding: 9px 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  cursor: pointer; font-size: var(--text-base); font-weight: 550;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.provider-btn:hover { background: var(--surface-3); border-color: var(--ink-4); }
.provider-btn[disabled] { cursor: not-allowed; }
.provider-btn[aria-busy="true"] { position: relative; opacity: .7; cursor: progress; }
.provider-btn[aria-busy="true"] .provider-btn__label { visibility: hidden; }
.provider-btn[aria-busy="true"]::after {
  content: ""; position: absolute; right: 14px; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.provider-btn__icon { width: 18px; height: 18px; flex: 0 0 18px; display: grid; place-items: center; color: var(--ink-2); }
.provider-btn__label { text-align: left; }

/* Linked accounts (profile modal) */
.linked-section { margin-top: var(--s-6); border-top: 1px solid var(--line); padding-top: var(--s-4); }
.linked-section__title { font-family: var(--font-display); font-size: var(--text-lg); }
.linked-list { display: flex; flex-direction: column; gap: var(--s-2); margin-top: var(--s-3); }
.linked-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
}
.linked-item__icon { width: 20px; height: 20px; flex: 0 0 20px; display: grid; place-items: center; color: var(--ink-2); }
.linked-item__meta { min-width: 0; }
.linked-item__provider { font-weight: 600; }
.linked-item__email { font-size: var(--text-xs); color: var(--ink-3); }
.linked-item__actions { margin-left: auto; display: flex; gap: 6px; white-space: nowrap; }
.linked-empty { color: var(--ink-3); font-size: var(--text-sm); margin-top: var(--s-2); }
.linked-link-actions { margin-top: var(--s-4); }
.linked-link-actions__label { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); margin-bottom: var(--s-2); }

/* -----------------------------------------------------------------------------
   5. App shell
   -------------------------------------------------------------------------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "sidebar topbar" "sidebar main";
  min-height: 100dvh;
}

.sidebar {
  grid-area: sidebar;
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  z-index: 40;
  display: flex; flex-direction: column;
  background: var(--chrome);
  border-right: 1px solid var(--chrome-line);
  color: var(--chrome-ink);
  transition: width var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.sidebar__head { padding: var(--s-4) var(--s-4) var(--s-3); }
.sidebar__foot {
  margin-top: auto; padding: var(--s-3) var(--s-4) var(--s-4);
  border-top: 1px solid var(--chrome-line);
  display: flex; align-items: center; gap: var(--s-2);
}
.nav { padding: var(--s-2) var(--s-3); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav__group-label {
  font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--chrome-ink-2); padding: var(--s-4) var(--s-3) var(--s-1);
}
.nav__link {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 8px 10px; border-radius: var(--r-md);
  color: var(--chrome-ink); text-decoration: none;
  font-size: var(--text-base); cursor: pointer;
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  position: relative;
}
.nav__link:hover { background: var(--chrome-2); color: #fff; }
.nav__link[aria-current="page"] {
  background: var(--chrome-2);
  color: #fff;
  border-color: var(--chrome-line);
}
.nav__link[aria-current="page"]::before {
  content: ""; position: absolute; left: -1px; top: 8px; bottom: 8px;
  width: 3px; border-radius: 3px; background: var(--accent);
}
.nav__icon {
  width: 18px; height: 18px; flex: 0 0 18px; display: grid; place-items: center;
  color: var(--chrome-ink-2);
}
.nav__link:hover .nav__icon, .nav__link[aria-current="page"] .nav__icon { color: var(--accent); }
.nav__badge {
  margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center; border-radius: var(--r-full);
  background: var(--accent); color: var(--accent-ink);
  font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.sidebar__collapse {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: var(--chrome-2); border: 1px solid var(--chrome-line);
  color: var(--chrome-ink-2); border-radius: var(--r-sm); cursor: pointer;
  transition: transform var(--dur) var(--ease), color var(--dur) var(--ease);
}
.sidebar__collapse:hover { color: #fff; }
.conn { display: flex; align-items: center; gap: var(--s-2); flex: 1; min-width: 0; font-size: var(--text-xs); color: var(--chrome-ink-2); }
.conn__dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px rgba(86,182,120,.15); flex: 0 0 8px; }
.conn__dot[data-state="down"] { background: var(--danger); box-shadow: 0 0 0 3px rgba(226,106,111,.18); }
.conn__dot[data-state="unknown"] { background: var(--ink-4); box-shadow: none; }
.conn__text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Collapsed (desktop) */
.app.sidebar-collapsed { --sidebar-w: 68px; }
.app.sidebar-collapsed .brand__text,
.app.sidebar-collapsed .nav__label,
.app.sidebar-collapsed .nav__group-label,
.app.sidebar-collapsed .nav__badge,
.app.sidebar-collapsed .conn { display: none; }
.app.sidebar-collapsed .sidebar__collapse { transform: rotate(180deg); }
.app.sidebar-collapsed .nav__link { justify-content: center; }
.app.sidebar-collapsed .sidebar__head { padding-inline: var(--s-3); }
.app.sidebar-collapsed .sidebar__foot { justify-content: center; }

/* -----------------------------------------------------------------------------
   6. Top bar
   -------------------------------------------------------------------------- */
.topbar {
  grid-area: topbar;
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h); padding: 0 var(--s-6);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__spacer { flex: 1; }
.crumbs { display: flex; align-items: baseline; gap: var(--s-3); min-width: 0; }
.crumbs__eyebrow { font-size: var(--text-xs); color: var(--ink-3); text-transform: uppercase; letter-spacing: .08em; }
.crumbs__title { font-family: var(--font-display); font-size: var(--text-lg); letter-spacing: -.01em; white-space: nowrap; }

.tenant {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 5px 10px; border: 1px solid var(--line);
  border-radius: var(--r-full); background: var(--surface-2);
  font-size: var(--text-xs);
}
.tenant__label { color: var(--ink-4); text-transform: uppercase; letter-spacing: .07em; }
.tenant__value { color: var(--ink-2); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-sm); cursor: pointer; color: var(--ink-2);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.topbar__menu { display: none; }
.icon-bars { width: 16px; height: 12px; position: relative; }
.icon-bars::before, .icon-bars::after, .icon-bars { border-top: 2px solid currentColor; }
.icon-bars { border-bottom: 2px solid currentColor; height: 2px; }
.icon-bars::before, .icon-bars::after { content: ""; position: absolute; left: 0; right: 0; }
.icon-bars::before { top: 4px; }
.icon-bars::after { top: 8px; }

.usermenu { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  font-weight: 700; font-size: var(--text-sm); cursor: pointer;
  transition: transform var(--dur) var(--ease);
}
.avatar:hover { transform: translateY(-1px); }
.usermenu__pop {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 50;
  width: 232px; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-md); box-shadow: var(--sh-2); overflow: hidden;
  animation: pop .16s var(--ease) both;
}
.usermenu__head { padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.usermenu__head strong { font-size: var(--text-base); }
.menuitem {
  display: block; width: 100%; text-align: left; padding: 10px var(--s-4);
  background: none; border: 0; cursor: pointer; color: var(--ink-2);
}
.menuitem:hover { background: var(--surface-3); color: var(--ink); }

/* -----------------------------------------------------------------------------
   7. Main / page
   -------------------------------------------------------------------------- */
.main {
  grid-area: main;
  padding: var(--s-7) var(--s-6) var(--s-9);
  min-width: 0;
}
.page { max-width: 1180px; margin: 0 auto; animation: fade .28s var(--ease) both; }
.page__head { display: flex; align-items: flex-end; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.page__title { font-family: var(--font-display); font-size: var(--text-2xl); letter-spacing: -.015em; line-height: 1.1; }
.page__desc { color: var(--ink-3); margin-top: var(--s-2); max-width: 62ch; }
.page__actions { margin-left: auto; display: flex; gap: var(--s-2); flex-wrap: wrap; }

.section { margin-top: var(--s-7); }
.section__head { display: flex; align-items: baseline; gap: var(--s-3); margin-bottom: var(--s-3); }
.section__title { font-family: var(--font-display); font-size: var(--text-xl); }
.section__hint { color: var(--ink-4); font-size: var(--text-sm); }
.section__note { margin-left: auto; display: inline-flex; align-items: center; }

/* -----------------------------------------------------------------------------
   8. Cards, stat tiles, panels
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card--pad { padding: var(--s-6); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: var(--s-4); }
.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: var(--s-5);
  box-shadow: var(--sh-1);
  display: flex; flex-direction: column; gap: var(--s-1);
  position: relative; overflow: hidden;
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--sh-2); }
.stat__label { color: var(--ink-3); font-size: var(--text-sm); }
.stat__value { font-family: var(--font-display); font-size: 34px; line-height: 1; font-variant-numeric: tabular-nums; }
.stat__meta { font-size: var(--text-xs); color: var(--ink-4); }
.stat__accent { position: absolute; right: -20px; top: -20px; width: 70px; height: 70px; border-radius: 50%; background: var(--accent-soft); opacity: .7; }
.stat--warn .stat__accent { background: var(--warn-soft); }

.panel-grid { display: grid; grid-template-columns: 1.35fr .95fr; gap: var(--s-5); align-items: start; }
@media (max-width: 900px) { .panel-grid { grid-template-columns: 1fr; } }

/* -----------------------------------------------------------------------------
   9. Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  padding: 9px 15px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); cursor: pointer;
  font-size: var(--text-base); font-weight: 550;
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              transform 90ms var(--ease), box-shadow var(--dur) var(--ease), opacity var(--dur) var(--ease);
}
.btn:hover { background: var(--surface-3); border-color: var(--ink-4); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-busy="true"] { opacity: .6; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 1px 2px var(--accent-ring); }
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); border-color: transparent; }
.btn--sm { padding: 5px 10px; font-size: var(--text-sm); border-radius: var(--r-sm); }
.btn--block { width: 100%; }
.btn__label { display: inline-block; }
.btn[aria-busy="true"] .btn__label { visibility: hidden; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; width: 15px; height: 15px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; animation: spin .7s linear infinite;
}
.btn { position: relative; }

/* -----------------------------------------------------------------------------
   10. Forms
   -------------------------------------------------------------------------- */
.form { display: flex; flex-direction: column; gap: var(--s-4); margin-top: var(--s-5); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.field__help { font-size: var(--text-xs); color: var(--ink-4); }
.field__error { font-size: var(--text-xs); color: var(--danger); }
.field__value { color: var(--ink); font-size: var(--text-base); }

/* Live password strength meter + match indicator */
.pw-meter-wrap { display: flex; align-items: center; gap: var(--s-3); margin-top: 6px; }
.pw-meter { display: flex; gap: 4px; flex: 0 0 96px; }
.pw-meter__seg {
  height: 5px; flex: 1; border-radius: var(--r-full);
  background: var(--surface-3); border: 1px solid var(--line);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.pw-meter__status { font-size: var(--text-xs); color: var(--ink-3); }
.pw-meter-wrap[data-level="weak"] .pw-meter__seg.is-on { background: var(--danger); border-color: var(--danger); }
.pw-meter-wrap[data-level="fair"] .pw-meter__seg.is-on { background: var(--warn); border-color: var(--warn); }
.pw-meter-wrap[data-level="good"] .pw-meter__seg.is-on { background: var(--accent); border-color: var(--accent); }
.pw-meter-wrap[data-level="strong"] .pw-meter__seg.is-on { background: var(--ok); border-color: var(--ok); }
.pw-match { display: inline-block; margin-top: 6px; font-size: var(--text-xs); }
.pw-match.is-ok { color: var(--ok); }
.pw-match.is-bad { color: var(--danger); }
.field__row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-4); }
@media (max-width: 560px) { .field__row { grid-template-columns: 1fr; } }

.input, .select, .textarea {
  width: 100%; padding: 9px 12px;
  font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), background var(--dur) var(--ease);
}
.textarea { resize: vertical; min-height: 80px; }
.input::placeholder, .textarea::placeholder { color: var(--ink-4); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-4); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"] {
  border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent);
}
.input-affix { position: relative; display: flex; align-items: center; }
.input-affix .input { padding-right: 62px; }
.input-affix .ghost-btn {
  position: absolute; right: 6px; background: none; border: 0; cursor: pointer;
  color: var(--ink-3); font-size: var(--text-xs); padding: 6px 8px; border-radius: var(--r-sm);
}
.input-affix .ghost-btn:hover { color: var(--ink); background: var(--surface-3); }
select.select { appearance: none; background-image:
  linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
  linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
  padding-right: 34px;
}
.checkrow { display: flex; align-items: center; gap: var(--s-2); font-size: var(--text-sm); }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }
.advanced { margin-top: var(--s-4); border-top: 1px dashed var(--line-strong); padding-top: var(--s-3); }
.advanced summary { cursor: pointer; color: var(--ink-2); font-size: var(--text-sm); }
.advanced[open] summary { margin-bottom: var(--s-3); }

/* Search / filter toolbar */
.toolbar { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.toolbar .input, .toolbar .select { width: auto; min-width: 200px; }
.toolbar__spacer { flex: 1; }

/* Multi-field filter form (Audit event log, etc.) */
.filter-form { margin-top: var(--s-4); }
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--s-4);
  align-items: start;
}
.filter-grid .field { gap: 5px; }
.filter-actions { display: flex; align-items: center; gap: var(--s-2); margin-top: var(--s-4); flex-wrap: wrap; }
.filter-form .banner { margin-top: var(--s-4); }

/* Visually hidden, available to assistive tech */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -----------------------------------------------------------------------------
   11. Data table
   -------------------------------------------------------------------------- */
.table-wrap {
  border: 1px solid var(--line); border-radius: var(--r-lg);
  background: var(--surface); overflow: hidden; box-shadow: var(--sh-1);
}
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
table.data thead th {
  text-align: left; font-size: 11px; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 700;
  padding: 11px var(--s-4); background: var(--surface-2);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data tbody td { padding: 12px var(--s-4); border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background var(--dur) var(--ease); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data td.actions { text-align: right; white-space: nowrap; }
table.data td.actions .btn + .btn { margin-left: 6px; }
.cell-primary { font-weight: 600; color: var(--ink); }
.cell-sub { font-size: var(--text-xs); color: var(--ink-4); }
.id-text { font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-3); }

/* Pagination (shared client-side pager on large lists) */
.pager__bar {
  display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap;
  margin-bottom: var(--s-3);
}
.pager__size { font-size: var(--text-sm); font-weight: 600; color: var(--ink-2); }
.pager__status { font-size: var(--text-sm); color: var(--ink-3); font-variant-numeric: tabular-nums; white-space: nowrap; }
.select--sm { width: auto; min-width: 0; padding: 5px 30px 5px 10px; font-size: var(--text-sm); }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: var(--text-xs); font-weight: 600; letter-spacing: .01em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge--neutral { color: var(--ink-2); background: var(--surface-3); border-color: var(--line); }
.badge--ok { color: var(--ok); background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.badge--warn { color: var(--warn); background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge--danger { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.badge--info { color: var(--info); background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 28%, transparent); }
.badge--accent { color: var(--accent); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, transparent); }
.badge--plain::before { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-family: var(--font-mono); font-size: 11px;
  padding: 2px 7px; border-radius: var(--r-sm);
  background: var(--surface-3); border: 1px solid var(--line); color: var(--ink-2);
}
.chip--accent { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 25%, transparent); color: var(--accent); }

/* -----------------------------------------------------------------------------
   12. States: empty, loading, error
   -------------------------------------------------------------------------- */
.state { padding: var(--s-9) var(--s-6); text-align: center; display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.state__icon {
  width: 46px; height: 46px; border-radius: var(--r-md);
  display: grid; place-items: center; margin-bottom: var(--s-2);
  background: var(--surface-3); border: 1px solid var(--line);
  color: var(--ink-3); font-family: var(--font-display); font-size: 22px;
}
.state__icon > svg { width: 22px; height: 22px; }
.state__title { font-family: var(--font-display); font-size: var(--text-lg); }
.state__desc { color: var(--ink-3); max-width: 46ch; }
.state--error .state__icon { color: var(--danger); background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.state__actions { margin-top: var(--s-3); }

/* Skeleton */
.skel { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 37%, var(--surface-3) 63%);
  background-size: 400% 100%; animation: shimmer 1.4s ease-in-out infinite; border-radius: var(--r-sm); height: 14px; }
.skel-row { display: flex; gap: var(--s-4); padding: 14px var(--s-4); border-bottom: 1px solid var(--line); }
.skel-row:last-child { border-bottom: 0; }
.skel-row .skel { flex: 1; }
.skel-row .skel:nth-child(2) { flex: 1.4; }
.skel-row .skel:nth-child(3) { flex: .6; }

/* Banner (inline alerts) */
.banner {
  display: flex; gap: var(--s-3); align-items: flex-start;
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: var(--text-sm); margin-top: var(--s-4);
}
.banner__body { min-width: 0; }
.banner__title { font-weight: 650; }
.banner--danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.banner--warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); color: var(--warn); }
.banner--info { background: var(--info-soft); border-color: color-mix(in srgb, var(--info) 30%, transparent); color: var(--info); }

/* -----------------------------------------------------------------------------
   13. Modal / drawer
   -------------------------------------------------------------------------- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: color-mix(in srgb, #0b0d0f 55%, transparent);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: var(--s-8) var(--s-4);
  overflow-y: auto;
  animation: fade .18s var(--ease) both;
}
.modal {
  width: 100%; max-width: 540px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-3);
  animation: rise .22s var(--ease) both;
  margin: auto 0;
}
.modal--wide { max-width: 640px; }
.modal__head { display: flex; align-items: flex-start; gap: var(--s-4); padding: var(--s-5) var(--s-6) var(--s-3); }
.modal__title { font-family: var(--font-display); font-size: var(--text-xl); }
.modal__desc { color: var(--ink-3); font-size: var(--text-sm); margin-top: var(--s-1); }
.modal__close {
  margin-left: auto; width: 32px; height: 32px; flex: 0 0 32px;
  display: grid; place-items: center; border-radius: var(--r-sm);
  background: none; border: 1px solid transparent; cursor: pointer; color: var(--ink-3);
}
.modal__close:hover { background: var(--surface-3); color: var(--ink); }
.modal__body { padding: 0 var(--s-6) var(--s-4); }
.modal__foot {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  padding: var(--s-4) var(--s-6) var(--s-5);
  border-top: 1px solid var(--line); background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.modal__lead { color: var(--ink-2); }
.modal .form { margin-top: var(--s-3); }

/* -----------------------------------------------------------------------------
   14. Toasts
   -------------------------------------------------------------------------- */
.toast-region {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 100;
  display: flex; flex-direction: column-reverse; gap: var(--s-2); max-width: min(380px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border-radius: var(--r-md);
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: var(--sh-2); font-size: var(--text-sm);
  animation: toast-in .24s var(--ease) both;
  position: relative; overflow: hidden;
}
.toast::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--accent);
}
.toast[data-kind="error"]::after { background: var(--danger); }
.toast[data-kind="warn"]::after { background: var(--warn); }
.toast__icon { font-weight: 700; color: var(--accent); }
.toast[data-kind="error"] .toast__icon { color: var(--danger); }
.toast__body { min-width: 0; }
.toast__title { font-weight: 650; }
.toast__msg { color: var(--ink-3); }
.toast.is-leaving { animation: toast-out .2s var(--ease) both; }

/* -----------------------------------------------------------------------------
   15. Tabs
   -------------------------------------------------------------------------- */
.tabs { display: inline-flex; gap: 2px; padding: 3px; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md); }
.tab {
  padding: 6px 14px; border-radius: var(--r-sm); border: 0; background: none;
  cursor: pointer; color: var(--ink-3); font-size: var(--text-sm); font-weight: 600;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }
.tab:hover { color: var(--ink); }

/* My-access list */
.access-list { display: flex; flex-direction: column; gap: var(--s-2); }
.access-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-4); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
  transition: border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.access-item:hover { border-color: var(--line-strong); transform: translateX(2px); }
.access-item__name { font-weight: 600; }
.access-item__slug { color: var(--ink-4); font-family: var(--font-mono); font-size: var(--text-xs); }
.access-item .chips { margin-left: auto; }

/* -----------------------------------------------------------------------------
   15b. Telemetry & RMM
   -------------------------------------------------------------------------- */
.chart-card { padding: var(--s-5) var(--s-6); }
.chart-head { display: flex; align-items: flex-start; gap: var(--s-3); flex-wrap: wrap; margin-bottom: var(--s-4); }
.chart-title { font-family: var(--font-mono); font-size: var(--text-md); font-weight: 600; }
.chart-sub { color: var(--ink-4); font-size: var(--text-xs); }
svg.chart { display: block; width: 100%; height: auto; }
.chart__grid { stroke: var(--line); stroke-width: 1; }
.chart__axis { fill: var(--ink-4); font-size: 11px; font-family: var(--font-mono); }
.chart__line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart__area { fill: var(--accent); opacity: .12; }
.chart__dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: var(--s-3); margin-top: var(--s-4); }
.chart-stat { padding: var(--s-3) var(--s-4); border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.chart-stat__label { font-size: var(--text-xs); color: var(--ink-4); text-transform: uppercase; letter-spacing: .06em; }
.chart-stat__value { font-family: var(--font-mono); font-size: var(--text-lg); font-variant-numeric: tabular-nums; }

/* Expandable command output */
.row-detail > td { background: var(--surface-2); }
.output-block { padding: var(--s-3) 0; }
.output-block__head { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-2); }
.output-label { font-size: var(--text-xs); text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
pre.output-pre {
  margin: 0; padding: var(--s-3) var(--s-4);
  background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--r-md);
  font-family: var(--font-mono); font-size: var(--text-xs); color: var(--ink-2);
  white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}
.output-meta { display: flex; gap: var(--s-5); flex-wrap: wrap; margin-top: var(--s-2); color: var(--ink-4); font-size: var(--text-xs); }

/* -----------------------------------------------------------------------------
   15c. Administration (provisioning, audit, maintenance)
   -------------------------------------------------------------------------- */
/* Copyable value row (one-time secrets) */
.copy-row { display: flex; align-items: center; gap: var(--s-2); }
.copy-row .input { flex: 1; min-width: 0; }

/* SCIM endpoint list */
.endpoint-list { display: flex; flex-direction: column; margin-top: var(--s-3); }
.endpoint-row {
  display: flex; align-items: baseline; gap: var(--s-3);
  padding: 9px 0; border-bottom: 1px dashed var(--line);
}
.endpoint-row:last-child { border-bottom: 0; }
.endpoint-row__method {
  font-family: var(--font-mono); font-size: var(--text-xs);
  color: var(--accent); background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  border-radius: var(--r-sm); padding: 1px 7px; white-space: nowrap;
}
.endpoint-row__path { color: var(--ink); }
.endpoint-row__desc { margin-left: auto; font-size: var(--text-xs); }
.endpoint-auth {
  margin-top: 6px; padding: 10px 12px;
  background: var(--surface-3); border: 1px solid var(--line);
  border-radius: var(--r-md); color: var(--ink-2); word-break: break-all;
}

/* Audit verification result card */
.verify-card { display: flex; align-items: center; gap: var(--s-4); padding: var(--s-5) var(--s-6); }
.verify-card__icon {
  width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center;
  border-radius: var(--r-md); font-family: var(--font-display); font-size: 24px;
}
.verify-card__title { font-family: var(--font-display); font-size: var(--text-xl); letter-spacing: -.01em; }
.verify-card__desc { color: var(--ink-3); margin-top: var(--s-1); max-width: 62ch; }
.verify-card--ok { border-color: color-mix(in srgb, var(--ok) 35%, transparent); background: var(--ok-soft); }
.verify-card--ok .verify-card__icon {
  background: color-mix(in srgb, var(--ok) 16%, var(--surface));
  color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
}
.verify-card--ok .verify-card__title { color: var(--ok); }
.verify-card--bad { border-color: color-mix(in srgb, var(--danger) 35%, transparent); background: var(--danger-soft); }
.verify-card--bad .verify-card__icon {
  background: color-mix(in srgb, var(--danger) 16%, var(--surface));
  color: var(--danger); border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
}
.verify-card--bad .verify-card__title { color: var(--danger); }

/* Cleanup report grid */
.cleanup-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
  gap: var(--s-3); margin-top: var(--s-4);
}
.cleanup-cell {
  padding: var(--s-3) var(--s-4); border: 1px solid var(--line);
  border-radius: var(--r-md); background: var(--surface-2);
}
.cleanup-cell__value { font-size: var(--text-xl); font-variant-numeric: tabular-nums; }
.cleanup-cell__label {
  font-size: var(--text-xs); color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .06em; margin-top: 2px;
}

/* -----------------------------------------------------------------------------
   15d. Security — Certificates (PKI)
   -------------------------------------------------------------------------- */
/* Inline header that pairs a status/relative time with an "Expired" badge */
.expiry { display: inline-flex; align-items: center; gap: var(--s-2); }

/* Copyable PEM block (CA certificate viewer + one-time issue reveal) */
.pem-block { margin-top: var(--s-4); }
.pem-block .output-block__head { margin-bottom: var(--s-2); }
.pem-block .output-pre { max-height: 280px; }

/* -----------------------------------------------------------------------------
   15e. Administration — Cluster (leadership)
   -------------------------------------------------------------------------- */
/* Prominent leader banner: a green variant when this node leads, neutral
   otherwise. The title text always states the leadership role, so the state is
   never carried by colour alone. */
.cluster-lead {
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-5) var(--s-6);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.cluster-lead__icon {
  width: 46px; height: 46px; flex: 0 0 46px; display: grid; place-items: center;
  border-radius: var(--r-md); font-family: var(--font-display); font-size: 24px;
}
.cluster-lead__title { font-family: var(--font-display); font-size: var(--text-xl); letter-spacing: -.01em; }
.cluster-lead__desc { color: var(--ink-3); margin-top: var(--s-1); max-width: 62ch; }
.cluster-lead--ok { background: var(--ok-soft); border-bottom: 1px solid color-mix(in srgb, var(--ok) 22%, transparent); }
.cluster-lead--ok .cluster-lead__icon {
  background: color-mix(in srgb, var(--ok) 16%, var(--surface));
  color: var(--ok); border: 1px solid color-mix(in srgb, var(--ok) 30%, transparent);
}
.cluster-lead--ok .cluster-lead__title { color: var(--ok); }
.cluster-lead--neutral { background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cluster-lead--neutral .cluster-lead__icon { background: var(--surface-3); color: var(--ink-3); border: 1px solid var(--line); }

.cluster-details { padding: var(--s-5) var(--s-6); }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--s-4); }
.detail-grid .field__value { font-size: var(--text-base); }

/* -----------------------------------------------------------------------------
   16. Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  .topbar { padding-left: var(--s-4); }
  .topbar__menu { display: grid; }
  .sidebar {
    transform: translateX(-100%); width: 264px; box-shadow: var(--sh-3);
  }
  .app.drawer-open .sidebar { transform: translateX(0); }
  .app.sidebar-collapsed { --sidebar-w: 246px; }
  .app.sidebar-collapsed .brand__text,
  .app.sidebar-collapsed .nav__label,
  .app.sidebar-collapsed .nav__group-label,
  .app.sidebar-collapsed .nav__badge,
  .app.sidebar-collapsed .conn { display: revert; }
  .app.sidebar-collapsed .nav__link { justify-content: flex-start; }
  .sidebar__collapse { display: none; }
  .drawer-backdrop {
    position: fixed; inset: 0; z-index: 35;
    background: color-mix(in srgb, #0b0d0f 45%, transparent);
    animation: fade .16s var(--ease) both;
  }
  .main { padding: var(--s-6) var(--s-4) var(--s-8); }
}
@media (max-width: 700px) {
  .tenant__label { display: none; }
  .crumbs__eyebrow { display: none; }
  .page__head { align-items: flex-start; }
  .page__actions { margin-left: 0; width: 100%; }
  .page__title { font-size: var(--text-xl); }
  .toast-region { left: var(--s-4); right: var(--s-4); bottom: var(--s-4); max-width: none; }
  .field__row { grid-template-columns: 1fr; }
}
@media (max-width: 460px) {
  .tenant { display: none; }
  .login-card { padding: var(--s-6) var(--s-5); }
}

/* -----------------------------------------------------------------------------
   17. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    scroll-behavior: auto !important;
  }
  .stat:hover, .access-item:hover { transform: none; }
}

/* -----------------------------------------------------------------------------
   18. Keyframes
   -------------------------------------------------------------------------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes toast-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* -----------------------------------------------------------------------------
   19. Ability catalog
   -------------------------------------------------------------------------- */
/* Filter chip rows (kind + platform). Buttons, not links: aria-pressed
   carries the selection for assistive tech, and the pressed state pairs the
   fill with a checkmark so state never rides on color alone. */
.ability-filters {
  display: flex; align-items: center; gap: var(--s-5); flex-wrap: wrap;
  margin-bottom: var(--s-4);
}
.ability-filter-group { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.ability-filter-label {
  font-size: var(--text-xs); text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-4); font-weight: 700;
}
.chip--filter {
  cursor: pointer; font-family: var(--font-sans); font-size: var(--text-sm); font-weight: 600;
  padding: 5px 12px; border-radius: var(--r-full); color: var(--ink-3);
  background: var(--surface); border: 1px solid var(--line-strong);
  transition: border-color var(--dur) var(--ease), background var(--dur) var(--ease), color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.chip--filter:hover { border-color: var(--ink-4); color: var(--ink); }
.chip--filter[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: var(--sh-1);
}
.chip--filter[aria-pressed="true"]::before { content: "✓"; font-size: 11px; margin-right: 4px; }

/* Catalog: grouped sections of cards (one column at small widths). */
.ability-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--s-4); }
.ability-card {
  padding: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.ability-card:hover { transform: translateY(-2px); box-shadow: var(--sh-2); border-color: var(--line-strong); }
.ability-card__top { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }
.ability-card__name { font-family: var(--font-display); font-size: var(--text-lg); line-height: 1.25; margin: 0; }
.ability-card__summary { color: var(--ink-3); font-size: var(--text-sm); margin: 0; }
.ability-card__meta { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
.ability-card__meta .id-text {
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ability-card__foot {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--s-3); margin-top: var(--s-2);
}
@media (max-width: 560px) { .ability-grid { grid-template-columns: 1fr; } }

/* Collapsed-by-default live JSON preview inside create forms. */
.ability-preview {
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
  background: var(--surface-2); padding: var(--s-3) var(--s-4);
}
.ability-preview summary {
  cursor: pointer; color: var(--ink-2); font-size: var(--text-sm); font-weight: 600;
  list-style: none; display: flex; align-items: center; gap: var(--s-2);
}
.ability-preview summary::-webkit-details-marker { display: none; }
.ability-preview summary::before { content: "▸"; transition: transform var(--dur) var(--ease); }
.ability-preview[open] summary::before { transform: rotate(90deg); }
.ability-preview__body { margin-top: var(--s-3); }
.ability-preview__body .output-pre { max-height: 240px; }