/* ==========================================================================
   Lumisphere ERP — Design System
   Thème : Anthracite + Amber | Polices : Inter, Oswald (system fallbacks)
   ========================================================================== */

/* --- Variables globales --- */
:root {
  --bg:           #0f1117;
  --bg-card:      #1a1d27;
  --bg-sidebar:   #13151d;
  --bg-input:     #1e2130;
  --border:       rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);

  --text:         #e5e7eb;
  --text-muted:   #9ca3af;
  --text-dim:     #6b7280;

  --gold:         #f59e0b;
  --gold-light:   #fbbf24;
  --gold-dark:    #d97706;
  --navy:         #1f2937;

  --green:        #22c55e;
  --blue:         #3b82f6;
  --red:          #ef4444;
  --purple:       #a855f7;
  --orange:       #f97316;

  --radius:       10px;
  --radius-lg:    16px;
  --shadow:       0 4px 24px rgba(0,0,0,0.3);

  --sidebar-width: 248px;
  --sidebar-rail-width: 72px;
  --header-height: 52px;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  min-height: 100%;
  overflow: hidden; /* un seul scroll : .app-main (évite scroll-sur-scroll + bande noire) */
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1117 0%, #1a1d27 100%);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 380px;
  box-shadow: var(--shadow);
}
.login-logo {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 28px; font-weight: 700;
  letter-spacing: 5px; text-align: center;
  color: #fff; margin-bottom: 4px;
}
.login-logo span { color: var(--gold); }
.login-sub {
  font-size: 11px; text-align: center; color: var(--text-dim);
  letter-spacing: 2px; text-transform: uppercase; margin-bottom: 36px;
}
.login-error {
  color: var(--red); font-size: 13px; text-align: center;
  margin-bottom: 12px; display: none;
}
.login-error.show { display: block; }

/* ==========================================================================
   LAYOUT — Sidebar + Main
   ========================================================================== */
.app-layout {
  display: none; /* Affiché après login */
  grid-template-columns: var(--sidebar-width) 1fr;
  grid-template-rows: var(--header-height) 1fr;
  height: 100%;
  height: 100dvh;
  max-height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  min-height: 0;
}
.app-layout.active { display: grid; }

/* --- Header — signature --- */
.app-header {
  grid-column: 1 / -1;
  background: #12151d;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 14px 0 12px;
  z-index: 100;
  height: var(--header-height);
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-shrink: 0;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}
.header-brand-mark {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--gold);
  flex-shrink: 0;
}
.header-brand-mark svg { width: 24px; height: 24px; }
.header-brand-text {
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  line-height: 1;
}
.header-brand-name {
  font-family: 'Oswald', 'Arial Narrow', sans-serif;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2.8px;
  color: #fff;
}
.header-brand-name span { color: var(--gold); }
.header-brand-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* Zone centrale : barre d'adresse + toolbar */
.header-center {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 48px; /* encore plus à droite du logo */
  margin-right: 12px;
}
.header-path {
  flex: 1;
  min-width: 120px;
  max-width: none; /* jusqu’aux boutons à droite */
  display: flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px 0 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  cursor: default;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.header-path:hover {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(0, 0, 0, 0.34);
}
.header-path-ico {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  flex-shrink: 0;
}
.header-path-ico svg { width: 14px; height: 14px; }
.header-path-input {
  flex: 1;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit; /* même police que la page */
  letter-spacing: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
}
.header-path-input::selection { background: rgba(245, 158, 11, 0.25); }

.header-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.header-toolbar[hidden] { display: none !important; }

/* Actions à droite : notif · profil · quitter */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.header-icon-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}
.header-icon-btn svg { width: 15px; height: 15px; }
.header-icon-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.16);
  color: var(--text);
}
.header-icon-btn-quit:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}
.header-icon-btn-magic:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.3);
  color: var(--gold-light);
}
.header-icon-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--gold);
  color: #111;
  font-size: 9px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.header-icon-badge[hidden] { display: none !important; }

/* ---- Inbox drawer (slide droite) ---- */
.inbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}
.inbox-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}
.inbox-overlay[hidden] { display: none !important; }
.inbox-overlay.is-open[hidden] { display: block !important; }

.inbox-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 100vw);
  background: #12151d;
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 310;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.26s ease;
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35);
}
.inbox-drawer.is-open {
  transform: translateX(0);
}
.inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px 13px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}
.inbox-head-left {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.inbox-head-ico {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  flex-shrink: 0;
}
.inbox-head-ico svg { width: 17px; height: 17px; }
.inbox-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.inbox-sub {
  margin: 2px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}
.inbox-close {
  width: 31px;
  height: 31px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.inbox-close svg { width: 14px; height: 14px; }
.inbox-close:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: rgba(239, 68, 68, 0.3);
  color: #fca5a5;
}
.inbox-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}
.inbox-empty {
  text-align: center;
  max-width: 260px;
}
.inbox-empty-ico {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  color: var(--text-dim);
}
.inbox-empty-ico svg { width: 26px; height: 26px; }
.inbox-empty-title {
  font-size: 15px;
  font-weight: 650;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.inbox-empty-sub {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.45;
}

.header-user-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  min-width: 0;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(245, 158, 11, 0.14);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: var(--gold-light);
  font-size: 11px;
  font-weight: 750;
  flex-shrink: 0;
}
.header-user-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  padding-right: 2px;
}
.header-user-card .user-name {
  font-weight: 650;
  color: var(--text);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.header-user-card .user-role {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--gold-light);
  font-weight: 700;
  white-space: nowrap;
}

/* aliases legacy */
.header-user { display: contents; }
.btn-logout { /* remplacé par .header-icon-btn */ }

/* --- Sidebar — signature + clip/clap --- */
.app-sidebar {
  background: #10131a;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  padding: 0;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  transition: width 0.22s ease;
}
.app-layout.active { grid-template-columns: var(--sidebar-width) 1fr; }
.app-layout.nav-rail {
  --sidebar-width: var(--sidebar-rail-width);
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 10px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}
.sidebar-top-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-dim);
  padding-left: 4px;
}
.sidebar-rail-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.sidebar-rail-btn svg { width: 14px; height: 14px; }
.sidebar-rail-btn .rail-ico-expand { display: none; }
.app-layout.nav-rail .sidebar-rail-btn .rail-ico-collapse { display: none; }
.app-layout.nav-rail .sidebar-rail-btn .rail-ico-expand { display: block; }
.sidebar-rail-btn:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.28);
  color: var(--gold-light);
}
.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 8px 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.12) transparent;
}
.sidebar-section {
  margin-bottom: 7px;
}
.sidebar-section.is-role-hidden {
  display: none !important;
}
/* Page (Général, Commandes…) — moyen / un peu skinny */
.sidebar-section-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  min-height: 44px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 9px;
  color: var(--text-muted);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.sec-ico {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: inherit;
  flex-shrink: 0;
}
.sec-ico svg { width: 14px; height: 14px; }
.sec-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  line-height: 1.2;
}
.sec-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: none;
  color: inherit;
}
.sec-desc {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sec-chevron {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
  opacity: 0.55;
  color: inherit;
}
.sidebar-section.is-collapsed .sec-chevron {
  transform: rotate(-90deg);
}
.sidebar-section-toggle:hover {
  background: rgba(255, 255, 255, 0.055);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.12);
}
.sidebar-section-toggle:hover .sec-desc { color: var(--text-muted); }
/* Page ouverte = neutre */
.sidebar-section:not(.is-collapsed) .sidebar-section-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
}
.sidebar-section:not(.is-collapsed) .sec-desc { color: var(--text-muted); }
.sidebar-section:not(.is-collapsed) .sec-ico {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(255, 255, 255, 0.1);
}
.sidebar-section-body {
  overflow: hidden;
  max-height: 520px;
  transition: max-height 0.26s ease, opacity 0.18s ease, margin 0.2s ease;
  opacity: 1;
  margin-top: 5px;
  padding: 0 3px 0 6px;
}
.sidebar-section.is-collapsed .sidebar-section-body {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  margin-top: 0;
}

/* Sub-pages — skinny */
.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
  margin-bottom: 3px;
  border: 1px solid transparent;
  user-select: none;
  min-height: 34px;
  background: rgba(255, 255, 255, 0.015);
}
.nav-item:hover {
  background: rgba(255, 255, 255, 0.045);
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.05);
}
.nav-item.active {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 2px;
  border-radius: 2px;
  background: currentColor;
}
.nav-ico {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: inherit;
  flex-shrink: 0;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.nav-ico svg { width: 14px; height: 14px; }
.nav-item:hover .nav-ico {
  background: rgba(255, 255, 255, 0.06);
}
.nav-item.active .nav-ico {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: inherit;
}
.nav-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.nav-item .icon { font-size: 14px; width: 16px; text-align: center; }

/* Couleur unique par sub-page sélectionnée */
.nav-item[data-panel="dashboard"].active {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.32);
  color: #93c5fd;
}
.nav-item[data-panel="dashboard"].active .nav-ico {
  background: rgba(96, 165, 250, 0.15);
  border-color: rgba(96, 165, 250, 0.3);
}
.nav-item[data-panel="devis"].active {
  background: rgba(245, 158, 11, 0.12);
  border-color: rgba(245, 158, 11, 0.32);
  color: #fbbf24;
}
.nav-item[data-panel="devis"].active .nav-ico {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.3);
}
.nav-item[data-panel="devis-liste"].active {
  background: rgba(34, 211, 238, 0.12);
  border-color: rgba(34, 211, 238, 0.32);
  color: #67e8f9;
}
.nav-item[data-panel="devis-liste"].active .nav-ico {
  background: rgba(34, 211, 238, 0.15);
  border-color: rgba(34, 211, 238, 0.3);
}
.nav-item[data-panel="nouveau-bc"].active {
  background: rgba(129, 140, 248, 0.12);
  border-color: rgba(129, 140, 248, 0.32);
  color: #a5b4fc;
}
.nav-item[data-panel="nouveau-bc"].active .nav-ico {
  background: rgba(129, 140, 248, 0.15);
  border-color: rgba(129, 140, 248, 0.3);
}
.nav-item[data-panel="reception-bc"].active {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.32);
  color: #7dd3fc;
}
.nav-item[data-panel="reception-bc"].active .nav-ico {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
}
.nav-item[data-panel="nouveau-projet"].active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.32);
  color: #6ee7b7;
}
.nav-item[data-panel="nouveau-projet"].active .nav-ico {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
}
.nav-item[data-panel="livraison"].active {
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.32);
  color: #fdba74;
}
.nav-item[data-panel="livraison"].active .nav-ico {
  background: rgba(251, 146, 60, 0.15);
  border-color: rgba(251, 146, 60, 0.3);
}
.nav-item[data-panel="sortie-simple"].active {
  background: rgba(148, 163, 184, 0.14);
  border-color: rgba(148, 163, 184, 0.35);
  color: #cbd5e1;
}
.nav-item[data-panel="sortie-simple"].active .nav-ico {
  background: rgba(148, 163, 184, 0.18);
  border-color: rgba(148, 163, 184, 0.32);
}
.nav-item[data-panel="annuler-bl"].active {
  background: rgba(251, 113, 133, 0.12);
  border-color: rgba(251, 113, 133, 0.32);
  color: #fda4af;
}
.nav-item[data-panel="annuler-bl"].active .nav-ico {
  background: rgba(251, 113, 133, 0.15);
  border-color: rgba(251, 113, 133, 0.3);
}
.nav-item[data-panel="annuler-projet"].active {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.32);
  color: #fca5a5;
}
.nav-item[data-panel="annuler-projet"].active .nav-ico {
  background: rgba(248, 113, 113, 0.15);
  border-color: rgba(248, 113, 113, 0.3);
}
.nav-item[data-panel="nouveau-client"].active {
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.32);
  color: #5eead4;
}
.nav-item[data-panel="nouveau-client"].active .nav-ico {
  background: rgba(45, 212, 191, 0.15);
  border-color: rgba(45, 212, 191, 0.3);
}
.nav-item[data-panel="nouveau-produit"].active {
  background: rgba(163, 230, 53, 0.1);
  border-color: rgba(163, 230, 53, 0.3);
  color: #bef264;
}
.nav-item[data-panel="nouveau-produit"].active .nav-ico {
  background: rgba(163, 230, 53, 0.14);
  border-color: rgba(163, 230, 53, 0.28);
}
.nav-item[data-panel="nouveau-fournisseur"].active {
  background: rgba(232, 121, 249, 0.1);
  border-color: rgba(232, 121, 249, 0.3);
  color: #f0abfc;
}
.nav-item[data-panel="nouveau-fournisseur"].active .nav-ico {
  background: rgba(232, 121, 249, 0.14);
  border-color: rgba(232, 121, 249, 0.28);
}
.nav-item[data-panel="devis-edit"].active {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.32);
  color: #fcd34d;
}
.nav-item[data-panel="devis-edit"].active .nav-ico {
  background: rgba(251, 191, 36, 0.15);
  border-color: rgba(251, 191, 36, 0.3);
}
.nav-item[data-panel="stock"].active {
  background: rgba(125, 211, 252, 0.12);
  border-color: rgba(125, 211, 252, 0.32);
  color: #bae6fd;
}
.nav-item[data-panel="stock"].active .nav-ico {
  background: rgba(125, 211, 252, 0.15);
  border-color: rgba(125, 211, 252, 0.3);
}
.nav-item[data-panel="employes"].active {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.32);
  color: #6ee7b7;
}
.nav-item[data-panel="employes"].active .nav-ico {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.3);
}
.nav-item[data-panel="presences"].active {
  background: rgba(251, 146, 60, 0.12);
  border-color: rgba(251, 146, 60, 0.32);
  color: #fdba74;
}
.nav-item[data-panel="presences"].active .nav-ico {
  background: rgba(251, 146, 60, 0.15);
  border-color: rgba(251, 146, 60, 0.3);
}
.nav-item[data-panel="bulletins-paie"].active {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.32);
  color: #c4b5fd;
}
.nav-item[data-panel="bulletins-paie"].active .nav-ico {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.3);
}

/* Rail mode — icônes seules */
.app-layout.nav-rail .sidebar-top-title,
.app-layout.nav-rail .sidebar-section-toggle,
.app-layout.nav-rail .nav-label {
  display: none;
}
.app-layout.nav-rail .sidebar-top {
  justify-content: center;
  padding: 10px 6px;
}
.app-layout.nav-rail .sidebar-section {
  margin-bottom: 8px;
}
.app-layout.nav-rail .sidebar-section-body {
  display: block !important;
  max-height: none !important;
  opacity: 1 !important;
  pointer-events: auto !important;
  overflow: visible !important;
}
.app-layout.nav-rail .nav-item {
  justify-content: center;
  width: 44px;
  padding: 6px;
  margin: 0 auto 2px;
}
.app-layout.nav-rail .nav-item.active::before { display: none; }
.app-layout.nav-rail .nav-item.active {
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.35);
}

/* --- Main content --- */
.app-main {
  padding: 24px 32px;
  overflow-y: auto;
  overflow-x: hidden;
  min-height: 0; /* seule zone de scroll verticale de l'app */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ==========================================================================
   PANELS (sections de contenu)
   ========================================================================== */
.panel { display: none; }
.panel.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.panel-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 24px;
}
.panel-header .icon { font-size: 1.5em; }
.panel-header h2 { font-size: 1.4em; font-weight: 700; color: #fff; }
.panel-desc { color: var(--text-muted); font-size: 0.9em; margin-bottom: 24px; line-height: 1.6; }

/* ==========================================================================
   FORM ELEMENTS
   ========================================================================== */
.form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { margin-bottom: 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label {
  display: block; font-size: 12px; font-weight: 600;
  color: var(--text-muted); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.form-group label .req { color: var(--red); }

input, select, textarea {
  width: 100%; padding: 11px 14px; border-radius: var(--radius);
  background: var(--bg-input); border: 1px solid var(--border);
  color: var(--text); font-family: inherit; font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s; outline: none;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,158,11,0.1);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
select { cursor: pointer; }
select option { background: var(--bg-card); color: var(--text); }
textarea { font-family: 'JetBrains Mono', 'Fira Code', monospace; font-size: 13px; resize: vertical; min-height: 100px; }

.csv-help { font-size: 12px; color: var(--text-dim); margin-top: 4px; font-style: italic; }

/* --- Search input with icon --- */
.search-box {
  position: relative;
}
.search-box input { padding-left: 36px; }
.search-box::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 14px; pointer-events: none;
}

/* --- Drop zone (upload PDF) --- */
.drop-zone {
  border: 2px dashed rgba(245,158,11,0.25); border-radius: var(--radius-lg);
  padding: 28px; text-align: center; cursor: pointer;
  transition: all 0.3s; background: rgba(245,158,11,0.03);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--gold); background: rgba(245,158,11,0.08);
  box-shadow: 0 0 20px rgba(245,158,11,0.1);
}
.drop-zone .dz-icon { font-size: 2em; margin-bottom: 8px; }
.drop-zone .dz-text { font-size: 14px; color: var(--text-muted); }
.drop-zone .dz-text strong { color: var(--gold-light); }
.drop-zone input[type="file"] { display: none; }
.drop-zone.processing { opacity: 0.6; pointer-events: none; }
.drop-zone .dz-formats { font-size: 0.75em; color: var(--text-muted); margin-top: 6px; opacity: 0.7; }
.ai-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72em; font-weight: 600; background: linear-gradient(135deg, rgba(168,85,247,0.2), rgba(59,130,246,0.2)); color: #c084fc; padding: 3px 10px; border-radius: 20px; margin-left: 8px; }
.ai-status { font-size: 0.82em; margin-top: 8px; padding: 8px 12px; border-radius: 8px; display: none; }
.ai-status.show { display: block; }
.ai-status.parsing { background: rgba(245,158,11,0.1); color: var(--gold-light); }
.ai-status.done { background: rgba(34,197,94,0.1); color: #4ade80; }
.ai-status.err { background: rgba(239,68,68,0.1); color: #f87171; }

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
  padding: 11px 24px; border-radius: var(--radius); border: none; cursor: pointer;
  font-size: 14px; font-weight: 600; font-family: inherit;
  display: inline-flex; align-items: center; gap: 8px;
  transition: all 0.2s;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1a2e;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,158,11,0.3); }
.btn-secondary {
  background: transparent; border: 1px solid var(--border);
  color: var(--text-muted);
}
.btn-secondary:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.btn-danger {
  background: rgba(239,68,68,0.15); color: var(--red);
  border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-sm { padding: 7px 14px; font-size: 12px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ==========================================================================
   RESPONSE / ALERTS
   ========================================================================== */
.alert {
  padding: 14px 18px; border-radius: var(--radius); margin-top: 16px;
  font-size: 13px; display: none; line-height: 1.5;
}
.alert.show { display: block; animation: fadeIn 0.2s ease; }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); color: #4ade80; }
.alert-error   { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); color: var(--gold-light); }
.alert-info    { background: rgba(59,130,246,0.1); border: 1px solid rgba(59,130,246,0.3); color: #93c5fd; }

/* ==========================================================================
   DASHBOARD — KPIs
   ========================================================================== */
.kpi-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 28px;
}
.kpi-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
  position: relative; overflow: hidden;
}
.kpi-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.kpi-card.kpi-gold::before   { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.kpi-card.kpi-green::before  { background: linear-gradient(90deg, var(--green), #4ade80); }
.kpi-card.kpi-blue::before   { background: linear-gradient(90deg, var(--blue), #60a5fa); }
.kpi-card.kpi-red::before    { background: linear-gradient(90deg, var(--red), #f87171); }
.kpi-card.kpi-purple::before { background: linear-gradient(90deg, var(--purple), #c084fc); }

.kpi-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-dim); margin-bottom: 8px; }
.kpi-value { font-size: 28px; font-weight: 700; color: #fff; }
.kpi-sub { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ==========================================================================
   TABLES
   ========================================================================== */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-card); border-radius: var(--radius-lg); overflow: hidden;
  border: 1px solid var(--border);
}
.data-table thead th {
  background: rgba(255,255,255,0.03); padding: 12px 16px;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1px; color: var(--text-dim); text-align: left;
  border-bottom: 1px solid var(--border);
}
.data-table tbody td {
  padding: 12px 16px; font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* --- Badges / Tags --- */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 20px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.5px;
}
.badge-green  { background: rgba(34,197,94,0.15); color: #4ade80; }
.badge-red    { background: rgba(239,68,68,0.15); color: #f87171; }
.badge-gold   { background: rgba(245,158,11,0.15); color: var(--gold-light); }
.badge-blue   { background: rgba(59,130,246,0.15); color: #93c5fd; }
.badge-purple { background: rgba(168,85,247,0.15); color: #c084fc; }

/* ==========================================================================
   DEVIS — Lignes dynamiques
   ========================================================================== */
.devis-lines { margin-top: 16px; }
.devis-line {
  background: rgba(255,255,255,0.02); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; margin-bottom: 10px;
  position: relative;
}
.devis-line .line-header {
  display: flex; align-items: center; gap: 4px; margin-bottom: 10px; padding-right: 30px;
}
.devis-line .line-number {
  font-size: 12px; font-weight: 700; color: var(--gold);
  background: rgba(245,158,11,0.1); padding: 2px 10px; border-radius: 20px;
}
.devis-line .line-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr; gap: 10px; align-items: end; }
.devis-line .btn-remove {
  position: absolute; top: 8px; right: 8px;
  background: none; border: none; color: var(--text-dim);
  cursor: pointer; font-size: 16px; padding: 4px 8px; border-radius: 4px;
}
.devis-line .btn-remove:hover { color: var(--red); background: rgba(239,68,68,0.1); }

/* --- Variante lines --- */
.devis-line-variante {
  background: rgba(124,58,237,0.06) !important;
  border: 2px dashed rgba(124,58,237,0.4) !important;
  position: relative;
}
.devis-line-variante .line-number {
  background: rgba(124,58,237,0.15) !important;
  color: #a855f7 !important;
}
.devis-line-variante input {
  font-style: italic;
}

/* --- Drag & drop --- */
.drag-handle {
  cursor: grab; font-size: 18px; color: var(--text-dim); user-select: none;
  padding: 0 6px; line-height: 1; opacity: 0.5; transition: opacity 0.15s;
}
.drag-handle:hover { opacity: 1; color: var(--gold); }
.drag-handle:active { cursor: grabbing; }
.devis-line[draggable="true"] { transition: opacity 0.2s, transform 0.2s, box-shadow 0.2s; }
.devis-line-dragging { opacity: 0.4; transform: scale(0.98); }
.devis-line-drag-over {
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.3);
  background: rgba(245,158,11,0.04) !important;
}

/* --- Move buttons --- */
.line-move-btns { display: flex; flex-direction: column; gap: 1px; margin-right: 8px; }
.btn-move {
  background: none; border: 1px solid var(--border); color: var(--text-dim);
  font-size: 10px; padding: 0 6px; line-height: 16px; border-radius: 4px;
  cursor: pointer; transition: all 0.15s;
}
.btn-move:hover { color: var(--gold); border-color: var(--gold); background: rgba(245,158,11,0.08); }

/* --- Custom line number input --- */
.line-num-edit { display: flex; align-items: center; }
.input-custom-num {
  width: 52px; text-align: center; font-size: 12px; font-weight: 700;
  color: var(--gold); background: rgba(245,158,11,0.1);
  border: 1px solid rgba(245,158,11,0.25); border-radius: 20px;
  padding: 2px 6px; outline: none; transition: border-color 0.15s;
}
.input-custom-num:focus {
  border-color: var(--gold); background: rgba(245,158,11,0.15);
}
.input-custom-num::placeholder { color: var(--text-dim); font-weight: 400; font-size: 11px; }
.devis-line-variante .input-custom-num {
  background: rgba(124,58,237,0.15) !important;
  color: #a855f7 !important;
  border-color: rgba(124,58,237,0.3) !important;
}

/* --- Fiche technique link in form --- */
.ft-link-inline {
  display: inline-block; margin-top: 6px; font-size: 12px;
  color: var(--gold); text-decoration: none; font-weight: 600;
  padding: 3px 10px; border-radius: 6px;
  background: rgba(245,158,11,0.08); border: 1px solid rgba(245,158,11,0.2);
  transition: all 0.15s;
}
.ft-link-inline:hover { background: rgba(245,158,11,0.15); border-color: var(--gold); }


.devis-totals {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; margin-top: 16px;
}
.devis-totals .total-row {
  display: flex; justify-content: space-between; padding: 6px 0;
  font-size: 14px; color: var(--text-muted);
}
.devis-totals .total-row.grand-total {
  border-top: 2px solid var(--gold); padding-top: 12px; margin-top: 8px;
  font-size: 18px; font-weight: 700; color: var(--gold-light);
}

/* ==========================================================================
   LOADING / SPINNER
   ========================================================================== */
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: var(--gold);
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay {
  position: fixed; inset: 0; background: rgba(15,17,23,0.8);
  display: flex; align-items: center; justify-content: center;
  z-index: 9999; display: none;
}
.loading-overlay.show { display: flex; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */


/* ==========================================================================
   RESPONSIVE — SMARTPHONE (max-width: 768px)
   ========================================================================== */

/* --- Hamburger Button --- */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
  width: 28px;
  height: 28px;
  z-index: 201;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.hamburger-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.14);
}
.hamburger-btn span {
  display: block;
  width: 12px;
  height: 1.5px;
  background: var(--text-muted);
  border-radius: 1px;
  transition: transform 0.2s ease, opacity 0.15s ease;
  margin: 0 auto;
}
.hamburger-btn.active span:nth-child(1) { transform: translateY(4.5px) rotate(45deg); }
.hamburger-btn.active span:nth-child(2) { opacity: 0; }
.hamburger-btn.active span:nth-child(3) { transform: translateY(-4.5px) rotate(-45deg); }

/* --- Sidebar Overlay --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 149;
}
.sidebar-overlay.show { display: block; }

@media (max-width: 768px) {

  /* --- Hamburger visible --- */
  .hamburger-btn { display: flex; }

  /* --- LOGIN PAGE --- */
  .login-wrapper {
    padding: 20px 16px;
    align-items: flex-start;
    padding-top: 15vh;
  }
  .login-card {
    width: 100%;
    max-width: 100%;
    padding: 32px 20px;
    border-radius: 12px;
  }
  .login-logo {
    font-size: 24px;
    letter-spacing: 4px;
  }
  .login-sub {
    font-size: 10px;
    margin-bottom: 28px;
  }
  #login-form .form-group input {
    padding: 14px 14px;
    font-size: 16px; /* prevents iOS zoom on focus */
  }
  #login-form .btn {
    min-height: 48px;
    font-size: 15px;
    border-radius: 10px;
  }

  /* --- APP LAYOUT — single column --- */
  .app-layout.active {
    grid-template-columns: 1fr;
    grid-template-rows: var(--header-height) 1fr;
  }

  /* --- HEADER compact --- */
  .app-header {
    padding: 0 10px 0 8px;
    position: sticky;
    top: 0;
    z-index: 200;
  }
  .header-brand-tag { display: none; }
  .header-center { margin-left: 20px; margin-right: 8px; }
  .header-path {
    max-width: none;
    height: 30px;
    padding: 0 8px;
  }
  .header-path-input { font-size: 11px; }
  .header-brand-name {
    font-size: 12px;
    letter-spacing: 2px;
  }
  .header-brand-mark { width: 22px; height: 22px; }
  .header-brand-mark svg { width: 20px; height: 20px; }
  .header-actions { gap: 6px; }
  .header-user-card { padding: 3px 8px 3px 3px; }
  .header-user-card .user-name { display: none; }
  .header-user-card .user-role { font-size: 8px; }
  .header-icon-btn { width: 30px; height: 30px; }
  .header-icon-btn svg { width: 14px; height: 14px; }

  /* --- SIDEBAR — slide-in overlay --- */
  .app-layout.nav-rail { --sidebar-width: 232px; } /* pas de rail sur mobile */
  .sidebar-rail-btn { display: none; }
  .app-sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    background: #10131a;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
    overflow: hidden;
  }
  .app-sidebar.open {
    transform: translateX(0);
  }

  /* --- MAIN CONTENT --- */
  .app-main {
    padding: 16px 12px;
    /* garder UN seul scroll (pas de scroll body + main) */
    overflow-y: auto;
    min-height: 0;
  }

  /* --- PANELS --- */
  .panel-header {
    margin-bottom: 16px;
  }
  .panel-header h2 {
    font-size: 1.15em;
  }
  .panel-desc {
    font-size: 0.82em;
    margin-bottom: 16px;
  }

  /* --- FORM CARDS --- */
  .form-card {
    padding: 16px 14px;
    margin-bottom: 14px;
    border-radius: 12px;
  }
  .form-card h3 {
    font-size: 15px !important;
  }

  /* --- FORM GRID — stack all --- */
  .form-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* --- INPUTS larger touch targets --- */
  input, select, textarea {
    padding: 12px 14px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 8px;
  }
  .form-group label {
    font-size: 11px;
  }
  .form-group {
    margin-bottom: 12px;
  }

  /* --- DROP ZONE compact --- */
  .drop-zone {
    padding: 20px 14px;
  }
  .drop-zone .dz-icon { font-size: 1.5em; }
  .drop-zone .dz-text { font-size: 13px; }

  /* --- BUTTONS — full width stacked --- */
  .form-actions {
    flex-direction: column;
    gap: 8px;
    padding: 0 !important;
  }
  .form-actions .btn {
    width: 100%;
    justify-content: center;
    min-height: 48px;
    font-size: 14px;
  }

  /* --- KPI GRID --- */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi-card { padding: 14px; }
  .kpi-value { font-size: 22px; }
  .kpi-label { font-size: 10px; }

  /* ==========================================================================
     DEVIS — Mobile Card Layout
     ========================================================================== */

  /* --- Devis header buttons: stack --- */
  #panel-devis .form-card > div[style*="display:flex"][style*="justify-content:space-between"] {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 12px !important;
  }
  #panel-devis .form-card > div[style*="display:flex"][style*="justify-content:space-between"] > div[style*="display:flex"][style*="gap:8px"] {
    flex-direction: column !important;
  }
  #panel-devis .form-card > div[style*="display:flex"][style*="gap:8px"] .btn,
  #panel-devis .form-card > div[style*="display:flex"][style*="gap:8px"] button {
    width: 100% !important;
    justify-content: center !important;
    min-height: 44px !important;
    font-size: 13px !important;
  }

  /* --- Devis lines — card mode --- */
  .devis-line {
    padding: 14px 12px;
    margin-bottom: 12px;
    border-radius: 10px;
  }

  .devis-line .line-header {
    flex-wrap: wrap;
    gap: 6px;
    padding-right: 0;
    margin-bottom: 12px;
  }

  /* Hide drag handle on mobile */
  .devis-line .drag-handle { display: none; }

  /* Show move buttons prominently */
  .devis-line .line-move-btns {
    flex-direction: row;
    gap: 4px;
  }
  .devis-line .btn-move {
    padding: 4px 12px;
    font-size: 12px;
  }

  /* Variante / toggle buttons */
  .devis-line .btn-toggle-variante {
    font-size: 10px !important;
    padding: 3px 8px !important;
  }

  /* Line grid — VERTICAL CARD layout */
  .devis-line .line-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }

  /* Make each field in the line a labeled card-row */
  .devis-line .line-grid .form-group {
    margin-bottom: 4px;
  }

  /* Recherche produit field full width */
  .devis-line .search-box input {
    font-size: 15px;
  }

  /* Quantity + price fields: 2-column on mobile */
  .devis-line .line-grid {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  /* --- Devis totals --- */
  .devis-totals {
    padding: 16px 14px;
    border-radius: 10px;
  }
  .devis-totals .total-row {
    font-size: 13px;
    padding: 5px 0;
  }
  .devis-totals .total-row.grand-total {
    font-size: 16px;
  }

  /* --- Search box --- */
  .search-box input {
    padding-left: 36px;
  }

  /* --- Tables — horizontal scroll --- */
  .data-table { display: block; overflow-x: auto; }

  /* --- Alerts --- */
  .alert { font-size: 12px; padding: 12px 14px; }

  /* --- AI badge compact --- */
  .ai-badge { font-size: 0.65em; padding: 2px 7px; }

  /* --- Prevent horizontal overflow --- */
  body { overflow-x: hidden; }
  .app-layout { overflow-x: hidden; }

}

/* ==========================================================================
   RESPONSIVE — SMALL PHONES (max-width: 375px)
   ========================================================================== */
@media (max-width: 375px) {
  .login-card { padding: 28px 16px; }
  .login-logo { font-size: 20px; letter-spacing: 3px; }
  .app-main { padding: 12px 8px; }
  .form-card { padding: 14px 10px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 20px; }
  .header-brand-name { font-size: 12px; letter-spacing: 1.5px; }
}

/* ==== APP TOAST + CONFIRM 20260723b ==== */
.alert { display: none !important; }

.app-toast-host {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 100050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(380px, calc(100vw - 28px));
  pointer-events: none;
}
.app-toast {
  pointer-events: auto;
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr 28px;
  gap: 10px;
  align-items: start;
  padding: 14px 12px 14px 12px;
  border-radius: 12px;
  background: #12141c;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
  color: #e5e7eb;
  overflow: hidden;
  opacity: 0;
  transform: translateX(18px) scale(0.98);
  transition: opacity .2s ease, transform .22s cubic-bezier(.2,.8,.2,1);
}
.app-toast.is-in { opacity: 1; transform: translateX(0) scale(1); }
.app-toast.is-leaving { opacity: 0; transform: translateX(14px) scale(0.98); }
.app-toast-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-toast-icon svg { width: 18px; height: 18px; }
.app-toast-body { min-width: 0; padding-top: 1px; }
.app-toast-title {
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
  margin-bottom: 3px; text-transform: uppercase;
}
.app-toast-msg {
  font-size: 13px; line-height: 1.45; color: #c4c9d4;
  word-break: break-word;
}
.app-toast-msg strong { color: #f3f4f6; font-weight: 700; }
.app-toast-msg small { color: #9aa3b2; font-size: 11.5px; }
.app-toast-msg pre {
  margin-top: 6px; max-height: 90px; overflow: auto;
  font-size: 11px; background: rgba(255,255,255,0.04);
  padding: 6px 8px; border-radius: 6px;
}
.app-toast-close {
  border: none; background: transparent; color: #8b93a7;
  font-size: 18px; line-height: 1; cursor: pointer;
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.app-toast-close:hover { background: rgba(255,255,255,0.06); color: #fff; }
.app-toast-bar {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  transform-origin: left center; transform: scaleX(1);
  opacity: .9;
}
.app-toast-bar.is-run { animation: appToastBar linear forwards; }
.app-toast-bar.is-paused { animation-play-state: paused; }
@keyframes appToastBar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.app-toast-success { border-color: rgba(34,197,94,0.28); }
.app-toast-success .app-toast-icon { background: rgba(34,197,94,0.14); color: #4ade80; }
.app-toast-success .app-toast-title { color: #86efac; }
.app-toast-success .app-toast-bar { background: #22c55e; }

.app-toast-error { border-color: rgba(239,68,68,0.3); }
.app-toast-error .app-toast-icon { background: rgba(239,68,68,0.14); color: #f87171; }
.app-toast-error .app-toast-title { color: #fca5a5; }
.app-toast-error .app-toast-bar { background: #ef4444; }

.app-toast-warning { border-color: rgba(245,158,11,0.3); }
.app-toast-warning .app-toast-icon { background: rgba(245,158,11,0.14); color: #fbbf24; }
.app-toast-warning .app-toast-title { color: #fcd34d; }
.app-toast-warning .app-toast-bar { background: #f59e0b; }

.app-toast-info { border-color: rgba(59,130,246,0.3); }
.app-toast-info .app-toast-icon { background: rgba(59,130,246,0.14); color: #93c5fd; }
.app-toast-info .app-toast-title { color: #93c5fd; }
.app-toast-info .app-toast-bar { background: #3b82f6; }

.app-confirm-overlay {
  position: fixed; inset: 0; z-index: 100060;
  background: rgba(0,0,0,0.55);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity .16s ease;
}
.app-confirm-overlay.is-in { opacity: 1; }
.app-confirm-overlay.is-leaving { opacity: 0; }
.app-confirm-dialog {
  width: min(420px, 100%);
  background: #141722;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 20px 20px 16px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  color: #e5e7eb;
  transform: translateY(8px) scale(.98);
  transition: transform .18s ease;
}
.app-confirm-overlay.is-in .app-confirm-dialog { transform: none; }
.app-confirm-head {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px;
}
.app-confirm-icon {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.app-confirm-icon svg { width: 20px; height: 20px; }
.app-confirm-dialog.tone-info .app-confirm-icon { background: rgba(59,130,246,.14); color: #93c5fd; }
.app-confirm-dialog.tone-warn .app-confirm-icon { background: rgba(245,158,11,.14); color: #fbbf24; }
.app-confirm-dialog.tone-danger .app-confirm-icon { background: rgba(239,68,68,.14); color: #f87171; }
.app-confirm-title {
  margin: 0; font-size: 16px; font-weight: 700; color: #f3f4f6;
}
.app-confirm-msg {
  margin: 0 0 18px; font-size: 13px; line-height: 1.5; color: #9ca3af;
}
.app-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
.app-confirm-cancel, .app-confirm-ok {
  border: none; border-radius: 8px; padding: 9px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.app-confirm-cancel { background: rgba(255,255,255,.06); color: #d1d5db; }
.app-confirm-cancel:hover { background: rgba(255,255,255,.1); }
.app-confirm-ok { background: #f59e0b; color: #111; }
.app-confirm-dialog.tone-danger .app-confirm-ok { background: #ef4444; color: #fff; }
.app-confirm-dialog.tone-warn .app-confirm-ok { background: #f59e0b; color: #111; }
.app-confirm-dialog.tone-info .app-confirm-ok { background: #3b82f6; color: #fff; }

@media (max-width: 720px) {
  .app-toast-host { top: 12px; right: 12px; left: 12px; width: auto; }
}
