/* ==========================================================================
   Ergon HR design system ("Crisp and calm")
   Tokens first, then the Bootstrap parts every page already uses, so existing
   markup picks up the look without changes. Load after other stylesheets.
   ========================================================================== */
:root {
  /* Colour */
  --ds-bg: #f7f7f8;
  --ds-surface: #ffffff;
  --ds-surface-2: #fafafa;
  --ds-surface-hover: #f4f4f5;
  --ds-border: #e4e4e7;
  --ds-border-strong: #d4d4d8;
  --ds-border-subtle: #f0f0f2;
  --ds-text: #18181b;
  --ds-text-2: #3f3f46;
  --ds-text-muted: #52525b;
  --ds-text-faint: #71717a;
  --ds-accent: #4f46e5;
  --ds-accent-hover: #4338ca;
  --ds-accent-active: #3730a3;
  --ds-accent-soft: #eef0ff;
  --ds-accent-text: #3730a3;
  --ds-on-accent: #ffffff;
  --ds-focus: rgba(79, 70, 229, 0.32);

  --ds-success: #047857;
  --ds-success-soft: #ecfdf5;
  --ds-success-dot: #10b981;
  --ds-warning: #92400e;
  --ds-warning-soft: #fffbeb;
  --ds-warning-dot: #f59e0b;
  --ds-danger: #b91c1c;
  --ds-danger-solid: #dc2626;
  --ds-danger-soft: #fef2f2;
  --ds-danger-dot: #ef4444;
  --ds-info: #1d4ed8;
  --ds-info-soft: #eff6ff;
  --ds-info-dot: #3b82f6;
  --ds-neutral-soft: #f4f4f5;

  /* Type */
  --ds-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --ds-font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ds-text-xs: 12px;
  --ds-text-sm: 13px;
  --ds-text-base: 14px;
  --ds-text-md: 15px;
  --ds-text-lg: 18px;
  --ds-text-xl: 24px;
  --ds-text-2xl: 30px;

  /* Shape and depth */
  --ds-radius-sm: 6px;
  --ds-radius: 8px;
  --ds-radius-lg: 12px;
  --ds-radius-xl: 16px;
  --ds-shadow-sm: 0 1px 2px rgba(24, 24, 27, 0.05);
  --ds-shadow: 0 1px 3px rgba(24, 24, 27, 0.06), 0 1px 2px rgba(24, 24, 27, 0.04);
  --ds-shadow-lg: 0 16px 40px -12px rgba(24, 24, 27, 0.22);
  --ds-ease: 150ms cubic-bezier(0.2, 0, 0, 1);

  /* The shell reads these */
  --shell-bg: var(--ds-bg);
  --shell-surface: var(--ds-surface);
  --shell-border: var(--ds-border);
  --shell-text: var(--ds-text);
  --shell-text-muted: var(--ds-text-muted);
  --shell-primary: var(--ds-accent);
  --shell-primary-soft: var(--ds-accent-soft);
  --shell-font: var(--ds-font);
  --shell-sidebar-width: 248px;
  --shell-topbar-height: 60px;
  --shell-sidebar-bg: var(--ds-surface);
  --shell-sidebar-text: var(--ds-text-2);
  --shell-sidebar-text-active: var(--ds-accent-text);
  --shell-shadow-sm: none;
}

[data-theme="dark"] {
  --ds-bg: #0c0c0e;
  --ds-surface: #141417;
  --ds-surface-2: #18181b;
  --ds-surface-hover: #1f1f23;
  --ds-border: #27272a;
  --ds-border-strong: #3f3f46;
  --ds-border-subtle: #1f1f23;
  --ds-text: #f4f4f5;
  --ds-text-2: #d4d4d8;
  --ds-text-muted: #a1a1aa;
  --ds-text-faint: #8b8b94;
  --ds-accent: #5b5bd6; /* white text on it is 5.4:1 */
  --ds-accent-hover: #4f4fc7;
  --ds-accent-active: #8b8ef7;
  --ds-accent-soft: rgba(99, 102, 241, 0.16);
  --ds-accent-text: #c7c9ff;
  --ds-focus: rgba(129, 140, 248, 0.45);
  --ds-success: #6ee7b7;
  --ds-success-soft: rgba(16, 185, 129, 0.14);
  --ds-warning: #fcd34d;
  --ds-warning-soft: rgba(245, 158, 11, 0.14);
  --ds-danger: #fca5a5;
  --ds-danger-solid: #ef4444;
  --ds-danger-soft: rgba(239, 68, 68, 0.14);
  --ds-info: #93c5fd;
  --ds-info-soft: rgba(59, 130, 246, 0.14);
  --ds-neutral-soft: #27272a;
  --ds-shadow-sm: none;
  --ds-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --ds-shadow-lg: 0 20px 48px -12px rgba(0, 0, 0, 0.6);
  color-scheme: dark;
}

/* ---------- Base ---------- */
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--ds-font);
  font-size: var(--ds-text-base);
  line-height: 1.5;
  color: var(--ds-text);
  background: var(--ds-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: 'cv11', 'ss01';
}
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 {
  color: var(--ds-text);
  font-weight: 600;
  letter-spacing: -0.015em;
}
h1, .h1 { font-size: var(--ds-text-2xl); }
h2, .h2 { font-size: var(--ds-text-xl); }
h3, .h3 { font-size: 20px; }
h4, .h4 { font-size: var(--ds-text-lg); }
h5, .h5 { font-size: var(--ds-text-md); }
h6, .h6 { font-size: var(--ds-text-base); }
a { color: var(--ds-accent); }
a:hover { color: var(--ds-accent-hover); }
.text-muted { color: var(--ds-text-muted) !important; }
.text-primary { color: var(--ds-accent) !important; }
.bg-light { background-color: var(--ds-surface-2) !important; }
.bg-white { background-color: var(--ds-surface) !important; }
.table-light, .table-light > th, .table-light > td, thead.table-light th { background-color: var(--ds-surface-2) !important; color: var(--ds-text-muted) !important; }
.border, .border-top, .border-bottom, .border-start, .border-end { border-color: var(--ds-border) !important; }
small, .small { font-size: var(--ds-text-sm); }
code, kbd, .font-monospace { font-family: var(--ds-font-mono); }
hr { border-color: var(--ds-border); opacity: 1; }
::selection { background: var(--ds-accent-soft); }
:focus-visible { outline: 2px solid var(--ds-accent); outline-offset: 2px; }
.tabular, td, .stat-value { font-variant-numeric: tabular-nums; }

/* ---------- Page header ---------- */
.app-content .page-header,
.ds-page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.app-content .page-title,
.ds-page-title {
  font-size: var(--ds-text-xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ds-text);
  margin: 0;
}
.app-content .page-subtitle,
.ds-page-subtitle {
  font-size: var(--ds-text-base);
  color: var(--ds-text-muted);
  margin: 4px 0 0;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: var(--ds-radius);
  font-family: var(--ds-font);
  font-size: var(--ds-text-base);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  box-shadow: none;
  transition: background-color var(--ds-ease), border-color var(--ds-ease), color var(--ds-ease), box-shadow var(--ds-ease);
}
.btn:focus, .btn:focus-visible { box-shadow: 0 0 0 3px var(--ds-focus); outline: none; }
.btn-sm { min-height: 30px; padding: 0 10px; font-size: var(--ds-text-sm); border-radius: var(--ds-radius-sm); gap: 6px; }
.btn-lg { min-height: 44px; padding: 0 20px; font-size: var(--ds-text-md); }
.btn i, .btn svg { font-size: 0.95em; }

.btn-primary {
  background: var(--ds-accent);
  border: 1px solid var(--ds-accent);
  color: var(--ds-on-accent);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), var(--ds-shadow-sm);
}
.btn-primary:hover { background: var(--ds-accent-hover); border-color: var(--ds-accent-hover); color: var(--ds-on-accent); }
.btn-primary:active, .btn-primary.active, .btn-check:checked + .btn-primary { background: var(--ds-accent-active); border-color: var(--ds-accent-active); color: var(--ds-on-accent); }
.btn-primary:disabled, .btn-primary.disabled { background: var(--ds-accent); border-color: var(--ds-accent); opacity: 0.5; }

.btn-secondary, .btn-light, .btn-outline-secondary, .btn-outline-primary, .btn-outline-dark, .btn-outline-light, .btn-white {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow-sm);
}
.btn-secondary:hover, .btn-light:hover, .btn-outline-secondary:hover, .btn-outline-primary:hover, .btn-outline-dark:hover, .btn-outline-light:hover, .btn-white:hover {
  background: var(--ds-surface-hover);
  border-color: var(--ds-border-strong);
  color: var(--ds-text);
}
.btn-secondary:active, .btn-light:active, .btn-outline-secondary:active, .btn-outline-primary:active, .btn-outline-dark:active,
.btn-check:checked + .btn-outline-primary, .btn-check:checked + .btn-outline-secondary,
.btn-outline-primary.active, .btn-outline-secondary.active {
  background: var(--ds-accent-soft);
  border-color: var(--ds-accent);
  color: var(--ds-accent-text);
}
.btn-outline-primary { color: var(--ds-accent-text); }

/* One accent colour: "go" actions styled as success or info read as primary */
.btn-success, .btn-info { background: var(--ds-accent); border: 1px solid var(--ds-accent); color: var(--ds-on-accent); }
.btn-success:hover, .btn-info:hover { background: var(--ds-accent-hover); border-color: var(--ds-accent-hover); color: var(--ds-on-accent); }
.btn-danger { background: var(--ds-danger-solid); border: 1px solid var(--ds-danger-solid); color: #fff; }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; color: #fff; }
/* Cautionary actions (unlock, hold) are a soft amber, not a loud orange block */
.btn-warning { background: var(--ds-warning-soft); border: 1px solid var(--ds-warning-dot); color: var(--ds-warning); }
.btn-warning:hover { background: var(--ds-warning-dot); border-color: var(--ds-warning-dot); color: #18181b; }
.btn-dark { background: var(--ds-text); border: 1px solid var(--ds-text); color: var(--ds-surface); }
.btn-dark:hover { background: var(--ds-text-2); border-color: var(--ds-text-2); color: var(--ds-surface); }
.btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  box-shadow: var(--ds-shadow-sm);
}
.btn-outline-success { color: var(--ds-success); }
.btn-outline-danger { color: var(--ds-danger); }
.btn-outline-warning { color: var(--ds-warning); }
.btn-outline-info { color: var(--ds-info); }
.btn-outline-success:hover { background: var(--ds-success-soft); border-color: var(--ds-success-dot); color: var(--ds-success); }
.btn-outline-danger:hover { background: var(--ds-danger-soft); border-color: var(--ds-danger-dot); color: var(--ds-danger); }
.btn-outline-warning:hover { background: var(--ds-warning-soft); border-color: var(--ds-warning-dot); color: var(--ds-warning); }
.btn-outline-info:hover { background: var(--ds-info-soft); border-color: var(--ds-info-dot); color: var(--ds-info); }
.btn-link { color: var(--ds-accent); text-decoration: none; padding-left: 4px; padding-right: 4px; }
.btn-link:hover { color: var(--ds-accent-hover); text-decoration: underline; }
.btn-close:focus { box-shadow: 0 0 0 3px var(--ds-focus); }
.btn-group > .btn { box-shadow: none; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---------- Forms ---------- */
.form-label, label.form-label, .col-form-label {
  font-size: var(--ds-text-sm);
  font-weight: 500;
  color: var(--ds-text-2);
  margin-bottom: 6px;
}
.form-control, .form-select, .input-group-text {
  min-height: 36px;
  padding: 7px 11px;
  font-family: var(--ds-font);
  font-size: var(--ds-text-base);
  color: var(--ds-text);
  background-color: var(--ds-surface);
  border: 1px solid var(--ds-border-strong);
  border-radius: var(--ds-radius);
  box-shadow: var(--ds-shadow-sm);
  transition: border-color var(--ds-ease), box-shadow var(--ds-ease);
}
.form-select { padding-right: 32px; background-position: right 10px center; }
.form-control-sm, .form-select-sm { min-height: 30px; padding: 4px 9px; font-size: var(--ds-text-sm); border-radius: var(--ds-radius-sm); }
.form-control-lg, .form-select-lg { min-height: 44px; font-size: var(--ds-text-md); }
textarea.form-control { min-height: 80px; }
.form-control::placeholder { color: var(--ds-text-faint); }
.form-control:hover, .form-select:hover { border-color: #a1a1aa; }
.form-control:focus, .form-select:focus {
  border-color: var(--ds-accent);
  box-shadow: 0 0 0 3px var(--ds-focus);
  background-color: var(--ds-surface);
  color: var(--ds-text);
}
.form-control:disabled, .form-control[readonly], .form-select:disabled {
  background-color: var(--ds-surface-2);
  color: var(--ds-text-muted);
  border-color: var(--ds-border);
}
.form-control.is-invalid, .form-select.is-invalid { border-color: var(--ds-danger-dot); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.25); }
.invalid-feedback { font-size: var(--ds-text-sm); color: var(--ds-danger); }
.form-text { font-size: var(--ds-text-xs); color: var(--ds-text-muted); }
.input-group-text { background: var(--ds-surface-2); color: var(--ds-text-muted); box-shadow: none; }
.input-group > .form-control, .input-group > .form-select { box-shadow: none; }
.form-check-input {
  width: 16px;
  height: 16px;
  margin-top: 0.2em;
  border: 1px solid var(--ds-border-strong);
  background-color: var(--ds-surface);
}
.form-check-input:checked { background-color: var(--ds-accent); border-color: var(--ds-accent); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--ds-focus); border-color: var(--ds-accent); }
.form-switch .form-check-input { width: 32px; height: 18px; }
.form-check-label { font-size: var(--ds-text-base); color: var(--ds-text-2); }
[data-theme="dark"] .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='%23a1a1aa' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* ---------- Cards ---------- */
.card {
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  box-shadow: var(--ds-shadow-sm);
  color: var(--ds-text);
}
.card.shadow, .card.shadow-sm, .card.shadow-lg { box-shadow: var(--ds-shadow-sm) !important; }
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--ds-border);
  padding: 14px 16px;
  font-weight: 600;
  font-size: var(--ds-text-md);
}
.card-header:first-child { border-radius: calc(var(--ds-radius-lg) - 1px) calc(var(--ds-radius-lg) - 1px) 0 0; }
.card-body { padding: 16px; }
.card-footer { background: var(--ds-surface-2); border-top: 1px solid var(--ds-border); padding: 12px 16px; }
.card-title { font-size: var(--ds-text-md); font-weight: 600; color: var(--ds-text); }
.card-subtitle, .card-text { color: var(--ds-text-muted); }
.card-header.bg-primary, .card-header.bg-dark, .card-header.bg-success, .card-header.bg-info, .card-header.bg-warning, .card-header.bg-danger,
.card-header.text-white {
  background: transparent !important;
  color: var(--ds-text) !important;
}

/* ---------- Tables ---------- */
.table {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: transparent;
  --bs-table-hover-bg: var(--ds-surface-hover);
  --bs-table-accent-bg: transparent;
  color: var(--ds-text);
  border-color: var(--ds-border-subtle);
  font-size: var(--ds-text-base);
  margin-bottom: 0;
}
.table > :not(caption) > * > * {
  padding: 10px 14px;
  border-bottom-color: var(--ds-border-subtle);
  box-shadow: none;
  vertical-align: middle;
}
.table > thead > tr > th, .table > thead th, .table thead.table-light th, .table thead.table-dark th {
  background: var(--ds-surface-2);
  color: var(--ds-text-muted);
  font-size: var(--ds-text-xs);
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid var(--ds-border);
  white-space: nowrap;
}
.table > :not(:first-child) { border-top: 0; }
.table-striped > tbody > tr:nth-of-type(odd) > * { --bs-table-accent-bg: transparent; }
.table-hover > tbody > tr:hover > *, .table > tbody > tr:hover > * { --bs-table-accent-bg: var(--ds-surface-hover); }
.table-bordered > :not(caption) > * > * { border-color: var(--ds-border-subtle); }
.table-sm > :not(caption) > * > * { padding: 6px 10px; }
.table-responsive { border-radius: inherit; }
.card > .table-responsive:last-child, .card > .table:last-child { border-radius: 0 0 var(--ds-radius-lg) var(--ds-radius-lg); }
.table .text-end, .table .num { font-variant-numeric: tabular-nums; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: var(--ds-text-xs);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: 0;
  text-transform: none;
}
.badge.bg-primary { background: var(--ds-accent-soft) !important; color: var(--ds-accent-text) !important; }
.badge.bg-success { background: var(--ds-success-soft) !important; color: var(--ds-success) !important; }
.badge.bg-warning { background: var(--ds-warning-soft) !important; color: var(--ds-warning) !important; }
.badge.bg-danger { background: var(--ds-danger-soft) !important; color: var(--ds-danger) !important; }
.badge.bg-info { background: var(--ds-info-soft) !important; color: var(--ds-info) !important; }
.badge.bg-secondary, .badge.bg-light, .badge.bg-dark { background: var(--ds-neutral-soft) !important; color: var(--ds-text-2) !important; }
/* Counters on icons stay solid so they read at a glance */
.topbar-badge, #sidebarNotificationBadge, .badge.rounded-circle { background: var(--ds-danger-solid) !important; color: #fff !important; }

/* ---------- Alerts ---------- */
.alert {
  border-radius: var(--ds-radius-lg);
  border: 1px solid var(--ds-border);
  padding: 12px 16px;
  font-size: var(--ds-text-base);
  background: var(--ds-surface);
  color: var(--ds-text);
}
.alert-primary, .alert-info { background: var(--ds-info-soft); border-color: transparent; color: var(--ds-info); }
.alert-success { background: var(--ds-success-soft); border-color: transparent; color: var(--ds-success); }
.alert-warning { background: var(--ds-warning-soft); border-color: transparent; color: var(--ds-warning); }
.alert-danger { background: var(--ds-danger-soft); border-color: transparent; color: var(--ds-danger); }
.alert-secondary, .alert-light { background: var(--ds-surface-2); color: var(--ds-text-2); }

/* ---------- Modals and menus ---------- */
.modal-content {
  background: var(--ds-surface);
  color: var(--ds-text);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-xl);
  box-shadow: var(--ds-shadow-lg);
  overflow: hidden;
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--ds-border);
  background: var(--ds-surface) !important;
  color: var(--ds-text) !important;
}
.modal-header .btn-close { filter: none; }
[data-theme="dark"] .modal-header .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }
.modal-title { font-size: var(--ds-text-lg); font-weight: 600; color: var(--ds-text) !important; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--ds-border); background: var(--ds-surface-2); gap: 8px; }
.modal-footer > * { margin: 0; }
.modal-backdrop.show { opacity: 1; background: rgba(9, 9, 11, 0.45); backdrop-filter: blur(2px); }

.dropdown-menu {
  padding: 4px;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
  background: var(--ds-surface);
  box-shadow: var(--ds-shadow-lg);
  font-size: var(--ds-text-base);
}
.dropdown-item {
  border-radius: var(--ds-radius-sm);
  padding: 7px 10px;
  color: var(--ds-text-2);
}
.dropdown-item:hover, .dropdown-item:focus { background: var(--ds-surface-hover); color: var(--ds-text); }
.dropdown-item.active, .dropdown-item:active { background: var(--ds-accent-soft); color: var(--ds-accent-text); }
.dropdown-divider { border-color: var(--ds-border); margin: 4px 0; }

/* ---------- Tabs, pills, pagination ---------- */
.nav-tabs {
  border-bottom: 1px solid var(--ds-border);
  gap: 4px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.nav-tabs .nav-link {
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  margin-bottom: -1px;
  padding: 10px 12px;
  font-size: var(--ds-text-base);
  font-weight: 500;
  color: var(--ds-text-muted);
  background: transparent;
  white-space: nowrap;
}
.nav-tabs .nav-link:hover { color: var(--ds-text); border-bottom-color: var(--ds-border-strong); }
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
  color: var(--ds-text);
  background: transparent;
  border-bottom-color: var(--ds-accent);
}
.nav-pills {
  gap: 2px;
  padding: 3px;
  background: var(--ds-neutral-soft);
  border-radius: var(--ds-radius);
  display: inline-flex;
}
.nav-pills .nav-link {
  border-radius: var(--ds-radius-sm);
  padding: 5px 12px;
  font-size: var(--ds-text-sm);
  font-weight: 500;
  color: var(--ds-text-muted);
}
.nav-pills .nav-link:hover { color: var(--ds-text); }
.nav-pills .nav-link.active, .nav-pills .show > .nav-link {
  background: var(--ds-surface);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow);
}
.pagination { gap: 4px; }
.page-link {
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-sm) !important;
  color: var(--ds-text-2);
  background: var(--ds-surface);
  font-size: var(--ds-text-sm);
  min-width: 32px;
  text-align: center;
}
.page-link:hover { background: var(--ds-surface-hover); color: var(--ds-text); border-color: var(--ds-border-strong); }
.page-item.active .page-link { background: var(--ds-accent); border-color: var(--ds-accent); color: var(--ds-on-accent); }
.page-item.disabled .page-link { background: var(--ds-surface); color: var(--ds-text-faint); }

/* ---------- Lists, progress, misc ---------- */
.list-group-item { background: var(--ds-surface); border-color: var(--ds-border); color: var(--ds-text); }
.list-group-item-action:hover { background: var(--ds-surface-hover); }
.list-group-item.active { background: var(--ds-accent-soft); border-color: var(--ds-border); color: var(--ds-accent-text); }
.progress { height: 6px; background: var(--ds-neutral-soft); border-radius: 999px; }
.progress-bar { background: var(--ds-accent); border-radius: 999px; }
.spinner-border { color: var(--ds-accent); }
.tooltip-inner { background: var(--ds-text); color: var(--ds-surface); font-size: var(--ds-text-xs); border-radius: var(--ds-radius-sm); padding: 5px 8px; }
.toast { border-radius: var(--ds-radius-lg); border: 1px solid var(--ds-border); box-shadow: var(--ds-shadow-lg); }

/* ---------- Design system parts for new markup ---------- */
.ds-stat {
  padding: 16px 18px;
  background: var(--ds-surface);
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-lg);
}
.ds-stat-label { font-size: var(--ds-text-sm); color: var(--ds-text-muted); margin: 0; }
.ds-stat-value { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; margin: 6px 0 0; font-variant-numeric: tabular-nums; }
.ds-stat-note { font-size: var(--ds-text-xs); color: var(--ds-text-muted); margin: 4px 0 0; }
/* A tone class alone (ds-status-success) is enough; ds-status is optional */
.ds-status, [class^="ds-status-"], [class*=" ds-status-"] { display: inline-flex; align-items: center; gap: 6px; padding: 2px 8px; border-radius: 999px; font-size: var(--ds-text-xs); font-weight: 500; }
.ds-status::before, [class^="ds-status-"]::before, [class*=" ds-status-"]::before { content: ''; width: 6px; height: 6px; border-radius: 999px; background: currentColor; }
.ds-status-success { background: var(--ds-success-soft); color: var(--ds-success); }
.ds-status-warning { background: var(--ds-warning-soft); color: var(--ds-warning); }
.ds-status-danger { background: var(--ds-danger-soft); color: var(--ds-danger); }
.ds-status-info { background: var(--ds-info-soft); color: var(--ds-info); }
.ds-status-neutral { background: var(--ds-neutral-soft); color: var(--ds-text-2); }
.ds-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--ds-text-muted);
}
.ds-empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: var(--ds-radius-lg);
  background: var(--ds-neutral-soft);
  display: grid;
  place-items: center;
  color: var(--ds-text-muted);
}
.ds-empty-title { font-size: var(--ds-text-md); font-weight: 600; color: var(--ds-text); margin: 0; }
.ds-empty-text { font-size: var(--ds-text-base); margin: 4px auto 16px; max-width: 360px; }
.ds-skeleton {
  border-radius: var(--ds-radius-sm);
  background: linear-gradient(90deg, var(--ds-neutral-soft) 0%, var(--ds-surface-hover) 50%, var(--ds-neutral-soft) 100%);
  background-size: 200% 100%;
  animation: ds-shimmer 1.2s ease-in-out infinite;
  min-height: 12px;
}
@keyframes ds-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.ds-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--ds-accent-soft);
  color: var(--ds-accent-text);
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  flex: none;
}
.ds-kbd {
  font: 500 11px/1 var(--ds-font);
  padding: 3px 5px;
  border: 1px solid var(--ds-border);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--ds-surface);
  color: var(--ds-text-muted);
}

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

/* ---------- Command palette (top bar search) ---------- */
.cmdk {
  width: min(560px, calc(100vw - 32px));
  max-height: min(480px, calc(100vh - 120px));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--ds-border);
  border-radius: var(--ds-radius-xl);
  background: var(--ds-surface);
  color: var(--ds-text);
  box-shadow: var(--ds-shadow-lg);
  overflow: hidden;
}
.cmdk[open] { display: flex; flex-direction: column; }
.cmdk::backdrop { background: rgba(9, 9, 11, 0.4); backdrop-filter: blur(2px); }
.cmdk-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  min-height: 52px;
  border-bottom: 1px solid var(--ds-border);
  color: var(--ds-text-muted);
}
.cmdk-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font: inherit;
  font-size: var(--ds-text-md);
  color: var(--ds-text);
}
.cmdk-list { list-style: none; margin: 0; padding: 6px; overflow-y: auto; }
.cmdk-item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--ds-radius);
  cursor: pointer;
  font-size: var(--ds-text-base);
}
.cmdk-item[aria-selected="true"] { background: var(--ds-accent-soft); color: var(--ds-accent-text); }
.cmdk-section { font-size: var(--ds-text-xs); color: var(--ds-text-muted); }
.cmdk-empty { margin: 0; padding: 24px; text-align: center; color: var(--ds-text-muted); }

@media (max-width: 767.98px) {
  .topbar-search { width: 36px; padding: 0; justify-content: center; margin-left: auto; }
  .topbar-search span, .topbar-search kbd { display: none; }
}

/* ---------- Underline tabs used as filters (links) ---------- */
.ds-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--ds-border);
  margin-bottom: 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.ds-tabs::-webkit-scrollbar { display: none; }
.ds-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ds-text-muted);
  font-size: var(--ds-text-base);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
}
.ds-tabs a:hover { color: var(--ds-text); }
.ds-tabs a.active { color: var(--ds-text); border-bottom-color: var(--ds-accent); }
.ds-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--ds-neutral-soft);
  color: var(--ds-text-muted);
  font-size: var(--ds-text-xs);
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}
.ds-tabs a.active .ds-count { background: var(--ds-accent-soft); color: var(--ds-accent-text); }
.ds-dot { display: inline-block; width: 8px; height: 8px; border-radius: 999px; flex: none; }

/* ---------- Breadcrumbs: quiet trail above the page title ---------- */
.breadcrumb { font-size: var(--ds-text-xs); margin-bottom: 8px !important; }
.breadcrumb-item, .breadcrumb-item.active { color: var(--ds-text-faint); }
.breadcrumb-item a { color: var(--ds-text-muted); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--ds-accent); }
.breadcrumb-item + .breadcrumb-item::before { color: var(--ds-border-strong); }

/* ---------- Icon-only buttons in tables: quiet until hovered (a11y.js marks them ds-icon-only) ---------- */
.table td .btn-icon,
.table td .btn-sm.ds-icon-only:not(.btn-primary) {
  width: 30px;
  height: 30px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ds-text-faint);
  font-size: 13px;
}
.table td .btn-icon:hover,
.table td .btn-sm.ds-icon-only:not(.btn-primary):hover { background: var(--ds-surface-hover); color: var(--ds-text); }
.table td .btn-icon.delete:hover,
.table td .btn-outline-danger.btn-sm.ds-icon-only:hover { background: var(--ds-danger-soft); color: var(--ds-danger); }
.ds-num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Any one-row "nothing here" table message gets the empty-state look */
.table tbody > tr:only-child > td[colspan] { padding: 40px 16px; text-align: center; color: var(--ds-text-muted); background: transparent; }
.table tbody > tr:only-child > td[colspan] > .ds-empty { padding: 8px 0; }
.ds-empty-row:hover > td { background: transparent !important; }

/* ---------- Accessibility ---------- */
/* Keyboard users can jump past the sidebar */
.ds-skip {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 2000;
  padding: 8px 14px;
  border-radius: var(--ds-radius);
  background: var(--ds-accent);
  color: var(--ds-on-accent);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 0.15s;
}
.ds-skip:focus { transform: translateY(0); color: var(--ds-on-accent); }
main:focus { outline: none; }

/* Visible focus on everything you can click or type in, mouse clicks excluded */
a:focus-visible, button:focus-visible, [role="button"]:focus-visible, summary:focus-visible,
.sidebar-link:focus-visible, .nav-link:focus-visible, .dropdown-item:focus-visible, .page-link:focus-visible {
  outline: 2px solid var(--ds-accent);
  outline-offset: 2px;
  box-shadow: none;
}
.form-check-input:focus-visible { box-shadow: 0 0 0 3px var(--ds-focus); }

/* Dark mode: links use the lighter indigo so text stays readable (6:1+ on dark surfaces) */
[data-theme="dark"] a:not(.btn):not(.sidebar-link):not(.nav-link):not(.dropdown-item):not(.cmdk-item),
[data-theme="dark"] .btn-link,
[data-theme="dark"] .widget-link,
[data-theme="dark"] .insight-view-all,
[data-theme="dark"] .cc-action-btn,
[data-theme="dark"] .emp-home-view-all,
[data-theme="dark"] .auth-link,
[data-theme="dark"] .text-primary { color: var(--ds-accent-text) !important; }
