/* Trainly Design System — Component Styles */
/* All var() references use tokens defined in trainly-tokens.css */

/* ══════════════════════════════════════════
   NAVBAR
══════════════════════════════════════════ */
.trainly-navbar {
  height: var(--navbar-height);
  background: var(--brand-primary);
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fixed);
  display: flex;
  align-items: center;
}

.trainly-navbar .navbar-logo {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--text-inverse);
  text-decoration: none;
}

.trainly-navbar .nav-link {
  color: var(--clr-white-85);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  transition: background var(--ease-fast), color var(--ease-fast);
}

.trainly-navbar .nav-link:hover,
.trainly-navbar .nav-link.active {
  background: var(--clr-white-15);
  color: var(--text-inverse);
}

.trainly-navbar .nav-link.active {
  font-weight: var(--weight-semibold);
}

.trainly-navbar .navbar-dropdown-menu {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background: var(--surface-overlay);
  padding: var(--space-1);
  margin-top: var(--space-1);
  z-index: var(--z-dropdown);
}

.trainly-navbar .navbar-right-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* ══════════════════════════════════════════
   PAGE HEADER
══════════════════════════════════════════ */
.page-header {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-6);
  margin-bottom: var(--space-4);
}

.page-header .breadcrumb {
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.page-header .breadcrumb-item a {
  color: var(--text-secondary);
  text-decoration: none;
}

.page-header .breadcrumb-item a:hover {
  color: var(--brand-primary);
}

.page-header .breadcrumb-item.active {
  color: var(--text-muted);
}

.page-header-title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
  margin: 0;
  line-height: 1.25;
}

.page-header-subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-1);
}

/* ══════════════════════════════════════════
   CARDS
══════════════════════════════════════════ */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  margin-bottom: var(--space-4);
}

.card .card-header {
  background: var(--surface-subtle);
  border-bottom: 1px solid var(--border-default);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-4) var(--space-6);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.card .card-body {
  background: var(--surface-card);
  padding: var(--space-4) var(--space-6);
}

.card .card-footer {
  background: var(--surface-subtle);
  border-top: 1px solid var(--border-default);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  padding: var(--space-3) var(--space-6);
}

/* Metric Card */
.metric-card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  margin-bottom: var(--space-4);
}

.metric-card .metric-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}

.metric-card .metric-value {
  font-size: var(--text-3xl);
  font-weight: var(--weight-metric);
  color: var(--text-primary);
  line-height: 1;
}

.metric-card .metric-change {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

/* ══════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.25;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--ease-fast), border-color var(--ease-fast), box-shadow var(--ease-fast), opacity var(--ease-fast);
  white-space: nowrap;
  user-select: none;
}

.btn:disabled,
.btn.disabled {
  opacity: 0.55;
  pointer-events: none;
}

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-inverse);
}

.btn-primary:hover,
.btn-primary:focus {
  background: var(--brand-primary-dark);
  border-color: var(--brand-primary-dark);
  color: var(--text-inverse);
}

.btn-secondary {
  background: var(--clr-slate-100);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--clr-slate-200);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.btn-outline-primary {
  background: transparent;
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.btn-outline-primary:hover {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.btn-success {
  background: var(--brand-success);
  border-color: var(--brand-success);
  color: var(--text-inverse);
}

.btn-danger {
  background: var(--brand-danger);
  border-color: var(--brand-danger);
  color: var(--text-inverse);
}

.btn-warning {
  background: var(--brand-warning);
  border-color: var(--brand-warning);
  color: var(--text-primary);
}

.btn-info {
  background: var(--brand-info);
  border-color: var(--brand-info);
  color: var(--text-inverse);
}

.btn-light {
  background: var(--surface-subtle);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.btn-dark {
  background: var(--clr-slate-800);
  border-color: var(--clr-slate-800);
  color: var(--text-inverse);
}

/* Sizes */
.btn-sm {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
}

.btn-lg {
  font-size: var(--text-base);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-lg);
}

/* Icon button */
.btn-icon {
  padding: var(--space-2);
  border-radius: var(--radius-md);
  width: 2.25rem;
  height: 2.25rem;
}

/* ══════════════════════════════════════════
   BADGES
══════════════════════════════════════════ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  padding: 0.25em 0.6em;
  border-radius: var(--radius-pill);
}

.badge-soft-primary {
  background: var(--clr-violet-100);
  color: var(--clr-violet-800);
}

.badge-soft-success {
  background: var(--clr-green-100);
  color: var(--clr-green-700);
}

.badge-soft-warning {
  background: var(--clr-yellow-100);
  color: var(--clr-yellow-900);
}

.badge-soft-danger {
  background: var(--clr-red-100);
  color: var(--clr-red-700);
}

.badge-soft-info {
  background: var(--clr-cyan-100);
  color: var(--clr-cyan-900);
}

.badge-soft-secondary {
  background: var(--clr-slate-100);
  color: var(--clr-slate-700);
}

/* ══════════════════════════════════════════
   AVATARS
══════════════════════════════════════════ */
.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-pill);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
  overflow: hidden;
  flex-shrink: 0;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs  { width: 1.5rem;   height: 1.5rem;   font-size: var(--text-xs);  }
.avatar-sm  { width: 2rem;     height: 2rem;     font-size: var(--text-xs);  }
.avatar-md  { width: 2.5rem;   height: 2.5rem;   font-size: var(--text-sm);  }
.avatar-lg  { width: 3rem;     height: 3rem;     font-size: var(--text-base);}
.avatar-xl  { width: 4rem;     height: 4rem;     font-size: var(--text-lg);  }

.avatar-square { border-radius: var(--radius-md); }

/* ══════════════════════════════════════════
   STATUS DOTS
══════════════════════════════════════════ */
.status-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
}

.status-dot-success  { background: var(--brand-success); }
.status-dot-warning  { background: var(--brand-warning); }
.status-dot-danger   { background: var(--brand-danger); }
.status-dot-info     { background: var(--brand-info); }
.status-dot-muted    { background: var(--clr-slate-400); }
.status-dot-primary  { background: var(--brand-primary); }

/* ══════════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════════ */
.form-group {
  margin-bottom: var(--space-4);
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.form-label .required-mark,
.form-label .required-marker {
  color: var(--brand-danger);
  margin-inline-start: 0.2em;
}

.form-control {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  appearance: none;
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:hover {
  border-color: var(--border-strong);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

.form-control:disabled,
.form-control[readonly] {
  background: var(--surface-subtle);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-select {
  display: block;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-normal);
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-input);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
  cursor: pointer;
}

.form-select:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

textarea.form-control {
  resize: vertical;
  min-height: 6rem;
}

.form-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-error,
.invalid-feedback {
  font-size: var(--text-xs);
  color: var(--brand-danger);
  margin-top: var(--space-1);
}

/* Segmented control */
.form-segmented {
  display: inline-flex;
  background: var(--surface-muted);
  border-radius: var(--radius-md);
  padding: 0.1875rem;
  gap: 0.1875rem;
}

.form-segmented input[type="radio"] {
  display: none;
}

.form-segmented label {
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--ease-fast), color var(--ease-fast), box-shadow var(--ease-fast);
}

.form-segmented input[type="radio"]:checked + label {
  background: var(--surface-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* Toggle */
.form-check.form-switch .form-check-input {
  cursor: pointer;
}

/* Tag input */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.tag-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 0.2em 0.6em;
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.tag-item .tag-remove {
  cursor: pointer;
  opacity: 0.6;
  line-height: 1;
}

.tag-item .tag-remove:hover {
  opacity: 1;
}

/* File upload */
.form-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-8);
  border: 2px dashed var(--border-default);
  border-radius: var(--radius-xl);
  background: var(--surface-subtle);
  cursor: pointer;
  transition: border-color var(--ease-fast), background var(--ease-fast);
  text-align: center;
}

.form-upload:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-light);
}

.form-upload input[type="file"] {
  display: none;
}

/* Form actions */
.form-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border-subtle);
  margin-top: var(--space-4);
}

/* ══════════════════════════════════════════
   TABLE
══════════════════════════════════════════ */
.table-wrapper {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.table {
  width: 100%;
  border-collapse: collapse;
  margin: 0;
}

.table th {
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: var(--text-sm);
  vertical-align: middle;
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover td {
  background: var(--surface-subtle);
}

/* Mobile card fallback */
@media (max-width: 768px) {
  .table-mobile-cards thead {
    display: none;
  }

  .table-mobile-cards,
  .table-mobile-cards tbody,
  .table-mobile-cards tr,
  .table-mobile-cards td {
    display: block;
    width: 100%;
  }

  .table-mobile-cards tr {
    background: var(--surface-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    margin-bottom: var(--space-3);
    padding: var(--space-3);
  }

  .table-mobile-cards td {
    border: none;
    padding: var(--space-1) 0;
    text-align: left !important;
    font-size: var(--text-sm);
  }

  .table-mobile-cards td::before {
    content: attr(data-label) ": ";
    font-weight: var(--weight-semibold);
    color: var(--text-secondary);
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: 0.04em;
  }
}

/* ══════════════════════════════════════════
   FILTER BAR
══════════════════════════════════════════ */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

.filter-bar .form-select,
.filter-bar .form-control {
  width: auto !important;
  min-width: 9rem;
  max-width: 13rem;
}

.filter-bar .filter-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  white-space: nowrap;
}

/* ══════════════════════════════════════════
   DROPDOWN MENU
══════════════════════════════════════════ */
.dropdown-menu {
  background: var(--surface-overlay);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-1);
  margin-top: var(--space-1);
  z-index: var(--z-dropdown);
  min-width: 12rem;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--ease-fast), color var(--ease-fast);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: start;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.dropdown-item.active {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

.dropdown-divider {
  border: none;
  border-top: 1px solid var(--border-default);
  margin: var(--space-1) 0;
}

.dropdown-header {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: var(--space-2) var(--space-3) var(--space-1);
}

/* ══════════════════════════════════════════
   ALERTS
══════════════════════════════════════════ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}

.alert-primary {
  background: var(--clr-violet-50);
  border-color: var(--clr-violet-200);
  color: var(--clr-violet-800);
}

.alert-success {
  background: var(--clr-green-50);
  border-color: var(--clr-green-100);
  color: var(--clr-green-700);
}

.alert-warning {
  background: var(--clr-yellow-50);
  border-color: var(--clr-yellow-100);
  color: var(--clr-yellow-900);
}

.alert-danger {
  background: var(--clr-red-50);
  border-color: var(--clr-red-100);
  color: var(--clr-red-700);
}

.alert-info {
  background: var(--clr-cyan-50);
  border-color: var(--clr-cyan-100);
  color: var(--clr-cyan-900);
}

.alert-secondary {
  background: var(--clr-slate-50);
  border-color: var(--clr-slate-200);
  color: var(--clr-slate-700);
}

/* ══════════════════════════════════════════
   MODAL
══════════════════════════════════════════ */
.modal-content {
  background: var(--surface-overlay);
  border: none;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-2xl);
  overflow: hidden;
}

.modal-header {
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-default);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
}

.modal-body {
  padding: var(--space-6);
  color: var(--text-primary);
}

.modal-footer {
  background: var(--surface-subtle);
  border-top: 1px solid var(--border-default);
  padding: var(--space-4) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

/* ══════════════════════════════════════════
   PROGRESS BAR
══════════════════════════════════════════ */
.progress {
  height: 0.5rem;
  background: var(--surface-muted);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.progress-bar {
  background: var(--brand-primary);
  border-radius: var(--radius-pill);
  transition: width var(--ease-slow);
}

.progress-bar.bg-success { background: var(--brand-success); }
.progress-bar.bg-warning { background: var(--brand-warning); }
.progress-bar.bg-danger  { background: var(--brand-danger); }
.progress-bar.bg-info    { background: var(--brand-info); }

/* ══════════════════════════════════════════
   PAGINATION
══════════════════════════════════════════ */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  padding: 0;
  margin: 0;
}

.page-item .page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  text-decoration: none;
  transition: background var(--ease-fast), color var(--ease-fast), border-color var(--ease-fast);
}

.page-item .page-link:hover {
  background: var(--surface-subtle);
  color: var(--text-primary);
}

.page-item.active .page-link {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-inverse);
}

.page-item.disabled .page-link {
  background: var(--surface-subtle);
  color: var(--text-muted);
  pointer-events: none;
  border-color: var(--border-default);
}

/* ══════════════════════════════════════════
   TABS
══════════════════════════════════════════ */
.nav-tabs {
  border-bottom: 2px solid var(--border-default);
  gap: var(--space-1);
  display: flex;
  flex-wrap: wrap;
}

.nav-tabs .nav-link {
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  border-radius: 0;
  background: transparent;
  transition: color var(--ease-fast), border-color var(--ease-fast);
  text-decoration: none;
}

.nav-tabs .nav-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-strong);
}

.nav-tabs .nav-link.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

/* Pills */
.nav-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.nav-pills .nav-link {
  padding: var(--space-1) var(--space-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  border-radius: var(--radius-pill);
  background: transparent;
  transition: background var(--ease-fast), color var(--ease-fast);
  text-decoration: none;
}

.nav-pills .nav-link:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

.nav-pills .nav-link.active {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

/* ══════════════════════════════════════════
   STEPPER
══════════════════════════════════════════ */
.stepper {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.stepper-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  position: relative;
}

.stepper-step + .stepper-step::before {
  content: '';
  position: absolute;
  top: 1rem;
  right: 50%;
  width: 100%;
  height: 2px;
  background: var(--border-default);
  z-index: var(--z-base);
}

.stepper-step.done + .stepper-step::before,
.stepper-step.active + .stepper-step::before {
  background: var(--brand-primary);
}

.stepper-icon {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-pill);
  background: var(--surface-muted);
  border: 2px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
  position: relative;
  z-index: var(--z-raised);
  transition: background var(--ease-fast), border-color var(--ease-fast), color var(--ease-fast);
}

.stepper-step.active .stepper-icon {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: var(--text-inverse);
}

.stepper-step.done .stepper-icon {
  background: var(--brand-success);
  border-color: var(--brand-success);
  color: var(--text-inverse);
}

.stepper-label {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-muted);
  text-align: center;
}

.stepper-step.active .stepper-label {
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

.stepper-step.done .stepper-label {
  color: var(--brand-success);
}

/* ══════════════════════════════════════════
   KANBAN
══════════════════════════════════════════ */
.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-4);
}

.kanban-column {
  flex: 0 0 17rem;
  background: var(--surface-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.kanban-column-header {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  padding: 0 0 var(--space-2);
  border-bottom: 1px solid var(--border-default);
  margin-bottom: var(--space-1);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kanban-card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  cursor: grab;
  transition: box-shadow var(--ease-fast);
}

.kanban-card:hover {
  box-shadow: var(--shadow-md);
}

/* ══════════════════════════════════════════
   SCHEDULE SLOT
══════════════════════════════════════════ */
.schedule-slot {
  background: var(--brand-primary-light);
  border-left: 3px solid var(--brand-primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--brand-primary);
}

.schedule-slot.success {
  background: var(--clr-green-50);
  border-left-color: var(--brand-success);
  color: var(--brand-success);
}

.schedule-slot.warning {
  background: var(--clr-yellow-50);
  border-left-color: var(--brand-warning);
  color: var(--clr-yellow-600);
}

.schedule-slot.danger {
  background: var(--clr-red-50);
  border-left-color: var(--brand-danger);
  color: var(--brand-danger);
}

/* ══════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-12) var(--space-8);
  color: var(--text-muted);
}

.empty-state-icon {
  width: 4rem;
  height: 4rem;
  margin-bottom: var(--space-4);
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-secondary);
  margin-bottom: var(--space-2);
}

.empty-state-body {
  font-size: var(--text-sm);
  color: var(--text-muted);
  max-width: 28rem;
  margin-bottom: var(--space-6);
}

/* ══════════════════════════════════════════
   BOOTSTRAP OVERRIDES
══════════════════════════════════════════ */
.text-primary  { color: var(--brand-primary)  !important; }
.text-success  { color: var(--brand-success)  !important; }
.text-warning  { color: var(--brand-warning)  !important; }
.text-danger   { color: var(--brand-danger)   !important; }
.text-info     { color: var(--brand-info)     !important; }
.text-muted    { color: var(--text-muted)     !important; }
.text-secondary{ color: var(--text-secondary) !important; }

.bg-primary   { background-color: var(--brand-primary) !important; }
.bg-success   { background-color: var(--brand-success) !important; }
.bg-warning   { background-color: var(--brand-warning) !important; }
.bg-danger    { background-color: var(--brand-danger)  !important; }
.bg-info      { background-color: var(--brand-info)    !important; }
.bg-light     { background-color: var(--surface-subtle)!important; }

.border-primary { border-color: var(--brand-primary) !important; }

.rounded    { border-radius: var(--radius-md)  !important; }
.rounded-sm { border-radius: var(--radius-sm)  !important; }
.rounded-lg { border-radius: var(--radius-xl)  !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow    { box-shadow: var(--shadow-md) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

/* Bootstrap form-control min-height fix */
.form-control,
.form-select {
  min-height: 2.25rem;
}

/* ══════════════════════════════════════════
   SELECT2 OVERRIDES
══════════════════════════════════════════ */
.select2-container--bootstrap-5 .select2-selection {
  border-color: var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
  background: var(--surface-input);
}

.select2-container--bootstrap-5.select2-container--focus .select2-selection,
.select2-container--bootstrap-5.select2-container--open .select2-selection {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}

.select2-container--bootstrap-5 .select2-dropdown {
  border-color: var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  background: var(--surface-overlay);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
}

.select2-container--bootstrap-5 .select2-results__option--highlighted[aria-selected] {
  background-color: var(--brand-primary);
  color: var(--text-inverse);
}

.select2-container--bootstrap-5 .select2-results__option[aria-selected="true"] {
  background-color: var(--brand-primary-light);
  color: var(--brand-primary);
}

.select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__choice {
  background: var(--brand-primary);
  border: none;
  color: var(--text-inverse);
  border-radius: var(--radius-xs);
  font-size: var(--text-xs);
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field {
  border-color: var(--border-default);
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.select2-container--bootstrap-5 .select2-search--dropdown .select2-search__field:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* ══════════════════════════════════════════
   ACCOUNTING — SHARED PAGE COMPONENTS
   (stat-card, modern-card, modern-table,
    badge-modern-*, btn-icon, btn-expand,
    account-name, account-code, modern-input)
══════════════════════════════════════════ */

.modern-page-header { margin-bottom: 2rem; }

/* Stat Cards */
.stat-card {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  border: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  gap: var(--space-4);
  transition: all var(--ease-base);
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card-icon {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card-primary .stat-card-icon {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.stat-card-warning .stat-card-icon {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #fff;
}
.stat-card-success .stat-card-icon {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: #fff;
}
.stat-card-danger .stat-card-icon {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  color: #fff;
}
.stat-card-content { flex: 1; }
.stat-card-label {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin-bottom: var(--space-1);
  font-weight: var(--weight-medium);
}
.stat-card-value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  margin: 0;
  color: var(--text-primary);
}

/* Modern Card (accounting pages) */
.modern-card {
  background: var(--surface-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-default);
  overflow: hidden;
}
.modern-card-header {
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-subtle);
}
.modern-card-body { padding: var(--space-6); }

/* Modern Table (accounting pages) */
.modern-table { font-size: 0.9rem; }
.modern-table thead th {
  background: var(--surface-subtle);
  color: var(--text-secondary);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 2px solid var(--border-default);
  padding: 0.875rem var(--space-4);
}
.modern-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  transition: background-color 0.15s;
}
.modern-table tbody tr:hover { background-color: var(--surface-subtle); }
.modern-table tbody td { padding: var(--space-4); vertical-align: middle; }
.modern-table tfoot th {
  background: var(--surface-subtle);
  border-top: 2px solid var(--border-default);
  padding: var(--space-4);
}

/* Account row indentation levels */
.account-row[data-level="0"] { background-color: rgba(0,0,0,0.01); }
.account-row[data-level="1"] { background-color: rgba(0,0,0,0.02); }
.account-row[data-level="2"] { background-color: rgba(0,0,0,0.03); }

/* Expand button */
.btn-expand {
  background: none;
  border: none;
  padding: 0;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--ease-fast);
}
.btn-expand:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}

/* Account code */
.account-code {
  background: var(--surface-subtle);
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

/* Account name */
.account-name { color: var(--text-primary); }

/* Account-type badges (badge-modern-*) */
.badge-modern {
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  display: inline-block;
}
.badge-modern-primary {
  background: var(--clr-violet-100);
  color: var(--clr-violet-700);
}
.badge-modern-warning {
  background: var(--clr-yellow-100);
  color: var(--clr-yellow-600);
}
.badge-modern-info {
  background: #dbeafe;
  color: #1d4ed8;
}
.badge-modern-success {
  background: var(--clr-green-100);
  color: var(--clr-green-700);
}
.badge-modern-danger {
  background: var(--clr-red-100);
  color: var(--clr-red-700);
}

/* Group and subtype badges */
.badge-group {
  background: var(--surface-muted);
  color: var(--text-muted);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
.badge-subtype {
  background: var(--clr-violet-100);
  color: var(--clr-violet-700);
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: var(--weight-medium);
}

/* Icon action buttons */
.btn-icon {
  border: none;
  background: var(--surface-subtle);
  color: var(--text-secondary);
  padding: 0.375rem 0.5rem;
  border-radius: var(--radius-md);
  transition: all var(--ease-fast);
}
.btn-icon:hover {
  background: var(--surface-muted);
  color: var(--text-primary);
}
.btn-icon-danger:hover {
  background: var(--clr-red-100);
  color: var(--brand-danger);
}

/* Modern form input */
.modern-input {
  border: 1px solid var(--border-default);
  background: var(--surface-input);
  color: var(--text-primary);
  border-radius: var(--radius-lg);
  padding: 0.625rem 0.875rem;
  transition: border-color var(--ease-fast), box-shadow var(--ease-fast);
}
.modern-input:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* ══════════════════════════════════════════
   DARK MODE — GLOBAL BOOTSTRAP OVERRIDES
══════════════════════════════════════════ */

[data-theme="dark"] {
  color-scheme: dark;
  background-color: var(--surface-page);
  color: var(--text-primary);
}

/* ── Body & page ── */
[data-theme="dark"] body {
  background-color: var(--surface-page);
  color: var(--text-primary);
}

/* ── Cards ── */
[data-theme="dark"] .card {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .card-header,
[data-theme="dark"] .card-header.bg-white,
[data-theme="dark"] .card-header.bg-light,
[data-theme="dark"] .card-footer,
[data-theme="dark"] .card-footer.bg-white,
[data-theme="dark"] .card-footer.bg-light {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .card-body { color: var(--text-primary); }
[data-theme="dark"] .card-title { color: var(--text-primary) !important; }
[data-theme="dark"] .card-subtitle,
[data-theme="dark"] .card-text { color: var(--text-secondary); }

/* ── Bootstrap utility overrides ── */
[data-theme="dark"] .bg-white  { background-color: var(--surface-card) !important; color: var(--text-primary) !important; }
[data-theme="dark"] .bg-light  { background-color: var(--surface-raised)  !important; }
[data-theme="dark"] .text-dark { color: var(--text-primary) !important; }
[data-theme="dark"] .border,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-end,
[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-start { border-color: var(--border-default) !important; }
[data-theme="dark"] .border-light { border-color: var(--border-subtle) !important; }
[data-theme="dark"] .shadow-sm    { box-shadow: 0 1px 4px rgba(0,0,0,.4) !important; }

/* ── Headings & text ── */
[data-theme="dark"] h1,[data-theme="dark"] h2,[data-theme="dark"] h3,
[data-theme="dark"] h4,[data-theme="dark"] h5,[data-theme="dark"] h6 {
  color: var(--text-primary);
}
[data-theme="dark"] p     { color: var(--text-primary); }
[data-theme="dark"] label { color: var(--text-primary); }
[data-theme="dark"] .text-muted     { color: var(--text-muted)     !important; }
[data-theme="dark"] .text-secondary { color: var(--text-secondary) !important; }
[data-theme="dark"] small { color: var(--text-secondary); }

/* ── Tables ── */
[data-theme="dark"] .table {
  --bs-table-bg:            var(--surface-card);
  --bs-table-color:         var(--text-primary);
  --bs-table-border-color:  var(--border-subtle);
  --bs-table-striped-bg:    var(--surface-raised);
  --bs-table-striped-color: var(--text-primary);
  --bs-table-hover-bg:      var(--surface-raised);
  --bs-table-hover-color:   var(--text-primary);
  color: var(--text-primary) !important;
  border-color: var(--border-subtle) !important;
}
[data-theme="dark"] .table thead th,
[data-theme="dark"] .table > thead > tr > th {
  color: var(--text-secondary) !important;
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .table td,
[data-theme="dark"] .table > tbody > tr > td {
  border-color: var(--border-subtle) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .table-light {
  --bs-table-bg: var(--surface-raised);
  --bs-table-color: var(--text-primary);
  --bs-table-border-color: var(--border-default);
}
[data-theme="dark"] .table-responsive { border-color: var(--border-default) !important; }

/* ── Form controls ── */
[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
  background-color: var(--surface-input) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .form-control:focus,
[data-theme="dark"] .form-select:focus {
  background-color: var(--surface-input) !important;
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 0.2rem rgba(167,139,250,0.2) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .form-control::placeholder { color: var(--text-muted) !important; }
[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-select:disabled {
  background-color: var(--surface-subtle) !important;
  color: var(--text-muted) !important;
}
[data-theme="dark"] .input-group-text {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .form-check-label { color: var(--text-primary); }
[data-theme="dark"] .form-text { color: var(--text-muted) !important; }
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="time"],
[data-theme="dark"] input[type="datetime-local"] { color-scheme: dark; }

/* ── Dropdown menus (general) ── */
[data-theme="dark"] .dropdown-menu {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .dropdown-item { color: var(--text-primary) !important; }
[data-theme="dark"] .dropdown-item:hover,
[data-theme="dark"] .dropdown-item:focus {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .dropdown-divider  { border-color: var(--border-default) !important; }
[data-theme="dark"] .dropdown-header   { color: var(--text-muted) !important; }
[data-theme="dark"] .dropdown-item.active,
[data-theme="dark"] .dropdown-item:active {
  background-color: var(--brand-primary) !important;
  color: #fff !important;
}

/* ── Modals ── */
[data-theme="dark"] .modal-content {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary);
}
[data-theme="dark"] .modal-header {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .modal-footer {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .modal-title { color: var(--text-primary) !important; }
[data-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ── Nav tabs / pills ── */
[data-theme="dark"] .nav-tabs { border-color: var(--border-default) !important; }
[data-theme="dark"] .nav-tabs .nav-link {
  color: var(--text-secondary) !important;
  border-color: transparent !important;
}
[data-theme="dark"] .nav-tabs .nav-link:hover {
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .nav-tabs .nav-link.active,
[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) var(--border-default) var(--surface-card) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .nav-pills .nav-link { color: var(--text-secondary) !important; }
[data-theme="dark"] .nav-pills .nav-link.active {
  background-color: var(--brand-primary) !important;
  color: #fff !important;
}
[data-theme="dark"] .tab-content > .tab-pane { color: var(--text-primary); }

/* ── List groups ── */
[data-theme="dark"] .list-group-item {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .list-group-item-action:hover,
[data-theme="dark"] .list-group-item-action:focus {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .list-group-item.active {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: #fff !important;
}

/* ── Badges ── */
[data-theme="dark"] .badge.bg-light,
[data-theme="dark"] .badge.text-bg-light {
  background-color: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .badge.bg-secondary { background-color: var(--surface-raised) !important; color: var(--text-secondary) !important; }
[data-theme="dark"] .badge.text-dark { color: var(--text-primary) !important; }

/* ── Alerts ── */
[data-theme="dark"] .alert { border-color: var(--border-default) !important; }
[data-theme="dark"] .alert-light,
[data-theme="dark"] .alert-secondary {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}

/* ── Breadcrumbs ── */
[data-theme="dark"] .breadcrumb-item,
[data-theme="dark"] .breadcrumb-item > a { color: var(--text-secondary) !important; }
[data-theme="dark"] .breadcrumb-item.active { color: var(--text-muted) !important; }
[data-theme="dark"] .breadcrumb-item + .breadcrumb-item::before { color: var(--text-muted) !important; }

/* ── Pagination ── */
[data-theme="dark"] .page-link {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .page-link:hover {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .page-item.disabled .page-link {
  background-color: var(--surface-card) !important;
  border-color: var(--border-subtle) !important;
  color: var(--text-muted) !important;
}
[data-theme="dark"] .page-item.active .page-link {
  background-color: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: #fff !important;
}

/* ── Accordion ── */
[data-theme="dark"] .accordion-item {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .accordion-button {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .accordion-button:not(.collapsed) {
  background-color: var(--surface-card) !important;
  color: var(--brand-primary) !important;
}
[data-theme="dark"] .accordion-button::after { filter: invert(0.8); }
[data-theme="dark"] .accordion-body {
  background-color: var(--surface-card) !important;
  color: var(--text-primary) !important;
}

/* ── Progress ── */
[data-theme="dark"] .progress { background-color: var(--surface-raised) !important; }

/* ── Offcanvas ── */
[data-theme="dark"] .offcanvas {
  background-color: var(--surface-card) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .offcanvas-header { border-color: var(--border-default) !important; }

/* ── Toast ── */
[data-theme="dark"] .toast {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .toast-header {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}

/* ── Popovers & Tooltips ── */
[data-theme="dark"] .popover {
  background-color: var(--surface-card) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .popover-header {
  background-color: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .popover-body { color: var(--text-primary) !important; }
[data-theme="dark"] .tooltip-inner {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}

/* ── Select2 dark mode ── */
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection {
  background-color: var(--surface-input) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection__rendered {
  color: var(--text-primary) !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection__placeholder {
  color: var(--text-muted) !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-search__field {
  background-color: var(--surface-input) !important;
  color: var(--text-primary) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option {
  color: var(--text-primary) !important;
  background-color: var(--surface-card) !important;
}
[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
  background-color: var(--brand-primary) !important;
  color: #fff !important;
}

/* ── Horizontal rules ── */
[data-theme="dark"] hr { border-color: var(--border-default) !important; opacity: 1; }

/* ── Code & pre ── */
[data-theme="dark"] code {
  background-color: var(--surface-raised);
  color: #a78bfa;
  border-radius: 4px;
  padding: 1px 5px;
}
[data-theme="dark"] pre {
  background-color: var(--surface-raised) !important;
  color: var(--text-primary);
  border-color: var(--border-default) !important;
}

/* ══════════════════════════════════════════
   DARK MODE — ACCOUNTING COMPONENT OVERRIDES
   (badge-modern, badge-group, badge-subtype,
    btn-icon, btn-expand, account-name,
    modern-card, modern-table, ledger styles)
══════════════════════════════════════════ */

/* Modern card (used in chart_of_accounts & ledger) */
[data-theme="dark"] .modern-card {
  background: var(--surface-card) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .modern-card-header {
  background: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .modern-card-body { background: var(--surface-card) !important; }

/* Modern table */
[data-theme="dark"] .modern-table thead th {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .modern-table tbody tr {
  border-color: var(--border-subtle) !important;
}
[data-theme="dark"] .modern-table tbody tr:hover {
  background-color: var(--surface-raised) !important;
}
[data-theme="dark"] .modern-table tfoot th {
  background: var(--surface-raised) !important;
  border-color: var(--border-default) !important;
}

/* Account name & code */
[data-theme="dark"] .account-name { color: var(--text-primary) !important; }
[data-theme="dark"] .account-code {
  background: var(--surface-raised) !important;
  color: #a78bfa !important;
}

/* Expand button */
[data-theme="dark"] .btn-expand {
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .btn-expand:hover {
  background: var(--surface-raised) !important;
  color: var(--text-primary) !important;
}

/* Icon buttons */
[data-theme="dark"] .btn-icon {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
  border-color: transparent !important;
}
[data-theme="dark"] .btn-icon:hover {
  background: var(--border-default) !important;
  color: var(--text-primary) !important;
}
[data-theme="dark"] .btn-icon-danger:hover {
  background: rgba(239,68,68,0.15) !important;
  color: var(--brand-danger) !important;
}

/* Account type badges (badge-modern-*) */
[data-theme="dark"] .badge-modern-primary {
  background: rgba(109,40,217,0.25) !important;
  color: #c4b5fd !important;
}
[data-theme="dark"] .badge-modern-warning {
  background: rgba(217,119,6,0.25) !important;
  color: #fcd34d !important;
}
[data-theme="dark"] .badge-modern-info {
  background: rgba(29,78,216,0.25) !important;
  color: #93c5fd !important;
}
[data-theme="dark"] .badge-modern-success {
  background: rgba(5,150,105,0.25) !important;
  color: #6ee7b7 !important;
}
[data-theme="dark"] .badge-modern-danger {
  background: rgba(220,38,38,0.25) !important;
  color: #fca5a5 !important;
}

/* Group & subtype badges */
[data-theme="dark"] .badge-group {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .badge-subtype {
  background: rgba(67,56,202,0.2) !important;
  color: #a5b4fc !important;
}

/* Badge reference (ledger) */
[data-theme="dark"] .badge-reference {
  background: rgba(67,56,202,0.2) !important;
  color: #a5b4fc !important;
}

/* Ledger info cards */
[data-theme="dark"] .ledger-info-card {
  background: var(--surface-card) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .ledger-info-icon {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] .ledger-info-label { color: var(--text-muted) !important; }
[data-theme="dark"] .ledger-info-value { color: var(--text-primary) !important; }

/* Stat cards (ledger & chart_of_accounts) */
[data-theme="dark"] .stat-card {
  background: var(--surface-card) !important;
  border-color: var(--border-default) !important;
}
[data-theme="dark"] .stat-card-label { color: var(--text-muted) !important; }
[data-theme="dark"] .stat-card-value { color: var(--text-primary) !important; }

/* Ledger total row */
[data-theme="dark"] .ledger-total-row {
  background: var(--surface-raised) !important;
}
[data-theme="dark"] .ledger-total-row th { color: var(--text-primary) !important; }

/* Entry number code */
[data-theme="dark"] .entry-number {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
}

/* Transaction description */
[data-theme="dark"] .transaction-description strong { color: var(--text-primary) !important; }

/* Modern input */
[data-theme="dark"] .modern-input {
  background: var(--surface-input) !important;
  border-color: var(--border-default) !important;
  color: var(--text-primary) !important;
}

/* Trial balance section header rows */
[data-theme="dark"] tr[style*="background:#f5f0ff"],
[data-theme="dark"] tr[style*="background:#f5f0ff"] td {
  background: var(--surface-raised) !important;
  color: var(--text-secondary) !important;
}
[data-theme="dark"] tfoot tr[style*="background:#f0ebf8"],
[data-theme="dark"] tfoot tr[style*="background:#f0ebf8"] td {
  background: var(--surface-raised) !important;
}

/* Daily sales report total row */
[data-theme="dark"] .total-row td { background: var(--surface-raised) !important; }

/* Daily sales report KPI cards */
[data-theme="dark"] .dsr-kpi { background: var(--surface-card) !important; }
[data-theme="dark"] .bar-track { background: var(--border-default) !important; }

/* Expenses page stat value */
[data-theme="dark"] .stat-value { color: var(--text-primary) !important; }

/* ══════════════════════════════════════════
   MODERN TRAINLY UI — EXTENDED COMPONENTS
══════════════════════════════════════════ */

/* ── Page Header Icon ── */
.page-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: var(--radius-lg);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  flex-shrink: 0;
}

.page-header-title {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Card Header Icon ── */
.card-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-md);
  background: var(--brand-primary-light);
  color: var(--brand-primary);
  flex-shrink: 0;
}

/* ── Select as form-control ── */
select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  padding-right: var(--space-8);
  cursor: pointer;
}

/* ── Tab Buttons ── */
.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--ease-fast), border-color var(--ease-fast);
  white-space: nowrap;
  text-decoration: none;
}

.tab-btn:hover {
  color: var(--text-primary);
  border-bottom-color: var(--border-strong);
}

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: var(--weight-semibold);
}

/* ── Status Badge ── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  padding: 0.3em 0.65em;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
}

.status-badge-active,
.status-badge-success {
  background: var(--clr-green-100);
  color: var(--clr-green-700);
  border-color: var(--clr-green-100);
}

.status-badge-inactive,
.status-badge-secondary {
  background: var(--clr-slate-100);
  color: var(--clr-slate-600);
  border-color: var(--clr-slate-200);
}

.status-badge-pending,
.status-badge-warning {
  background: var(--clr-yellow-100);
  color: var(--clr-yellow-900);
  border-color: var(--clr-yellow-100);
}

.status-badge-danger,
.status-badge-error {
  background: var(--clr-red-100);
  color: var(--clr-red-700);
  border-color: var(--clr-red-100);
}

.status-badge-info {
  background: var(--clr-cyan-100);
  color: var(--clr-cyan-900);
  border-color: var(--clr-cyan-100);
}

/* ── Ghost Button ── */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

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

.btn-ghost:focus {
  box-shadow: var(--shadow-focus);
  outline: none;
}

/* ── Optional Toggle ── */
.optional-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  transition: background var(--ease-fast), color var(--ease-fast);
  user-select: none;
}

.optional-toggle:hover {
  background: var(--surface-muted);
  color: var(--brand-primary);
}

.optional-toggle input[type="checkbox"] {
  accent-color: var(--brand-primary);
  width: 1rem;
  height: 1rem;
  cursor: pointer;
}

/* ── Checkbox Row ── */
.checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--ease-fast);
  cursor: pointer;
}

.checkbox-row:hover {
  background: var(--surface-subtle);
}

.checkbox-row input[type="checkbox"] {
  accent-color: var(--brand-primary);
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-row .checkbox-row-label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  flex: 1;
}

.checkbox-row .checkbox-row-hint {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 0.1rem;
}

/* ── Sticky Footer ── */
.sticky-footer {
  position: sticky;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface-card);
  border-top: 1px solid var(--border-default);
  padding: var(--space-3) var(--space-6);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  z-index: var(--z-sticky);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
}

/* ── Topnav Refinements ── */
.topnav {
  height: var(--navbar-height);
  background: var(--purple, #6C3FC5);
  box-shadow: var(--shadow-sm);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-fixed);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-3);
}

.topnav .topnav-brand {
  font-family: var(--font-sans);
  font-weight: var(--weight-bold);
  font-size: var(--text-lg);
  color: var(--clr-white);
  text-decoration: none;
  flex-shrink: 0;
}

.topnav .topnav-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1;
}

.topnav .topnav-link {
  color: var(--clr-white-85);
  font-weight: var(--weight-medium);
  font-size: var(--text-sm);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-3);
  text-decoration: none;
  transition: background var(--ease-fast), color var(--ease-fast);
  white-space: nowrap;
}

.topnav .topnav-link:hover,
.topnav .topnav-link.active {
  background: var(--clr-white-15);
  color: var(--clr-white);
}

.topnav .topnav-link.active {
  font-weight: var(--weight-semibold);
}

.topnav .topnav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

/* ══════════════════════════════════════════
   LIST PAGE STANDARD — shared utility classes
   Used across all list/index pages for a unified look
══════════════════════════════════════════ */

/* Avatar initials circle (cycling 5-color palette) */
.list-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
.list-avatar-0 { background: #eef2ff; color: #4f46e5; }
.list-avatar-1 { background: #eafaf1; color: #0d9488; }
.list-avatar-2 { background: #f0fdf4; color: #16a34a; }
.list-avatar-3 { background: #fffbeb; color: #d97706; }
.list-avatar-4 { background: #fff1f2; color: #e11d48; }

/* Purple-tinted inline code / ID label */
.list-code {
  color: #7c3aed;
  background: rgba(124, 58, 237, 0.08);
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 11px;
  font-family: var(--font-mono, ui-monospace, monospace);
  font-weight: 600;
  white-space: nowrap;
}

/* Standardized status pill badges */
.badge-status-active,
.badge-status-approved,
.badge-status-paid,
.badge-status-posted {
  background: rgba(16, 185, 129, 0.1);
  color: #059669;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-inactive,
.badge-status-draft {
  background: #f3f4f6;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-pending {
  background: rgba(245, 158, 11, 0.1);
  color: #d97706;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-overdue,
.badge-status-rejected,
.badge-status-cancelled,
.badge-status-canceled {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-invited,
.badge-status-enrolled,
.badge-status-partial,
.badge-status-installments {
  background: rgba(124, 58, 237, 0.1);
  color: #7c3aed;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-transferred {
  background: rgba(59, 130, 246, 0.1);
  color: rgb(37, 99, 235);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}
.badge-status-completed {
  background: rgba(100, 116, 139, 0.12);
  color: rgb(71, 85, 105);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Standard table column header */
.th-std {
  font-size: 11px !important;
  font-weight: 700 !important;
  text-transform: uppercase !important;
  letter-spacing: .5px !important;
  color: #6b7280 !important;
}

/* Compact icon action buttons */
.act-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  flex-shrink: 0;
}
.act-btn-label {
  width: auto;
  padding: 0 10px;
  gap: 5px;
}
.act-btn-text {
  font-size: 12px;
  font-weight: 600;
  font-family: 'Figtree', sans-serif;
  letter-spacing: .01em;
}
.act-btn:hover { background: #f3f4f6; color: #111827; }
.act-btn.view-btn  { background: #eef2ff; color: #6366f1; border-color: #c7d2fe; }
.act-btn.view-btn:hover  { background: #e0e7ff; color: #4f46e5; border-color: #a5b4fc; }
.act-btn.edit-btn  { background: #f0fdf9; color: #0d9488; border-color: #99f6e4; }
.act-btn.edit-btn:hover  { background: #ccfbf1; color: #0f766e; border-color: #5eead4; }
.act-btn.freeze-btn { background: #f0fdf9; color: #0d9488; border-color: #99f6e4; }
.act-btn.freeze-btn:hover { background: #ccfbf1; color: #0f766e; border-color: #5eead4; }
.act-btn.transfer-btn { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.act-btn.transfer-btn:hover { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }
.act-btn.del-btn   { background: #fff5f5; color: #ef4444; border-color: #fecaca; }
.act-btn.del-btn:hover   { background: #fef2f2; color: #dc2626; border-color: #fca5a5; }
.act-btn.warn-btn:hover  { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.act-btn.info-btn:hover  { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }

/* Ellipsis "..." row actions trigger */
.btn-row-actions {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #6b7280;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 15px;
  letter-spacing: 1px;
  line-height: 1;
  transition: all .15s;
}
.btn-row-actions:hover {
  background: #f3f4f6;
  color: #111827;
  border-color: #d1d5db;
}
.btn-row-actions.dropdown-toggle::after {
  display: none;
}

/* Dark mode support */
[data-theme="dark"] .list-avatar-0 { background: rgba(79,70,229,.18); color: #818cf8; }
[data-theme="dark"] .list-avatar-1 { background: rgba(13,148,136,.18); color: #2dd4bf; }
[data-theme="dark"] .list-avatar-2 { background: rgba(22,163,74,.18);  color: #4ade80; }
[data-theme="dark"] .list-avatar-3 { background: rgba(217,119,6,.18);  color: #fbbf24; }
[data-theme="dark"] .list-avatar-4 { background: rgba(225,29,72,.18);  color: #fb7185; }
[data-theme="dark"] .list-code     { color: #a78bfa; background: rgba(167,139,250,.15); }
[data-theme="dark"] .act-btn { background: #1e293b; border-color: #334155; color: #94a3b8; }
[data-theme="dark"] .act-btn:hover { background: #2d3f58; color: #e2e8f0; border-color: #475569; }
[data-theme="dark"] .act-btn.view-btn  { background: rgba(99,102,241,.18); color: #a5b4fc; border-color: rgba(99,102,241,.4); }
[data-theme="dark"] .act-btn.view-btn:hover  { background: rgba(99,102,241,.28); color: #c7d2fe; border-color: rgba(99,102,241,.6); }
[data-theme="dark"] .act-btn.edit-btn  { background: rgba(13,148,136,.15); color: #2dd4bf; border-color: rgba(13,148,136,.35); }
[data-theme="dark"] .act-btn.edit-btn:hover  { background: rgba(13,148,136,.25); color: #5eead4; border-color: rgba(13,148,136,.55); }
[data-theme="dark"] .act-btn.freeze-btn { background: rgba(13,148,136,.15); color: #2dd4bf; border-color: rgba(13,148,136,.35); }
[data-theme="dark"] .act-btn.freeze-btn:hover { background: rgba(13,148,136,.25); color: #5eead4; border-color: rgba(13,148,136,.55); }
[data-theme="dark"] .act-btn.transfer-btn { background: rgba(96,165,250,.15); color: #60a5fa; border-color: rgba(96,165,250,.35); }
[data-theme="dark"] .act-btn.transfer-btn:hover { background: rgba(96,165,250,.25); color: #93c5fd; border-color: rgba(96,165,250,.55); }
[data-theme="dark"] .act-btn.del-btn   { background: rgba(239,68,68,.15); color: #fca5a5; border-color: rgba(239,68,68,.35); }
[data-theme="dark"] .act-btn.del-btn:hover   { background: rgba(239,68,68,.25); color: #fca5a5; border-color: rgba(239,68,68,.55); }

/* Dark mode overrides for new components */
[data-theme="dark"] .sticky-footer {
  background: var(--surface-card);
  border-top-color: var(--border-default);
}

[data-theme="dark"] .card-header-icon,
[data-theme="dark"] .page-header-icon {
  background: var(--brand-primary-light);
}

[data-theme="dark"] .checkbox-row:hover,
[data-theme="dark"] .optional-toggle:hover {
  background: var(--surface-raised);
}
