/* =============================================================
   SAB SAT RH — Component styles (Bootstrap 5 overrides + custom)
   ============================================================= */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#root { min-height: 100vh; }

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }

::selection { background: var(--brand-500); color: white; }

:focus-visible {
  outline: none;
  box-shadow: var(--shadow-focus);
  border-radius: var(--r-sm);
}

.mono { font-family: var(--font-mono); font-feature-settings: "tnum" 1, "ss01" 1; }
.tabular { font-variant-numeric: tabular-nums; }

/* =============================================================
   App shell
   ============================================================= */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns var(--tr-base);
}
.app-shell.is-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* =============================================================
   Sidebar
   ============================================================= */
.sidebar {
  background: var(--bg-sidebar);
  color: var(--text-on-sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.04);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  height: var(--header-h);
  flex-shrink: 0;
}
.brand-mark {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #2d5594 0%, #14213d 100%);
  display: grid; place-items: center;
  font-family: var(--font-mono);
  font-weight: 700;
  color: white;
  font-size: 13px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.15);
}
.brand-emblem {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  background: rgba(255,255,255,0.94);
  display: grid;
  place-items: center;
  padding: 4px;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 8px 22px rgba(0,0,0,0.18), inset 0 1px 0 rgba(255,255,255,0.72);
}
.brand-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name {
  color: white;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-tag {
  color: var(--text-on-sidebar-muted);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
  white-space: nowrap;
}
.is-collapsed .brand-text { display: none; }

.sidebar-search {
  padding: 12px 12px 6px;
  flex-shrink: 0;
}
.is-collapsed .sidebar-search { display: none; }
.sidebar-search input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text-on-sidebar);
  padding: 7px 10px 7px 30px;
  border-radius: var(--r-sm);
  font-size: 13px;
  outline: none;
  transition: background var(--tr-fast);
}
.sidebar-search input::placeholder { color: var(--text-on-sidebar-muted); }
.sidebar-search input:focus {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.18);
}
.sidebar-search-wrap { position: relative; }
.sidebar-search-wrap i {
  position: absolute;
  left: 9px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-on-sidebar-muted);
  font-size: 14px;
  pointer-events: none;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 8px 16px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }

.nav-section-label {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-on-sidebar-muted);
  padding: 14px 12px 6px;
}
.is-collapsed .nav-section-label {
  text-align: center;
  font-size: 0;
  padding: 12px 0 4px;
}
.is-collapsed .nav-section-label::before {
  content: "";
  display: block;
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0 14px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  color: var(--text-on-sidebar);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: 1px;
  white-space: nowrap;
  position: relative;
  transition: background var(--tr-fast), color var(--tr-fast);
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: white; text-decoration: none; }
.nav-item.is-active {
  background: var(--bg-sidebar-active);
  color: white;
  box-shadow: inset 2px 0 0 var(--brand-300);
}
.nav-item i {
  font-size: 17px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: var(--text-on-sidebar-muted);
}
.nav-item.is-active i { color: var(--brand-200); }
.nav-item .nav-badge {
  margin-left: auto;
  background: rgba(255,255,255,0.10);
  color: white;
  font-size: 11px;
  padding: 1px 6px;
  border-radius: var(--r-pill);
  font-weight: 600;
}
.is-collapsed .nav-item { justify-content: center; padding: 9px 0; }
.is-collapsed .nav-item span,
.is-collapsed .nav-item .nav-badge { display: none; }

.sidebar-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sidebar-footer .avatar { flex-shrink: 0; }
.sidebar-footer-info { min-width: 0; flex: 1; }
.sidebar-footer-name {
  color: white;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer-role {
  color: var(--text-on-sidebar-muted);
  font-size: 11px;
  white-space: nowrap;
}
.is-collapsed .sidebar-footer-info { display: none; }
.sidebar-footer button {
  background: transparent;
  border: none;
  color: var(--text-on-sidebar-muted);
  padding: 4px;
  cursor: pointer;
  border-radius: var(--r-sm);
}
.sidebar-footer button:hover { background: var(--bg-sidebar-hover); color: white; }
.is-collapsed .sidebar-footer button:not(.always-visible) { display: none; }

/* =============================================================
   Header
   ============================================================= */
.app-main { display: flex; flex-direction: column; min-width: 0; }

.app-header {
  height: var(--header-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header-toggle {
  background: transparent;
  border: 1px solid transparent;
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-secondary);
}
.header-toggle:hover { background: var(--bg-hover); }
.header-toggle i { font-size: 18px; }

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 13px;
}
.breadcrumbs .sep { color: var(--text-disabled); }
.breadcrumbs .current { color: var(--text-primary); font-weight: 600; }

.header-search {
  margin-left: auto;
  position: relative;
  width: 320px;
}
.header-search input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--border-default);
  background: var(--bg-app);
  border-radius: var(--r-sm);
  padding: 0 36px 0 32px;
  font-size: 13px;
  outline: none;
  color: var(--text-primary);
  transition: border-color var(--tr-fast), background var(--tr-fast);
}
.header-search input::placeholder { color: var(--text-tertiary); }
.header-search input:focus {
  border-color: var(--border-focus);
  background: var(--bg-surface);
  box-shadow: var(--shadow-focus);
}
.header-search i {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 14px;
}
.header-search .kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-tertiary);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 3px;
  padding: 1px 5px;
  pointer-events: none;
}

.header-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: var(--r-sm);
  cursor: pointer;
  position: relative;
  color: var(--text-secondary);
}
.header-icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.header-icon-btn i { font-size: 18px; }
.header-icon-btn .dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 7px; height: 7px;
  background: var(--err-500);
  border-radius: 50%;
  border: 2px solid var(--bg-surface);
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 4px 4px;
  border-radius: var(--r-pill);
  cursor: pointer;
  border: 1px solid transparent;
}
.header-user:hover { background: var(--bg-hover); }
.header-user .name { font-size: 13px; font-weight: 600; color: var(--text-primary); line-height: 1.1; }
.header-user .role { font-size: 11px; color: var(--text-tertiary); line-height: 1.1; }
.header-user-info { display: flex; flex-direction: column; gap: 2px; }
.header-user i { color: var(--text-tertiary); font-size: 14px; }

/* =============================================================
   Page container
   ============================================================= */
.page {
  padding: 24px 32px 40px;
  width: 100%;
  max-width: 100%;
}
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--text-primary);
}
.page-subtitle {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin: 4px 0 0;
}

/* =============================================================
   Avatar
   ============================================================= */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 12px;
  font-weight: 600;
  color: white;
  flex-shrink: 0;
  background: var(--brand-500);
  user-select: none;
}
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; }
.avatar.lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.xl { width: 64px; height: 64px; font-size: 22px; }

/* Auto color tints based on initials class */
.avatar.tint-1 { background: #2d5594; }
.avatar.tint-2 { background: #6f4f9f; }
.avatar.tint-3 { background: #2f8c4a; }
.avatar.tint-4 { background: #b87913; }
.avatar.tint-5 { background: #1f8c8c; }
.avatar.tint-6 { background: #b8362c; }
.avatar.tint-7 { background: #5f6a7a; }

/* =============================================================
   Buttons
   ============================================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--tr-fast), border-color var(--tr-fast), color var(--tr-fast);
  text-decoration: none !important;
}
.btn i { font-size: 15px; }
.btn:disabled { opacity: 0.5; pointer-events: none; }

.btn-primary {
  background: var(--brand-700);
  color: white;
  border-color: var(--brand-700);
}
.btn-primary:hover { background: var(--brand-600); border-color: var(--brand-600); }

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-strong); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-danger {
  background: var(--err-500);
  color: white;
}
.btn-danger:hover { background: var(--err-600); }

.btn-success {
  background: var(--ok-500);
  color: white;
}
.btn-success:hover { background: var(--ok-600); }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn.lg { height: 40px; padding: 0 18px; font-size: 14px; }
.btn.icon-only { padding: 0; width: 34px; }
.btn.sm.icon-only { width: 28px; }

/* =============================================================
   Cards
   ============================================================= */
.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-xs);
}
.card-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}
.card-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
  margin: 2px 0 0;
}
.card-body { padding: 18px; }
.card-footer {
  padding: 12px 18px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--r-md) var(--r-md);
  font-size: 12px;
  color: var(--text-secondary);
}

/* KPI card */
.kpi {
  padding: 18px 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-label i { font-size: 14px; color: var(--text-tertiary); }
.kpi-value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-top: 4px;
}
.kpi-value .unit {
  font-size: 14px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-left: 2px;
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.kpi-delta.up   { color: var(--ok-600); }
.kpi-delta.down { color: var(--err-600); }
.kpi-delta.flat { color: var(--text-tertiary); }
.kpi-delta i { font-size: 14px; }
.kpi-sparkline {
  margin-top: 10px;
  height: 36px;
  width: 100%;
}

/* =============================================================
   Badges / status pills
   ============================================================= */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  line-height: 16px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot-mark {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-neutral { background: var(--slate-100); color: var(--slate-700); }
.badge-ok      { background: var(--ok-50);  color: var(--ok-700); border-color: var(--ok-100); }
.badge-warn    { background: var(--warn-50); color: var(--warn-700); border-color: var(--warn-100); }
.badge-err     { background: var(--err-50);  color: var(--err-700); border-color: var(--err-100); }
.badge-info    { background: var(--info-50); color: var(--info-600); border-color: var(--info-100); }
.badge-brand   { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }
.badge-outline { background: transparent; color: var(--text-secondary); border-color: var(--border-default); }

[data-theme="dark"] .badge-neutral { background: #232c3b; color: #c8d2e3; }
[data-theme="dark"] .badge-brand   { background: rgba(45,85,148,0.18); color: #adc1e0; border-color: rgba(45,85,148,0.4); }

/* =============================================================
   Form controls
   ============================================================= */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.field-label .req { color: var(--err-500); margin-left: 2px; }
.field-hint { font-size: 12px; color: var(--text-tertiary); }
.field-error { font-size: 12px; color: var(--err-600); }

.input, .select, .textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.input::placeholder { color: var(--text-tertiary); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: var(--shadow-focus);
}
.input:disabled { background: var(--bg-sunken); color: var(--text-disabled); cursor: not-allowed; }
.input.is-error, .select.is-error { border-color: var(--err-500); }
.input.is-error:focus { box-shadow: 0 0 0 3px rgba(184,54,44,0.18); }
.textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; }

.input-group { position: relative; }
.input-group .input { padding-left: 34px; }
.input-group > i {
  position: absolute;
  left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 15px;
  pointer-events: none;
}

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235f6a7a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.checkbox, .radio {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}
.checkbox input, .radio input {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--brand-700);
  cursor: pointer;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
}
.switch input { display: none; }
.switch-track {
  width: 32px;
  height: 18px;
  background: var(--slate-300);
  border-radius: 999px;
  position: relative;
  transition: background var(--tr-fast);
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: white;
  border-radius: 50%;
  transition: left var(--tr-fast);
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}
.switch input:checked + .switch-track { background: var(--brand-600); }
.switch input:checked + .switch-track::after { left: 16px; }

/* =============================================================
   Tables
   ============================================================= */
.table-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  overflow: hidden;
}
.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}
.table-toolbar .filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-toolbar .actions { margin-left: auto; display: flex; gap: 8px; }

.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-default);
  background: var(--bg-sunken);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.table th .sort {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.table th .sort:hover { color: var(--text-primary); }
.table th .sort i { font-size: 13px; opacity: 0.5; }
.table th .sort.is-active { color: var(--text-primary); }
.table th .sort.is-active i { opacity: 1; color: var(--brand-600); }

.table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--tr-fast); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: none; }
.table td.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.table .row-checkbox { width: 36px; }
.table .row-actions {
  width: 50px;
  text-align: right;
  white-space: nowrap;
}

.table .cell-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.cell-user-info { display: flex; flex-direction: column; }
.cell-user-name { font-weight: 600; color: var(--text-primary); font-size: 13px; }
.cell-user-meta { font-size: 11.5px; color: var(--text-tertiary); }

.table-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 12.5px;
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination button {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.pagination button:hover { background: var(--bg-hover); color: var(--text-primary); }
.pagination button.is-active {
  background: var(--brand-700);
  color: white;
  border-color: var(--brand-700);
}
.pagination button[disabled] { opacity: 0.4; cursor: default; pointer-events: none; }

/* =============================================================
   Tabs
   ============================================================= */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border-default);
  margin-bottom: 20px;
}
.tab {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab:hover { color: var(--text-primary); }
.tab.is-active { color: var(--brand-700); border-bottom-color: var(--brand-700); }
[data-theme="dark"] .tab.is-active { color: var(--brand-200); border-bottom-color: var(--brand-300); }
.tab .count {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-sunken);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  color: var(--text-tertiary);
}
.tab.is-active .count { background: var(--brand-50); color: var(--brand-700); }
[data-theme="dark"] .tab.is-active .count { background: rgba(45,85,148,0.25); color: var(--brand-200); }

/* =============================================================
   Toast
   ============================================================= */
.toast-stack {
  position: fixed;
  bottom: 20px; right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-left: 3px solid var(--brand-500);
  border-radius: var(--r-md);
  padding: 12px 14px;
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: toastIn 200ms cubic-bezier(.4,0,.2,1);
}
.toast.ok   { border-left-color: var(--ok-500); }
.toast.warn { border-left-color: var(--warn-500); }
.toast.err  { border-left-color: var(--err-500); }
.toast i.lead { font-size: 18px; flex-shrink: 0; margin-top: 1px; }
.toast.ok i.lead { color: var(--ok-500); }
.toast.warn i.lead { color: var(--warn-500); }
.toast.err i.lead { color: var(--err-500); }
.toast.info i.lead { color: var(--brand-500); }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.toast-text { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }
.toast-close {
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 2px;
}
@keyframes toastIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* =============================================================
   Modal
   ============================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  display: none;
  place-items: center;
  z-index: 100;
}
.modal-backdrop.is-open {
  display: grid;
  animation: fadeIn 160ms ease-out;
}
.dropdown-menu.is-open { display: block !important; }
.modal {
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  animation: modalIn 200ms cubic-bezier(.4,0,.2,1);
}
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; margin: 0; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* =============================================================
   Charts
   ============================================================= */
.chart-wrap { width: 100%; position: relative; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}
.chart-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* =============================================================
   Empty states
   ============================================================= */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 48px 24px;
  color: var(--text-secondary);
}
.empty-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--bg-sunken);
  display: grid;
  place-items: center;
  margin-bottom: 16px;
  color: var(--text-tertiary);
}
.empty-icon i { font-size: 24px; }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.empty-text { font-size: 13px; color: var(--text-secondary); max-width: 340px; margin-bottom: 16px; }

/* =============================================================
   Skeleton / loading
   ============================================================= */
.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 0%, var(--bg-hover) 50%, var(--bg-sunken) 100%);
  background-size: 200% 100%;
  animation: shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.progress {
  height: 6px;
  background: var(--bg-sunken);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progress > span {
  display: block;
  height: 100%;
  background: var(--brand-600);
  border-radius: inherit;
  transition: width 400ms ease-out;
}
.progress.ok > span   { background: var(--ok-500); }
.progress.warn > span { background: var(--warn-500); }
.progress.err > span  { background: var(--err-500); }

/* =============================================================
   Grids / utilities
   ============================================================= */
.row-flex { display: flex; gap: var(--sp-4); flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; }
.stack-2 { gap: 8px; } .stack-3 { gap: 12px; } .stack-4 { gap: 16px; } .stack-5 { gap: 20px; } .stack-6 { gap: 24px; }
.inline { display: inline-flex; align-items: center; }
.inline-2 { gap: 8px; } .inline-3 { gap: 12px; } .inline-4 { gap: 16px; }
.justify-between { justify-content: space-between; }
.items-center { align-items: center; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-sm { font-size: 12.5px; }
.text-xs { font-size: 11.5px; }
.fw-600 { font-weight: 600; }
.flex-1 { flex: 1; }

.grid { display: grid; gap: var(--sp-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-12 { grid-template-columns: repeat(12, 1fr); }
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.divider {
  height: 1px;
  background: var(--border-subtle);
  margin: 16px 0;
}

/* Utilitaire d'affichage (compatibilité Bootstrap-like) */
.d-none { display: none !important; }

/* =============================================================
   Auth layout
   ============================================================= */
.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-app);
}
.auth-side {
  background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand-800) 60%, #08122a 100%);
  color: white;
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.auth-side::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle at 80% 20%, rgba(173,193,224,0.10) 0%, transparent 40%),
    radial-gradient(circle at 10% 90%, rgba(45,85,148,0.30) 0%, transparent 50%);
  pointer-events: none;
}
.auth-side > * { position: relative; }
.auth-form-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}
.auth-form {
  width: 100%;
  max-width: 380px;
}
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 32px;
}
.auth-logo .brand-mark { width: 36px; height: 36px; font-size: 14px; }
.auth-h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 6px;
}
.auth-sub { color: var(--text-secondary); font-size: 13.5px; margin: 0 0 24px; }
.auth-side-h1 {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  margin: 0 0 16px;
}
.auth-side-text { color: rgba(255,255,255,0.75); font-size: 14px; line-height: 1.6; }
.auth-republic {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12.5px;
  color: rgba(255,255,255,0.6);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.auth-republic-flag {
  display: inline-flex;
  width: 24px; height: 16px;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.2);
}
.auth-republic-flag span { flex: 1; height: 100%; }
.auth-republic-flag span:nth-child(1) { background: #00813e; }
.auth-republic-flag span:nth-child(2) { background: #fcd116; }
.auth-republic-flag span:nth-child(3) { background: #e8112d; }

.benin-identity {
  display: flex;
  align-items: center;
  gap: 18px;
}
.benin-identity.is-compact {
  gap: 12px;
}
.benin-emblem {
  width: 104px;
  height: 104px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 10px;
  border-radius: 28px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255,255,255,0.12);
  backdrop-filter: blur(10px);
}
.benin-identity.is-surface .benin-emblem {
  background: linear-gradient(180deg, #ffffff 0%, #f6f8fc 100%);
  border-color: rgba(20,33,61,0.08);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08), inset 0 1px 0 rgba(255,255,255,0.72);
}
.benin-identity.is-compact .benin-emblem {
  width: 54px;
  height: 54px;
  padding: 6px;
  border-radius: 18px;
}
.benin-emblem img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.benin-identity-copy {
  min-width: 0;
}
.benin-identity-eyebrow {
  color: rgba(255,255,255,0.72);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 11px;
  font-weight: 700;
}
.benin-identity.is-surface .benin-identity-eyebrow {
  color: var(--text-tertiary);
}
.benin-identity-title {
  margin-top: 6px;
  color: white;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.03em;
}
.benin-identity.is-compact .benin-identity-title {
  font-size: 14px;
  margin-top: 0;
}
.benin-identity.is-surface .benin-identity-title {
  color: var(--text-primary);
}
.benin-identity-subtitle {
  margin-top: 6px;
  color: rgba(255,255,255,0.72);
  font-size: 13px;
  line-height: 1.5;
}
.benin-identity.is-compact .benin-identity-subtitle {
  margin-top: 1px;
  font-size: 11px;
}
.benin-identity.is-surface .benin-identity-subtitle {
  color: var(--text-secondary);
}
.benin-identity-ribbon {
  margin-top: 14px;
  width: 220px;
  max-width: 100%;
  height: 6px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.18);
}
.benin-identity-ribbon span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg,
    #008751 0 33.33%,
    #fcd116 33.33% 66.66%,
    #e8112d 66.66% 100%);
}

@media (max-width: 900px) {
  .auth-shell { grid-template-columns: 1fr; }
  .auth-side { display: none; }
}

/* OTP boxes */
.otp-row { display: flex; gap: 10px; justify-content: center; }
.otp-cell {
  width: 48px; height: 56px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-surface);
  outline: none;
  transition: border-color var(--tr-fast), box-shadow var(--tr-fast);
}
.otp-cell:focus { border-color: var(--border-focus); box-shadow: var(--shadow-focus); }
.otp-cell.filled { border-color: var(--brand-600); }

/* =============================================================
   Dropzone
   ============================================================= */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  padding: 40px 24px;
  text-align: center;
  background: var(--bg-sunken);
  transition: border-color var(--tr-fast), background var(--tr-fast);
  cursor: pointer;
}
.dropzone:hover, .dropzone.is-drag {
  border-color: var(--brand-500);
  background: var(--brand-50);
}
[data-theme="dark"] .dropzone:hover { background: rgba(45,85,148,0.12); }
.dropzone-icon {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  color: var(--brand-600);
}
.dropzone-icon i { font-size: 22px; }
.dropzone-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.dropzone-sub { font-size: 12.5px; color: var(--text-secondary); }

/* =============================================================
   Session banner
   ============================================================= */
.session-banner {
  background: var(--warn-50);
  border: 1px solid var(--warn-100);
  color: var(--warn-700);
  padding: 10px 14px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 500;
}

/* =============================================================
   Token swatches (design system page)
   ============================================================= */
.swatch-grid { display: grid; gap: 10px; grid-template-columns: repeat(5, 1fr); }
.swatch {
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  overflow: hidden;
  font-size: 11px;
}
.swatch-color { height: 60px; }
.swatch-meta { padding: 8px 10px; background: var(--bg-surface); }
.swatch-name { font-weight: 600; font-size: 11.5px; }
.swatch-hex {
  font-family: var(--font-mono);
  color: var(--text-tertiary);
  font-size: 10.5px;
  margin-top: 1px;
}
@media (max-width: 800px) { .swatch-grid { grid-template-columns: repeat(3, 1fr); } }

.type-row {
  display: grid;
  grid-template-columns: 100px 1fr 160px;
  align-items: baseline;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-subtle);
  gap: 16px;
}
.type-row:last-child { border-bottom: none; }
.type-label { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-tertiary); }
.type-meta { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-tertiary); text-align: right; }

/* =============================================================
   Profile / detail
   ============================================================= */
.profile-header {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  margin-bottom: 20px;
}
.profile-header .avatar {
  width: 72px; height: 72px;
  font-size: 24px;
}
.profile-info-pairs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px 24px;
}
.profile-pair-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-tertiary);
}
.profile-pair-value {
  font-size: 13.5px;
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 2px;
}

/* =============================================================
   Timeline (permissions workflow)
   ============================================================= */
.timeline { position: relative; padding-left: 24px; }
.timeline::before {
  content: "";
  position: absolute;
  left: 7px; top: 4px; bottom: 4px;
  width: 1.5px;
  background: var(--border-default);
}
.tl-item { position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-dot {
  position: absolute;
  left: -22px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border-strong);
}
.tl-dot.ok { border-color: var(--ok-500); background: var(--ok-500); }
.tl-dot.warn { border-color: var(--warn-500); background: var(--warn-500); }
.tl-dot.err { border-color: var(--err-500); background: var(--err-500); }
.tl-dot.brand { border-color: var(--brand-600); background: var(--brand-600); }
.tl-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.tl-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.tl-text { font-size: 12.5px; color: var(--text-secondary); margin-top: 6px; }

/* =============================================================
   Job status indicator
   ============================================================= */
.job-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
}
.job-status .pulse {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-500);
  position: relative;
}
.job-status .pulse::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--brand-500);
  opacity: 0;
  animation: ping 1.6s ease-out infinite;
}
@keyframes ping {
  0% { transform: scale(0.6); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}
.job-status.ok .pulse { background: var(--ok-500); }
.job-status.ok .pulse::after { border-color: var(--ok-500); animation: none; opacity: 0; }
.job-status.err .pulse { background: var(--err-500); }
.job-status.err .pulse::after { animation: none; opacity: 0; }

/* =============================================================
   Error pages
   ============================================================= */
.errpage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 40px;
  background: var(--bg-app);
}
.errpage-card {
  max-width: 560px;
  width: 100%;
  text-align: center;
}
.errpage-code {
  font-family: var(--font-mono);
  font-size: 96px;
  font-weight: 700;
  letter-spacing: -0.04em;
  color: var(--brand-700);
  line-height: 1;
  margin-bottom: 12px;
  background: linear-gradient(180deg, var(--brand-600), var(--brand-800));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
[data-theme="dark"] .errpage-code {
  background: linear-gradient(180deg, #adc1e0, #4f74b1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* ===== Leaflet en modale (pointage web - configuration site) ===== */
/* Confinement via isolation+overflow ; on NE TOUCHE PAS aux z-index internes de Leaflet */
#siteMap {
  isolation: isolate;
}
#siteMap .leaflet-container {
  background: #ddd;
  height: 100%;
  width: 100%;
}
/* Le template projet a des règles globales `img { width:100%; object-fit:cover; ... }`
   qui cassent les tuiles 256x256 de Leaflet (damier). On force les dimensions natives. */
#siteMap img,
.leaflet-container img.leaflet-tile,
.leaflet-container .leaflet-pane img {
  max-width: none !important;
  max-height: none !important;
  width: auto !important;
  height: auto !important;
  object-fit: initial !important;
  position: absolute !important;
  border: 0 !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}
#siteMap img.leaflet-tile {
  width: 256px !important;
  height: 256px !important;
}
/* Marqueur Leaflet (icône PNG du pin) — garder sa taille native */
#siteMap .leaflet-marker-icon,
#siteMap .leaflet-marker-shadow {
  width: auto !important;
  height: auto !important;
  position: absolute !important;
}

/* =====================================================================
   ANALYTICS / RAPPORTS — palette et composants
   ===================================================================== */
:root {
    --an-brand-50: #eff6ff;
    --an-brand-100: #dbeafe;
    --an-brand-600: #2563eb;
    --an-brand-700: #1d4ed8;
    --an-ok-50: #ecfdf5;
    --an-ok-500: #10b981;
    --an-ok-600: #059669;
    --an-warn-50: #fffbeb;
    --an-warn-500: #f59e0b;
    --an-warn-600: #d97706;
    --an-danger-50: #fef2f2;
    --an-danger-500: #ef4444;
    --an-danger-600: #dc2626;
    --an-info-50: #ecfeff;
    --an-info-500: #06b6d4;
    --an-info-600: #0891b2;
    --an-neutral-50: #f8fafc;
    --an-neutral-100: #f1f5f9;
    --an-neutral-200: #e2e8f0;
    --an-neutral-400: #94a3b8;
    --an-neutral-600: #475569;
    --an-neutral-800: #1e293b;
}

/* ----- Barre de filtres ----- */
.analytics-filters {
    background: #fff;
    border: 1px solid var(--an-neutral-200);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.analytics-filters__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.analytics-filters__title {
    font-weight: 600;
    color: var(--an-neutral-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.analytics-filters__body {
    display: grid;
    gap: 0.75rem;
    margin-top: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.analytics-filters__body.is-collapsed {
    display: none;
}

.analytics-filters .filter-group label {
    font-size: 0.78rem;
    color: var(--an-neutral-600);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.analytics-filters__actions {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--an-neutral-200);
}

.preset-btn {
    background: var(--an-neutral-100);
    border: 1px solid var(--an-neutral-200);
    color: var(--an-neutral-800);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all .15s;
}

.preset-btn:hover {
    background: var(--an-brand-50);
    border-color: var(--an-brand-600);
    color: var(--an-brand-700);
}

.preset-btn.is-active {
    background: var(--an-brand-600);
    border-color: var(--an-brand-600);
    color: #fff;
}

/* ----- KPI cards ----- */
.analytics-kpi-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 1.25rem;
}

.analytics-kpi {
    background: #fff;
    border: 1px solid var(--an-neutral-200);
    border-radius: 0.6rem;
    padding: 1rem 1.1rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.analytics-kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--an-brand-600);
}

.analytics-kpi--success::before { background: var(--an-ok-500); }
.analytics-kpi--warning::before { background: var(--an-warn-500); }
.analytics-kpi--danger::before  { background: var(--an-danger-500); }
.analytics-kpi--info::before    { background: var(--an-info-500); }

.analytics-kpi__label {
    font-size: 0.78rem;
    color: var(--an-neutral-600);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 0.4rem;
}

.analytics-kpi__value {
    font-size: 1.7rem;
    font-weight: 700;
    color: var(--an-neutral-800);
    line-height: 1.1;
}

.analytics-kpi__hint {
    font-size: 0.78rem;
    color: var(--an-neutral-600);
    margin-top: 0.35rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.analytics-kpi__hint .pill {
    background: var(--an-neutral-100);
    border-radius: 999px;
    padding: 0.1rem 0.5rem;
    font-size: 0.72rem;
}

/* ----- Chart cards ----- */
.analytics-chart-card {
    background: #fff;
    border: 1px solid var(--an-neutral-200);
    border-radius: 0.6rem;
    padding: 1rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.analytics-chart-card__head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    gap: 0.5rem;
}

.analytics-chart-card__title {
    font-weight: 600;
    color: var(--an-neutral-800);
    margin: 0;
    font-size: 0.95rem;
}

.analytics-chart-card__body {
    position: relative;
    width: 100%;
    height: 320px;
}

.analytics-chart-card__body--sm {
    height: 240px;
}

.analytics-chart-card__body--lg {
    height: 380px;
}

/* ----- Loader ----- */
.analytics-loader {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5;
    border-radius: 0.5rem;
}

.analytics-loader.is-on {
    display: flex;
}

.analytics-loader .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--an-neutral-200);
    border-top-color: var(--an-brand-600);
    border-radius: 50%;
    animation: an-spin 0.8s linear infinite;
}

@keyframes an-spin { to { transform: rotate(360deg); } }

/* ----- Timeline calendaire employé ----- */
.timeline-cal {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.3rem;
    margin-top: 0.5rem;
}

.timeline-cal__weekday {
    font-size: 0.72rem;
    text-align: center;
    color: var(--an-neutral-600);
    text-transform: uppercase;
    font-weight: 600;
    padding-bottom: 0.25rem;
}

.timeline-cal .day {
    aspect-ratio: 1 / 1;
    border-radius: 0.35rem;
    background: var(--an-neutral-100);
    border: 1px solid var(--an-neutral-200);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    color: var(--an-neutral-600);
    position: relative;
    cursor: default;
    transition: transform .12s;
}

.timeline-cal .day:hover {
    transform: scale(1.05);
    z-index: 2;
}

.timeline-cal .day.empty {
    background: transparent;
    border-color: transparent;
}

.timeline-cal .day.present    { background: var(--an-ok-50);    border-color: var(--an-ok-500);    color: var(--an-ok-600); }
.timeline-cal .day.retard     { background: var(--an-warn-50);  border-color: var(--an-warn-500);  color: var(--an-warn-600); }
.timeline-cal .day.absent     { background: var(--an-danger-50);border-color: var(--an-danger-500);color: var(--an-danger-600); }
.timeline-cal .day.autorise   { background: var(--an-info-50);  border-color: var(--an-info-500);  color: var(--an-info-600); }
.timeline-cal .day.weekend    { background: var(--an-neutral-100); color: var(--an-neutral-400); }
.timeline-cal .day.ferie      { background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 4px, #e2e8f0 4px, #e2e8f0 8px); color: var(--an-neutral-600); }
.timeline-cal .day.depart-anticipe { background: var(--an-warn-50); border-color: var(--an-warn-500); color: var(--an-warn-600); }

.timeline-cal__legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 0.75rem;
    font-size: 0.78rem;
    color: var(--an-neutral-600);
}

.timeline-cal__legend .legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.timeline-cal__legend .swatch {
    width: 14px;
    height: 14px;
    border-radius: 0.25rem;
    border: 1px solid var(--an-neutral-200);
    display: inline-block;
}

.swatch.present  { background: var(--an-ok-50);    border-color: var(--an-ok-500); }
.swatch.retard   { background: var(--an-warn-50);  border-color: var(--an-warn-500); }
.swatch.absent   { background: var(--an-danger-50);border-color: var(--an-danger-500); }
.swatch.autorise { background: var(--an-info-50);  border-color: var(--an-info-500); }
.swatch.weekend  { background: var(--an-neutral-100); }
.swatch.ferie    { background: repeating-linear-gradient(45deg, #f1f5f9, #f1f5f9 4px, #e2e8f0 4px, #e2e8f0 8px); }

/* ----- Liste rapports ----- */
.rapports-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.rapport-card {
    background: #fff;
    border: 1px solid var(--an-neutral-200);
    border-radius: 0.6rem;
    padding: 1.1rem;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    transition: all .18s;
}

.rapport-card:hover {
    border-color: var(--an-brand-600);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
    transform: translateY(-2px);
    color: inherit;
}

.rapport-card__icon {
    width: 42px;
    height: 42px;
    border-radius: 0.5rem;
    background: var(--an-brand-50);
    color: var(--an-brand-700);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.rapport-card__title {
    font-weight: 600;
    color: var(--an-neutral-800);
    margin: 0;
}

.rapport-card__desc {
    font-size: 0.82rem;
    color: var(--an-neutral-600);
    margin: 0;
}

/* ----- Bandeau erreur ----- */
.analytics-error {
    background: var(--an-danger-50);
    border: 1px solid var(--an-danger-500);
    color: var(--an-danger-600);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin: 1rem 0;
    display: none;
}

.analytics-error.is-on { display: block; }

/* ----- Responsive tweaks ----- */
@media (max-width: 575.98px) {
    .analytics-kpi__value { font-size: 1.4rem; }
    .analytics-chart-card__body { height: 260px; }
    .timeline-cal { gap: 0.2rem; }
    .timeline-cal .day { font-size: 0.7rem; }
}

/* =====================================================================
   Heatmap calendaire (absences + retards par jour)
   Composant maison (pas de dependance graphique).
   ===================================================================== */
.heatmap-cal {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    padding: 10px 8px 6px;
    overflow-x: auto;
    align-items: center;
}

.heatmap-cal__grid {
    width: fit-content;
    max-width: 100%;
}

.heatmap-cal--wide {
    align-items: stretch;
    gap: 6px;
}

.heatmap-cal--wide .heatmap-cal__grid {
    width: 100%;
}

.heatmap-cal--wide .heatmap-axis-x,
.heatmap-cal--wide .heatmap-row {
    grid-template-columns: 44px repeat(7, minmax(34px, 1fr));
    width: 100%;
}

.heatmap-cal--wide .heatmap-cell {
    width: 100%;
    min-height: 34px;
    border-radius: 5px;
    font-size: 0.68rem;
}

.heatmap-cal--wide .heatmap-axis-y,
.heatmap-cal--wide .heatmap-axis-x__cell {
    font-size: 0.67rem;
}

.heatmap-cal--wide .heatmap-axis-y {
    min-height: 34px;
}

.heatmap-cal--wide .heatmap-cal__legend {
    padding-left: 44px;
}

.heatmap-cal--soft .heatmap-cell {
    border-radius: 6px;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.35);
}

.heatmap-cal--soft .heatmap-cell[data-density="0"] { background-color: #f8fafc; color: #0f766e; }
.heatmap-cal--soft .heatmap-cell[data-density="1"] { background-color: #e0f2fe; color: #0369a1; }
.heatmap-cal--soft .heatmap-cell[data-density="2"] { background-color: #fef9c3; color: #a16207; }
.heatmap-cal--soft .heatmap-cell[data-density="3"] { background-color: #fde68a; color: #b45309; }
.heatmap-cal--soft .heatmap-cell[data-density="4"] { background-color: #fecdd3; color: #9f1239; }

.heatmap-cal--soft .heatmap-cell:hover {
    transform: scale(1.015);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.10);
}

.heatmap-axis-x,
.heatmap-row {
    display: grid;
    grid-template-columns: 36px repeat(7, 24px);
    gap: 3px;
    align-items: center;
    width: fit-content;
    margin: 0 auto;
}

.heatmap-axis-x {
    margin-bottom: 2px;
}

.heatmap-axis-x__cell {
    font-size: 0.6rem;
    color: #64748b;
    text-align: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.heatmap-axis-y {
    font-size: 0.6rem;
    color: #64748b;
    text-align: right;
    padding-right: 4px;
    font-variant-numeric: tabular-nums;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    min-height: 24px;
}

.heatmap-cell {
    position: relative;
    aspect-ratio: 1 / 1;
    width: 24px;
    min-height: 24px;
    border-radius: 3px;
    background-color: #f1f5f9;
    color: #1e293b;
    font-size: 0.6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
    transition: transform 0.12s ease, box-shadow 0.12s ease, background-color 0.12s ease;
    border: 1px solid rgba(15, 23, 42, 0.04);
}

.heatmap-cell:hover {
    transform: scale(1.02);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
    z-index: 2;
}

.heatmap-cell.is-empty {
    background-color: transparent;
    border-color: transparent;
    color: transparent;
}

.heatmap-cell.is-noop {
    opacity: 0.55;
}

/* Paliers de densite : palette plus douce */
.heatmap-cell[data-density="0"] { background-color: #f0fdf4; color: #166534; }
.heatmap-cell[data-density="1"] { background-color: #dcfce7; color: #166534; }
.heatmap-cell[data-density="2"] { background-color: #fef3c7; color: #854d0e; }
.heatmap-cell[data-density="3"] { background-color: #fed7aa; color: #9a3412; }
.heatmap-cell[data-density="4"] { background-color: #fecaca; color: #7f1d1d; }

.heatmap-cell--legend {
    width: 12px;
    height: 12px;
    min-height: 12px;
    aspect-ratio: 1 / 1;
    font-size: 0;
    cursor: default;
}

.heatmap-cell--legend:hover { transform: none; box-shadow: none; }

.heatmap-cal__legend {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 4px;
    padding-left: 36px;
    justify-content: flex-start;
    font-size: 0.67rem;
    color: #64748b;
}

.heatmap-cal__legend-label {
    font-weight: 500;
}

.heatmap-cal__empty {
    padding: 24px;
    text-align: center;
}

@media (max-width: 575.98px) {
    .heatmap-cal {
        align-items: flex-start;
    }
    .heatmap-cal__grid {
        width: 100%;
    }
    .heatmap-axis-x,
    .heatmap-row {
        grid-template-columns: 26px repeat(7, 20px);
        gap: 2px;
        width: fit-content;
    }
    .heatmap-cell { width: 20px; min-height: 20px; font-size: 0.55rem; }
    .heatmap-axis-y {
        font-size: 0.55rem;
        padding-right: 2px;
        min-height: 20px;
    }
    .heatmap-cal__legend {
        padding-left: 26px;
    }
    .heatmap-cal--wide .heatmap-axis-x,
    .heatmap-cal--wide .heatmap-row {
        grid-template-columns: 26px repeat(7, 20px);
    }
    .heatmap-cal--wide .heatmap-cell {
        width: 20px;
        min-height: 20px;
    }
}

/* ===== Sections pliables (modale Règles de traitement) ===== */
.rules-section {
  border: 1px solid var(--border-subtle);
  border-radius: var(--r-md);
  background: #fff;
  overflow: hidden;
}
.rules-section summary {
  cursor: pointer;
  padding: 12px 14px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
  list-style: none;
  background: var(--bg-sunken);
  transition: background var(--tr-fast);
}
.rules-section summary::-webkit-details-marker { display: none; }
.rules-section summary::after {
  content: "\ea4e";
  font-family: "remixicon";
  margin-left: auto;
  font-size: 16px;
  color: var(--text-tertiary);
  transition: transform var(--tr-fast);
}
.rules-section[open] summary::after { transform: rotate(180deg); }
.rules-section summary:hover { background: var(--bg-hover); }
.rules-section .rules-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--brand-600);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.rules-section .rules-content { padding: 14px 16px; }
.rules-section .rules-content p { margin: 0 0 8px; }
.rules-section .rules-content ul { margin: 0; padding-left: 20px; }
.rules-section .rules-content ul li { margin-bottom: 4px; }
