/* ══════════════════════════════════════════════════════
   Au Suivant — Feuille de styles principale
   Thème : Blanc + Vert foncé (#1a5c38)
   ══════════════════════════════════════════════════════ */

:root {
  --primary:       #1a5c38;
  --primary-hover: #155030;
  --primary-dark:  #0f3d26;
  --primary-light: #e8f5ee;
  --primary-mid:   #2d7a52;
  --primary-muted: #c6e8d4;

  --white:      #ffffff;
  --gray-50:    #f9fafb;
  --gray-100:   #f3f4f6;
  --gray-200:   #e5e7eb;
  --gray-300:   #d1d5db;
  --gray-400:   #9ca3af;
  --gray-500:   #6b7280;
  --gray-600:   #4b5563;
  --gray-700:   #374151;
  --gray-800:   #1f2937;
  --gray-900:   #111827;

  --red:        #dc2626;
  --red-light:  #fee2e2;
  --orange:     #d97706;
  --orange-light: #fef3c7;
  --blue:       #2563eb;
  --blue-light: #dbeafe;
  --green:      #16a34a;
  --green-light: #dcfce7;

  --sidebar-width: 268px;
  --topbar-height: 60px;
  --border-radius: 10px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.05);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -1px rgba(0,0,0,.05);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -2px rgba(0,0,0,.05);
  --transition: .18s ease;
}

/* ── Reset & base ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Layout principal ─────────────────────────────────── */
/* Sidebar en fixed : ne pas la mettre en flex avec le main (sinon double largeur + marge = grand vide) */
.app-layout {
  display: block;
  min-height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
}

.sidebar-logo {
  padding: 14px 12px 12px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: stretch;
}
/* Pas de cadre autour du logo (le fichier peut contenir du vert ; pas de double bordure) */
.sidebar-logo .logo-slot,
.sidebar-logo .logo-slot--plain {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
}
/* Zone logo blanche : évite le chevauchement texte / image et le rendu du logo sur fond coloré */
.logo-slot {
  background: var(--white);
  border-radius: 10px;
  min-height: 56px;
  width: 100%;
  max-width: none;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border: 1px solid var(--gray-100);
  box-sizing: border-box;
}
/* Logo sans cadre (contour retiré) */
.logo-slot--plain {
  border: none;
  background: transparent;
  padding: 6px 4px;
}
.logo-slot .app-logo-img {
  max-width: 100%;
  max-height: 56px;
  width: auto;
  height: auto;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.22s ease;
  display: block;
}
.logo-slot.is-loaded .app-logo-img {
  opacity: 1;
}
.sidebar-logo .logo-text,
.logo-slot .logo-fallback.logo-text {
  font-size: 17px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.5px;
  text-align: center;
}

/* Sélecteur organisation (superadmin) */
.sidebar-org-switcher {
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 4px;
}
.sidebar-org-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
  margin-bottom: 6px;
}
.sidebar-org-select {
  font-size: 13px !important;
  padding: 8px 10px !important;
  width: 100%;
}

.nav-separator-super {
  flex-shrink: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gray-300), transparent);
  margin: 10px 14px 6px;
}
.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  padding: 6px 16px 8px;
}
.sidebar-nav-super {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 8px;
}

/* Mode pill */
.mode-pill {
  margin: 10px 12px 4px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.mode-pill.mode-super {
  background: rgba(26,92,56,.12);
  color: var(--primary);
}
.mode-pill.mode-org {
  background: rgba(16,185,129,.12);
  color: #065f46;
}
.mode-pill i { opacity: 0.9; }

/* Navigation */
.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
  border-radius: 8px;
  margin: 2px 8px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-item.active {
  background: var(--primary);
  color: var(--white);
}
.nav-item.active .nav-icon { color: var(--white); }
.nav-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
  width: 22px;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon i { font-size: 15px; opacity: 0.92; }
.nav-label { flex: 1; }

/* Superadmin link */
.superadmin-link {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 8px 8px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  background: var(--orange-light);
  color: #92400e;
  transition: background var(--transition);
}
.superadmin-link .nav-icon {
  width: 22px;
  color: #92400e;
}
.superadmin-link .nav-label { flex: 1; }
.superadmin-link:hover { background: #fde68a; }
.superadmin-link.active { background: var(--orange); color: var(--white); }

/* Sidebar footer : liste déroulante, puis logo ANRS (empilés) */
.sidebar-footer {
  border-top: 1px solid var(--gray-100);
  padding: 12px 12px;
}
.sidebar-footer-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}
.sidebar-user-menu-wrap {
  position: relative;
  width: 100%;
  min-width: 0;
  text-align: center;
}
.sidebar-user-trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 30px;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--gray-800);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  transition: background var(--transition), border-color var(--transition), box-shadow var(--transition);
  box-shadow: none;
}
/* « Plaque » du bouton : visible au survol ou quand le menu est ouvert */
.sidebar-user-trigger:hover,
.sidebar-user-trigger:focus-visible {
  background: var(--gray-50);
  border-color: var(--gray-200);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}
.sidebar-user-trigger[aria-expanded="true"] {
  background: var(--white);
  border-color: var(--primary-muted);
  box-shadow: 0 0 0 2px rgba(26, 92, 56, 0.1);
}
.sidebar-user-line {
  flex: 0 1 auto;
  max-width: 100%;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
  text-align: center;
}
.sidebar-user-chevron {
  font-size: 9px;
  opacity: 0;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.sidebar-user-trigger:hover .sidebar-user-chevron,
.sidebar-user-trigger:focus-visible .sidebar-user-chevron,
.sidebar-user-trigger[aria-expanded="true"] .sidebar-user-chevron {
  opacity: 0.55;
}
.sidebar-user-dropdown {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 4px);
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 6px;
  box-shadow: var(--shadow);
  z-index: 80;
  overflow: hidden;
}
.sidebar-user-dropdown[hidden] {
  display: none !important;
}
.sidebar-user-dropdown-item {
  display: block;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  color: var(--gray-800);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition);
}
.sidebar-user-dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.sidebar-footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding-top: 2px;
}
.sidebar-anrs-logo {
  width: auto;
  height: auto;
  max-height: 40px;
  max-width: 160px;
  object-fit: contain;
  display: block;
}
/* Lien admin globale (superadmin en contexte organisation) */
.sidebar-footer-sa-admin {
  flex-shrink: 0;
  padding: 8px 12px 4px;
  border-top: 1px solid var(--gray-100);
}
.superadmin-link-footer {
  margin: 0;
  width: 100%;
  box-sizing: border-box;
}

/* ── Contenu principal ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: none;
  width: calc(100% - var(--sidebar-width));
  max-width: none;
  min-width: 0;
  padding: 24px;
  box-sizing: border-box;
  transition: opacity 0.15s ease;
}

/* ── Mobile topbar ────────────────────────────────────── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  z-index: 60;
  box-shadow: var(--shadow-sm);
}
.mobile-menu-btn {
  border: none;
  background: transparent;
  color: var(--primary);
  font-size: 22px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  transition: background var(--transition);
}
.mobile-menu-btn:hover { background: var(--primary-light); }
.mobile-topbar .mobile-logo-slot {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-topbar .logo-slot {
  min-height: 40px;
  max-width: 200px;
  width: auto;
  padding: 6px 12px;
}
.mobile-topbar .logo-slot--plain {
  padding: 4px 8px;
}
.mobile-topbar .logo-slot .app-logo-img {
  max-height: 32px;
  max-width: 140px;
}
.mobile-topbar-anrs {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
.mobile-anrs-logo {
  max-height: 28px;
  max-width: 140px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 40;
}

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 900px) {
  .mobile-topbar { display: flex; }
  .main-content {
    margin-left: 0;
    width: 100%;
    padding: calc(var(--topbar-height) + 16px) 14px 16px;
  }
  .sidebar {
    transform: translateX(-110%);
  }
  body.sidebar-open .sidebar {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  body.sidebar-open .sidebar-backdrop { display: block; }
}

/* ── Cards & conteneurs ───────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-900);
}
.card-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 2px;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1.2;
}
.page-subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 4px;
}

/* Grid stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 6px;
}
.stat-label i {
  margin-right: 6px;
  opacity: 0.88;
  font-size: 13px;
}
.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.stat-sub {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* ── Tableaux ─────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--border-radius);
  border: 1px solid var(--gray-200);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: var(--white);
}
.table th {
  background: var(--gray-50);
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }

/* ── Formulaires ──────────────────────────────────────── */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
.form-control {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  color: var(--gray-900);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,92,56,.12);
}
.form-control:read-only { background: var(--gray-50); color: var(--gray-600); }
select.form-control { cursor: pointer; }
textarea.form-control { min-height: 100px; resize: vertical; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-grid .full { grid-column: 1 / -1; }

/* ── Boutons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: background var(--transition), color var(--transition), box-shadow var(--transition);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.2;
}
.btn-primary {
  background: var(--primary);
  color: var(--white);
}
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary {
  background: var(--gray-700);
  color: var(--white);
}
.btn-secondary:hover { background: var(--gray-800); }
.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1.5px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-100); }
.btn-danger {
  background: var(--red);
  color: var(--white);
}
.btn-danger:hover { background: #b91c1c; }
.btn-ghost {
  background: transparent;
  color: var(--gray-600);
  border: none;
}
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 6px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 5px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Groupe boutons */
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ── Badges & Pills ───────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-green  { background: var(--green-light); color: #166534; }
.badge-red    { background: var(--red-light); color: #991b1b; }
.badge-orange { background: var(--orange-light); color: #92400e; }
.badge-blue   { background: var(--blue-light); color: #1e40af; }
.badge-gray   { background: var(--gray-100); color: var(--gray-600); }
.badge-primary{ background: var(--primary-light); color: var(--primary); }

/* ── Alertes ──────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 12px;
  border: 1px solid transparent;
}
.alert-success {
  background: var(--green-light);
  color: #166534;
  border-color: #bbf7d0;
}
.alert-error {
  background: var(--red-light);
  color: #991b1b;
  border-color: #fecaca;
}
.alert-warning {
  background: var(--orange-light);
  color: #92400e;
  border-color: #fed7aa;
}
.alert-info {
  background: var(--blue-light);
  color: #1e40af;
  border-color: #bfdbfe;
}
.alert-hidden { display: none; }

/* ── Modal ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--white);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-12px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-title {
  font-size: 17px;
  font-weight: 700;
}
.modal-close {
  background: none;
  border: none;
  color: var(--gray-400);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}
.modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-body { padding: 18px 20px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* Modale large (ex. routage comptoirs) */
.modal.modal--wide {
  max-width: min(960px, 96vw);
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal.modal--wide .modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
.modal.modal--wide .modal-footer {
  flex-shrink: 0;
}
.modal.modal--wide .modal-header {
  flex-shrink: 0;
}
.ctr-routing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  align-items: start;
}
@media (max-width: 720px) {
  .ctr-routing-grid {
    grid-template-columns: 1fr;
  }
}
.ctr-routing-cats {
  border: 1px solid var(--gray-100);
  border-radius: 10px;
  padding: 12px;
  background: var(--gray-50, #f9fafb);
}
.ctr-routing-cats-inner {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 220px;
  overflow-y: auto;
}
.ctr-slots-panel {
  margin-top: 16px;
}
.call-slot-row {
  border: 1px solid var(--gray-100);
  border-radius: 10px;
}

/* ── Loading spinner ──────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3.5px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  flex-direction: column;
  gap: 14px;
  color: var(--gray-500);
  font-size: 14px;
}

/* ── Empty state ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.empty-state-icon { font-size: 40px; margin-bottom: 12px; color: var(--gray-400); opacity: 0.55; }
.empty-state-icon i { font-size: inherit; vertical-align: middle; }
.empty-state-title { font-size: 15px; font-weight: 600; color: var(--gray-600); margin-bottom: 6px; }
.empty-state-desc { font-size: 13px; }

/* ── Utilitaires ──────────────────────────────────────── */
.text-muted { color: var(--gray-500); font-size: 13px; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-primary { color: var(--primary); }
.text-danger  { color: var(--red); }
.text-center { text-align: center; }
.font-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ── Page login ───────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-mid) 100%);
  padding: 20px;
}
.login-card {
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo img {
  max-width: 180px;
  max-height: 60px;
  object-fit: contain;
}
.login-logo .logo-text {
  font-size: 26px;
  font-weight: 800;
  color: var(--primary);
}
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 6px;
}
.login-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 24px;
}
.login-footer {
  margin-top: 20px;
  text-align: center;
  font-size: 12px;
  color: var(--gray-400);
}

/* ── Reset-password ───────────────────────────────────── */
.reset-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 60%, var(--primary-mid) 100%);
  padding: 20px;
}
.reset-card {
  background: var(--white);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
  width: 100%;
  max-width: 420px;
}

/* ── Organisation detail ──────────────────────────────── */
.org-header-card {
  background: var(--primary);
  color: var(--white);
  border-radius: var(--border-radius);
  padding: 20px 24px;
  margin-bottom: 18px;
}
.org-header-name { font-size: 20px; font-weight: 800; }
.org-header-meta { font-size: 13px; opacity: .8; margin-top: 4px; }

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--gray-200);
  margin-bottom: 20px;
  overflow-x: auto;
}
.tab {
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition);
  white-space: nowrap;
}
.tab:hover { color: var(--primary); }
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Inline items list */
.item-list { display: flex; flex-direction: column; gap: 8px; }
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
}
.item-row:hover { background: var(--primary-light); border-color: var(--primary-muted); }
.item-name { font-weight: 600; font-size: 14px; }
.item-meta { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Color swatch */
.color-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,0,0,.12);
  flex-shrink: 0;
  vertical-align: middle;
  margin-right: 6px;
}

/* Search bar */
.search-bar {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 340px;
}
.search-bar input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--white);
  transition: border-color var(--transition);
}
.search-bar input:focus { border-color: var(--primary); }
.search-bar-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 15px;
  pointer-events: none;
}
.search-bar-icon i { font-size: 14px; opacity: 0.9; }

/* ── Devices cards ────────────────────────────────────── */
.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.device-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--border-radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.device-name { font-weight: 700; font-size: 14px; }
.device-status {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.device-status.online  { background: var(--green); box-shadow: 0 0 0 3px rgba(22,163,74,.2); }
.device-status.offline { background: var(--gray-300); }
.device-token { font-family: ui-monospace, monospace; font-size: 11px; color: var(--gray-500); }

/* ── Stat chart placeholder ───────────────────────────── */
.chart-placeholder {
  background: var(--gray-50);
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: var(--gray-400);
  font-size: 14px;
}

/* ── Toast notification ───────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--gray-900);
  color: var(--white);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn .2s ease;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 340px;
}
.toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.toast-icon i { font-size: 14px; opacity: 0.95; }
.toast.toast-success { background: #166534; }
.toast.toast-error   { background: #991b1b; }
.toast.toast-warning { background: #92400e; }
@keyframes toastIn {
  from { transform: translateX(40px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Licence key ──────────────────────────────────────── */
.license-key-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.license-key-val { font-family: ui-monospace, monospace; font-size: 12px; }

/* ── Section titles ───────────────────────────────────── */
.section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-800);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-light);
}

/* ── Password change form ─────────────────────────────── */
.password-field-wrap { position: relative; }
.password-field-wrap .form-control { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  display: flex;
}
.password-toggle:hover { color: var(--gray-700); }

/* ── Temp password display ────────────────────────────── */
.temp-pwd-box {
  background: var(--primary-light);
  border: 1.5px solid var(--primary-muted);
  border-radius: 8px;
  padding: 12px 16px;
  font-family: ui-monospace, monospace;
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
  letter-spacing: 2px;
  margin: 8px 0;
}

/* ── Superadmin config nav cards ──────────────────────── */
.admin-nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.admin-nav-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  background: var(--white);
  border: 1.5px solid var(--gray-200);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  text-align: left;
}
.admin-nav-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(26,92,56,.1);
}
.admin-nav-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.admin-nav-card .icon { font-size: 22px; margin-bottom: 4px; display: flex; align-items: center; justify-content: center; }
.admin-nav-card .icon i { font-size: 22px; color: var(--primary); opacity: 0.92; }
.admin-nav-card .title { font-weight: 700; font-size: 14px; }
.admin-nav-card .desc { font-size: 12px; color: var(--gray-500); }
