/* ==========================================================================
   Navitrack CRM — design tokens + base components
   v1.0 · 2026-09-25 · Vire
   Evolved from "Light CRM" styles.css. Plain CSS, no build step.
   Font: Inter (self-host /fonts/InterVariable.woff2), falls back to system UI.
   ========================================================================== */

@font-face {
  font-family: "Inter";
  src: url("/fonts/InterVariable.woff2") format("woff2");
  font-weight: 100 900; font-style: normal; font-display: swap;
}

:root {
  /* Brand — sampled from the PolarCurve logo ("CURVE" blue, night-sky navy) */
  --brand-50:  #eaf4fb;
  --brand-100: #d3e8f6;
  --brand-200: #a8d0ec;
  --brand-500: #0981cb;   /* logo blue: icons, decorative only (4.19:1 on white) */
  --brand-600: #0a6cb0;   /* primary actions, links, active nav */
  --brand-700: #095d98;   /* hover */
  --brand-800: #0a4a78;   /* active/pressed */
  --navy-900:  #0c2340;   /* logo night sky: dark surfaces, tooltips */

  /* Neutrals — cool blue-grey (logo tagline slate), replaces old lilac tint */
  --bg:            #f2f5f8;
  --surface:       #ffffff;
  --surface-2:     #f7f9fb; /* table header, read-only fields, footers */
  --surface-3:     #eef2f5; /* hover on surface, neutral badge */
  --border:        #d5dde5; /* dividers, card outlines */
  --border-strong: #b9c5d0; /* table header rule, secondary button */
  --border-input:  #8595a6; /* form control outline, 3.07:1 on white */
  --text:          #15263b; /* primary text, 15.3:1 */
  --text-2:        #3e5468; /* secondary text, labels, 7.9:1 */
  --text-muted:    #5d6f80; /* meta, placeholders, hints, 5.2:1 */
  --text-disabled: #8b99a7;
  --text-on-brand: #ffffff;

  /* Semantic — fg (text/icon), bg (subtle fill), border */
  --success:        #146c3f; --success-bg: #e3f3ea; --success-border: #b3dcc3; --success-dot: #1f9d5c;
  --warning:        #8a5100; --warning-bg: #fdf1d8; --warning-border: #f1d08f; --warning-dot: #e3a008;
  --danger:         #c0231a; --danger-bg:  #fcebea; --danger-border:  #f2bcb8; --danger-dot:  #d93a2f;
  --danger-hover:   #a51d15; --danger-active: #8a170f;
  --info:           #0a6cb0; --info-bg:    #eaf4fb; --info-border:    #a8d0ec; --info-dot:    #0981cb;
  --neutral-dot:    #8b99a7;

  /* Focus */
  --focus:       #0a6cb0;
  --focus-ring:  0 0 0 3px rgba(10, 108, 176, 0.28);

  /* Typography */
  --font-sans: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --fs-xs: 12px;  --lh-xs: 16px;
  --fs-sm: 13px;  --lh-sm: 18px;
  --fs-md: 14px;  --lh-md: 20px;   /* base UI + table text */
  --fs-lg: 16px;  --lh-lg: 24px;
  --fs-xl: 20px;  --lh-xl: 28px;   /* card / section titles */
  --fs-2xl: 24px; --lh-2xl: 32px;  /* page title */
  --fw-regular: 400; --fw-medium: 500; --fw-semibold: 600; --fw-bold: 700;

  /* Spacing — 4px base */
  --sp-0: 0; --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px; --sp-12: 48px; --sp-16: 64px;

  /* Radii */
  --r-sm: 6px;    /* checkbox, small chips, kbd */
  --r-md: 8px;    /* inputs, buttons */
  --r-lg: 12px;   /* cards, menus */
  --r-xl: 16px;   /* dialogs */
  --r-full: 999px;/* badges, pills, avatars */

  /* Borders */
  --bw: 1px; --bw-strong: 2px;

  /* Elevation */
  --shadow-xs: 0 1px 2px rgba(12, 35, 64, 0.06);
  --shadow-sm: 0 1px 3px rgba(12, 35, 64, 0.08), 0 1px 2px rgba(12, 35, 64, 0.04);
  --shadow-md: 0 8px 24px rgba(12, 35, 64, 0.12), 0 2px 6px rgba(12, 35, 64, 0.06);
  --shadow-lg: 0 24px 64px rgba(12, 35, 64, 0.22), 0 4px 12px rgba(12, 35, 64, 0.08);

  /* Sizes */
  --control-h-sm: 32px; --control-h: 40px; --control-h-lg: 48px;
  --row-h: 48px; --row-h-compact: 40px;
  --topbar-h: 72px; --content-max: 1280px;

  /* Layers */
  --z-sticky: 10; --z-topbar: 20; --z-dropdown: 30; --z-overlay: 40; --z-dialog: 50; --z-toast: 60;

  /* Motion */
  --ease: cubic-bezier(0.2, 0, 0, 1); --dur-fast: 120ms; --dur: 180ms;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-sans); font-size: var(--fs-md); line-height: var(--lh-md);
  font-feature-settings: "cv11", "ss01"; /* Inter: single-storey a off, open digits */
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--text); letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); text-decoration: underline; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--lg { width: 20px; height: 20px; }
.num, .tabular { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-size: 0.93em; }
.muted { color: var(--text-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App shell: top bar (follows Light CRM header + entity picker) ---------- */
.topbar {
  position: sticky; top: 0; z-index: var(--z-topbar);
  background: var(--surface); border-bottom: var(--bw) solid var(--border);
}
.topbar__inner {
  max-width: var(--content-max); margin: 0 auto; height: var(--topbar-h);
  padding: 0 var(--sp-6); display: flex; align-items: center; gap: var(--sp-6);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); flex: none; color: var(--text); }
.brand__logo { height: 56px; width: auto; display: block; }
.brand__name { font-size: var(--fs-lg); line-height: 20px; font-weight: var(--fw-bold); letter-spacing: -0.015em; }
.brand__sub { display: block; font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: var(--fw-medium); color: var(--text-muted); letter-spacing: 0; }
.nav { display: flex; align-items: center; gap: var(--sp-1); min-width: 0; padding-left: var(--sp-6); border-left: var(--bw) solid var(--border); height: 40px; }
.nav__link {
  display: inline-flex; align-items: center; height: 36px; padding: 0 var(--sp-3);
  border-radius: var(--r-md); color: var(--text-2); font-weight: var(--fw-medium); white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav__link:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav__link[aria-current="page"] { background: var(--brand-50); color: var(--brand-700); font-weight: var(--fw-semibold); box-shadow: inset 0 0 0 1px var(--brand-100); }
.topbar__end { margin-left: auto; display: flex; align-items: center; gap: var(--sp-2); }
.usermenu {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: 40px; padding: 0 var(--sp-2) 0 var(--sp-1);
  border: var(--bw) solid transparent; border-radius: var(--r-full); background: none; color: var(--text); font: inherit; cursor: pointer;
}
.usermenu:hover { background: var(--surface-3); }
.avatar {
  width: 32px; height: 32px; border-radius: var(--r-full); display: grid; place-items: center;
  background: var(--navy-900); color: #fff; font-size: var(--fs-xs); font-weight: var(--fw-semibold); letter-spacing: 0.02em;
}
.usermenu__name { font-weight: var(--fw-medium); }
.usermenu .icon { color: var(--text-muted); }
.btn.nav-toggle { display: none; }

.page { max-width: var(--content-max); margin: 0 auto; padding: var(--sp-8) var(--sp-6) var(--sp-12); }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-6); margin-bottom: var(--sp-6); }
.page-title { font-size: var(--fs-2xl); line-height: var(--lh-2xl); font-weight: var(--fw-bold); }
.page-title-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-3); }
.page-sub { margin-top: var(--sp-1); color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--sp-3); }

.breadcrumb { display: flex; align-items: center; gap: var(--sp-2); margin-bottom: var(--sp-2); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.breadcrumb a { color: var(--text-2); font-weight: var(--fw-medium); }
.breadcrumb .icon { width: 14px; height: 14px; color: var(--text-disabled); }
.breadcrumb [aria-current] { color: var(--text-muted); }

/* ---------- Card ---------- */
.card { background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card__header { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-4) var(--sp-5); border-bottom: var(--bw) solid var(--border); }
.card__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); }
.card__body { padding: var(--sp-5); }
.card__footer { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-5); border-top: var(--bw) solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); }

/* ---------- Buttons ---------- */
.btn {
  --_bg: var(--surface); --_fg: var(--text); --_bd: var(--border-strong);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: var(--control-h); padding: 0 var(--sp-4); border: var(--bw) solid var(--_bd); border-radius: var(--r-md);
  background: var(--_bg); color: var(--_fg); font: inherit; font-weight: var(--fw-semibold); white-space: nowrap;
  cursor: pointer; user-select: none; text-decoration: none;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.btn--primary { --_bg: var(--brand-600); --_fg: var(--text-on-brand); --_bd: var(--brand-600); box-shadow: var(--shadow-xs); }
.btn--primary:hover { --_bg: var(--brand-700); --_bd: var(--brand-700); color: #fff; }
.btn--primary:active { --_bg: var(--brand-800); --_bd: var(--brand-800); }
.btn--secondary { box-shadow: var(--shadow-xs); }
.btn--secondary:hover { --_bg: var(--surface-2); --_bd: var(--border-input); color: var(--text); }
.btn--secondary:active { --_bg: var(--surface-3); }
.btn--ghost { --_bg: transparent; --_bd: transparent; --_fg: var(--text-2); }
.btn--ghost:hover { --_bg: var(--surface-3); --_fg: var(--text); }
.btn--ghost:active { --_bg: var(--border); }
.btn--danger { --_bg: var(--danger); --_fg: #fff; --_bd: var(--danger); box-shadow: var(--shadow-xs); }
.btn--danger:hover { --_bg: var(--danger-hover); --_bd: var(--danger-hover); color: #fff; }
.btn--danger:active { --_bg: var(--danger-active); --_bd: var(--danger-active); }
.btn--danger:focus-visible { outline-color: var(--danger); }
.btn--danger-ghost { --_bg: transparent; --_bd: transparent; --_fg: var(--danger); }
.btn--danger-ghost:hover { --_bg: var(--danger-bg); --_fg: var(--danger-hover); }
.btn--sm { height: var(--control-h-sm); padding: 0 var(--sp-3); font-size: var(--fs-sm); gap: 6px; }
.btn--lg { height: var(--control-h-lg); padding: 0 var(--sp-5); font-size: var(--fs-lg); }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn:disabled, .btn[aria-disabled="true"] {
  --_bg: var(--surface-3); --_fg: var(--text-disabled); --_bd: var(--border); box-shadow: none; cursor: not-allowed;
}
.btn--ghost:disabled { --_bg: transparent; --_bd: transparent; }
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading .spinner { position: absolute; inset: 0; margin: auto; color: var(--_fg); }
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Forms ---------- */
.form-section { padding: var(--sp-6) var(--sp-6); border-bottom: var(--bw) solid var(--border); display: grid; grid-template-columns: 200px 1fr; gap: var(--sp-6); }
.form-section:last-of-type { border-bottom: 0; }
.form-section__title { font-size: var(--fs-md); line-height: var(--lh-md); font-weight: var(--fw-semibold); }
.form-section__desc { margin-top: var(--sp-1); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.form-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: var(--sp-5) var(--sp-4); }
.col-6 { grid-column: span 6; } .col-4 { grid-column: span 4; } .col-3 { grid-column: span 3; } .col-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.label { font-size: var(--fs-sm); line-height: var(--lh-sm); font-weight: var(--fw-semibold); color: var(--text-2); }
.req { color: var(--danger); margin-left: 2px; font-weight: var(--fw-semibold); }
.optional { color: var(--text-muted); font-weight: var(--fw-regular); margin-left: 4px; }
.hint { font-size: var(--fs-xs); line-height: var(--lh-xs); color: var(--text-muted); }
.error-msg { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: var(--fw-medium); color: var(--danger); }
.error-msg .icon { width: 14px; height: 14px; }
.input, .select, .textarea {
  width: 100%; height: var(--control-h); padding: 0 var(--sp-3);
  border: var(--bw) solid var(--border-input); border-radius: var(--r-md); background: var(--surface);
  color: var(--text); font: inherit; font-size: var(--fs-md);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.textarea { height: auto; min-height: 88px; padding: 10px var(--sp-3); resize: vertical; line-height: var(--lh-md); }
.input::placeholder, .textarea::placeholder { color: var(--text-muted); opacity: 1; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-muted); }
.input:focus, .select:focus, .textarea:focus,
.input.is-focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus-ring); }
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-3); border-color: var(--border); color: var(--text-disabled); cursor: not-allowed;
}
.input[readonly], .textarea[readonly] { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.field.has-error .input, .field.has-error .select, .field.has-error .textarea,
.input[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(192, 35, 26, 0.12); }
.field.has-error .label { color: var(--danger); }
.select {
  appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%235d6f80' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 16px;
}
.input-group { position: relative; display: flex; align-items: center; }
.input-group > .icon { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.input-group > .input { padding-left: 36px; }
.input-group > .kbd ~ .input, .input-group > .input:has(~ .kbd) { padding-right: 40px; }
.input-group > .kbd { position: absolute; right: 8px; }
.kbd { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; border: var(--bw) solid var(--border); border-bottom-width: 2px; border-radius: var(--r-sm); background: var(--surface-2); color: var(--text-muted); font-size: var(--fs-xs); font-weight: var(--fw-medium); }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.check input { appearance: none; margin: 2px 0 0; flex: none; width: 18px; height: 18px; border: var(--bw) solid var(--border-input); border-radius: 5px; background: var(--surface); display: grid; place-items: center; cursor: pointer; }
.check input:checked { background: var(--brand-600); border-color: var(--brand-600); }
.check input:checked::after { content: ""; width: 10px; height: 6px; border: 2px solid #fff; border-top: 0; border-right: 0; transform: translateY(-1px) rotate(-45deg); }
.check input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.check__label { font-weight: var(--fw-medium); color: var(--text); }
.check__desc { display: block; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); font-weight: var(--fw-regular); margin-top: 2px; }
.form-footer {
  position: sticky; bottom: 0; z-index: var(--z-sticky);
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-4) var(--sp-6); background: var(--surface-2); border-top: var(--bw) solid var(--border);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.form-footer__meta { font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.form-footer__actions { display: flex; gap: var(--sp-3); }

/* ---------- Filter chips ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-5); border-bottom: var(--bw) solid var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip {
  display: inline-flex; align-items: center; gap: var(--sp-2); height: var(--control-h-sm); padding: 0 var(--sp-3);
  border: var(--bw) solid var(--border-strong); border-radius: var(--r-full); background: var(--surface);
  color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); cursor: pointer;
}
.chip:hover { background: var(--surface-2); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--navy-900); border-color: var(--navy-900); color: #fff; }
.chip__count { font-variant-numeric: tabular-nums; color: var(--text-muted); font-weight: var(--fw-medium); }
.chip[aria-pressed="true"] .chip__count { color: #b8c7d6; }
.chip .dot { margin-right: -2px; }

/* ---------- Table ---------- */
.table-wrap { overflow: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-md); line-height: var(--lh-md); }
.table th {
  position: sticky; top: 0; z-index: 1; height: 40px; padding: 0 var(--sp-4);
  background: var(--surface-2); border-bottom: var(--bw) solid var(--border-strong);
  text-align: left; white-space: nowrap; font-size: var(--fs-xs); line-height: var(--lh-xs);
  font-weight: var(--fw-semibold); color: var(--text-2); letter-spacing: 0.04em; text-transform: uppercase;
}
.table td { height: var(--row-h); padding: 0 var(--sp-4); border-bottom: var(--bw) solid var(--border); vertical-align: middle; color: var(--text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur-fast) var(--ease); }
.table tbody tr:hover, .table tbody tr.is-hover { background: #f0f5f9; }
.table tbody tr.is-selected { background: var(--brand-50); }
.table tbody tr.is-selected td:first-child { box-shadow: inset 3px 0 0 var(--brand-600); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .id { font-variant-numeric: tabular-nums; color: var(--text-2); white-space: nowrap; } /* IDs, codes: left-aligned */
.table .col-check { width: 44px; padding-right: 0; }
.table .col-actions { width: 56px; text-align: right; padding-right: var(--sp-3); }
.table .cell-primary { font-weight: var(--fw-semibold); color: var(--text); }
.table .cell-primary a { color: inherit; }
.table .cell-sub { display: block; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); font-weight: var(--fw-regular); }
.truncate { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.th-sort { display: inline-flex; align-items: center; gap: 4px; color: inherit; background: none; border: 0; padding: 0; font: inherit; letter-spacing: inherit; text-transform: inherit; cursor: pointer; }
.th-sort .icon { width: 14px; height: 14px; color: var(--text-disabled); }
.th-sort:hover { color: var(--text); }
.th-sort:hover .icon { color: var(--text-muted); }
th[aria-sort="ascending"] .th-sort, th[aria-sort="descending"] .th-sort { color: var(--text); }
th[aria-sort] .th-sort .icon { color: var(--brand-600); }
.row-actions { display: inline-flex; gap: var(--sp-1); opacity: 0; transition: opacity var(--dur-fast); }
tr:hover .row-actions, tr.is-hover .row-actions, tr:focus-within .row-actions, .row-actions.is-open { opacity: 1; }
.table-footer { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); padding: var(--sp-3) var(--sp-5); border-top: var(--bw) solid var(--border); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.pagination { display: flex; align-items: center; gap: var(--sp-1); }
.page-btn { min-width: 32px; height: 32px; padding: 0 var(--sp-2); display: inline-grid; place-items: center; border-radius: var(--r-md); border: var(--bw) solid transparent; background: none; color: var(--text-2); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; cursor: pointer; }
.page-btn:hover { background: var(--surface-3); color: var(--text); }
.page-btn[aria-current="page"] { background: var(--surface); border-color: var(--border-strong); color: var(--text); font-weight: var(--fw-semibold); box-shadow: var(--shadow-xs); }
.page-btn:disabled { color: var(--text-disabled); cursor: not-allowed; background: none; }
.page-gap { color: var(--text-muted); padding: 0 4px; }

/* ---------- Dropdown menu ---------- */
.menu {
  position: absolute; z-index: var(--z-dropdown); min-width: 196px; padding: var(--sp-1);
  background: var(--surface); border: var(--bw) solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-md);
  text-align: left;
}
.menu__item { display: flex; align-items: center; gap: 10px; width: 100%; height: 36px; padding: 0 var(--sp-3); border: 0; border-radius: var(--r-sm); background: none; color: var(--text); font: inherit; font-weight: var(--fw-medium); cursor: pointer; }
.menu__item .icon { color: var(--text-muted); }
.menu__item:hover, .menu__item.is-active { background: var(--surface-3); }
.menu__item--danger, .menu__item--danger .icon { color: var(--danger); }
.menu__item--danger:hover { background: var(--danger-bg); }
.menu__sep { height: 1px; margin: var(--sp-1) 0; background: var(--border); }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 var(--sp-2);
  border-radius: var(--r-full); border: var(--bw) solid transparent; white-space: nowrap;
  font-size: var(--fs-xs); line-height: var(--lh-xs); font-weight: var(--fw-semibold);
  background: var(--surface-3); color: var(--text-2);
}
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--neutral-dot); flex: none; }
.badge--active   { background: var(--success-bg); color: var(--success); border-color: var(--success-border); }
.badge--active .dot { background: var(--success-dot); }
.badge--pending  { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-border); }
.badge--pending .dot { background: var(--warning-dot); }
.badge--inactive { background: var(--surface-3); color: var(--text-2); border-color: var(--border); }
.badge--error    { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-border); }
.badge--error .dot { background: var(--danger-dot); }
.badge--tag      { background: var(--surface); color: var(--text-2); border-color: var(--border-strong); border-radius: var(--r-sm); font-weight: var(--fw-medium); }
.badge--count    { height: 20px; min-width: 20px; justify-content: center; padding: 0 6px; background: var(--surface-3); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* ---------- Alerts & toasts ---------- */
.alert { display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4); border: var(--bw) solid var(--info-border); border-radius: var(--r-md); background: var(--info-bg); color: var(--text); font-size: var(--fs-sm); line-height: var(--lh-sm); }
.alert > .icon { margin-top: 1px; color: var(--info); }
.alert__title { font-weight: var(--fw-semibold); }
.alert--success { background: var(--success-bg); border-color: var(--success-border); } .alert--success > .icon { color: var(--success); }
.alert--warning { background: var(--warning-bg); border-color: var(--warning-border); } .alert--warning > .icon { color: var(--warning); }
.alert--danger  { background: var(--danger-bg);  border-color: var(--danger-border); }  .alert--danger > .icon  { color: var(--danger); }
.toast-region { position: fixed; right: var(--sp-6); bottom: var(--sp-6); z-index: var(--z-toast); display: grid; gap: var(--sp-2); }
.toast {
  display: flex; align-items: center; gap: var(--sp-3); min-width: 300px; max-width: 420px; padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  background: var(--navy-900); color: #fff; border-radius: var(--r-lg); box-shadow: var(--shadow-md); font-weight: var(--fw-medium);
}
.toast > .icon { color: #5fd49a; }
.toast--error > .icon { color: #ff8a80; }
.toast .btn--ghost { --_fg: #c9d6e3; height: 28px; padding: 0 8px; margin-left: auto; }
.toast .btn--ghost:hover { --_bg: rgba(255,255,255,0.1); --_fg: #fff; }

/* ---------- Empty / loading ---------- */
.empty { display: grid; justify-items: center; gap: var(--sp-2); padding: var(--sp-16) var(--sp-6); text-align: center; }
.empty__icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: var(--r-lg); background: var(--surface-3); color: var(--text-muted); margin-bottom: var(--sp-2); }
.empty__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); }
.empty__text { max-width: 360px; color: var(--text-muted); margin-bottom: var(--sp-3); }
.skeleton { display: block; height: 12px; border-radius: var(--r-sm); background: linear-gradient(90deg, #e4e9ee 0%, #f1f4f7 50%, #e4e9ee 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton, .spinner { animation-duration: 2.4s; } * { transition: none !important; } }

/* ---------- Dialog ---------- */
.overlay { position: fixed; inset: 0; z-index: var(--z-overlay); background: rgba(12, 35, 64, 0.56); display: grid; place-items: center; padding: var(--sp-6); }
.dialog {
  position: relative; z-index: var(--z-dialog); width: min(100%, 520px); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
}
.dialog__body { display: grid; grid-template-columns: 40px 1fr; gap: var(--sp-4); padding: var(--sp-6) var(--sp-6) var(--sp-5); }
.dialog__icon { width: 40px; height: 40px; border-radius: var(--r-full); display: grid; place-items: center; background: var(--danger-bg); color: var(--danger); }
.dialog__title { font-size: var(--fs-lg); line-height: var(--lh-lg); font-weight: var(--fw-semibold); }
.dialog__text { margin-top: var(--sp-2); color: var(--text-2); }
.dialog__list { margin: var(--sp-3) 0 0; padding: 0 0 0 18px; color: var(--text-2); }
.dialog__list li + li { margin-top: 2px; }
.dialog__confirm { margin-top: var(--sp-4); }
.dialog__footer { display: flex; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-6); background: var(--surface-2); border-top: var(--bw) solid var(--border); border-radius: 0 0 var(--r-xl) var(--r-xl); }
.dialog__close { position: absolute; top: 12px; right: 12px; }

/* ---------- Layout helpers ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-6); align-items: start; }
.stack { display: grid; gap: var(--sp-6); }
.list { list-style: none; margin: 0; padding: 0; }
.list__item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: var(--sp-1) var(--sp-3); padding: var(--sp-3) var(--sp-5); border-bottom: var(--bw) solid var(--border); }
.list__item:last-child { border-bottom: 0; }
.list__title { font-weight: var(--fw-semibold); }
.list__meta { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-muted); }
.status-line { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-sm); line-height: var(--lh-sm); color: var(--text-2); font-weight: var(--fw-medium); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: var(--sp-2) var(--sp-4); margin: 0; font-size: var(--fs-sm); line-height: var(--lh-sm); }
.dl dt { color: var(--text-muted); } .dl dd { margin: 0; text-align: right; color: var(--text); font-weight: var(--fw-medium); font-variant-numeric: tabular-nums; }

/* ---------- Responsive ≤ 900px ---------- */
@media (max-width: 900px) {
  .topbar__inner { height: 60px; padding: 0 var(--sp-4); gap: var(--sp-3); }
  .brand__logo { height: 40px; }
  .brand__sub, .usermenu__name { display: none; }
  .btn.nav-toggle { display: inline-flex; }
  .nav {
    position: fixed; inset: 60px 0 auto 0; z-index: var(--z-dropdown); display: none;
    flex-direction: column; align-items: stretch; height: auto; padding: var(--sp-2) var(--sp-3) var(--sp-3);
    background: var(--surface); border-left: 0; border-bottom: var(--bw) solid var(--border); box-shadow: var(--shadow-md);
  }
  .nav.is-open { display: flex; }
  .nav__link { height: 44px; }
  .page { padding: var(--sp-5) var(--sp-4) var(--sp-10); }
  .page-header { flex-direction: column; align-items: stretch; gap: var(--sp-4); }
  .page-actions { flex-wrap: wrap; }
  .page-actions .input-group { flex: 1 1 100%; }
  .split { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; gap: var(--sp-4); padding: var(--sp-5) var(--sp-4); }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid > * { grid-column: 1 / -1; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .chips { flex-wrap: nowrap; overflow-x: auto; }
  .table .hide-md { display: none; }
  .form-footer { padding: var(--sp-3) var(--sp-4); }
  .form-footer__meta { display: none; }
  .form-footer__actions { width: 100%; } .form-footer__actions .btn { flex: 1; }
  .dialog__footer { flex-direction: column-reverse; } .dialog__footer .btn { width: 100%; }
}
