/* ================================================================
   Beacon Trusteeship CMDB — Design System
   Brand Navy  #0A0D30   Brand Gold  #A09261
   ================================================================ */

:root {
  /* Design system — semantic tokens (Modern Soft Skeuomorphism) */
  --color-bg:        #EEF2F7;
  --color-card:      #FFFFFF;
  --color-primary:   #18244B;
  --color-primary-2: #223258;
  --color-primary-3: #2C3D6C;
  --color-accent:    #D4AF37;
  --color-accent-2:  #E0C05F;
  --color-accent-3:  #8A6D1A;
  --color-border:    #D8DEE8;
  --color-text:      #273142;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-7: 28px;
  --space-8: 32px;
  --space-10: 40px;

  /* Radius */
  --radius-sm:   10px;
  --radius:      14px;
  --radius-lg:   16px;
  --radius-pill: 999px;

  /* Elevation / shadow hierarchy */
  --shadow-xs:           0 1px 2px rgba(18,25,38,.06);
  --shadow-card:         0 8px 24px rgba(18,25,38,.08);
  --shadow-card-hover:   0 12px 32px rgba(18,25,38,.12);
  --shadow-button:       0 4px 12px rgba(18,25,38,.18);
  --shadow-button-hover: 0 6px 16px rgba(18,25,38,.22);
  --shadow-modal:        0 20px 48px rgba(18,25,38,.16);
  --shadow-input-inset:  inset 0 2px 4px rgba(18,25,38,.08), inset 0 -1px 0 rgba(255,255,255,.6);

  /* Typography */
  --font-sans: -apple-system, 'SF Pro Text', 'Segoe UI Variable', 'Segoe UI', system-ui, sans-serif;
  --text-xs:   .72rem;
  --text-sm:   .82rem;
  --text-base: .9rem;
  --text-md:   1rem;
  --text-lg:   1.125rem;
  --text-xl:   1.35rem;
  --text-2xl:  1.65rem;

  /* Transitions */
  --transition-fast: 150ms ease-out;
  --transition-base: 200ms ease-out;
  --transition-slow: 250ms ease-out;

  /* Brand (aliases onto the semantic tokens above) */
  --navy:   var(--color-primary);
  --navy-2: var(--color-primary-2);
  --navy-3: var(--color-primary-3);
  --gold:   var(--color-accent);
  --gold-2: var(--color-accent-2);
  --gold-3: var(--color-accent-3);

  /* Neutrals */
  --gray-50:  #F5F7FB;
  --gray-100: var(--color-bg);
  --gray-200: var(--color-border);
  --gray-300: #C3CBDA;
  --gray-500: #6B7488;
  --gray-700: #414A5E;
  --gray-900: var(--color-text);

  /* Semantic colours */
  --success:      #16a34a;
  --success-bg:   #f0fdf4;
  --success-bd:   #bbf7d0;
  --success-text: #15803d;
  --warning:      #d97706;
  --warning-bg:   #fffbeb;
  --warning-bd:   #fde68a;
  --warning-text: #92400e;
  --danger:       #dc2626;
  --danger-bg:    #fef2f2;
  --danger-bd:    #fecaca;
  --danger-text:  #991b1b;
  --info:         #0284c7;
  --info-bg:      #f0f9ff;
  --info-bd:      #bae6fd;
  --info-text:    #075985;
  --teal:         #0d9488;
  --teal-bg:      #f0fdfa;
  --teal-bd:      #99f6e4;

  /* Layout */
  --sidebar-w: 240px;
  --topbar-h:  56px;

  /* Elevation (legacy aliases) */
  --shadow-sm: var(--shadow-xs);
  --shadow-md: var(--shadow-card);
}

/* ── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Visible keyboard-focus indicator — mouse/touch clicks stay clean */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Skip-to-content link — hidden until keyboard-focused */
.skip-link {
  position: absolute;
  top: -40px;
  left: 8px;
  z-index: 2000;
  background: var(--color-primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: top var(--transition-fast);
}
.skip-link:focus {
  top: 8px;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  background: linear-gradient(180deg, #EEF2F7 0%, #E7ECF4 100%) fixed;
  color: var(--gray-900);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-3); text-decoration: underline; }

h1, h2, h3, h4, h5, h6 {
  color: var(--gray-900);
  font-weight: 700;
  line-height: 1.25;
  margin-top: 0;
}

/* ── Layout shell ──────────────────────────────────────────── */
#wrapper {
  display: flex;
  min-height: 100vh;
}

#page-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--gray-50);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Logo strip */
.sidebar-logo-area {
  background: #fff;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--color-border);
  text-align: center;
  flex-shrink: 0;
  text-decoration: none;
  display: block;
}

.sidebar-logo-area img {
  width: 148px;
  height: auto;
  display: block;
  margin: 0 auto;
}

/* Nav container */
.sidebar-nav {
  flex: 1;
  padding: 10px 0 8px;
  background: linear-gradient(180deg, rgba(24,36,75,.02) 0%, rgba(24,36,75,0) 12%, rgba(24,36,75,0) 88%, rgba(24,36,75,.02) 100%);
}

/* Grouped nav section — raised tray */
.sidebar-group {
  background: rgba(24,36,75,.025);
  border-radius: var(--radius-sm);
  margin: 2px 8px 10px;
  padding: 2px 0 4px;
}

/* Section heading (now a button — reset browser chrome) */
.sidebar-section {
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--gold-3);
  padding: 14px 14px 4px;
  opacity: .85;
  display: flex;
  align-items: center;
  gap: 5px;
}

.sidebar-group .sidebar-section {
  padding: 10px 10px 4px;
}

.sidebar-section-label {
  flex: 1;
  text-align: left;
}

.sidebar-section-icon {
  color: var(--gray-500);
  flex-shrink: 0;
}

.sidebar-chevron {
  margin-left: auto;
  color: var(--gray-500);
  opacity: .6;
  flex-shrink: 0;
  transition: transform var(--transition-base);
}

.sidebar-group.collapsed .sidebar-chevron {
  transform: rotate(-90deg);
}

/* Collapsible link panel */
.sidebar-group-links {
  max-height: 320px;
  overflow: hidden;
  opacity: 1;
  transition: max-height var(--transition-base), opacity var(--transition-base);
}

.sidebar-group.collapsed .sidebar-group-links {
  max-height: 0;
  opacity: 0;
}

/* Nav links */
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 1px 8px;
  padding: 6px 10px 6px 13px;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  border-left: 3px solid transparent;
  transition: background var(--transition-base), color var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-link:hover {
  background: rgba(24,36,75,.05);
  color: var(--color-primary);
  text-decoration: none;
  transform: translateX(2px);
}

.sidebar-link.active {
  background: var(--color-card);
  box-shadow: var(--shadow-xs);
  color: var(--color-primary);
  border-left-color: var(--gold);
  font-weight: 600;
}

/* User footer */
.sidebar-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--color-border);
  padding: 10px 14px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 9px;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--navy);
  font-size: var(--text-xs);
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 155px;
}

.sidebar-logout {
  font-size: var(--text-xs);
  color: var(--gold-3);
  text-decoration: none;
  opacity: .85;
}
.sidebar-logout:hover { opacity: 1; text-decoration: underline; color: var(--gold-3); }

/* Scrollbar */
#sidebar::-webkit-scrollbar { width: 3px; }
#sidebar::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 2px; }

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  box-shadow: var(--shadow-xs);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.topbar-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.topbar-flash {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-sm);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-weight: 500;
}

.topbar-flash.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid var(--success-bd);
}

.topbar-flash.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger-bd);
}

/* ── Page body ─────────────────────────────────────────────── */
.page-body {
  padding: var(--space-8);
  flex: 1;
}

/* ── Page header (title row + actions) ─────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  gap: 12px;
}

.page-header-left h4,
.page-header-left h3 {
  margin: 0;
  font-size: var(--text-xl);
  font-weight: 800;
  letter-spacing: -.01em;
  color: var(--navy);
}

.page-header-left .page-subtitle {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--color-card);
  border: 1px solid rgba(216,222,232,.35);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,.9);
  transition: box-shadow var(--transition-base);
}

.card:hover {
  box-shadow: var(--shadow-card-hover), inset 0 1px 0 rgba(255,255,255,.9);
}

/* Form-card width buckets — replaces one-off inline max-width per form */
.form-card       { max-width: 600px; }
.form-card-md     { max-width: 700px; }
.form-card-narrow { max-width: 540px; }
.form-card-wide   { max-width: 800px; }

.card-header {
  position: relative;
  background: rgba(24,36,75,.03);
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0 !important;
  padding: 16px var(--space-7) 16px calc(var(--space-7) + 14px);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -.005em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-header::before {
  content: '';
  position: absolute;
  left: var(--space-7);
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

/* Real per-section icon instead of the generic accent dot */
.card-header.has-icon {
  padding-left: var(--space-7);
}
.card-header.has-icon::before {
  display: none;
}
.card-header-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.card-header-title svg {
  color: var(--color-accent-3);
  flex-shrink: 0;
}

/* Sub-group micro-label inside a card body */
.form-subgroup-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
  margin: var(--space-5) 0 var(--space-2);
}
.form-subgroup-label:first-child {
  margin-top: 0;
}

.card-header a,
.card-header .card-header-link {
  color: var(--color-accent-3);
  font-size: var(--text-xs);
  text-decoration: none;
  opacity: .85;
}
.card-header a:hover { opacity: 1; text-decoration: underline; }

.card-header-plain {
  position: relative;
  background: rgba(24,36,75,.03);
  color: var(--color-primary);
  border-bottom: 1px solid var(--color-border);
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0 !important;
  padding: 16px var(--space-7) 16px calc(var(--space-7) + 14px);
  font-size: var(--text-md);
  font-weight: 700;
  letter-spacing: -.005em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header-plain::before {
  content: '';
  position: absolute;
  left: var(--space-7);
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-accent);
}

.card-body { padding: var(--space-7); }
.card-body.p-0 { padding: 0; overflow-x: auto; }
.card-body.py-2 { padding-top: 10px; padding-bottom: 10px; }

/* ── KPI / Stat cards ──────────────────────────────────────── */
.kpi-card {
  background: var(--color-card);
  border: 1px solid rgba(216,222,232,.35);
  border-radius: var(--radius-lg);
  border-left: 4px solid var(--gold);
  padding: 22px 24px 18px;
  box-shadow: var(--shadow-card), inset 0 1px 0 rgba(255,255,255,.9);
  transition: box-shadow var(--transition-base);
  display: flex;
  flex-direction: column;
  height: 100%;
  position: relative;
}

.kpi-card:hover {
  box-shadow: var(--shadow-card-hover), inset 0 1px 0 rgba(255,255,255,.9);
}

.kpi-card.kpi-danger  { border-left-color: var(--danger); }
.kpi-card.kpi-warning { border-left-color: var(--warning); }
.kpi-card.kpi-success { border-left-color: var(--success); }
.kpi-card.kpi-info    { border-left-color: var(--info); }

.kpi-icon {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.4rem;
  opacity: .18;
}

.kpi-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.kpi-value {
  font-size: var(--text-2xl);
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: 10px;
}

.kpi-card.kpi-danger  .kpi-value { color: var(--danger); }
.kpi-card.kpi-warning .kpi-value { color: var(--warning); }
.kpi-card.kpi-success .kpi-value { color: var(--success); }

.kpi-link {
  font-size: var(--text-xs);
  color: var(--gray-500);
  text-decoration: none;
  margin-top: auto;
}
.kpi-link:hover { color: var(--navy); text-decoration: underline; }

/* ── Filter bar ────────────────────────────────────────────── */
.filter-bar {
  background: var(--color-card);
  border: 1px solid rgba(216,222,232,.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  padding: 16px 20px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 16px;
}

.filter-bar .filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.filter-bar label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gray-500);
}

.filter-bar .form-select,
.filter-bar .form-control {
  font-size: var(--text-sm);
  min-width: 150px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
}

.filter-bar .filter-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding-bottom: 1px;
  padding-left: 16px;
  margin-left: 4px;
  border-left: 1px solid var(--color-border);
}

.filter-bar .filter-actions .btn-primary {
  padding: 9px 22px;
  font-weight: 700;
}

/* ── Tables ────────────────────────────────────────────────── */
.table {
  font-size: var(--text-sm);
  color: var(--gray-900);
  margin-bottom: 0;
  border-collapse: separate;
  border-spacing: 0 4px;
}

.table thead th {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--navy);
  background: var(--gray-50);
  border-bottom: 1px solid var(--color-border) !important;
  padding: 9px 12px;
  white-space: nowrap;
}

.table tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  background: var(--color-card);
  border-top: 1px solid transparent;
  border-bottom: 1px solid transparent;
  transition: background var(--transition-base), box-shadow var(--transition-base);
}

.table tbody td:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.table tbody td:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.table-hover > tbody > tr:hover > td {
  background: var(--gray-50);
  box-shadow: var(--shadow-xs);
}

.table-sm thead th { padding: 7px 10px; }
.table-sm tbody td { padding: 6px 10px; }

/* Monospace cell */
.cell-mono {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: var(--text-xs);
  color: var(--gray-700);
}

/* Table actions column */
.table-actions {
  text-align: right;
  white-space: nowrap;
}

/* ── Badges ────────────────────────────────────────────────── */

/* Base badge reset */
.badge {
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: .03em;
  box-shadow: var(--shadow-xs);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge:not(.badge-type)::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Semantic status glyph — overrides the plain dot for the four meaningful
   color families; neutral badges keep the dot (no strong "neutral" shape). */
.badge-active::before, .badge-mfa-on::before, .badge-enc-yes::before,
.badge-insert::before, .badge.bg-success::before,
.badge-retired::before, .badge-delete::before, .badge-fail::before,
.badge.bg-danger::before,
.badge-rma::before, .badge-export::before, .badge-mfa-off::before,
.badge.bg-warning::before,
.badge-update::before, .badge-role-viewer::before, .badge.bg-info::before {
  width: 10px;
  height: 10px;
  border-radius: 0;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}
.badge-active::before, .badge-mfa-on::before, .badge-enc-yes::before,
.badge-insert::before, .badge.bg-success::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E");
}
.badge-retired::before, .badge-delete::before, .badge-fail::before,
.badge.bg-danger::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M18 6 6 18'/%3E%3Cpath d='m6 6 12 12'/%3E%3C/svg%3E");
}
.badge-rma::before, .badge-export::before, .badge-mfa-off::before,
.badge.bg-warning::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpolyline points='12 6 12 12 16 14'/%3E%3C/svg%3E");
}
.badge-update::before, .badge-role-viewer::before, .badge.bg-info::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='M12 16v-4'/%3E%3Cpath d='M12 8h.01'/%3E%3C/svg%3E");
}

/* Status badges */
.badge-active   { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.badge-spare    { background: var(--gray-100);   color: var(--gray-700); border: 1px solid var(--gray-300); }
.badge-rma      { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }
.badge-retired  { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bd); }

/* Action / audit badges */
.badge-insert   { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.badge-update   { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-bd); }
.badge-delete   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bd); }
.badge-login    { background: var(--teal-bg);      color: var(--teal);    border: 1px solid var(--teal-bd); }
.badge-logout   { background: var(--gray-100);   color: var(--gray-700); border: 1px solid var(--gray-300); }
.badge-export   { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }
.badge-fail     { background: var(--danger-bg);  color: var(--danger);  border: 1px solid var(--danger-bd); }

/* Role badges */
.badge-role-admin   { background: rgba(24,36,75,.08); color: var(--navy);    border: 1px solid rgba(24,36,75,.18); }
.badge-role-editor  { background: rgba(212,175,55,.12); color: var(--gold-3); border: 1px solid rgba(212,175,55,.35); }
.badge-role-viewer  { background: var(--info-bg);    color: var(--info);    border: 1px solid var(--info-bd); }
.badge-role-auditor { background: var(--gray-100);   color: var(--gray-700); border: 1px solid var(--gray-300); }

/* MFA badges */
.badge-mfa-on  { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.badge-mfa-off { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning-bd); }

/* Asset type badge */
.badge-type {
  background: rgba(24,36,75,.06);
  color: var(--navy-2);
  border: 1px solid rgba(24,36,75,.12);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* Encrypted badge */
.badge-enc-yes { background: var(--success-bg); color: var(--success); border: 1px solid var(--success-bd); }
.badge-enc-no  { background: var(--gray-100);   color: var(--gray-500); border: 1px solid var(--gray-300); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 6px 14px;
  transition: background var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}

.btn:active {
  transform: translateY(1px);
}

.btn-sm {
  font-size: var(--text-xs);
  padding: 4px 10px;
}

/* Primary tier — raised, gradient, hover lift, pressed state */
.btn-primary {
  background: linear-gradient(180deg, var(--color-primary-2) 0%, var(--color-primary) 100%) !important;
  border-color: var(--navy) !important;
  color: #fff !important;
  box-shadow: var(--shadow-button);
}
.btn-primary:hover, .btn-primary:focus {
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
}
.btn-primary:active {
  box-shadow: var(--shadow-xs);
  transform: translateY(1px);
}

/* Ghost tier — minimal background at rest, soft fill on hover */
.btn-secondary {
  background: transparent !important;
  border-color: transparent !important;
  color: var(--gray-700) !important;
}
.btn-secondary:hover {
  background: var(--gray-100) !important;
  color: var(--gray-900) !important;
}

/* Secondary tier — outlined, subtle shadow */
.btn-outline-secondary {
  background: transparent !important;
  border-color: var(--gray-300) !important;
  color: var(--gray-700) !important;
  box-shadow: var(--shadow-xs);
}
.btn-outline-secondary:hover {
  background: var(--gray-100) !important;
  color: var(--gray-900) !important;
  box-shadow: var(--shadow-button);
}

.btn-outline-primary {
  background: transparent !important;
  border-color: var(--navy) !important;
  color: var(--navy) !important;
  box-shadow: var(--shadow-xs);
}
.btn-outline-primary:hover {
  background: var(--navy) !important;
  color: #fff !important;
  box-shadow: var(--shadow-button);
}

/* Primary tier (destructive) — raised, gradient, hover lift, pressed state */
.btn-danger {
  background: linear-gradient(180deg, #e64c4c 0%, var(--danger) 100%) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
  box-shadow: var(--shadow-button);
}
.btn-danger:hover {
  background: #b91c1c !important;
  border-color: #b91c1c !important;
  box-shadow: var(--shadow-button-hover);
  transform: translateY(-1px);
}
.btn-danger:active {
  box-shadow: var(--shadow-xs);
  transform: translateY(1px);
}

/* Secondary tier (destructive) — outlined, subtle shadow */
.btn-outline-danger {
  background: transparent !important;
  border-color: var(--danger) !important;
  color: var(--danger) !important;
  box-shadow: var(--shadow-xs);
}
.btn-outline-danger:hover {
  background: var(--danger-bg) !important;
  box-shadow: var(--shadow-button);
}

.btn-outline-warning {
  background: transparent !important;
  border-color: var(--warning) !important;
  color: var(--warning) !important;
  box-shadow: var(--shadow-xs);
}
.btn-outline-warning:hover {
  background: var(--warning-bg) !important;
  box-shadow: var(--shadow-button);
}

/* Submit-button loading spinner (prevents double-submit) */
.btn-spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: btn-spin .6s linear infinite;
  vertical-align: -2px;
}
@keyframes btn-spin {
  to { transform: rotate(360deg); }
}
.is-submitting {
  cursor: default;
  opacity: .85;
}

/* ── Action icons (Add / Edit / Delete) — keyed off href/data attributes,
   no view-file markup needed. Verified these patterns are exclusive to
   real create/edit/delete controls in this app before relying on them. ── */
a[href$="/create"]::before,
a[href$="/edit"]::before,
button[data-bs-target="#deleteModal"]::before,
form[action*="/delete"] > .btn-outline-danger::before,
.modal-footer .btn-danger::before {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  background-color: currentColor;
}
a[href$="/create"]::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='M12 5v14'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12h14'/%3E%3Cpath d='M12 5v14'/%3E%3C/svg%3E");
}
a[href$="/edit"]::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z'/%3E%3Cpath d='m15 5 4 4'/%3E%3C/svg%3E");
}
button[data-bs-target="#deleteModal"]::before,
form[action*="/delete"] > .btn-outline-danger::before,
.modal-footer .btn-danger::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6'/%3E%3Cpath d='M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2'/%3E%3Cline x1='10' x2='10' y1='11' y2='17'/%3E%3Cline x1='14' x2='14' y1='11' y2='17'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 6h18'/%3E%3Cpath d='M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6'/%3E%3Cpath d='M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2'/%3E%3Cline x1='10' x2='10' y1='11' y2='17'/%3E%3Cline x1='14' x2='14' y1='11' y2='17'/%3E%3C/svg%3E");
}

/* Filter button — funnel icon */
.filter-bar .filter-actions .btn-primary::before {
  content: '';
  display: inline-block;
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  background-color: currentColor;
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3'/%3E%3C/svg%3E");
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3'/%3E%3C/svg%3E");
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.form-control,
.form-select {
  font-size: var(--text-sm);
  min-height: 44px;
  padding: 11px 16px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  box-shadow: var(--shadow-input-inset);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--gold);
  box-shadow: var(--shadow-input-inset), 0 0 0 3px rgba(212,175,55,.22);
  outline: none;
}

/* Leading icon — only where it earns its keep: email & password fields */
input[type="email"].form-control,
input[type="password"].form-control {
  padding-left: 40px;
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 15px 15px;
}
input[type="email"].form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='20' height='16' x='2' y='4' rx='2'/%3E%3Cpath d='m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7'/%3E%3C/svg%3E");
}
input[type="password"].form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect width='18' height='11' x='3' y='11' rx='2' ry='2'/%3E%3Cpath d='M7 11V7a5 5 0 0 1 10 0v4'/%3E%3C/svg%3E");
}

.form-control-sm,
.form-select-sm {
  font-size: var(--text-xs);
  min-height: 36px;
  padding: 7px 12px;
}

/* Password autofill — keep the recessed look instead of the browser yellow */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--color-bg) inset;
  -webkit-text-fill-color: var(--color-text);
}

/* Clickable table rows (see app.js tr[data-href] delegation) */
tr[data-href] {
  cursor: pointer;
}

/* Date picker icon — match theme instead of default browser gray */
input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: .6;
  cursor: pointer;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

/* Textarea — grow with rows, don't clamp to the 44px single-line height */
textarea.form-control {
  min-height: 96px;
  resize: vertical;
}

/* Native select — custom arrow matching the new palette */
.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%236B7488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' d='M4 6l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 14px 10px;
  padding-right: 40px;
  appearance: none;
  cursor: pointer;
}

.form-text {
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* Required star */
.req { color: var(--danger); }

/* ── Alert banners ─────────────────────────────────────────── */
.alert-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--radius);
  border-left: 5px solid;
  margin-bottom: 20px;
  font-size: var(--text-sm);
}

.alert-banner-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.alert-banner.success {
  background: var(--success-bg);
  border-left-color: var(--success);
  color: var(--success-text);
}

.alert-banner.warning {
  background: var(--warning-bg);
  border-left-color: var(--warning);
  color: var(--warning-text);
}

.alert-banner.danger {
  background: var(--danger-bg);
  border-left-color: var(--danger);
  color: var(--danger-text);
}

.alert-banner.info {
  background: var(--info-bg);
  border-left-color: var(--info);
  color: var(--info-text);
}

/* Bootstrap alert overrides */
.alert { border-radius: var(--radius); font-size: var(--text-sm); }
.alert-info    { background: var(--info-bg);    color: var(--info-text);    border-color: var(--info-bd); }
.alert-success { background: var(--success-bg); color: var(--success-text); border-color: var(--success-bd); }
.alert-warning { background: var(--warning-bg); color: var(--warning-text); border-color: var(--warning-bd); }
.alert-danger  { background: var(--danger-bg);  color: var(--danger-text);  border-color: var(--danger-bd); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-content {
  border-radius: var(--radius-lg);
  border: 1px solid rgba(216,222,232,.6);
  box-shadow: var(--shadow-modal);
}

.modal-header {
  border-bottom: 1px solid rgba(212,175,55,.35);
  padding: 14px 20px;
  background: var(--gray-50);
  border-radius: calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px) 0 0;
}

.modal-title { font-size: var(--text-md); font-weight: 700; color: var(--navy); }

.modal-footer {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 12px 20px;
  border-radius: 0 0 calc(var(--radius-lg) - 1px) calc(var(--radius-lg) - 1px);
}

.modal-body { padding: 20px; }

/* ── Diff viewer (audit log) ───────────────────────────────── */
.diff-block {
  background: #1a1d2e;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 8px;
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: .7rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.diff-before {
  border-left: 3px solid var(--danger);
  color: #fca5a5;
}

.diff-after {
  border-left: 3px solid var(--success);
  color: #86efac;
  margin-top: 4px;
}

/* ── Avatar initials ───────────────────────────────────────── */
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: 800;
  flex-shrink: 0;
}

.avatar-navy  { background: rgba(24,36,75,.1);  color: var(--navy); }
.avatar-gold  { background: rgba(212,175,55,.18); color: var(--gold-3); }
.avatar-teal  { background: var(--teal-bg); color: var(--teal); }
.avatar-gray  { background: var(--gray-100); color: var(--gray-700); }

/* ── Info note ──────────────────────────────────────────────── */
.info-note {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: var(--text-sm);
  color: var(--gray-700);
}

.info-note code {
  background: var(--gray-200);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: var(--text-xs);
  color: var(--gray-900);
}

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  padding: 40px 20px;
  text-align: center;
  color: var(--gray-500);
  font-size: var(--text-sm);
}

/* ── Section divider ───────────────────────────────────────── */
.section-title {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--gold-3);
  font-weight: 700;
  border-bottom: 1px solid rgba(212,175,55,.4);
  padding-bottom: 6px;
  margin-top: var(--space-6);
  margin-bottom: var(--space-4);
}

/* ── Pagination ─────────────────────────────────────────────── */
.page-link {
  color: var(--navy);
  border-color: var(--color-border);
  border-radius: var(--radius-pill);
  font-size: var(--text-sm);
}

.page-item.active .page-link {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
  box-shadow: var(--shadow-xs);
}

.page-link:hover { background: var(--gray-50); color: var(--navy); }

/* ── DataTables overrides ───────────────────────────────────── */
div.dataTables_wrapper {
  font-size: var(--text-sm);
}

/* Top controls bar: "Show X entries" + "Filter:" */
div.dataTables_wrapper > div.row:first-child {
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  padding: 14px 18px;
  margin: 0 !important;
  align-items: center;
  border-radius: calc(var(--radius) - 1px) calc(var(--radius) - 1px) 0 0;
}

div.dataTables_wrapper > div.row:first-child > div {
  padding: 4px 8px;
}

/* Bottom row: info + pagination */
div.dataTables_wrapper > div.row:last-child {
  background: var(--gray-50);
  border-top: 1px solid var(--gray-200);
  padding: 8px 16px;
  margin: 0 !important;
  align-items: center;
  border-radius: 0 0 calc(var(--radius) - 1px) calc(var(--radius) - 1px);
}

div.dataTables_wrapper > div.row:last-child > div {
  padding: 4px 8px;
}

/* Length + Filter labels */
div.dataTables_wrapper div.dataTables_filter label,
div.dataTables_wrapper div.dataTables_length label {
  font-size: var(--text-sm);
  color: var(--gray-700);
  font-weight: 500;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

/* "Show N entries" select */
div.dataTables_wrapper div.dataTables_length select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 3px 28px 3px 8px;
  font-size: var(--text-sm);
  color: var(--gray-900);
  background-color: #fff;
  box-shadow: var(--shadow-input-inset);
  height: 30px;
  line-height: 1;
  appearance: auto;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

div.dataTables_wrapper div.dataTables_length select:focus {
  border-color: var(--gold);
  box-shadow: var(--shadow-input-inset), 0 0 0 3px rgba(212,175,55,.22);
  outline: none;
}

/* Large search bar */
div.dataTables_wrapper div.dataTables_filter input {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-pill);
  padding: 10px 16px 10px 38px;
  font-size: var(--text-sm);
  color: var(--gray-900);
  background-color: var(--color-card);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7488' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 14px center;
  background-size: 15px 15px;
  box-shadow: var(--shadow-input-inset);
  min-height: 44px;
  height: auto;
  margin-left: 6px !important;
  min-width: 260px;
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

div.dataTables_wrapper div.dataTables_filter input:focus {
  border-color: var(--gold);
  box-shadow: var(--shadow-input-inset), 0 0 0 3px rgba(212,175,55,.22);
  outline: none;
}

/* Info text */
div.dataTables_wrapper div.dataTables_info {
  font-size: var(--text-xs);
  color: var(--gray-500);
  padding-top: 0;
  line-height: 30px;
}

/* Pagination wrapper */
div.dataTables_wrapper div.dataTables_paginate {
  padding-top: 0;
}

/* Pagination buttons — Bootstrap .pagination ul */
div.dataTables_wrapper div.dataTables_paginate ul.pagination {
  margin: 0;
  gap: 2px;
}

div.dataTables_wrapper .pagination .page-item .page-link {
  font-size: var(--text-xs);
  padding: 6px 12px;
  border-radius: var(--radius-pill) !important;
  border: 1px solid var(--color-border);
  color: var(--navy);
  background: var(--color-card);
  line-height: 1.4;
  font-weight: 500;
  transition: background var(--transition-base), box-shadow var(--transition-base);
}

div.dataTables_wrapper .pagination .page-item .page-link:hover {
  background: var(--gray-50);
  color: var(--navy);
  border-color: var(--color-border);
}

div.dataTables_wrapper .pagination .page-item.active .page-link {
  background: var(--navy) !important;
  border-color: var(--navy) !important;
  color: #fff !important;
  box-shadow: var(--shadow-xs);
}

div.dataTables_wrapper .pagination .page-item.disabled .page-link {
  color: var(--gray-300);
  background: var(--gray-50);
  border-color: var(--gray-200);
}

/* Sort arrow colours in DT thead */
table.dataTable thead > tr > th.sorting:before,
table.dataTable thead > tr > th.sorting:after,
table.dataTable thead > tr > th.sorting_asc:before,
table.dataTable thead > tr > th.sorting_asc:after,
table.dataTable thead > tr > th.sorting_desc:before,
table.dataTable thead > tr > th.sorting_desc:after {
  color: var(--gold);
  opacity: .5;
}

table.dataTable thead > tr > th.sorting_asc:before,
table.dataTable thead > tr > th.sorting_desc:after {
  opacity: 1;
  color: var(--gold);
}

/* ── Tom Select overrides ───────────────────────────────────── */
.ts-wrapper .ts-control {
  min-height: 44px;
  padding: 8px 16px;
  background: var(--color-bg);
  border-color: var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-input-inset);
  font-size: var(--text-sm);
  transition: border-color var(--transition-base), box-shadow var(--transition-base);
}

.ts-wrapper.focus .ts-control {
  border-color: var(--gold) !important;
  box-shadow: var(--shadow-input-inset), 0 0 0 3px rgba(212,175,55,.22) !important;
}

.ts-dropdown {
  margin-top: 4px;
  padding: 6px;
  border-color: var(--color-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-modal);
  font-size: var(--text-sm);
  transition: opacity var(--transition-base), transform var(--transition-base);
}

@starting-style {
  .ts-dropdown {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.ts-dropdown .option {
  border-radius: calc(var(--radius-sm) - 4px);
  padding: 8px 10px;
}

.ts-dropdown .option.active,
.ts-dropdown .option:hover {
  background: rgba(212,175,55,.12);
  color: var(--navy);
}

/* ── Login page ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(150deg, var(--navy) 0%, #111750 55%, #1e1040 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--color-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.login-card-header {
  background: var(--color-card);
  padding: 28px 32px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(212,175,55,.35);
}

.login-card-header img {
  width: 180px;
  height: auto;
  display: block;
  margin: 0 auto;
}

.login-tagline {
  color: var(--navy);
  font-size: var(--text-xs);
  letter-spacing: .15em;
  text-transform: uppercase;
  font-weight: 700;
  margin-top: 8px;
  opacity: .6;
}

.login-card-body { padding: 24px 32px 28px; }

.login-card-body .form-label {
  color: var(--navy);
  font-weight: 600;
  font-size: var(--text-sm);
}

.login-card-footer {
  text-align: center;
  padding: 10px;
  border-top: 1px solid var(--gray-100);
  font-size: var(--text-xs);
  color: var(--gray-500);
}

/* ── Tab overrides ──────────────────────────────────────────── */
.nav-tabs .nav-link {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--gray-500);
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 16px;
  border-radius: 0;
  transition: color var(--transition-fast), border-color var(--transition-fast);
}

.nav-tabs .nav-link:hover { color: var(--navy); }

.nav-tabs .nav-link.active {
  color: var(--navy);
  border-bottom-color: var(--gold);
  background: transparent;
}

.nav-tabs { border-bottom: 1px solid var(--gray-200); }

/* ── Utility ────────────────────────────────────────────────── */
.monospace { font-family: 'Menlo', 'Consolas', monospace; }
.text-dim  { color: var(--gray-500); }
.gap-actions { display: flex; gap: 6px; align-items: center; }
.text-navy { color: var(--navy); }
.text-gold { color: var(--gold); }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.mb-4 { margin-bottom: var(--space-6) !important; }
.mb-3 { margin-bottom: var(--space-5) !important; }

/* Old row gutter → new spacing scale */
.row.g-3 { --bs-gutter-y: 1.5rem; }

/* ═══════════════════════════════════════════════════════════════
   BOOTSTRAP UTILITY RETHEME
   Every view uses plain Bootstrap classes (card-title, breadcrumb,
   text-muted, btn-link, form-check-input, …) rather than one-off
   component classes. These rules retheme those Bootstrap classes to
   match the design system, app-wide, in one place.
   ═══════════════════════════════════════════════════════════════ */

.card-title {
  color: var(--navy);
  font-weight: 800;
  letter-spacing: -.005em;
  font-size: var(--text-lg);
}

.form-check-input {
  border: 1px solid var(--color-border);
  box-shadow: none;
}
.form-check-input:checked {
  background-color: var(--gold);
  border-color: var(--gold);
}
.form-check-input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(212,175,55,.22);
}

.list-group-item {
  border-color: var(--color-border);
  font-size: var(--text-sm);
  padding: 10px 0;
}

/* Bootstrap semantic badge colours → design-system palette */
.badge.bg-success  { background: var(--success-bg) !important; color: var(--success) !important; border: 1px solid var(--success-bd) !important; }
.badge.bg-warning  { background: var(--warning-bg) !important; color: var(--warning) !important; border: 1px solid var(--warning-bd) !important; }
.badge.bg-danger   { background: var(--danger-bg)  !important; color: var(--danger)  !important; border: 1px solid var(--danger-bd)  !important; }
.badge.bg-secondary{ background: var(--gray-100)   !important; color: var(--gray-700) !important; border: 1px solid var(--gray-300)  !important; }
.badge.bg-primary  { background: rgba(24,36,75,.08) !important; color: var(--navy)   !important; border: 1px solid rgba(24,36,75,.18) !important; }
.badge.bg-info     { background: var(--info-bg)    !important; color: var(--info)    !important; border: 1px solid var(--info-bd)    !important; }

/* Standard Cancel button — btn-link text-muted */
.btn-link.text-muted,
a.btn-link.text-muted {
  color: var(--gray-500) !important;
  text-decoration: none !important;
  border: 1px solid var(--gray-200) !important;
  border-radius: var(--radius-sm) !important;
  padding: 4px 10px !important;
  font-size: var(--text-xs) !important;
  font-weight: 600 !important;
  background: transparent !important;
}

.btn-link.text-muted:hover,
a.btn-link.text-muted:hover {
  background: var(--gray-100) !important;
  color: var(--gray-700) !important;
  text-decoration: none !important;
}

.text-success { color: var(--success) !important; }
.text-muted   { color: var(--gray-500) !important; font-size: inherit; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }

/* Right-aligned table action column */
td.text-end { text-align: right; white-space: nowrap; }

.small, small { font-size: var(--text-xs) !important; }

.breadcrumb {
  background: transparent;
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: var(--text-sm);
}

.breadcrumb-item a { color: var(--navy); }
.breadcrumb-item.active { color: var(--color-text); font-weight: 600; }
.breadcrumb-item + .breadcrumb-item::before { color: var(--color-border); }

.form-label.small,
label.form-label.small {
  font-size: var(--text-xs) !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .06em !important;
  color: var(--gray-500) !important;
}

.d-flex.gap-2 { gap: 8px !important; }

code {
  font-family: 'Menlo', 'Consolas', monospace;
  font-size: var(--text-xs);
  color: var(--navy-2);
  background: var(--gray-100);
  padding: 1px 5px;
  border-radius: 3px;
}

/* ── Network Topology ──────────────────────────────────────────────────────── */
#topology-canvas {
  border-radius: 0;
}
/* vis-network navigation buttons override */
.vis-navigation .vis-button {
  background-color: var(--color-card) !important;
  border: 1px solid var(--gray-200) !important;
  border-radius: var(--radius-sm) !important;
  box-shadow: var(--shadow-xs) !important;
}
/* Tooltip panel */
#topo-tooltip {
  font-family: var(--font-sans);
}
#topo-tooltip b {
  color: var(--navy);
  font-weight: 600;
}

/* ── Error pages (404 / 403 / 500) ───────────────────────────── */
.error-page {
  max-width: 440px;
  margin: var(--space-10) auto;
  text-align: center;
  background: var(--color-card);
  border: 1px solid rgba(216,222,232,.6);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-8);
}
.error-page-code {
  font-size: 3rem;
  font-weight: 800;
  color: var(--navy);
  line-height: 1;
  margin-bottom: var(--space-3);
}
.error-page-message {
  color: var(--gray-500);
  margin-bottom: var(--space-6);
}

/* ── Responsive (mobile / tablet) ────────────────────────────── */
.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-toggle:hover { background: var(--gray-100); }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(18,25,38,.4);
  z-index: 999;
}
.sidebar-backdrop.show { display: block; }

@media (max-width: 960px) {
  .sidebar-toggle { display: inline-flex; }

  #sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
  }
  #sidebar.sidebar-open {
    transform: translateX(0);
  }

  #page-content {
    width: 100%;
  }

  .page-body {
    padding: var(--space-4);
  }

  .page-header {
    flex-wrap: wrap;
    row-gap: var(--space-3);
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar .filter-group {
    width: 100%;
  }
  .filter-bar .form-select,
  .filter-bar .form-control {
    width: 100%;
  }
  .filter-bar .filter-actions {
    width: 100%;
    border-left: none;
    margin-left: 0;
    padding-left: 0;
    padding-top: var(--space-3);
    border-top: 1px solid var(--color-border);
  }

  .card-header {
    flex-wrap: wrap;
    row-gap: var(--space-2);
  }

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

  .error-page {
    margin: var(--space-6) var(--space-4);
    padding: var(--space-6);
  }
}
