/* ==========================================================================
   CyntrolX Security+ — application shell & component styles
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  font-weight: var(--fw-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
}

#app { height: 100%; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; }

h1, h2, h3, h4, h5 { margin: 0; font-weight: var(--fw-semi); line-height: var(--lh-tight); color: var(--text); }
p  { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; border-radius: var(--r-xs); }

code, pre, .mono { font-family: var(--font-mono); font-size: .92em; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }

/* --------------------------------------------------------------------------
   Preloader
   -------------------------------------------------------------------------- */
.preloader {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-4);
  background: var(--bg);
  color: var(--brand-500);
  transition: opacity var(--dur-slow) var(--ease), visibility var(--dur-slow);
}
.preloader--hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.preloader__label { font-size: var(--fs-sm); color: var(--text-faint); letter-spacing: .01em; }
.spinner { transform-origin: center; animation: spin 1.6s linear infinite; }
.spinner circle { stroke-dasharray: 46 14; animation: dash 1.6s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes dash {
  0%   { stroke-dasharray: 1 58; stroke-dashoffset: 0; }
  50%  { stroke-dasharray: 42 18; stroke-dashoffset: -14; }
  100% { stroke-dasharray: 1 58; stroke-dashoffset: -59; }
}

/* --------------------------------------------------------------------------
   App layout
   -------------------------------------------------------------------------- */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  transition: grid-template-columns var(--dur) var(--ease);
}
.app-shell[data-collapsed="true"] { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

.app-main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; height: 100%;
  background: var(--bg);
}

.app-content {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: var(--s-6) var(--s-8) var(--s-16);
}
.app-content > .content-inner { max-width: var(--content-max); margin: 0 auto; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  display: flex; flex-direction: column;
  min-height: 0;
  background: var(--ink-900);
  border-right: 1px solid rgba(255, 255, 255, .07);
  color: var(--ink-300);
  overflow: hidden;
}

.sidebar__brand {
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-4);
  flex: none;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar__mark { flex: none; width: 26px; height: 26px; }
.sidebar__name {
  font-size: var(--fs-md); font-weight: var(--fw-semi);
  color: #fff; letter-spacing: -.01em; white-space: nowrap;
}
.sidebar__name sup {
  color: var(--brand-400); font-size: 10px;
  font-weight: var(--fw-bold); margin-left: 2px;
}
[data-collapsed="true"] .sidebar__name,
[data-collapsed="true"] .sidebar__section-label,
[data-collapsed="true"] .nav-item__text,
[data-collapsed="true"] .nav-item__badge,
[data-collapsed="true"] .sidebar__footer-text { display: none; }
[data-collapsed="true"] .sidebar__brand { justify-content: center; padding: 0; }

.sidebar__nav { flex: 1; min-height: 0; overflow-y: auto; padding: var(--s-3) var(--s-2) var(--s-4); }
.sidebar__nav::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .14); border-color: transparent; }

.sidebar__section { margin-bottom: var(--s-2); }
.sidebar__section-label {
  padding: var(--s-4) var(--s-3) var(--s-2);
  font-size: 10px; font-weight: var(--fw-bold);
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-600);
}

.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  width: 100%;
  padding: 7px var(--s-3);
  margin-bottom: 1px;
  border: 0; border-radius: var(--r-md);
  background: transparent;
  color: var(--ink-300);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  text-align: left; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-item[aria-current="page"] { background: rgba(20, 184, 166, .15); color: #fff; }
.nav-item[aria-current="page"] .nav-item__icon { color: var(--brand-400); }
.nav-item__icon { flex: none; width: 17px; height: 17px; color: var(--ink-400); }
.nav-item__text { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-item__badge {
  flex: none; min-width: 20px; padding: 1px 6px;
  border-radius: var(--r-full);
  background: rgba(255, 255, 255, .1);
  color: var(--ink-200);
  font-size: 10px; font-weight: var(--fw-bold); text-align: center;
}
.nav-item__badge--alert { background: var(--sev-critical); color: #fff; }
.nav-item__count {
  flex: none; min-width: 18px; padding: 1px 6px; border-radius: var(--r-full);
  background: rgba(255, 255, 255, .08); color: var(--ink-300);
  font-size: 10px; font-weight: var(--fw-semi); text-align: center;
}
.nav-item[aria-current="page"] .nav-item__count { background: rgba(255, 255, 255, .16); color: #fff; }
.nav-item__add {
  flex: none; display: none; align-items: center; justify-content: center;
  width: 20px; height: 20px; margin-left: 2px;
  border: 1px solid rgba(255, 255, 255, .12); border-radius: var(--r-sm);
  background: transparent; color: var(--ink-300); cursor: pointer;
}
.nav-item:hover .nav-item__add { display: inline-flex; }
.nav-item:hover .nav-item__count { display: none; }
.nav-item__add:hover { background: rgba(255, 255, 255, .12); color: #fff; }
[data-collapsed="true"] .nav-item__count, [data-collapsed="true"] .nav-item__add { display: none; }
[data-collapsed="true"] .nav-item { justify-content: center; padding: 8px 0; }

.sidebar__footer {
  flex: none; padding: var(--s-3);
  border-top: 1px solid rgba(255, 255, 255, .07);
}
.plan-card {
  padding: var(--s-3);
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, .04);
  border: 1px solid rgba(255, 255, 255, .07);
}
.plan-card__row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); }
.plan-card__name { font-size: var(--fs-sm); font-weight: var(--fw-semi); color: #fff; }
.plan-card__meta { margin-top: 2px; font-size: var(--fs-xs); color: var(--ink-500); }
.plan-card__bar { height: 4px; margin-top: var(--s-2); border-radius: var(--r-full); background: rgba(255,255,255,.1); overflow: hidden; }
.plan-card__bar i { display: block; height: 100%; border-radius: inherit; background: var(--brand-400); }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar {
  flex: none;
  display: flex; align-items: center; gap: var(--s-3);
  height: var(--topbar-h);
  padding: 0 var(--s-6) 0 var(--s-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; flex: none;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--text-muted);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn--dot { position: relative; }
.icon-btn--dot::after {
  content: ""; position: absolute; top: 5px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--sev-critical); border: 1.5px solid var(--surface);
}

.topbar__search {
  position: relative; flex: 1; max-width: 460px;
}
.topbar__search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-faint); pointer-events: none;
}
.topbar__search input {
  width: 100%; height: 32px;
  padding: 0 var(--s-10) 0 32px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.topbar__search input::placeholder { color: var(--text-faint); }
.topbar__search input:focus { outline: 0; border-color: var(--brand-500); box-shadow: var(--ring); background: var(--surface); }
.topbar__kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  display: flex; gap: 3px; pointer-events: none;
}
.kbd {
  min-width: 17px; padding: 1px 4px;
  border: 1px solid var(--border); border-bottom-width: 2px; border-radius: var(--r-xs);
  background: var(--surface); color: var(--text-faint);
  font-family: var(--font-mono); font-size: 10px; text-align: center;
}

.topbar__spacer { flex: 1; }

.org-switch {
  display: flex; align-items: center; gap: var(--s-2);
  height: 32px; padding: 0 var(--s-2) 0 var(--s-1);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
.org-switch:hover { background: var(--surface-3); }
.org-switch__avatar {
  width: 22px; height: 22px; flex: none;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, var(--brand-500), var(--accent-500));
  color: #fff;
  display: grid; place-items: center;
  font-size: 10px; font-weight: var(--fw-bold);
}
.org-switch__name { font-size: var(--fs-base); font-weight: var(--fw-medium); }
.org-switch svg { width: 13px; height: 13px; color: var(--text-faint); }

.avatar {
  display: grid; place-items: center; flex: none;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--ink-700); color: #fff;
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   Page header
   -------------------------------------------------------------------------- */
.page-head { margin-bottom: var(--s-6); }
.page-head__top {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--s-4); flex-wrap: wrap;
}
.breadcrumb {
  display: flex; align-items: center; gap: var(--s-2);
  margin-bottom: var(--s-2);
  font-size: var(--fs-sm); color: var(--text-faint);
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb span[aria-hidden] { color: var(--border-strong); }
.page-title {
  display: flex; align-items: center; gap: var(--s-3);
  font-size: var(--fs-2xl); letter-spacing: -.02em;
}
.page-sub { margin-top: var(--s-2); font-size: var(--fs-md); color: var(--text-muted); max-width: 72ch; }
.page-head__actions { display: flex; align-items: center; gap: var(--s-2); flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s-2);
  height: 32px; padding: 0 var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  white-space: nowrap; cursor: pointer;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
              box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; flex: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.btn--primary {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn--primary:hover { background: var(--brand-700); border-color: var(--brand-700); }

.btn--accent { background: var(--accent-500); border-color: var(--accent-500); color: #fff; }
.btn--accent:hover { background: var(--accent-600); border-color: var(--accent-600); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.93); }

.btn--ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn--ghost:hover { background: var(--surface-3); color: var(--text); }

.btn--sm { height: 26px; padding: 0 var(--s-3); font-size: var(--fs-sm); }
.btn--lg { height: 42px; padding: 0 var(--s-6); font-size: var(--fs-md); border-radius: var(--r-lg); }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--r-md) 0 0 var(--r-md); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--r-md) var(--r-md) 0; }
.btn-group .btn[aria-pressed="true"] {
  background: var(--surface-inverse); border-color: var(--surface-inverse); color: var(--text-invert); z-index: 1;
}

/* --------------------------------------------------------------------------
   Cards & panels
   -------------------------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
}
.card--flush { overflow: hidden; }
.card__head {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border);
}
.card__title { display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-md); font-weight: var(--fw-semi); }
.card__title svg,
.page-title svg,
.modal__title svg,
.stat__label svg,
.timeline__title svg,
.empty__title svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-faint);
}
.page-title svg { width: 20px; height: 20px; }
.card__title > svg:first-child { color: var(--text-muted); }

.card__desc { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); font-weight: var(--fw-normal); }
.card__body { padding: var(--s-5); }
.card__body--tight { padding: var(--s-4); }
.card__foot {
  padding: var(--s-3) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: var(--fs-sm); color: var(--text-muted);
}

.grid { display: grid; gap: var(--s-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 340px; }
.stack { display: flex; flex-direction: column; gap: var(--s-4); }
.row { display: flex; align-items: center; gap: var(--s-3); }
.row--wrap { flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }

/* --------------------------------------------------------------------------
   Stat tiles
   -------------------------------------------------------------------------- */
.stat {
  position: relative;
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.stat__label {
  display: flex; align-items: center; gap: var(--s-2);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text-muted);
}
.stat__value {
  margin-top: var(--s-2);
  font-size: var(--fs-3xl); font-weight: var(--fw-semi);
  letter-spacing: -.03em; line-height: 1;
}
.stat__value small { font-size: var(--fs-lg); color: var(--text-faint); font-weight: var(--fw-medium); }
.stat__foot { margin-top: var(--s-3); display: flex; align-items: center; gap: var(--s-2); font-size: var(--fs-sm); }
.stat__spark { position: absolute; right: 0; bottom: 0; opacity: .5; pointer-events: none; }

.delta { display: inline-flex; align-items: center; gap: 3px; font-weight: var(--fw-semi); }
.delta svg { width: 13px; height: 13px; }
.delta--up { color: var(--sev-critical); }
.delta--down { color: var(--ok); }
.delta--flat { color: var(--text-faint); }

/* --------------------------------------------------------------------------
   Badges & pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  letter-spacing: .01em; white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 11px; height: 11px; }
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
.badge--nodot::before { display: none; }

.badge--critical { color: var(--sev-critical); background: var(--sev-critical-bg); border-color: color-mix(in srgb, var(--sev-critical) 22%, transparent); }
.badge--high     { color: var(--sev-high);     background: var(--sev-high-bg);     border-color: color-mix(in srgb, var(--sev-high) 22%, transparent); }
.badge--medium   { color: #a16207;             background: var(--sev-medium-bg);   border-color: color-mix(in srgb, var(--sev-medium) 30%, transparent); }
.badge--low      { color: var(--sev-low);      background: var(--sev-low-bg);      border-color: color-mix(in srgb, var(--sev-low) 22%, transparent); }
.badge--info     { color: var(--sev-info);     background: var(--sev-info-bg);     border-color: color-mix(in srgb, var(--sev-info) 22%, transparent); }
.badge--ok       { color: var(--ok);           background: var(--ok-bg);           border-color: color-mix(in srgb, var(--ok) 22%, transparent); }
.badge--warn     { color: #b45309;             background: var(--warn-bg);         border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.badge--neutral  { color: var(--text-muted);   background: var(--surface-3);       border-color: var(--border); }
.badge--brand    { color: var(--brand-700);    background: var(--brand-50);        border-color: color-mix(in srgb, var(--brand-500) 24%, transparent); }
.badge--accent   { color: var(--accent-600);   background: var(--accent-100);      border-color: color-mix(in srgb, var(--accent-500) 24%, transparent); }

[data-theme="dark"] .badge--medium { color: #facc15; }
[data-theme="dark"] .badge--warn { color: #fbbf24; }
[data-theme="dark"] .badge--brand { color: var(--brand-300); background: color-mix(in srgb, var(--brand-500) 14%, transparent); }
[data-theme="dark"] .badge--accent { color: var(--accent-300); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge--medium { color: #facc15; }
  :root:not([data-theme="light"]) .badge--warn { color: #fbbf24; }
  :root:not([data-theme="light"]) .badge--brand { color: var(--brand-300); background: color-mix(in srgb, var(--brand-500) 14%, transparent); }
  :root:not([data-theme="light"]) .badge--accent { color: var(--accent-300); }
}

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface-2); color: var(--text-muted);
  font-size: var(--fs-xs); font-weight: var(--fw-medium);
  font-family: var(--font-mono);
}

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-base); }
.table th {
  position: sticky; top: 0; z-index: 2;
  padding: var(--s-2) var(--s-4);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-xs); font-weight: var(--fw-semi);
  letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint);
  text-align: left; white-space: nowrap;
}
.table th.is-sortable { cursor: pointer; user-select: none; }
.table th.is-sortable:hover { color: var(--text); }
.table th .sort-caret { margin-left: 4px; opacity: .4; }
.table th[aria-sort] .sort-caret { opacity: 1; color: var(--brand-600); }
.table td {
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr.is-clickable { cursor: pointer; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .td-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .td-tight { width: 1%; white-space: nowrap; }

.cell-primary { font-weight: var(--fw-medium); color: var(--text); }
.cell-sub { font-size: var(--fs-sm); color: var(--text-faint); margin-top: 1px; }
.cell-mono { font-family: var(--font-mono); font-size: var(--fs-sm); }

.sev-rail { display: inline-block; width: 3px; height: 26px; border-radius: var(--r-full); vertical-align: middle; }
.sev-rail--critical { background: var(--sev-critical); }
.sev-rail--high { background: var(--sev-high); }
.sev-rail--medium { background: var(--sev-medium); }
.sev-rail--low { background: var(--sev-low); }
.sev-rail--info { background: var(--sev-info); }

/* --------------------------------------------------------------------------
   Toolbar / filters
   -------------------------------------------------------------------------- */
.toolbar {
  display: flex; align-items: center; gap: var(--s-2);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.field {
  position: relative;
  display: inline-flex; align-items: center;
}
.field svg.field__icon {
  position: absolute; left: 9px; width: 14px; height: 14px;
  color: var(--text-faint); pointer-events: none;
}
.input, .select {
  height: 30px;
  padding: 0 var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-base);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.input:focus, .select:focus { outline: 0; border-color: var(--brand-500); box-shadow: var(--ring); }
.input--with-icon { padding-left: 29px; }
.input--search { min-width: 240px; }
.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238b98ab' stroke-width='1.6' stroke-linecap='round'><path d='M4 6.5 8 10.5 12 6.5'/></svg>");
  background-repeat: no-repeat; background-position: right 7px center; background-size: 14px;
  cursor: pointer;
}
textarea.input { height: auto; min-height: 84px; padding: var(--s-2) var(--s-3); resize: vertical; line-height: var(--lh-snug); }
.label { display: block; margin-bottom: 5px; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--text); }
.hint { margin-top: 5px; font-size: var(--fs-sm); color: var(--text-faint); }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-full);
  background: var(--surface); color: var(--text-muted);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease);
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip[aria-pressed="true"] {
  background: var(--brand-50); border-color: var(--brand-400); color: var(--brand-700);
}
[data-theme="dark"] .chip[aria-pressed="true"] { background: color-mix(in srgb, var(--brand-500) 16%, transparent); color: var(--brand-300); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .chip[aria-pressed="true"] { background: color-mix(in srgb, var(--brand-500) 16%, transparent); color: var(--brand-300); }
}
.chip__count {
  padding: 0 5px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--text-faint);
  font-size: 10px; font-weight: var(--fw-bold);
}

/* --------------------------------------------------------------------------
   Tabs
   -------------------------------------------------------------------------- */
.tabs {
  display: flex; align-items: center; gap: var(--s-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--s-5);
  overflow-x: auto;
}
.tab {
  position: relative;
  padding: var(--s-3) var(--s-3);
  border: 0; background: transparent;
  color: var(--text-muted);
  font-size: var(--fs-base); font-weight: var(--fw-medium);
  white-space: nowrap; cursor: pointer;
  transition: color var(--dur-fast) var(--ease);
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--text); font-weight: var(--fw-semi); }
.tab[aria-selected="true"]::after {
  content: ""; position: absolute; left: var(--s-2); right: var(--s-2); bottom: -1px;
  height: 2px; border-radius: var(--r-full); background: var(--brand-500);
}
.tab__count { margin-left: 5px; color: var(--text-faint); font-weight: var(--fw-normal); }

/* --------------------------------------------------------------------------
   Empty / loading states
   -------------------------------------------------------------------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--s-3); padding: var(--s-16) var(--s-6); text-align: center;
}
.empty__icon {
  display: grid; place-items: center;
  width: 46px; height: 46px; border-radius: var(--r-lg);
  background: var(--surface-3); color: var(--text-faint);
}
.empty__icon svg { width: 22px; height: 22px; }
.empty__title { font-size: var(--fs-md); font-weight: var(--fw-semi); }
.empty__text { font-size: var(--fs-base); color: var(--text-muted); max-width: 42ch; }

.skeleton {
  background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* --------------------------------------------------------------------------
   Charts (hand-rolled SVG)
   -------------------------------------------------------------------------- */
.chart { width: 100%; display: block; overflow: visible; }
.chart .grid-line { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .axis-text { fill: var(--text-faint); font-size: 10px; font-family: var(--font-sans); }
.chart .bar { transition: opacity var(--dur-fast) var(--ease); }
.chart .bar:hover { opacity: .78; }

.legend { display: flex; flex-wrap: wrap; gap: var(--s-3); margin-top: var(--s-3); }
.legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); color: var(--text-muted); }
.legend__swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }

.donut-center { text-align: center; }
.donut-center__value { font-size: var(--fs-2xl); font-weight: var(--fw-semi); letter-spacing: -.02em; }
.donut-center__label { font-size: var(--fs-sm); color: var(--text-muted); }

.meter { height: 6px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; }

.heat-cell { rx: 2; transition: opacity var(--dur-fast) var(--ease); }
.heat-cell:hover { opacity: .75; }

/* --------------------------------------------------------------------------
   Detail views
   -------------------------------------------------------------------------- */
.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--s-5); align-items: start; }
.kv { display: grid; grid-template-columns: 128px minmax(0, 1fr); gap: var(--s-2) var(--s-3); font-size: var(--fs-base); }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text); font-weight: var(--fw-medium); word-break: break-word; }

.code-block {
  padding: var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-inset);
  overflow-x: auto;
  font-family: var(--font-mono); font-size: var(--fs-sm); line-height: 1.65;
  white-space: pre;
}
.code-block .ln { display: inline-block; width: 30px; color: var(--text-faint); user-select: none; }
.code-block .hl { background: color-mix(in srgb, var(--sev-critical) 12%, transparent); display: block; margin: 0 calc(var(--s-4) * -1); padding: 0 var(--s-4); }
.code-block .add { color: var(--ok); }
.code-block .del { color: var(--sev-critical); }

.timeline { position: relative; padding-left: var(--s-6); }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px;
  width: 1px; background: var(--border);
}
.timeline__item { position: relative; padding-bottom: var(--s-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: calc(var(--s-6) * -1 + 3px); top: 3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 2px solid var(--border-strong);
}
.timeline__dot--active { background: var(--brand-500); border-color: var(--brand-500); }
.timeline__title { font-size: var(--fs-base); font-weight: var(--fw-medium); }
.timeline__meta { font-size: var(--fs-sm); color: var(--text-faint); margin-top: 1px; }

/* --------------------------------------------------------------------------
   Modal & toast
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 500;
  display: grid; place-items: center;
  padding: var(--s-6);
  background: rgba(7, 11, 20, .55);
  backdrop-filter: blur(3px);
  animation: fade var(--dur) var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px;
  max-height: 85vh; overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--r-xl);
  box-shadow: var(--shadow-xl);
  animation: pop var(--dur-slow) var(--ease-out);
}
.modal--wide { max-width: 760px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-4);
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--border);
}
.modal__title { font-size: var(--fs-lg); }
.modal__desc { margin-top: 4px; font-size: var(--fs-base); color: var(--text-muted); }
.modal__body { padding: var(--s-5); }
.modal__foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s-2);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
}

.toast-stack {
  position: fixed; right: var(--s-5); bottom: var(--s-5); z-index: 600;
  display: flex; flex-direction: column; gap: var(--s-2);
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s-3);
  min-width: 280px; max-width: 380px;
  padding: var(--s-3) var(--s-4);
  background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--brand-500);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  animation: slide-in var(--dur-slow) var(--ease-out);
}
@keyframes slide-in { from { opacity: 0; transform: translateX(16px); } }
.toast--ok { border-left-color: var(--ok); }
.toast--warn { border-left-color: var(--warn); }
.toast--danger { border-left-color: var(--danger); }
.toast__title { font-size: var(--fs-base); font-weight: var(--fw-semi); }
.toast__text { margin-top: 2px; font-size: var(--fs-sm); color: var(--text-muted); }

/* --------------------------------------------------------------------------
   Misc utilities
   -------------------------------------------------------------------------- */
.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.tnum { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-lg { font-size: var(--fs-lg); }
.fw-semi { font-weight: var(--fw-semi); }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); } .mt-5 { margin-top: var(--s-5); } .mt-6 { margin-top: var(--s-6); }
.mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); } .mb-5 { margin-bottom: var(--s-5); }
.divider { height: 1px; background: var(--border); border: 0; margin: var(--s-4) 0; }
.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;
}

.callout {
  display: flex; gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2);
  font-size: var(--fs-base);
}
.callout svg { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.callout--info { background: var(--info-bg); border-color: color-mix(in srgb, var(--info) 24%, transparent); color: var(--text); }
.callout--info svg { color: var(--info); }
.callout--warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.callout--warn svg { color: var(--warn); }
.callout--danger { background: var(--danger-bg); border-color: color-mix(in srgb, var(--danger) 24%, transparent); }
.callout--danger svg { color: var(--danger); }
.callout--accent { background: var(--accent-100); border-color: color-mix(in srgb, var(--accent-500) 24%, transparent); }
.callout--accent svg { color: var(--accent-500); }

.avatar-stack { display: flex; }
.avatar-stack .avatar { width: 22px; height: 22px; font-size: 9px; margin-left: -6px; border: 2px solid var(--surface); }
.avatar-stack .avatar:first-child { margin-left: 0; }

.progress-ring { transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-linecap: round; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1280px) {
  .grid--5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid--sidebar { grid-template-columns: minmax(0, 1fr); }
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 1024px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-content { padding: var(--s-5) var(--s-5) var(--s-12); }
}
@media (max-width: 860px) {
  .app-shell { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }
  .app-shell .sidebar__name,
  .app-shell .sidebar__section-label,
  .app-shell .nav-item__text,
  .app-shell .nav-item__badge,
  .app-shell .sidebar__footer { display: none; }
  .app-shell .nav-item { justify-content: center; padding: 8px 0; }
  .app-shell .sidebar__brand { justify-content: center; padding: 0; }
  .grid--2, .grid--3, .grid--4, .grid--5 { grid-template-columns: minmax(0, 1fr); }
  .topbar__search { max-width: none; }
  .topbar__kbd { display: none; }
  .org-switch__name { display: none; }
}

/* --------------------------------------------------------------------------
   Toggle switch
   -------------------------------------------------------------------------- */
.switch { position: relative; display: inline-block; width: 38px; height: 22px; flex: none; }
.switch input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.switch__track { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background var(--dur) var(--ease); }
.switch__track::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform var(--dur) var(--ease); }
.switch input:checked + .switch__track { background: var(--brand-500); }
.switch input:checked + .switch__track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch__track { box-shadow: var(--ring); }

/* --------------------------------------------------------------------------
   Reports catalogue
   -------------------------------------------------------------------------- */
.reports-group { font-size: var(--fs-md); font-weight: var(--fw-semi); margin: 0 0 var(--s-3); color: var(--text); }
.reports-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-3); }
.report-tile {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-4); text-align: left;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); color: var(--text); cursor: pointer;
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.report-tile:hover { border-color: var(--brand-400); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.report-tile__ico { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--r-md); background: var(--surface-3); color: var(--text-muted); }
.report-tile__body { flex: 1; min-width: 0; }
.report-tile__name { display: block; font-weight: var(--fw-medium); font-size: var(--fs-base); }
.report-tile__desc { display: block; font-size: var(--fs-sm); color: var(--text-faint); margin-top: 2px; line-height: 1.4; }
.report-tile__arrow { flex: none; color: var(--text-faint); }
@media (max-width: 1024px) { .reports-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .reports-grid { grid-template-columns: minmax(0, 1fr); } }


/* -------------------------------------------------------------------------
   Sign-in gate
   Replaces the app entirely when a session is required and absent, so it can
   rely on nothing: no shell, no store, no live data. Two panes — a brand aside
   that states what the platform actually does, and the sign-in action itself.
   The aside is decorative and hidden from assistive tech; below 900px it is
   dropped and the panel carries its own wordmark.
   ------------------------------------------------------------------------- */
.auth-gate {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  background: var(--bg);
}

/* ---- brand aside ------------------------------------------------------- */
.auth-gate__aside {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  padding: var(--s-12);
  background:
    linear-gradient(160deg,
      color-mix(in srgb, var(--brand-900) 92%, #000) 0%,
      var(--brand-800) 48%,
      color-mix(in srgb, var(--brand-700) 88%, var(--accent-700)) 100%);
  isolation: isolate;
}
/* A slow, low-contrast wash so the panel reads as lit rather than flat. It
   sits under the content and never animates layout — transform and opacity
   only, so it cannot cost a frame on the sign-in path. */
.auth-gate__aurora {
  position: absolute;
  inset: -30%;
  z-index: -1;
  background:
    radial-gradient(38% 42% at 22% 28%, color-mix(in srgb, var(--brand-300) 42%, transparent) 0%, transparent 70%),
    radial-gradient(34% 38% at 76% 68%, color-mix(in srgb, var(--accent-300) 34%, transparent) 0%, transparent 72%);
  filter: blur(28px);
  animation: gate-drift 22s var(--ease) infinite alternate;
}
@keyframes gate-drift {
  from { transform: translate3d(-3%, -2%, 0) scale(1); }
  to   { transform: translate3d(4%, 3%, 0) scale(1.08); }
}

.auth-gate__aside-inner { position: relative; max-width: 30rem; }

.auth-gate__proof {
  margin: var(--s-8) 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: var(--s-4);
}
.auth-gate__proof li {
  display: flex;
  align-items: flex-start;
  gap: var(--s-3);
  font-size: var(--fs-md);
  line-height: 1.5;
  color: color-mix(in srgb, #fff 88%, transparent);
  /* --i staggers the entrance; set inline per item in renderAuthGate. */
  animation: gate-rise var(--dur-slow) var(--ease-out) backwards;
  animation-delay: calc(120ms + var(--i) * 90ms);
}
.auth-gate__proof svg {
  flex: none;
  margin-top: 2px;
  color: var(--brand-300);
}
.auth-gate__aside-foot {
  margin: var(--s-10) 0 0;
  font-size: var(--fs-sm);
  color: color-mix(in srgb, #fff 62%, transparent);
}

/* ---- sign-in pane ------------------------------------------------------ */
.auth-gate__main {
  display: grid;
  place-items: center;
  padding: var(--s-8);
}
.auth-gate__panel {
  width: 100%;
  max-width: 24rem;
  animation: gate-rise 420ms var(--ease-out) backwards;
}
.auth-gate__panel h1 {
  margin: var(--s-5) 0 var(--s-2);
  font-family: var(--font-display, var(--font-sans));
  font-size: var(--fs-xl);
  font-weight: var(--fw-semi);
  letter-spacing: -0.015em;
  color: var(--text);
}
.auth-gate__lede {
  margin: 0 0 var(--s-6);
  font-size: var(--fs-md);
  line-height: 1.55;
  color: var(--text-muted);
}
.auth-gate__cta {
  width: 100%;
  justify-content: center;
  height: 2.75rem;
  font-size: var(--fs-md);
}
.auth-gate__foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  margin: var(--s-6) 0 0;
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-faint);
}
.auth-gate__foot svg { flex: none; }

/* ---- wordmark ---------------------------------------------------------- */
.auth-gate__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  font-family: var(--font-display, var(--font-sans));
  letter-spacing: -0.01em;
  color: var(--text);
}
.auth-gate__brand b { font-weight: var(--fw-semi); }
.auth-gate__brand--lg {
  font-size: var(--fs-lg);
  color: #fff;
}
.auth-gate__brand--lg svg { color: var(--brand-300); }
.auth-gate__brand--sm { font-size: var(--fs-md); }
.auth-gate__brand--sm svg { color: var(--brand-600); }

@keyframes gate-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* Single column below 900px: the aside is decoration, so it goes first. */
@media (max-width: 900px) {
  .auth-gate { grid-template-columns: minmax(0, 1fr); }
  .auth-gate__aside { display: none; }
  .auth-gate__brand--sm { margin-bottom: var(--s-2); }
}
@media (min-width: 901px) {
  .auth-gate__brand--sm { display: none; }
}


/* -------------------------------------------------------------------------
   Motion layer
   The marketing site was already animated; the console was not, which made the
   product feel like two applications. These are the console's counterpart.

   Three rules held throughout:
   - transform and opacity only, so nothing here triggers layout or paint on a
     scroll or resize;
   - entrance animations are gated behind [data-enter], set in render() on a
     path change only. `subscribe(render)` fires on every store mutation, so
     without that gate every keystroke in the search field would replay the
     whole page;
   - durations come from the token scale. tokens.css already zeroes all of this
     under prefers-reduced-motion via a `*` rule, so none of it needs its own
     media query.
   ------------------------------------------------------------------------- */

/* ---- page entrance ----------------------------------------------------- */
.app-content[data-enter] > .content-inner,
.app-content[data-enter] > * {
  animation: page-enter 260ms var(--ease-out) backwards;
}
@keyframes page-enter {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* ---- stat tiles: short cascade ----------------------------------------
   Capped at six. Past that the last tile waits long enough to read as lag
   rather than as motion. */
.app-content[data-enter] .stat {
  animation: tile-rise 300ms var(--ease-out) backwards;
}
.app-content[data-enter] .stat:nth-child(1) { animation-delay: 40ms; }
.app-content[data-enter] .stat:nth-child(2) { animation-delay: 80ms; }
.app-content[data-enter] .stat:nth-child(3) { animation-delay: 120ms; }
.app-content[data-enter] .stat:nth-child(4) { animation-delay: 160ms; }
.app-content[data-enter] .stat:nth-child(5) { animation-delay: 200ms; }
.app-content[data-enter] .stat:nth-child(n+6) { animation-delay: 240ms; }
@keyframes tile-rise {
  from { opacity: 0; transform: translateY(8px) scale(.994); }
  to   { opacity: 1; transform: none; }
}

/* ---- cards ------------------------------------------------------------- */
.app-content[data-enter] .card {
  animation: card-rise 320ms var(--ease-out) backwards;
  animation-delay: 90ms;
}
@keyframes card-rise {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---- charts -----------------------------------------------------------
   The SVG is hand-rolled (lib/charts.js), so the series is revealed with a
   clip-style scale from the baseline rather than a path-length trick that
   would need per-path JS measurement. transform-box/origin keep the scale
   anchored to the x-axis instead of the SVG viewport centre. */
.app-content[data-enter] svg .area,
.app-content[data-enter] svg path[fill^="url"],
.app-content[data-enter] svg polyline,
.app-content[data-enter] svg .bar,
.app-content[data-enter] svg rect.bar {
  transform-box: fill-box;
  transform-origin: bottom;
  animation: chart-grow 520ms var(--ease-out) backwards;
  animation-delay: 140ms;
}
@keyframes chart-grow {
  from { opacity: 0; transform: scaleY(.72); }
  to   { opacity: 1; transform: none; }
}
/* Gridlines and axis labels settle in first so the series draws onto a
   finished frame. */
.app-content[data-enter] svg .grid-line {
  animation: fade 300ms var(--ease-out) backwards;
}
/* Donut / progress rings sweep rather than scale. */
.app-content[data-enter] svg circle[stroke-dasharray] {
  animation: ring-sweep 620ms var(--ease-out) backwards;
  animation-delay: 120ms;
}
@keyframes ring-sweep {
  from { opacity: 0; stroke-dashoffset: 999; }
  to   { opacity: 1; }
}

/* ---- table rows -------------------------------------------------------
   Only the first rows are staggered. A long findings table animating every
   row costs real frames and reads as jank on a 200-row feed. */
.app-content[data-enter] tbody tr:nth-child(-n+8) {
  animation: row-in 260ms var(--ease-out) backwards;
}
.app-content[data-enter] tbody tr:nth-child(1) { animation-delay: 120ms; }
.app-content[data-enter] tbody tr:nth-child(2) { animation-delay: 150ms; }
.app-content[data-enter] tbody tr:nth-child(3) { animation-delay: 180ms; }
.app-content[data-enter] tbody tr:nth-child(4) { animation-delay: 210ms; }
.app-content[data-enter] tbody tr:nth-child(5) { animation-delay: 240ms; }
.app-content[data-enter] tbody tr:nth-child(6) { animation-delay: 265ms; }
.app-content[data-enter] tbody tr:nth-child(7) { animation-delay: 285ms; }
.app-content[data-enter] tbody tr:nth-child(8) { animation-delay: 300ms; }
@keyframes row-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

/* -------------------------------------------------------------------------
   Interaction feedback
   Always-on, unlike the entrance work above: these respond to the pointer, so
   they must not depend on a navigation having just happened.
   ------------------------------------------------------------------------- */

/* Cards lift only where they are actually a link or a button. A hover effect
   on a static panel suggests an affordance that is not there. */
a.card,
.card--link,
.card[data-href] {
  transition:
    transform var(--dur) var(--ease-out),
    box-shadow var(--dur) var(--ease-out),
    border-color var(--dur) var(--ease);
}
a.card:hover,
.card--link:hover,
.card[data-href]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: color-mix(in srgb, var(--brand-500) 34%, var(--border));
}

/* Nav: a brand rail slides in on hover and locks on the active item, which
   reads faster than a background change alone. */
.nav-item {
  position: relative;
  transition:
    background-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}
.nav-item::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  inset-block: 18%;
  width: 2px;
  border-radius: var(--r-full);
  background: var(--brand-400);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--dur) var(--ease-out);
}
.nav-item:hover::before { transform: scaleY(.6); }
.nav-item[aria-current="page"]::before,
.nav-item.is-active::before { transform: scaleY(1); }

/* Rows highlight on hover only when they navigate. */
tr[data-href] {
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease);
}

/* Buttons: a small, quick press. Scale rather than translate so a button in a
   flex row cannot nudge its neighbours. */
.btn { transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease); }
.btn:active:not([disabled]) { transform: scale(.978); }

/* Badges and severity pills settle when their value changes after a scan. */
.badge { transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease); }

/* A live-data badge that actually indicates liveness. The dot is drawn here
   rather than in markup so the demo variant stays a plain badge. */
.badge--live { display: inline-flex; align-items: center; gap: 6px; }
.badge--live::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: currentColor;
  animation: pulse-live 2.4s var(--ease) infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: .4; transform: scale(.82); }
}

/* Modals and toasts reuse the existing `pop` and `slide-in` keyframes so there
   is one motion vocabulary rather than two. The panel class is `.modal` —
   `.modal-backdrop` is its parent, and fading that separately stops the
   backdrop from appearing to snap in behind the panel. */
.modal-backdrop { animation: fade var(--dur) var(--ease); }
.modal { animation: pop var(--dur-slow) var(--ease-out); }
.toast { animation: slide-in var(--dur-slow) var(--ease-out); }

/* Focus is never animated away — it must appear instantly for keyboard use. */
:focus-visible { transition: none !important; }
