/* ============================================================
   CRM - Dark Theme (based on BetPal design system)
   Font: Inter (Google Fonts)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --bg-900:     #0d0d14;
  --bg-800:     #12121f;
  --bg-700:     #1a1a2e;
  --bg-600:     #22223a;
  --bg-500:     #2a2a45;
  --bg-400:     #333355;

  --text:       #f1f1f5;
  --text-muted: rgba(255,255,255,.45);
  --text-subtle:rgba(255,255,255,.25);

  --border:       rgba(255,255,255,.08);
  --border-hover: rgba(255,255,255,.15);
  --border-focus: rgba(99,102,241,.6);

  --primary:       #6366f1;
  --primary-dark:  #4f46e5;
  --primary-light: #818cf8;
  --accent:        #10b981;
  --warning:       #f59e0b;
  --danger:        #ef4444;
  --info:          #3b82f6;
  --orange:        #f97316;

  --radius:     10px;
  --radius-sm:  6px;
  --radius-lg:  14px;
  --transition: all .18s ease;

  --sidebar-w:  240px;
  --sidebar-collapsed: 68px;
  --header-h:   60px;
}

/* ── Reset & Base ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-900);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary-light); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--text); }

h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; }

img { max-width: 100%; }

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

/* ── Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-800);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  transition: width .22s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--header-h);
  text-decoration: none;
}
.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-logo .logo-text {
  font-size: .95rem; font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}
.sidebar.collapsed .logo-text { display: none; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: .75rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-600) transparent;
}

.nav-section-label {
  font-size: .68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-subtle);
  padding: .5rem 1.25rem .25rem;
  white-space: nowrap;
}
.sidebar.collapsed .nav-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  margin: .1rem .5rem;
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  white-space: nowrap;
  position: relative;
}
.nav-item:hover {
  background: var(--bg-600);
  color: var(--text);
}
.nav-item.active {
  background: rgba(99,102,241,.15);
  color: var(--primary-light);
}
.nav-item.active .nav-icon { color: var(--primary); }
.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--text-subtle);
  transition: var(--transition);
}
.nav-item:hover .nav-icon { color: var(--text-muted); }
.nav-label { flex: 1; }
.sidebar.collapsed .nav-label { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: .55rem; margin: .1rem .5rem; }

.sidebar-footer {
  padding: .75rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ── Collapsible nav group ───────────────────────────────────── */
.nav-group-toggle {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  margin: .1rem .5rem;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  transition: var(--transition);
  background: none;
  border: none;
  width: calc(100% - 1rem);
  text-align: left;
}
.nav-group-toggle:hover { background: var(--bg-600); color: var(--text); }
.nav-group-toggle .nav-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--text-subtle); transition: var(--transition); }
.nav-group-toggle:hover .nav-icon { color: var(--text-muted); }
.nav-group-toggle .nav-label { flex: 1; }
.nav-group-chevron {
  width: 14px; height: 14px; flex-shrink: 0;
  color: var(--text-subtle);
  transition: transform .2s ease;
}
.nav-group-toggle.open .nav-group-chevron { transform: rotate(90deg); }
.nav-group-items {
  overflow: hidden;
  transition: max-height .22s ease;
}
.nav-group-items .nav-item {
  padding-left: 2.75rem;
  font-size: .84rem;
}
.sidebar.collapsed .nav-group-toggle { justify-content: center; padding: .55rem; margin: .1rem .5rem; }
.sidebar.collapsed .nav-group-toggle .nav-label,
.sidebar.collapsed .nav-group-chevron { display: none; }
.sidebar.collapsed .nav-group-items { display: none; }

/* ── Toggle button ───────────────────────────────────────────── */
.sidebar-toggle {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: .4rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.sidebar-toggle:hover { color: var(--text); background: var(--bg-600); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  transition: margin-left .22s ease;
  min-width: 0;
}
.main-content.sidebar-collapsed { margin-left: var(--sidebar-collapsed); }

/* ── Top Header ──────────────────────────────────────────────── */
.top-header {
  height: var(--header-h);
  background: var(--bg-800);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky; top: 0; z-index: 50;
}
.top-header .page-title { font-size: 1rem; font-weight: 600; }
.top-header .header-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

/* ── Page Body ───────────────────────────────────────────────── */
.page-body { padding: 1.75rem 2rem; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}
.card-header {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-actions { margin-left: auto; display: flex; gap: .5rem; }

.card-sm { padding: .875rem 1rem; }

/* ── Stat Cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background: rgba(99,102,241,.15); }
.stat-icon.green  { background: rgba(16,185,129,.15); }
.stat-icon.orange { background: rgba(249,115,22,.15); }
.stat-icon.red    { background: rgba(239,68,68,.15); }
.stat-icon.purple { background: rgba(168,85,247,.15); }
.stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1.1; margin-top: .1rem; }

/* ── Tabs ────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.tab-btn {
  background: none; border: none; cursor: pointer;
  padding: .7rem 1.25rem;
  color: var(--text-muted);
  font-size: .875rem; font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--bg-800);
  padding: .65rem 1rem;
  text-align: left;
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--text); }
tbody tr { border-bottom: 1px solid var(--border); transition: var(--transition); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.025); }
tbody td { padding: .75rem 1rem; vertical-align: middle; }
.th-sort-icon { display: inline-block; margin-left: .25rem; opacity: .5; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer; transition: var(--transition);
  text-decoration: none; line-height: 1;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }

.btn-danger { background: rgba(239,68,68,.15); color: #f87171; border-color: rgba(239,68,68,.3); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-warning { background: rgba(245,158,11,.15); color: #fbbf24; border-color: rgba(245,158,11,.3); }
.btn-warning:hover { background: var(--warning); color: #fff; }

.btn-secondary { background: var(--bg-600); color: var(--text-muted); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg-500); color: var(--text); }

.btn-outline { background: transparent; border-color: var(--border); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--border-hover); color: var(--text); background: var(--bg-600); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); padding: .4rem .6rem; }
.btn-ghost:hover { color: var(--text); background: var(--bg-600); }

.btn-sm { padding: .3rem .65rem; font-size: .8rem; }
.btn-lg { padding: .7rem 1.4rem; font-size: 1rem; }
.btn-icon { padding: .4rem; }

/* ── Forms ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block;
  font-size: .8rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin-bottom: .35rem;
}
.form-label .required { color: var(--danger); margin-left: .2rem; }
.form-control {
  width: 100%;
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .55rem .85rem;
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.15);
}
.form-control::placeholder { color: var(--text-subtle); }
.form-control:disabled { opacity: .5; cursor: not-allowed; }

textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

.form-hint { font-size: .75rem; color: var(--text-subtle); margin-top: .3rem; }
.form-error { font-size: .75rem; color: #f87171; margin-top: .3rem; }

.form-row {
  display: grid;
  gap: 1rem;
}
.form-row.cols-2 { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-row.cols-4 { grid-template-columns: repeat(4, 1fr); }

.form-section {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.form-section:last-child { border-bottom: none; margin-bottom: 0; }
.form-section-title {
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--text-subtle);
  margin-bottom: 1rem;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: .2rem .65rem;
  border-radius: 100px;
  font-size: .72rem; font-weight: 600;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge-success  { background: rgba(16,185,129,.15); color: #34d399; }
.badge-danger   { background: rgba(239,68,68,.15);  color: #f87171; }
.badge-warning  { background: rgba(245,158,11,.15); color: #fbbf24; }
.badge-info     { background: rgba(59,130,246,.15); color: #60a5fa; }
.badge-primary  { background: rgba(99,102,241,.15); color: #a5b4fc; }
.badge-orange   { background: rgba(249,115,22,.15); color: #fb923c; }
.badge-muted    { background: rgba(255,255,255,.07); color: var(--text-muted); }
.badge-purple   { background: rgba(168,85,247,.15); color: #c084fc; }

/* ── Alerts ──────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex; align-items: flex-start; gap: .5rem;
}
.alert-success { background: rgba(16,185,129,.1);  color: #34d399;  border: 1px solid rgba(16,185,129,.2); }
.alert-danger  { background: rgba(239,68,68,.1);   color: #f87171;  border: 1px solid rgba(239,68,68,.2); }
.alert-warning { background: rgba(245,158,11,.1);  color: #fbbf24;  border: 1px solid rgba(245,158,11,.2); }
.alert-info    { background: rgba(59,130,246,.1);  color: #60a5fa;  border: 1px solid rgba(59,130,246,.2); }

/* ── Modals ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity .18s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(8px);
  transition: transform .18s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 860px; }
.modal-header {
  display: flex; align-items: center;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1rem; font-weight: 600; }
.modal-close {
  margin-left: auto;
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem;
  transition: var(--transition); line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.25rem 1.5rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: .75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

/* ── Search & Filter bar ─────────────────────────────────────── */
.list-controls {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.search-input-wrap svg { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--text-subtle); width: 16px; }
.search-input { padding-left: 2.25rem !important; }

/* ── Tags ────────────────────────────────────────────────────── */
.tag-list { display: flex; flex-wrap: wrap; gap: .35rem; }
.tag-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .15rem .55rem;
  border-radius: 100px;
  font-size: .72rem; font-weight: 600;
  background: rgba(99,102,241,.15);
  color: var(--primary-light);
  border: 1px solid rgba(99,102,241,.2);
}
.tag-chip .tag-remove {
  background: none; border: none; cursor: pointer;
  color: inherit; opacity: .7; font-size: .85rem;
  line-height: 1; padding: 0; transition: var(--transition);
}
.tag-chip .tag-remove:hover { opacity: 1; }

/* ── Attachments ─────────────────────────────────────────────── */
.attachment-list { display: flex; flex-direction: column; gap: .5rem; }
.attachment-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .8rem;
}
.attachment-name { flex: 1; color: var(--text); }
.attachment-size { color: var(--text-subtle); font-size: .72rem; }

/* ── Custom Fields ───────────────────────────────────────────── */
.custom-fields-list { display: flex; flex-direction: column; gap: .5rem; }
.custom-field-row {
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem .75rem;
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.custom-field-name { font-size: .8rem; font-weight: 600; color: var(--text-muted); width: 35%; }
.custom-field-value { flex: 1; font-size: .875rem; }

/* ── Activity Feed ───────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 0; }
.activity-item {
  display: flex; gap: 1rem;
  padding: .875rem 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: .35rem;
  flex-shrink: 0;
}
.activity-dot.success { background: var(--accent); }
.activity-dot.danger  { background: var(--danger); }
.activity-dot.warning { background: var(--warning); }
.activity-content { flex: 1; min-width: 0; }
.activity-type { font-size: .875rem; font-weight: 600; }
.activity-date { font-size: .75rem; color: var(--text-muted); }
.activity-notes { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; }

/* ── Kanban Board ────────────────────────────────────────────── */
.kanban-board {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  align-items: flex-start;
}
.kanban-col {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 280px;
  flex-shrink: 0;
}
.kanban-col-header {
  display: flex; align-items: center;
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--border);
  gap: .5rem;
}
.kanban-col-title { font-size: .85rem; font-weight: 600; flex: 1; }
.kanban-col-total {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-light);
  letter-spacing: -.01em;
}
.kanban-col-add {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); transition: var(--transition);
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: var(--radius-sm);
}
.kanban-col-add:hover { color: var(--text); background: var(--bg-600); }
.kanban-cards {
  padding: .75rem;
  min-height: 80px;
  display: flex; flex-direction: column; gap: .5rem;
}
.kanban-card {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem;
  cursor: pointer;
  transition: var(--transition);
}
.kanban-card:hover { border-color: var(--border-hover); background: var(--bg-600); }
.kanban-card.dragging { opacity: .4; }
.kanban-card-title { font-size: .85rem; font-weight: 600; margin-bottom: .35rem; }
.kanban-card-meta { display: flex; align-items: center; justify-content: space-between; }
.kanban-card-value { font-size: .8rem; color: var(--accent); font-weight: 600; }
.sortable-ghost { opacity: .2; background: var(--bg-500) !important; }

/* ── Invoice line items table ────────────────────────────────── */
.line-items-table { width: 100%; font-size: .875rem; }
.line-items-table th {
  background: var(--bg-800);
  padding: .5rem .75rem;
  text-align: left;
  font-size: .72rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted);
}
.line-items-table td { padding: .4rem .75rem; vertical-align: middle; }
.line-items-table tbody tr { border-bottom: 1px solid var(--border); }
.line-items-table .form-control { padding: .35rem .6rem; font-size: .85rem; }
.invoice-totals { max-width: 340px; margin-left: auto; margin-top: 1rem; }
.invoice-totals td { padding: .35rem .5rem; font-size: .875rem; }
.invoice-totals .total-row td { font-size: 1rem; font-weight: 700; border-top: 2px solid var(--border); padding-top: .65rem; }

/* ── Select2 Dark Overrides ──────────────────────────────────── */
.select2-container { font-family: 'Inter', sans-serif; }

.select2-container--default .select2-selection--single {
  background-color: #12121f !important;
  border: 1px solid rgba(255,255,255,.08) !important;
  border-radius: 6px !important;
  height: 38px !important;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.select2-container--default.select2-container--focus .select2-selection--single,
.select2-container--default.select2-container--open .select2-selection--single {
  border-color: #6366f1 !important;
  box-shadow: 0 0 0 3px rgba(99,102,241,.15) !important;
  outline: none !important;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  color: #f1f1f5 !important;
  line-height: 36px !important;
  padding-left: .85rem !important;
  padding-right: 2rem !important;
}
.select2-container--default .select2-selection--single .select2-selection__placeholder {
  color: rgba(255,255,255,.25) !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px !important;
  right: .5rem !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow b {
  border-color: rgba(255,255,255,.4) transparent transparent transparent !important;
}
.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b {
  border-color: transparent transparent rgba(255,255,255,.4) transparent !important;
}
.select2-container--default .select2-selection--single .select2-selection__clear {
  color: rgba(255,255,255,.4);
  margin-right: 1.2rem;
}
/* Dropdown portal (appends to body) */
.select2-dropdown {
  background-color: #1a1a2e !important;
  border: 1px solid rgba(255,255,255,.1) !important;
  border-radius: 6px !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.5) !important;
  color: #f1f1f5;
}
.select2-container--default .select2-search--dropdown {
  padding: .5rem .5rem .25rem;
  background: #1a1a2e;
}
.select2-container--default .select2-search--dropdown .select2-search__field {
  background-color: #12121f !important;
  border: 1px solid rgba(255,255,255,.1) !important;
  color: #f1f1f5 !important;
  border-radius: 6px !important;
  padding: .4rem .65rem !important;
  outline: none !important;
  width: 100%;
  font-family: 'Inter', sans-serif;
  font-size: .875rem;
}
.select2-container--default .select2-search--dropdown .select2-search__field::placeholder {
  color: rgba(255,255,255,.3);
}
.select2-results__options { background-color: #1a1a2e !important; }
.select2-container--default .select2-results__option {
  padding: .5rem .85rem !important;
  color: rgba(255,255,255,.65) !important;
  font-size: .875rem !important;
  background-color: transparent !important;
  transition: background .12s ease;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
  background-color: #6366f1 !important;
  color: #fff !important;
}
.select2-container--default .select2-results__option[aria-selected=true] {
  background-color: rgba(99,102,241,.15) !important;
  color: #a5b4fc !important;
}
.select2-container--default .select2-results__message,
.select2-results__option--loading {
  color: rgba(255,255,255,.4) !important;
  font-size: .825rem !important;
  padding: .5rem .85rem !important;
}

/* ── Flatpickr Dark ──────────────────────────────────────────── */
.flatpickr-calendar {
  background: var(--bg-700) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius) !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.4) !important;
}
.flatpickr-months, .flatpickr-weekdays { background: var(--bg-800) !important; }
.flatpickr-month { color: var(--text) !important; }
.flatpickr-weekday { color: var(--text-muted) !important; }
.flatpickr-day { color: var(--text-muted) !important; border-radius: var(--radius-sm) !important; }
.flatpickr-day:hover { background: var(--bg-600) !important; color: var(--text) !important; }
.flatpickr-day.selected { background: var(--primary) !important; border-color: var(--primary) !important; color: #fff !important; }
.flatpickr-day.today { border-color: var(--primary) !important; }

/* ── Toast notifications ─────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--bg-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .75rem 1rem;
  font-size: .875rem;
  min-width: 240px;
  display: flex; align-items: center; gap: .5rem;
  animation: slideIn .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.4);
}
.toast.success { border-left: 3px solid var(--accent); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Breadcrumbs ─────────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: .4rem; font-size: .8rem; color: var(--text-muted); }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-subtle); }
.breadcrumb .current { color: var(--text); }

/* ── Pagination ──────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: .25rem; margin-top: 1rem; }
.page-btn {
  padding: .3rem .65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  font-size: .8rem;
  cursor: pointer;
  transition: var(--transition);
}
.page-btn:hover { background: var(--bg-600); color: var(--text); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Loading spinner ─────────────────────────────────────────── */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator { display: inline-flex; }
.spinner { width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Utility ─────────────────────────────────────────────────── */
.text-muted { color: var(--text-muted) !important; }
.text-success { color: var(--accent) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary { color: var(--primary-light) !important; }
.text-sm  { font-size: .8rem !important; }
.text-xs  { font-size: .72rem !important; }
.text-lg  { font-size: 1.1rem !important; }
.fw-600   { font-weight: 600 !important; }
.fw-700   { font-weight: 700 !important; }
.d-flex   { display: flex !important; }
.align-center { align-items: center !important; }
.gap-sm  { gap: .5rem !important; }
.gap-md  { gap: 1rem !important; }
.mt-1 { margin-top: .5rem !important; }
.mt-2 { margin-top: 1rem !important; }
.mb-1 { margin-bottom: .5rem !important; }
.mb-2 { margin-bottom: 1rem !important; }
.ms-auto { margin-left: auto !important; }
.w-100  { width: 100% !important; }
.text-right { text-align: right !important; }
.nowrap { white-space: nowrap !important; }
.divider { border: none; border-top: 1px solid var(--border); margin: 1.25rem 0; }
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.empty-state-icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    position: fixed; z-index: 200;
  }
  .sidebar.mobile-open { transform: translateX(0); width: var(--sidebar-w) !important; }
  .main-content { margin-left: 0 !important; }
  .page-body { padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-row.cols-2,
  .form-row.cols-3,
  .form-row.cols-4 { grid-template-columns: 1fr; }
  .top-header .page-title { font-size: .9rem; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ── Login page ──────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-900);
  padding: 1rem;
}
.login-card {
  background: var(--bg-800);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%; max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo .logo-icon {
  width: 56px; height: 56px;
  background: var(--primary);
  border-radius: var(--radius);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 800; color: #fff;
  margin-bottom: .75rem;
}
.login-logo h1 { font-size: 1.3rem; }
.login-logo p { color: var(--text-muted); font-size: .875rem; }
