/* ===========================================================================
   NeoTrader Sales Portal — design system (on top of Bootstrap 5)
   Brand: navy ink #131623 + rainbow gradient accent (from the logo).
   =========================================================================== */
:root {
  --nt-ink: #131623;
  --nt-ink-2: #1b1f31;
  --nt-ink-3: #262c42;
  --nt-grad: linear-gradient(115deg, #2fd97a 0%, #1fc8db 22%, #3b82f6 44%, #8b5cf6 64%, #ec4899 82%, #fb923c 100%);

  --nt-primary: #3b82f6;
  --nt-primary-600: #2f6fe0;
  --nt-primary-700: #2861c9;

  --nt-surface: #f4f6fb;
  --nt-card: #ffffff;
  --nt-border: #e7eaf1;
  --nt-border-2: #eef1f6;
  --nt-text: #1b2231;
  --nt-muted: #6a7488;
  --nt-muted-2: #97a0b2;

  --nt-success: #16a34a;
  --nt-success-bg: #e7f6ec;
  --nt-warning: #b45309;
  --nt-warning-bg: #fdf1de;
  --nt-danger: #dc2626;
  --nt-danger-bg: #fdecec;
  --nt-info-bg: #e8f0fe;

  --nt-shadow-sm: 0 1px 2px rgba(19, 22, 35, 0.06), 0 1px 3px rgba(19, 22, 35, 0.05);
  --nt-shadow: 0 6px 24px -12px rgba(19, 22, 35, 0.18);
  --nt-shadow-lg: 0 24px 60px -28px rgba(19, 22, 35, 0.32);

  --nt-radius: 14px;
  --nt-radius-sm: 10px;
  --sidebar-w: 256px;
  --topbar-h: 64px;

  /* Themeable aliases (dark mode overrides these) */
  --nt-heading: var(--nt-ink);
  --nt-topbar-bg: rgba(255, 255, 255, 0.82);
  --nt-thead-bg: #fbfcfe;
  --nt-row-hover: #f7f9fd;
  --nt-code-color: #b5389a;
  --nt-code-bg: #faf2f8;

  --bs-primary-rgb: 59, 130, 246;
  --bs-link-color: var(--nt-primary-600);
  --bs-link-hover-color: var(--nt-primary-700);

  color-scheme: light;
}

/* ===========================================================================
   Dark theme — override the design tokens; component rules follow via tokens,
   plus a few targeted overrides for values that can't be a single token.
   Applied when <html data-theme="dark"> (set by the no-flash loader in <head>).
   =========================================================================== */
:root[data-theme="dark"] {
  color-scheme: dark;

  --nt-ink: #181b25;      /* sidebar panel */
  --nt-ink-2: #242836;
  --nt-ink-3: #2d3242;

  --nt-surface: #13151d;  /* app background (soft dark base) */
  --nt-card: #1c1f2a;     /* cards (elevated) */
  --nt-border: #2d3242;
  --nt-border-2: #242836;
  --nt-text: #e7eaf2;
  --nt-heading: #f5f7fc;
  --nt-muted: #9aa4b8;
  --nt-muted-2: #6c7589;

  --nt-primary: #3b82f6;
  --nt-primary-600: #60a5fa;
  --nt-primary-700: #93c5fd;

  --nt-success: #4ade80;
  --nt-success-bg: rgba(34, 197, 94, 0.15);
  --nt-warning: #fbbf24;
  --nt-warning-bg: rgba(245, 158, 11, 0.15);
  --nt-danger: #f87171;
  --nt-danger-bg: rgba(239, 68, 68, 0.15);
  --nt-info-bg: rgba(59, 130, 246, 0.16);

  --nt-topbar-bg: rgba(19, 21, 29, 0.82);
  --nt-thead-bg: #242836;
  --nt-row-hover: rgba(255, 255, 255, 0.03);
  --nt-code-color: #f4a9db;
  --nt-code-bg: rgba(244, 169, 219, 0.1);

  --nt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
  --nt-shadow: 0 8px 28px -14px rgba(0, 0, 0, 0.7);
  --nt-shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
}

/* No-JS fallback: honour the OS preference when no explicit choice was made. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) {
    color-scheme: dark;
    --nt-ink: #10131f; --nt-ink-2: #171b29; --nt-ink-3: #212637;
    --nt-surface: #0b0d15; --nt-card: #161a28;
    --nt-border: #272c3c; --nt-border-2: #1f2432;
    --nt-text: #e6e9f2; --nt-heading: #f3f5fb; --nt-muted: #9aa3b8; --nt-muted-2: #6b7488;
    --nt-primary-600: #60a5fa; --nt-primary-700: #93c5fd;
    --nt-success: #4ade80; --nt-success-bg: rgba(34, 197, 94, 0.15);
    --nt-warning: #fbbf24; --nt-warning-bg: rgba(245, 158, 11, 0.15);
    --nt-danger: #f87171; --nt-danger-bg: rgba(239, 68, 68, 0.15);
    --nt-info-bg: rgba(59, 130, 246, 0.16);
    --nt-topbar-bg: rgba(11, 13, 21, 0.82);
    --nt-thead-bg: #1b2030; --nt-row-hover: #1c2231;
    --nt-code-color: #f4a9db; --nt-code-bg: rgba(244, 169, 219, 0.1);
    --nt-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
    --nt-shadow: 0 8px 28px -14px rgba(0, 0, 0, 0.7);
    --nt-shadow-lg: 0 24px 60px -28px rgba(0, 0, 0, 0.8);
  }
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--nt-text);
  background: var(--nt-surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Smooth the light/dark switch on the main surfaces (no flash on load: the
   theme attribute is set before first paint, so these only animate on toggle). */
body,
.app-sidebar,
.app-topbar,
.card,
.stat-tile,
.table-card,
.btn-signout,
.topbar-icon-btn {
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.grad {
  background: var(--nt-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ===========================================================================
   App shell
   =========================================================================== */
.app-shell { min-height: 100vh; }

.app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--nt-ink);
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  overflow-y: auto;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 1.15rem 1.25rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.sidebar-brand img { height: 30px; width: auto; }
.sidebar-brand-text {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: #fff;
}

.sidebar-nav { padding: 0.75rem 0.75rem 1rem; flex: 1; }

.sidebar-section {
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.34);
  padding: 0.9rem 0.75rem 0.4rem;
}
.sidebar-section:first-child { padding-top: 0.35rem; }

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.62rem 0.8rem;
  margin: 0.12rem 0;
  border-radius: var(--nt-radius-sm);
  color: rgba(255, 255, 255, 0.74);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.925rem;
  transition: background 0.15s ease, color 0.15s ease;
}
.side-link svg { width: 20px; height: 20px; fill: currentColor; opacity: 0.85; flex: 0 0 20px; }
.side-link:hover { background: rgba(255, 255, 255, 0.07); color: #fff; }
.side-link.active { background: rgba(255, 255, 255, 0.1); color: #fff; }
.side-link.active::before {
  content: "";
  position: absolute;
  left: -0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 22px;
  border-radius: 0 3px 3px 0;
  background: var(--nt-grad);
}
.side-link.active svg { opacity: 1; }

.sidebar-foot {
  padding: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}
.side-user { display: flex; align-items: center; gap: 0.65rem; padding: 0.35rem; }
.side-avatar {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  font-weight: 700; color: #fff; font-size: 0.95rem;
  background: var(--nt-grad);
}
.side-user-meta { display: flex; flex-direction: column; min-width: 0; }
.side-user-name { color: #fff; font-weight: 600; font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-role { font-size: 0.76rem; color: rgba(255, 255, 255, 0.5); }

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(19, 22, 35, 0.45);
  z-index: 1035;
  backdrop-filter: blur(1px);
}

/* Main column */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-topbar {
  position: sticky;
  top: 0;
  z-index: 1020;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0 1.5rem;
  background: var(--nt-topbar-bg);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--nt-border);
}
.topbar-toggle {
  display: none;
  border: none;
  background: transparent;
  padding: 0.35rem;
  border-radius: 8px;
  color: var(--nt-text);
  cursor: pointer;
}
.topbar-toggle svg { width: 24px; height: 24px; fill: currentColor; display: block; }
.topbar-toggle:hover { background: var(--nt-border-2); }
.topbar-brand { display: none; }
.topbar-brand img { height: 26px; }
.topbar-spacer { flex: 1; }

.topbar-user { display: flex; align-items: center; gap: 0.85rem; }
.topbar-user-info { display: flex; flex-direction: column; line-height: 1.2; text-align: right; }
.topbar-user-name { font-weight: 600; font-size: 0.9rem; }
.topbar-user-email { font-size: 0.76rem; color: var(--nt-muted); }

.role-badge {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 0.28rem 0.6rem;
  border-radius: 999px;
  letter-spacing: 0.01em;
  background: var(--nt-info-bg);
  color: var(--nt-primary-700);
  white-space: nowrap;
}
.role-badge--super_admin { background: #f1eafe; color: #7c3aed; }
.role-badge--sales_support { background: #e8f0fe; color: #2563eb; }
.role-badge--finance { background: #e7f6ec; color: #15803d; }
.role-badge--tech_admin { background: #fdf1de; color: #b45309; }

.btn-signout {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.8rem;
  border-radius: 9px;
  border: 1px solid var(--nt-border);
  background: var(--nt-card);
  color: var(--nt-text);
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}
.btn-signout svg { width: 17px; height: 17px; fill: currentColor; }
.btn-signout:hover { border-color: var(--nt-danger); color: var(--nt-danger); box-shadow: var(--nt-shadow-sm); }

/* Theme toggle (and other topbar icon buttons) */
.topbar-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  border-radius: 10px;
  border: 1px solid var(--nt-border);
  background: var(--nt-card);
  color: var(--nt-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.topbar-icon-btn svg { width: 19px; height: 19px; fill: currentColor; display: block; }
.topbar-icon-btn:hover { color: var(--nt-text); border-color: var(--nt-muted-2); }
.auth-theme-toggle { position: fixed; top: 1.1rem; right: 1.1rem; z-index: 5; }
/* Show the correct glyph for the active theme (both are in the button) */
.topbar-icon-btn .icon-moon { display: none; }
.topbar-icon-btn .icon-sun { display: block; }
:root[data-theme="dark"] .topbar-icon-btn .icon-moon { display: block; }
:root[data-theme="dark"] .topbar-icon-btn .icon-sun { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="dark"]) .topbar-icon-btn .icon-moon { display: block; }
  :root:not([data-theme="light"]):not([data-theme="dark"]) .topbar-icon-btn .icon-sun { display: none; }
}

.app-content { padding: 1.75rem 1.75rem 3rem; flex: 1; max-width: 1320px; width: 100%; }
.message-stack { margin-bottom: 1.25rem; }

/* ===========================================================================
   Page header (works with existing .d-flex ... .border-bottom pattern too)
   =========================================================================== */
.app-content h1.h3,
.page-title {
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--nt-heading);
}
.app-content > .d-flex.border-bottom {
  border-bottom: 1px solid var(--nt-border) !important;
  padding-bottom: 1rem !important;
  margin-bottom: 1.5rem !important;
}

/* ===========================================================================
   Cards
   =========================================================================== */
.card {
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius);
  box-shadow: var(--nt-shadow-sm);
  background: var(--nt-card);
}
.card .card-body { padding: 1.25rem 1.35rem; }
.card.text-bg-light { background: var(--nt-card) !important; color: var(--nt-text) !important; }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--nt-border);
  font-weight: 600;
  padding: 1rem 1.35rem;
}

/* ===========================================================================
   Stat tiles (dashboard)
   =========================================================================== */
.stat-tile {
  position: relative;
  background: var(--nt-card);
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius);
  padding: 1.25rem 1.35rem;
  box-shadow: var(--nt-shadow-sm);
  height: 100%;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--nt-shadow); }
.stat-tile-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.75rem; }
.stat-label { font-size: 0.82rem; color: var(--nt-muted); font-weight: 500; }
.stat-icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  color: #fff;
}
.stat-icon svg { width: 21px; height: 21px; fill: currentColor; }
.stat-icon--blue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon--violet { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-icon--green { background: linear-gradient(135deg, #22c55e, #15803d); }
.stat-icon--amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.stat-value { font-size: 1.9rem; font-weight: 800; letter-spacing: -0.02em; color: var(--nt-ink); line-height: 1.1; }

/* ===========================================================================
   Tables
   =========================================================================== */
.card > .table-responsive, .card > .table { margin-bottom: 0; }
.table {
  --bs-table-hover-bg: var(--nt-row-hover);
  --bs-table-color: var(--nt-text);
  color: var(--nt-text);
  margin-bottom: 0;
}
.table thead th {
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  color: var(--nt-muted);
  font-weight: 700;
  border-bottom: 1px solid var(--nt-border);
  padding: 0.85rem 0.9rem;
  background: var(--nt-thead-bg);
  white-space: nowrap;
}
.table tbody td {
  padding: 0.85rem 0.9rem;
  border-bottom: 1px solid var(--nt-border-2);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }

/* Wrap a table in .table-card for a clean framed look */
.table-card {
  background: var(--nt-card);
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius);
  box-shadow: var(--nt-shadow-sm);
  overflow: hidden;
}
.table-card .table-responsive { border-radius: var(--nt-radius); }

/* ===========================================================================
   Buttons
   =========================================================================== */
.btn { border-radius: 10px; font-weight: 600; }
.btn-sm { border-radius: 8px; }
.btn-primary {
  --bs-btn-bg: var(--nt-primary);
  --bs-btn-border-color: var(--nt-primary);
  --bs-btn-hover-bg: var(--nt-primary-600);
  --bs-btn-hover-border-color: var(--nt-primary-600);
  --bs-btn-active-bg: var(--nt-primary-700);
  --bs-btn-active-border-color: var(--nt-primary-700);
  box-shadow: 0 6px 16px -8px rgba(59, 130, 246, 0.7);
}
.btn-outline-primary {
  --bs-btn-color: var(--nt-primary-600);
  --bs-btn-border-color: #b9d0fb;
  --bs-btn-hover-bg: var(--nt-primary);
  --bs-btn-hover-border-color: var(--nt-primary);
  --bs-btn-active-bg: var(--nt-primary-600);
}
.btn-outline-secondary {
  --bs-btn-color: var(--nt-text);
  --bs-btn-border-color: var(--nt-border);
  --bs-btn-hover-bg: var(--nt-surface);
  --bs-btn-hover-border-color: var(--nt-muted-2);
  --bs-btn-hover-color: var(--nt-text);
  --bs-btn-active-bg: var(--nt-border-2);
  --bs-btn-active-color: var(--nt-text);
}

/* ===========================================================================
   Badges (semantic pills)
   =========================================================================== */
.badge { font-weight: 600; padding: 0.4em 0.7em; border-radius: 999px; letter-spacing: 0.01em; }
.badge.bg-success { background: var(--nt-success-bg) !important; color: var(--nt-success) !important; }
.badge.bg-primary { background: var(--nt-info-bg) !important; color: var(--nt-primary-700) !important; }
.badge.bg-secondary { background: #eef1f6 !important; color: var(--nt-muted) !important; }
.badge.bg-warning { background: var(--nt-warning-bg) !important; color: var(--nt-warning) !important; }
.badge.bg-danger { background: var(--nt-danger-bg) !important; color: var(--nt-danger) !important; }

/* ===========================================================================
   Forms
   =========================================================================== */
.form-control, .form-select {
  border-radius: 10px;
  border-color: var(--nt-border);
  padding: 0.55rem 0.8rem;
  color: var(--nt-text);
}
.form-control::placeholder { color: var(--nt-muted-2); }
.form-control:focus, .form-select:focus {
  border-color: var(--nt-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.form-label { font-weight: 600; font-size: 0.85rem; color: var(--nt-text); margin-bottom: 0.35rem; }
.form-text { color: var(--nt-muted); }

/* ===========================================================================
   Alerts
   =========================================================================== */
.alert { border-radius: var(--nt-radius-sm); border: 1px solid transparent; padding: 0.9rem 1.1rem; }
.alert-success { background: var(--nt-success-bg); border-color: #bfe7cb; color: #12692f; }
.alert-warning { background: var(--nt-warning-bg); border-color: #f6dca8; color: #8a4a06; }
.alert-danger, .alert-error { background: var(--nt-danger-bg); border-color: #f6c4c4; color: #b21f1f; }
.alert-info { background: var(--nt-info-bg); border-color: #c6dcfd; color: #1e4fa3; }
.alert-light { background: #fff; border-color: var(--nt-border); color: var(--nt-text); }

/* ===========================================================================
   Empty state helper
   =========================================================================== */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--nt-card);
  border: 1px dashed var(--nt-border);
  border-radius: var(--nt-radius);
  color: var(--nt-muted);
}
.empty-state svg { width: 42px; height: 42px; fill: var(--nt-muted-2); margin-bottom: 0.75rem; }

.text-muted { color: var(--nt-muted) !important; }
code { color: var(--nt-code-color); background: var(--nt-code-bg); padding: 0.1em 0.35em; border-radius: 5px; font-size: 0.86em; }

/* ===========================================================================
   Responsive — collapse the sidebar under lg
   =========================================================================== */
@media (max-width: 991.98px) {
  .app-sidebar { transform: translateX(-100%); transition: transform 0.24s cubic-bezier(0.2, 0.7, 0.2, 1); }
  body.sidebar-open .app-sidebar { transform: translateX(0); box-shadow: var(--nt-shadow-lg); }
  .app-main { margin-left: 0; }
  .topbar-toggle { display: inline-flex; }
  .topbar-brand { display: inline-flex; align-items: center; }
  .app-content { padding: 1.25rem 1.1rem 2.5rem; }
}
@media (min-width: 992px) {
  .sidebar-backdrop { display: none !important; }
}
@media (max-width: 575.98px) {
  .topbar-user-info { display: none; }
  .app-topbar { padding: 0 1rem; }
}

/* ===========================================================================
   Unauthenticated pages (login / access-denied)
   Brand palette pulled from the NeoTrader logo (rainbow mark on navy #131623).
   =========================================================================== */
.auth-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  overflow: hidden;
  /* soft branded "aurora" so the page doesn't feel empty around the card */
  background:
    radial-gradient(58% 50% at 12% 16%, rgba(31, 200, 219, 0.18), transparent 70%),
    radial-gradient(55% 52% at 88% 84%, rgba(139, 92, 246, 0.20), transparent 70%),
    radial-gradient(42% 42% at 80% 10%, rgba(236, 72, 153, 0.14), transparent 70%),
    radial-gradient(46% 46% at 16% 88%, rgba(47, 217, 122, 0.12), transparent 70%),
    linear-gradient(135deg, #eef1f6 0%, #e7ecf5 100%);
}
/* faint dot texture, faded toward the edges */
.auth-shell::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(rgba(19, 22, 35, 0.06) 1px, transparent 1.6px);
  background-size: 26px 26px;
  -webkit-mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, #000 25%, transparent 82%);
          mask-image: radial-gradient(ellipse 75% 75% at 50% 50%, #000 25%, transparent 82%);
  pointer-events: none;
}
.auth-shell > * { position: relative; z-index: 1; }

/* ---- access-denied keeps the simple narrow card ---- */
.login-card {
  width: 100%;
  max-width: 400px;
  border: none;
  border-radius: 18px;
  box-shadow: 0 24px 60px -28px rgba(19, 22, 35, 0.4);
}

/* ---- split-screen login ---- */
.auth-split {
  width: 100%;
  max-width: 1040px;
  min-height: 620px;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: #fff;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 40px 90px -40px rgba(19, 22, 35, 0.55);
  animation: auth-rise 0.6s cubic-bezier(0.2, 0.7, 0.2, 1) both;
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.99); }
  to   { opacity: 1; transform: none; }
}

/* ---- brand (left) panel ---- */
.auth-brand {
  position: relative;
  background: var(--nt-ink);
  color: #fff;
  padding: 3rem 2.75rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  isolation: isolate;
}

/* animated gradient blobs — kept toward the edges, away from the logo */
.auth-brand-blobs span {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.55;
  z-index: -1;
  animation: blob-float 14s ease-in-out infinite;
}
.auth-brand-blobs span:nth-child(1) { width: 260px; height: 260px; top: -70px;  right: -60px; background: #8b5cf6; }
.auth-brand-blobs span:nth-child(2) { width: 240px; height: 240px; bottom: -80px; left: -50px; background: #1fc8db; animation-delay: -4s; }
.auth-brand-blobs span:nth-child(3) { width: 200px; height: 200px; bottom: -40px; right: -30px; background: #ec4899; animation-delay: -8s; }

@keyframes blob-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(14px, -18px) scale(1.08); }
  66%      { transform: translate(-12px, 12px) scale(0.95); }
}

.brand-logo {
  width: 232px;
  max-width: 70%;
  height: auto;
  margin-bottom: 2rem;
}

.brand-title {
  font-size: 2.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  line-height: 1.05;
}
.brand-title .grad {
  color: #3b82f6;
  -webkit-text-fill-color: currentColor;
  background: none;
}

.brand-sub {
  color: rgba(255, 255, 255, 0.72);
  font-size: 1.02rem;
  line-height: 1.55;
  max-width: 34ch;
  margin: 0 0 2rem;
}

.brand-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.brand-points li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.95rem;
}
.brand-points li::before {
  content: "";
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  border-radius: 7px;
  background: var(--nt-grad);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 15px no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M9 16.17 4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E") center / 15px no-repeat;
}

/* ---- form (right) panel ---- */
.auth-form {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 2.75rem;
}
.auth-form-inner { width: 100%; max-width: 360px; }

.auth-welcome {
  font-size: 1.6rem;
  font-weight: 700;
  color: #0f1320;
  margin: 0 0 0.4rem;
}
.auth-welcome-sub {
  color: #5b6577;
  font-size: 0.95rem;
  margin: 0 0 1.75rem;
  line-height: 1.5;
}

/* Microsoft button */
.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid #d7dce5;
  border-radius: 12px;
  background: #fff;
  color: #1b1f2b;
  font-weight: 600;
  font-size: 0.98rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.ms-btn:hover {
  transform: translateY(-2px);
  border-color: #b9c2d0;
  box-shadow: 0 12px 24px -12px rgba(19, 22, 35, 0.35);
  color: #1b1f2b;
}
.ms-btn:active { transform: translateY(0); }
.ms-btn:disabled,
.ms-btn.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
.ms-btn svg { flex: 0 0 auto; }

/* developer sign-in section */
.dev-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.75rem 0 1.1rem;
  color: #98a2b3;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.dev-divider::before,
.dev-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: #e6e9f0;
}

.dev-grid { display: flex; flex-direction: column; gap: 0.55rem; }
.dev-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.8rem;
  border: 1px solid #e6e9f0;
  border-radius: 10px;
  background: #fbfcfe;
  text-decoration: none;
  color: #2b3445;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.dev-chip:hover {
  transform: translateX(2px);
  border-color: #cfd6e2;
  box-shadow: 0 8px 18px -12px rgba(19, 22, 35, 0.3);
  color: #2b3445;
}
.dev-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.dev-dot--super_admin { background: #8b5cf6; }
.dev-dot--sales_support { background: #3b82f6; }
.dev-dot--finance { background: #2fd97a; }
.dev-dot--tech_admin { background: #f59e0b; }
.dev-dot--customer { background: #94a3b8; }
.dev-chip-name { font-weight: 600; font-size: 0.9rem; }
.dev-chip-role { margin-left: auto; font-size: 0.72rem; color: #8a93a6; }

/* local password sign-in form */
.auth-error {
  margin: 0 0 1.1rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid #f4c7c7;
  border-left: 3px solid #dc2626;
  border-radius: 10px;
  background: #fef4f4;
  color: #a3232c;
  font-size: 0.86rem;
  line-height: 1.45;
}

.pw-form { display: flex; flex-direction: column; gap: 0.85rem; }
.pw-field { display: flex; flex-direction: column; gap: 0.35rem; }
.pw-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #465061;
}
.pw-input {
  width: 100%;
  padding: 0.72rem 0.85rem;
  border: 1px solid #d7dce5;
  border-radius: 10px;
  background: #fff;
  color: #1b1f2b;
  font-size: 0.95rem;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.pw-input::placeholder { color: #aab3c2; }
.pw-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}
/* Solid brand blue, matching .btn-primary — the rainbow --nt-grad is for brand
   moments (the login panel, headings), not for a routine form control. */
.pw-submit {
  width: 100%;
  margin-top: 0.2rem;
  padding: 0.8rem 1rem;
  border: 0;
  border-radius: 12px;
  background: var(--nt-primary);
  color: #fff;
  font-weight: 650;
  font-size: 0.96rem;
  cursor: pointer;
  box-shadow: 0 6px 16px -8px rgba(59, 130, 246, 0.7);
  transition: background-color 0.15s ease;
}
.pw-submit:hover { background: var(--nt-primary-600); }
.pw-submit:active { background: var(--nt-primary-700); }
.pw-submit:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.5);
}
.pw-note {
  margin: 0.85rem 0 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #98a2b3;
}

.auth-foot {
  margin: 1.75rem 0 0;
  text-align: center;
  font-size: 0.76rem;
  color: #98a2b3;
}

/* ---------------------------------------------------------------------------
   Record pages (one user, one role): breadcrumb + a compact header that folds
   identity, quick actions and child tabs into a single card. Replaces the
   section title + pill tabs, which are redundant inside a record and cost far
   more vertical space than they earn.
   --------------------------------------------------------------------------- */
.crumbs {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0 0 0.7rem;
  font-size: 0.82rem;
  color: var(--nt-muted);
}
.crumbs a { color: var(--nt-muted); text-decoration: none; }
.crumbs a:hover { color: var(--nt-primary-600); }
.crumb-sep { color: var(--nt-muted-2); opacity: 0.7; }
.crumb-current { color: var(--nt-text); font-weight: 600; }

.rec {
  margin-bottom: 1rem;
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius);
  background: var(--nt-card);
  box-shadow: var(--nt-shadow-sm);
}
.rec-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0.85rem;
  flex-wrap: wrap;
}
.rec-title {
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.25;
  color: var(--nt-heading);
}
.rec-sub { font-size: 0.78rem; line-height: 1.3; color: var(--nt-muted); }
.rec-pills {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

/* ---------------------------------------------------------------------------
   Child tabs (e.g. a single user's Role & access / Sign-in password).
   Underlined rather than pill-shaped so they read as one level *below* the
   pill `.tabs` nav above them instead of competing with it.
   --------------------------------------------------------------------------- */
.subtabs {
  display: flex;
  align-items: flex-end;
  gap: 0.25rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid var(--nt-border);
  overflow-x: auto;
}
/* Sitting inside .rec: the card already draws the bottom edge. */
.subtabs--inset {
  margin: 0;
  padding: 0 0.5rem;
  border-bottom: 0;
  border-top: 1px solid var(--nt-border);
}
.subtabs--inset .subtab { padding: 0.5rem 0.7rem; margin: 0; border-bottom-width: 2px; }
.subtab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.6rem 0.85rem;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--nt-muted);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.subtab:hover { color: var(--nt-text); border-bottom-color: var(--nt-border); }
.subtab.active { color: var(--nt-primary-600); border-bottom-color: var(--nt-primary); }
.subtab-badge {
  padding: 0.05rem 0.4rem;
  border-radius: 999px;
  background: var(--nt-warning-bg);
  color: var(--nt-warning);
  font-size: 0.68rem;
  font-weight: 700;
}

/* Inline search inside a table header — sits next to the rows it filters. */
.tsearch {
  position: relative;
  display: flex;
  align-items: center;
  /* Shrinkable with no minimum basis, so a narrow header squeezes the input
     instead of wrapping the whole row. */
  flex: 1 1 0;
  min-width: 7rem;
  max-width: 20rem;
}
.tsearch-icon {
  position: absolute;
  left: 0.6rem;
  width: 15px;
  height: 15px;
  fill: var(--nt-muted-2);
  pointer-events: none;
}
.tsearch-input {
  width: 100%;
  padding: 0.4rem 1.9rem 0.4rem 2rem;
  border: 1px solid var(--nt-border);
  border-radius: 999px;
  background: var(--nt-ink-2);
  color: var(--nt-text);
  font-size: 0.82rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.tsearch-input::placeholder { color: var(--nt-muted-2); }
.tsearch-input:focus {
  outline: none;
  border-color: var(--nt-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}
/* Hide the browser's own clear affordance — we provide one that also drops the
   query from the URL rather than only emptying the box. */
.tsearch-input::-webkit-search-cancel-button { display: none; }
.tsearch-clear {
  position: absolute;
  right: 0.5rem;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--nt-ink-3);
  color: var(--nt-muted);
  font-size: 0.9rem;
  line-height: 1;
  text-decoration: none;
}
.tsearch-clear:hover { background: var(--nt-danger-bg); color: var(--nt-danger); }

/* A stat tile that doubles as a filter shortcut. */
.stat-link { display: block; text-decoration: none; cursor: pointer; }
.stat-link:hover { border-color: var(--nt-muted-2); }
.stat-link.is-on {
  border-color: var(--nt-primary);
  box-shadow: 0 0 0 1px var(--nt-primary) inset;
}

/* Whole-row click target for tables that open a detail panel. */
.row-click { cursor: pointer; }
.row-click:focus-visible {
  outline: 2px solid var(--nt-primary);
  outline-offset: -2px;
}

/* Sub-line under a stat tile's number — carries the money figure that belongs to
   that one status, so no tile has to imply a total. */
.stat-foot {
  margin-top: 0.2rem;
  font-size: 0.75rem;
  line-height: 1.35;
  color: var(--nt-muted);
  font-variant-numeric: tabular-nums;
}

/* ---------------------------------------------------------------------------
   Modal close button. It floats over scrolling content, so it needs its own
   surface — a transparent icon on top of a price or a heading is unreadable and
   looks like a rendering fault.
   --------------------------------------------------------------------------- */
.modal-panel > .icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--nt-ink-3);
  border: 1px solid var(--nt-border);
  color: var(--nt-muted);
  box-shadow: var(--nt-shadow-sm);
}
.modal-panel > .icon-btn:hover {
  background: var(--nt-danger-bg);
  border-color: var(--nt-danger);
  color: var(--nt-danger);
}
.modal-panel > .icon-btn svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------------------
   Stepped form sections — groups a long form into "why am I filling this in"
   chunks instead of one undifferentiated column of inputs.
   --------------------------------------------------------------------------- */
.fsec { padding: 1.15rem 1.25rem; border-bottom: 1px solid var(--nt-border); }
.fsec--last { border-bottom: 0; }
.fsec-head { display: flex; align-items: flex-start; gap: 0.7rem; margin-bottom: 0.9rem; }
.fstep {
  flex: 0 0 24px;
  width: 24px;
  height: 24px;
  margin-top: 0.05rem;
  border-radius: 50%;
  background: var(--nt-info-bg);
  color: var(--nt-primary-600);
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fsec-title { margin: 0; font-size: 0.92rem; font-weight: 700; color: var(--nt-heading); }
.fsec-sub { margin: 0.1rem 0 0; font-size: 0.79rem; color: var(--nt-muted); }
.fsec-body { padding-left: 2.2rem; }
.fsec-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.9rem 1.25rem;
  border-top: 1px solid var(--nt-border);
  background: var(--nt-thead-bg);
  border-radius: 0 0 var(--nt-radius) var(--nt-radius);
}
.req { color: var(--nt-danger); font-weight: 700; }

/* small inline text button (Generate / Show) */
.linkbtn {
  padding: 0.1rem 0.3rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--nt-primary-600);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.linkbtn:hover { background: var(--nt-info-bg); }

/* password strength meter + live rule checklist */
.meter {
  height: 4px;
  margin-top: 0.5rem;
  border-radius: 999px;
  background: var(--nt-border);
  overflow: hidden;
}
.meter > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 999px;
  background: var(--nt-danger);
  transition: width 0.2s ease, background-color 0.2s ease;
}
.meter[data-level="2"] > span { background: var(--nt-warning); }
.meter[data-level="3"] > span { background: var(--nt-success); }

.pwrules { list-style: none; margin: 0.55rem 0 0; padding: 0; }
.pwrules li {
  position: relative;
  padding-left: 1.15rem;
  font-size: 0.78rem;
  line-height: 1.7;
  color: var(--nt-muted);
}
.pwrules li::before {
  content: "○";
  position: absolute;
  left: 0;
  color: var(--nt-muted-2);
}
.pwrules li.ok { color: var(--nt-success); }
.pwrules li.ok::before { content: "✓"; color: var(--nt-success); }

/* Applied from portal.js (see the note there) — kept here, not as Tailwind
   utilities, because Tailwind's content globs don't include static/js. */
.is-ok { color: var(--nt-success); }
.is-bad { color: var(--nt-danger); }

/* guidance lists in the side column */
.ticks, .steps { margin: 0; padding: 0; list-style: none; }
.ticks li {
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--nt-text);
}
.ticks li + li { margin-top: 0.55rem; }
.ticks li::before { position: absolute; left: 0; font-weight: 700; }
.tick-yes::before { content: "✓"; color: var(--nt-success); }
.tick-no::before { content: "✕"; color: var(--nt-danger); }
.tick-no { color: var(--nt-muted); }

.steps { counter-reset: s; }
.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 1.5rem;
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--nt-muted);
}
.steps li + li { margin-top: 0.55rem; }
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0.05rem;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid var(--nt-border);
  color: var(--nt-muted-2);
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .fsec-body { padding-left: 0; }
}

/* ---------------------------------------------------------------------------
   Filter chips (quick, counted views over a list).
   --------------------------------------------------------------------------- */
.fchips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin: 0 0 0.9rem;
}
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.34rem 0.75rem;
  border: 1px solid var(--nt-border);
  border-radius: 999px;
  background: var(--nt-card);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--nt-muted);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}
.fchip:hover { color: var(--nt-text); border-color: var(--nt-muted-2); }
.fchip.active {
  background: var(--nt-primary);
  border-color: var(--nt-primary);
  color: #fff;
}
.fchip-n {
  padding: 0 0.38rem;
  border-radius: 999px;
  background: var(--nt-border-2);
  color: var(--nt-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
}
.fchip:hover .fchip-n { color: var(--nt-text); }
/* A chip that means "there's work waiting" carries the warning tint on its count. */
.fchip--warn .fchip-n { background: var(--nt-warning-bg); color: var(--nt-warning); }
.fchip.active .fchip-n,
.fchip--warn.active .fchip-n {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}

/* ---------------------------------------------------------------------------
   Audit timeline (sign-ins, account changes).
   --------------------------------------------------------------------------- */
.tl { list-style: none; margin: 0; padding: 0; }
.tl-item {
  position: relative;
  display: flex;
  gap: 0.7rem;
  padding: 0.55rem 0;
}
.tl-item + .tl-item { border-top: 1px dashed var(--nt-border-2); }
.tl-dot {
  flex: 0 0 8px;
  width: 8px;
  height: 8px;
  margin-top: 0.42rem;
  border-radius: 50%;
  background: var(--nt-muted-2);
}
.tl-dot--microsoft { background: #3b82f6; }
.tl-dot--password { background: #8b5cf6; }
.tl-dot--dev { background: var(--nt-muted-2); }
.tl-dot--change { background: var(--nt-warning); }
.tl-main { font-size: 0.85rem; font-weight: 600; color: var(--nt-text); }
.tl-detail {
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--nt-muted);
  margin-top: 0.1rem;
  overflow-wrap: anywhere;
}
.tl-meta {
  font-size: 0.74rem;
  color: var(--nt-muted-2);
  margin-top: 0.15rem;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================================
   Access editor (Administration -> Users -> Manage access)
   Collapsible module sections + a tri-state control per feature. Built on
   <details>/<summary> and radio inputs so it works without JavaScript: the
   sections still open and the state still posts.
   =========================================================================== */
.acc {
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius-sm);
  overflow: hidden;
}
.acc-item + .acc-item { border-top: 1px solid var(--nt-border); }

.acc-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s ease;
}
.acc-head::-webkit-details-marker { display: none; }
.acc-head:hover { background: var(--nt-row-hover); }
.acc-item[open] > .acc-head { background: var(--nt-thead-bg); }

.acc-chev {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  fill: var(--nt-muted-2);
  transition: transform 0.18s ease;
}
.acc-item[open] > .acc-head .acc-chev { transform: rotate(90deg); }

.acc-title { font-weight: 600; font-size: 0.9rem; color: var(--nt-heading); }
.acc-meta { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }
.acc-count {
  font-size: 0.76rem;
  color: var(--nt-muted);
  font-variant-numeric: tabular-nums;
}

.acc-tag {
  display: inline-block;
  padding: 0.08rem 0.4rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1.5;
}
.acc-tag--ok { background: var(--nt-success-bg); color: var(--nt-success); }
.acc-tag--bad { background: var(--nt-danger-bg); color: var(--nt-danger); }
.acc-tag--warn { background: var(--nt-warning-bg); color: var(--nt-warning); }

.acc-body { padding: 0.2rem 0.85rem 0.5rem; }

/* one feature row */
.feat {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  flex-wrap: wrap;
}
.feat + .feat { border-top: 1px dashed var(--nt-border-2); }
.feat-info { min-width: 0; flex: 1 1 22rem; }
.feat-name {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  flex-wrap: wrap;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--nt-text);
}
.feat-desc {
  margin: 0.15rem 0 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--nt-muted);
  max-width: 52ch;
}

/* tri-state segmented control */
.seg {
  display: inline-flex;
  flex: 0 0 auto;
  border: 1px solid var(--nt-border);
  border-radius: 9px;
  background: var(--nt-thead-bg);
  padding: 2px;
  gap: 2px;
}
.seg-radio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}
.seg-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.6rem;
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--nt-muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease;
}
.seg-btn:hover { color: var(--nt-text); }
.seg-sub { font-size: 0.64rem; font-weight: 500; opacity: 0.75; }
.seg-radio:checked + .seg-btn {
  background: var(--nt-card);
  color: var(--nt-heading);
  box-shadow: var(--nt-shadow-sm);
}
.seg-radio:checked + .seg-btn--ok { color: var(--nt-success); }
.seg-radio:checked + .seg-btn--bad { color: var(--nt-danger); }
/* Keyboard focus has to be visible even though the input itself is hidden. */
.seg-radio:focus-visible + .seg-btn { outline: 2px solid var(--nt-primary); outline-offset: 1px; }

/* sticky save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--nt-border);
  border-radius: var(--nt-radius-sm);
  background: var(--nt-card);
  box-shadow: var(--nt-shadow);
}

@media (max-width: 640px) {
  .feat { align-items: flex-start; }
  .seg { width: 100%; }
  .seg-btn { flex: 1; }
}

/* ---- responsive: stack on small screens, hide heavy brand copy ---- */
@media (max-width: 820px) {
  .auth-split { grid-template-columns: 1fr; max-width: 440px; min-height: 0; }
  .auth-brand { padding: 2.25rem 2rem; text-align: center; align-items: center; }
  .brand-logo { margin: 0 auto 1.25rem; }
  .brand-sub { margin-left: auto; margin-right: auto; }
  .brand-points { display: none; }
  .auth-form { padding: 2.25rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .auth-split { animation: none; }
  .auth-brand-blobs span { animation: none; }
  .stat-tile { transition: none; }
}

/* ===========================================================================
   Dark theme — component overrides for colors that can't reduce to one token.
   =========================================================================== */
/* Alerts */
:root[data-theme="dark"] .alert-success { border-color: rgba(74, 222, 128, 0.35); color: #86efac; }
:root[data-theme="dark"] .alert-warning { border-color: rgba(251, 191, 36, 0.35); color: #fcd34d; }
:root[data-theme="dark"] .alert-danger,
:root[data-theme="dark"] .alert-error { border-color: rgba(248, 113, 113, 0.35); color: #fca5a5; }
:root[data-theme="dark"] .alert-info { border-color: rgba(96, 165, 250, 0.35); color: #93c5fd; }
:root[data-theme="dark"] .alert-light { background: var(--nt-card); border-color: var(--nt-border); color: var(--nt-text); }

/* Role badges + secondary badge -> translucent tints on dark */
:root[data-theme="dark"] .role-badge { background: rgba(148, 163, 184, 0.16); color: #cbd5e1; }
:root[data-theme="dark"] .role-badge--super_admin { background: rgba(139, 92, 246, 0.20); color: #c4b5fd; }
:root[data-theme="dark"] .role-badge--sales_support { background: rgba(59, 130, 246, 0.20); color: #93c5fd; }
:root[data-theme="dark"] .role-badge--finance { background: rgba(34, 197, 94, 0.20); color: #86efac; }
:root[data-theme="dark"] .role-badge--tech_admin { background: rgba(245, 158, 11, 0.20); color: #fcd34d; }
:root[data-theme="dark"] .badge.bg-secondary { background: rgba(148, 163, 184, 0.18) !important; color: #cbd5e1 !important; }

/* Form controls */
:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select {
  background-color: var(--nt-ink-2);
  color: var(--nt-text);
  border-color: var(--nt-border);
}
:root[data-theme="dark"] .form-control::placeholder { color: var(--nt-muted-2); }

/* Auth (login / access-denied) pages */
:root[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(58% 50% at 12% 16%, rgba(31, 200, 219, 0.14), transparent 70%),
    radial-gradient(55% 52% at 88% 84%, rgba(139, 92, 246, 0.18), transparent 70%),
    radial-gradient(42% 42% at 80% 10%, rgba(236, 72, 153, 0.12), transparent 70%),
    radial-gradient(46% 46% at 16% 88%, rgba(47, 217, 122, 0.10), transparent 70%),
    linear-gradient(135deg, #0b0d15 0%, #10131f 100%);
}
:root[data-theme="dark"] .auth-shell::before {
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1.6px);
}
:root[data-theme="dark"] .auth-split,
:root[data-theme="dark"] .login-card { background: var(--nt-card); }
:root[data-theme="dark"] .auth-welcome { color: var(--nt-heading); }
:root[data-theme="dark"] .auth-welcome-sub { color: var(--nt-muted); }
:root[data-theme="dark"] .ms-btn,
:root[data-theme="dark"] .dev-chip { background: var(--nt-ink-2); border-color: var(--nt-border); color: var(--nt-text); }
:root[data-theme="dark"] .ms-btn:hover,
:root[data-theme="dark"] .dev-chip:hover { border-color: var(--nt-muted-2); color: var(--nt-text); }
:root[data-theme="dark"] .dev-chip-name { color: var(--nt-text); }
:root[data-theme="dark"] .dev-divider::before,
:root[data-theme="dark"] .dev-divider::after { background: var(--nt-border); }
:root[data-theme="dark"] .pw-label { color: var(--nt-muted); }
:root[data-theme="dark"] .pw-input {
  background: var(--nt-ink-2);
  border-color: var(--nt-border);
  color: var(--nt-text);
}
:root[data-theme="dark"] .pw-input::placeholder { color: var(--nt-muted-2); }
:root[data-theme="dark"] .auth-error {
  background: rgba(248, 113, 113, 0.10);
  border-color: rgba(248, 113, 113, 0.35);
  color: #fca5a5;
}

/* ---------------------------------------------------------------------------
   List loading state (Customers page): a sliding progress bar above the list
   and a dimmed "Loading…" overlay on it while a page / filter / search loads.
   --------------------------------------------------------------------------- */
.list-progress {
  position: relative;
  height: 2px;
  margin-bottom: 0.5rem;
  overflow: hidden;
  border-radius: 9999px;
}
.list-progress::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  background: #3b82f6;
  border-radius: inherit;
  animation: list-progress 1s ease-in-out infinite;
}
@keyframes list-progress {
  from { left: -40%; }
  to   { left: 100%; }
}
.list-loading { position: relative; }
.list-loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(19, 21, 29, 0.55);
  border-radius: 0.75rem;
}
@media (prefers-reduced-motion: reduce) {
  .list-progress::before { animation: none; left: 0; width: 100%; opacity: 0.6; }
}

/* ---------------------------------------------------------------------------
   Sortable table headers: look like the other headers (not browser links),
   with a subtle up/down icon; the active column gets light text + brand icon.
   --------------------------------------------------------------------------- */
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  margin: -0.25rem -0.375rem;
  padding: 0.25rem 0.375rem;
  border-radius: 0.375rem;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.th-sort:link,
.th-sort:visited { color: inherit; text-decoration: none; }
.th-sort:hover { color: #e7eaf2; background: rgba(255, 255, 255, 0.04); }
.th-sort:focus-visible { outline: 2px solid #3b82f6; outline-offset: 1px; }
.th-sort.is-active { color: #f5f7fc; }
.th-sort-icon {
  width: 0.8rem;
  height: 0.8rem;
  flex-shrink: 0;
  fill: currentColor;
  opacity: 0.35;
  transition: opacity 0.15s ease;
}
.th-sort:hover .th-sort-icon { opacity: 0.7; }
.th-sort.is-active .th-sort-icon { opacity: 1; color: #3b82f6; }

/* ---------------------------------------------------------------------------
   Account forms (Add password account): leading icon inside a .field input,
   selectable role cards, and password rules as inline chips.
   --------------------------------------------------------------------------- */
.input-icon { position: relative; }
.input-icon > svg {
  position: absolute; left: 0.85rem; top: 50%; transform: translateY(-50%);
  width: 1rem; height: 1rem; fill: currentColor; color: #6c7589; pointer-events: none;
}
.input-icon .field { padding-left: 2.5rem; }

.role-card {
  display: flex; gap: 0.75rem; align-items: flex-start; cursor: pointer;
  padding: 0.85rem 0.95rem; border-radius: 0.75rem;
  border: 1px solid #2d3242; background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}
.role-card:hover { border-color: #3b4458; background: rgba(255, 255, 255, 0.04); }
.role-card input { margin-top: 0.2rem; accent-color: #3b82f6; flex-shrink: 0; }
.role-card:has(input:checked) { border-color: #3b82f6; background: rgba(59, 130, 246, 0.08); }
.role-card:has(input:focus-visible) { outline: 2px solid #3b82f6; outline-offset: 2px; }

.pwrules.pwrules--chips { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pwrules.pwrules--chips li {
  padding: 0.2rem 0.6rem; border-radius: 9999px;
  border: 1px solid #2d3242; background: rgba(255, 255, 255, 0.02); font-size: 0.75rem;
}
.pwrules.pwrules--chips li.ok { border-color: rgba(74, 222, 128, 0.35); background: rgba(74, 222, 128, 0.08); }
.pwrules.pwrules--chips li { padding-left: 1.45rem; line-height: 1.5; }
.pwrules.pwrules--chips li::before { left: 0.55rem; }
