/* =============================================
   Portail Entrepreneurial — Styles principaux
   Norme EU e-invoicing compliant app
   ============================================= */

:root {
  --primary: #073ee6;
  --primary-dark: #052ca8;
  --primary-light: #4f7cff;
  --primary-bg: #edf4ff;
  --secondary: #2ec4b6;
  --danger: #e63946;
  --warning: #f4a261;
  --success: #2a9d8f;
  --info: #4361ee;

  --bg: #f7faff;
  --bg-card: #ffffff;
  --bg-sidebar: #07183d;
  --bg-sidebar-hover: #102b66;
  --bg-sidebar-active: #073ee6;

  --text: #1a1a2e;
  --text-muted: #64708f;
  --text-sidebar: #c8d8ff;
  --text-sidebar-active: #ffffff;

  --border: #d9e4ff;
  --border-focus: #073ee6;
  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;
  --shadow: 0 2px 12px rgba(7,62,230,0.08);
  --shadow-lg: 0 8px 32px rgba(7,62,230,0.16);

  --sidebar-width: 240px;
  --header-height: 60px;
  --transition: 0.2s ease;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif; font-size: 14px; }
body { background: var(--bg); color: var(--text); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; }
ul { list-style: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-light); }

/* ============ LAYOUT ============ */
#root { height: 100%; }

.app-wrapper { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  overflow-x: hidden;
  transition: width var(--transition);
  z-index: 2100;
}
.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .sidebar-logo {
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
}
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-footer,
.sidebar.collapsed .mobile-nav-close {
  display: none;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  min-height: var(--header-height);
}
.sidebar-logo-icon {
  width: 32px; height: 32px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px; font-weight: 700; flex-shrink: 0;
}
.sidebar-logo-text { color: #fff; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; }

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-section-label {
  padding: 12px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(200,196,232,0.4);
  white-space: nowrap;
}
.collapsed .sidebar-section-label { opacity: 0; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  color: var(--text-sidebar);
  cursor: pointer;
  border-radius: 0;
  transition: background var(--transition), color var(--transition);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex-shrink: 0; width: 18px; height: 18px; }
.nav-item-label { font-size: 13px; font-weight: 500; overflow: hidden; }
.collapsed .nav-item-label { display: none; }
.collapsed .nav-item { justify-content: center; padding: 10px; }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: auto;
}

.sidebar-info-card {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  padding: 14px;
  color: #fff;
  background:
    radial-gradient(circle at 12% 16%, rgba(255,255,255,0.22), transparent 27%),
    linear-gradient(145deg, rgba(155,133,224,0.34), rgba(46,196,182,0.16)),
    rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
}
.sidebar-info-card::before {
  content: "";
  position: absolute;
  inset: -32px -26px auto auto;
  width: 150px;
  height: 150px;
  border-radius: 44%;
  border: 1px solid rgba(255,255,255,0.10);
  transform: rotate(-18deg);
}
.sidebar-user-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  margin-bottom: 12px;
}
.sidebar-user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: #fff;
  color: var(--primary-dark);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0,0,0,0.18);
}
.sidebar-user-meta {
  min-width: 0;
  flex: 1;
}
.sidebar-user-name,
.sidebar-user-role {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar-user-name {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.2;
}
.sidebar-user-role {
  margin-top: 2px;
  font-size: 11px;
  color: rgba(255,255,255,0.72);
}
.sidebar-info-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 10px;
}
.sidebar-info-chip {
  min-width: 0;
  width: 100%;
  border-radius: var(--radius);
  padding: 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.10);
  color: inherit;
  font: inherit;
  text-align: left;
}
.sidebar-info-chip.clickable {
  cursor: pointer;
  transition: background var(--transition), transform 0.1s;
}
.sidebar-info-chip.clickable:hover { background: rgba(255,255,255,0.18); }
.sidebar-info-chip.clickable:active { transform: scale(0.98); }
.sidebar-info-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.56);
}
.sidebar-info-value {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  margin-top: 3px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.sidebar-info-value span:last-child {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sidebar-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sidebar-card-actions {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.sidebar-card-button {
  min-width: 0;
  justify-content: center;
  border-radius: var(--radius);
  background: rgba(255,255,255,0.92);
  color: var(--text);
}
.sidebar-card-button:hover {
  background: #fff;
  color: var(--text);
}
.sidebar-card-button.icon-only {
  width: 34px;
  padding-left: 0;
  padding-right: 0;
}

/* Main area */
.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.header {
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  flex-shrink: 0;
  z-index: 50;
}
.header-title { font-size: 17px; font-weight: 600; flex: 1; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.sidebar-toggle,
.mobile-nav-close { display: inline-flex; }
.mobile-nav-backdrop { display: none; }

/* Page content */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-title { font-size: 15px; font-weight: 600; }

/* Stats grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow);
}
.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}
.stat-card-icon svg { width: 20px; height: 20px; }
.stat-card-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.stat-card-value { font-size: 24px; font-weight: 700; }
.stat-card-sub { font-size: 12px; color: var(--text-muted); }

/* ============ ROLE DASHBOARD ============ */
.dashboard-role {
  display:grid;
  gap:18px;
}
.dashboard-role-head {
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:16px;
  padding:18px 20px;
  background:var(--bg-card);
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  box-shadow:var(--shadow);
}
.dashboard-role-head h2 {
  margin:0 0 6px;
  font-size:20px;
  font-weight:800;
  color:var(--text);
}
.dashboard-role-head p {
  margin:0;
  color:var(--text-muted);
  font-size:13px;
}
.dashboard-role-count {
  min-width:126px;
  text-align:right;
  font-size:24px;
  font-weight:800;
  color:var(--primary);
}
.dashboard-role-count span {
  display:block;
  margin-top:2px;
  font-size:12px;
  font-weight:600;
  color:var(--text-muted);
}
.dashboard-focus-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(220px, 1fr));
  gap:12px;
}
.dashboard-focus-card {
  min-height:82px;
  display:flex;
  align-items:center;
  gap:12px;
  padding:14px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:#fff;
  text-align:left;
  box-shadow:var(--shadow);
  cursor:pointer;
}
.dashboard-focus-card:hover,
.dashboard-module-card:hover {
  border-color:var(--border-focus);
  box-shadow:0 10px 26px rgba(49,42,92,.10);
}
.dashboard-focus-icon,
.dashboard-module-icon {
  width:40px;
  height:40px;
  border-radius:var(--radius);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  flex:0 0 auto;
}
.dashboard-focus-icon svg,
.dashboard-module-icon svg {
  width:20px;
  height:20px;
}
.dashboard-focus-body {
  display:grid;
  gap:3px;
}
.dashboard-focus-body strong {
  font-size:22px;
  line-height:1;
  color:var(--text);
}
.dashboard-focus-body span {
  font-size:13px;
  color:var(--text-muted);
}
.dashboard-module-grid {
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(250px, 1fr));
  gap:16px;
}
.dashboard-module-card {
  display:flex;
  flex-direction:column;
  gap:10px;
  min-height:230px;
  padding:18px;
  border:1px solid var(--border);
  border-radius:var(--radius-lg);
  background:#fff;
  text-align:left;
  box-shadow:var(--shadow);
  cursor:pointer;
}
.dashboard-module-top {
  display:flex;
  justify-content:space-between;
  align-items:center;
}
.dashboard-module-action {
  color:var(--text-muted);
  font-size:12px;
  font-weight:700;
}
.dashboard-module-title {
  font-size:17px;
  font-weight:800;
  color:var(--text);
}
.dashboard-module-sub {
  min-height:34px;
  color:var(--text-muted);
  font-size:13px;
  line-height:1.35;
}
.dashboard-module-metrics {
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
  margin-top:auto;
}
.dashboard-module-metric {
  min-height:58px;
  padding:10px;
  border-radius:var(--radius-sm);
  background:var(--bg);
  display:grid;
  align-content:center;
  gap:3px;
}
.dashboard-module-metric strong {
  font-size:20px;
  color:var(--text);
  line-height:1;
}
.dashboard-module-metric span {
  color:var(--text-muted);
  font-size:11px;
  line-height:1.25;
}
.dashboard-module-card.purple .dashboard-module-icon,
.dashboard-focus-card.purple .dashboard-focus-icon { background:var(--primary-bg); color:var(--primary); }
.dashboard-module-card.blue .dashboard-module-icon,
.dashboard-focus-card.blue .dashboard-focus-icon { background:#eaf0fd; color:var(--info); }
.dashboard-module-card.teal .dashboard-module-icon,
.dashboard-focus-card.teal .dashboard-focus-icon { background:#e8f7f5; color:var(--success); }
.dashboard-module-card.orange .dashboard-module-icon,
.dashboard-focus-card.orange .dashboard-focus-icon { background:#fef3e7; color:#c47a1b; }
.dashboard-module-card.dark .dashboard-module-icon,
.dashboard-focus-card.dark .dashboard-focus-icon { background:#eef0f4; color:#374151; }
@media(max-width:680px){
  .dashboard-role-head {
    flex-direction:column;
  }
  .dashboard-role-count {
    text-align:left;
  }
  .dashboard-module-grid {
    grid-template-columns:1fr;
  }
}

/* ============ TABLES ============ */
.table-wrapper { overflow-x: auto; max-height: calc(100vh - 430px);}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left;
  padding: 10px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); transition: background var(--transition); }
tbody tr:hover { background: var(--primary-bg); }
tbody td { padding: 12px 12px; font-size: 13px; }
tbody tr:last-child { border-bottom: none; }

/* ============ FORMS ============ */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.custom-dropdown.form-group { gap: 12px; margin-bottom: 0px;}
.form-label { font-size: 13px; font-weight: 500; color: var(--text); }
.form-control {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}
.form-control:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(7,62,230,0.12); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b6b8a' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.form-error { font-size: 12px; color: var(--danger); }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  transition: background var(--transition), transform 0.1s, box-shadow var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(7,62,230,0.3); }
.btn-secondary { background: var(--primary-bg); color: var(--primary); }
.btn-secondary:hover { background: #e0d8f7; }
.btn-danger { background: #fdecea; color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-success { background: #e8f7f5; color: var(--success); }
.btn-success:hover { background: var(--success); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); }
.btn-block { width: 100%; justify-content: center; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}
.badge-success { background: #e8f7f5; color: var(--success); }
.badge-warning { background: #fef3e7; color: #c47a1b; }
.badge-danger { background: #fdecea; color: var(--danger); }
.badge-info { background: #eaedfd; color: var(--info); }
.badge-muted { background: var(--bg); color: var(--text-muted); }
.badge-primary { background: var(--primary-bg); color: var(--primary); }

/* ============ MODALS ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(26,26,46,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 1000;
  padding: 24px 16px;
  overflow-y: auto;
}
.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }
@keyframes modalIn { from { opacity: 0; transform: translateY(-16px) scale(0.98); } to { opacity: 1; transform: none; } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 0 24px 20px;
  display: flex; justify-content: flex-end; gap: 8px;
}

/* La carte Leaflet (ses contrôles montent à z-index 1000) ne doit jamais recouvrir
   les modals : on la confine dans son propre contexte d'empilement à z-index 0. */
.leaflet-container { position: relative; z-index: 0; }

/* ============ SEARCH + TOOLBAR ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.order-lines {
  display: grid;
  gap: 3px;
  font-size: 12px;
}
.order-line-editor {
  display: grid;
  gap: 8px;
}
.order-line-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 90px minmax(160px, 1fr) 36px;
  gap: 8px;
  align-items: center;
}
.barcode-input-row {
  display:flex;
  gap:8px;
  align-items:center;
}
.barcode-input-row .form-control {
  flex:1;
}
.barcode-pill {
  display:inline-flex;
  align-items:center;
  min-height:24px;
  padding:2px 8px;
  border:1px solid var(--border);
  border-radius:6px;
  background:#f8fafc;
  color:var(--text);
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:12px;
  white-space:nowrap;
}
.barcode-order-tools {
  display:flex;
  justify-content:flex-end;
  margin:-6px 0 10px;
}
.barcode-scan-modal {
  max-width:520px;
}
.barcode-camera-box {
  position:relative;
  width:100%;
  aspect-ratio:4 / 3;
  overflow:hidden;
  border-radius:10px;
  background:#0f172a;
}
.barcode-video {
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}
.barcode-frame {
  position:absolute;
  left:12%;
  right:12%;
  top:34%;
  height:32%;
  border:2px solid rgba(255,255,255,.92);
  border-radius:10px;
  box-shadow:0 0 0 999px rgba(15,23,42,.34), 0 0 18px rgba(7,62,230,.45);
  pointer-events:none;
}
.barcode-manual {
  display:flex;
  gap:8px;
  margin-top:14px;
}
@media(max-width:640px){
  .barcode-order-tools {
    justify-content:stretch;
  }
  .barcode-order-tools .btn {
    width:100%;
    justify-content:center;
  }
  .barcode-manual {
    flex-direction:column;
  }
  .order-line-row {
    grid-template-columns:1fr 86px 36px;
  }
  .order-line-row .form-control[placeholder="Note"] {
    grid-column:1 / -1;
  }
}
.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.search-box svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px; height: 16px;
  pointer-events: none;
}
.search-box input {
  padding-left: 34px;
}

/* ============ PROGRESS BARS ============ */
.progress { height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.progress-bar-primary { background: var(--primary); }
.progress-bar-success { background: var(--success); }
.progress-bar-warning { background: var(--warning); }
.progress-bar-danger { background: var(--danger); }
.update-progress {
  margin-top:12px;
  padding:12px;
  border:1px solid var(--border);
  border-radius:var(--radius-sm);
  background:#fff;
}
.update-progress-head {
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-bottom:8px;
  color:var(--text);
  font-size:12px;
  font-weight:600;
}
.update-progress-head span:last-child {
  color:var(--text-muted);
  font-weight:500;
}
.update-progress-track {
  position:relative;
}
.update-progress-bar.is-indeterminate {
  animation:updateIndeterminate 1.15s ease-in-out infinite;
}
@keyframes updateIndeterminate {
  0% { margin-left:-45%; }
  100% { margin-left:100%; }
}

/* ============ ALERTS ============ */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 13px;
}
.alert-info { background: #eaedfd; border: 1px solid #c5cbfa; color: #2c3e9e; }
.alert-warning { background: #fef3e7; border: 1px solid #f8d09b; color: #7c4e0a; }
.alert-success { background: #e8f7f5; border: 1px solid #9dddd7; color: #1a6b60; }
.alert-danger { background: #fdecea; border: 1px solid #f5b0ad; color: #8b1a14; }

/* ============ USERS / ROLES ============ */
.user-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
}
.user-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.user-card:hover { border-color: var(--primary-light); box-shadow: var(--shadow); }
.user-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}
.user-card-avatar.role-admin { background: #dc2626; }
.user-card-avatar.role-manager { background: #ea580c; }
.user-card-avatar.role-viewer { background: #2563eb; }
.user-card-body { flex: 1; min-width: 0; }
.user-card-name { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-card-email { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.user-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 7px; flex-wrap: wrap; }
.user-status-dot { width: 6px; height: 6px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.user-card-actions { display: flex; gap: 4px; flex-shrink: 0; }
.user-card-empty { grid-column: 1/-1; text-align: center; color: var(--text-muted); padding: 40px 20px; font-size: 13px; }
.role-badge { padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.role-badge.role-admin { background: #fef2f2; color: #dc2626; }
.role-badge.role-manager { background: #fff7ed; color: #ea580c; }
.role-badge.role-viewer { background: #eff6ff; color: #2563eb; }

.role-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.role-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--bg-card);
  display: grid;
  gap: 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.role-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.role-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.role-card-icon,
.role-color-preview {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
  flex-shrink: 0;
}
.role-card-body {
  flex: 1;
  min-width: 0;
}
.role-card-title {
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.role-card-sub,
.role-card-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.role-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.role-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.role-editor-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.permissions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.permission-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--bg);
}
.permission-group-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  margin-bottom: 10px;
}
.permission-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  font-size: 13px;
}
.permission-toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.contract-compliance-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 18px;
  border: 1px solid #fde1c7;
  border-radius: var(--radius-lg);
  background: #fff7ed;
  color: #7c2d12;
}
.contract-compliance-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffedd5;
  color: #ea580c;
  flex-shrink: 0;
}
.contract-compliance-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 3px;
}
.contract-compliance-text {
  font-size: 13px;
  line-height: 1.45;
}
.contract-list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
    max-height: calc(100vh - 520px);
    overflow: auto;
}
.contract-template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 12px;
  margin-top: 16px;
}
.contract-template-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.contract-template-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.contract-template-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.contract-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.contract-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow);
}
.contract-card-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.contract-doc-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius);
  background: var(--primary-bg);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.contract-card-body {
  min-width: 0;
}
.contract-card-title {
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contract-card-sub,
.contract-card-meta {
  color: var(--text-muted);
  font-size: 12px;
}
.contract-card-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 7px;
}
.contract-card-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 6px;
}
.contract-content-input {
  min-height: 190px;
  line-height: 1.5;
}
.internal-sign-modal { max-width: 620px; }
.signature-pad-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
  margin: 10px 0 14px;
}
.signature-pad {
  display: block;
  width: 100%;
  height: 190px;
  touch-action: none;
  cursor: crosshair;
}
.signature-consent {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
}
.signature-consent input {
  width: 17px;
  height: 17px;
  margin-top: 2px;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.mdm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .85fr);
  gap: 18px;
}
.mdm-console {
  display: grid;
  gap: 16px;
}
.mdm-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow-x: auto;
}
.mdm-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: max-content;
}
.mdm-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 700;
  cursor: pointer;
}
.mdm-tab svg { width: 16px; height: 16px; }
.mdm-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.mdm-top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: max-content;
}
.mdm-header {
  display: grid;
  grid-template-columns: max-content minmax(180px, 1fr) max-content max-content;
  align-items: center;
  gap: 12px;
}
.mdm-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 900;
}
.mdm-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
}
.mdm-search input {
  border: 0;
  outline: 0;
  width: 100%;
  background: transparent;
  color: var(--text);
}
.mdm-live {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--success);
  font-size: 13px;
  font-weight: 800;
}
.mdm-live::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
}
.mdm-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) max-content;
  gap: 10px;
  align-items: center;
}
.mdm-filter-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}
.mdm-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.mdm-kpi {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.mdm-kpi strong { font-size: 22px; }
.mdm-kpi span:last-child { color: var(--text-muted); font-size: 13px; }
.mdm-kpi.blue { background: rgba(37,99,235,.12); }
.mdm-kpi.green { background: rgba(34,197,94,.12); }
.mdm-kpi.gray { background: rgba(148,163,184,.12); }
.mdm-kpi.amber { background: rgba(245,158,11,.16); }
.mdm-map-layout {
  display: grid;
  grid-template-columns: minmax(340px, .72fr) minmax(420px, 1fr);
  gap: 16px;
  min-height: 560px;
}
.mdm-device-panel {
  display: grid;
  align-content: start;
  gap: 10px;
}
.mdm-device-row {
  display: grid;
  grid-template-columns: max-content max-content max-content minmax(0, 1fr) max-content;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  cursor: pointer;
}
.mdm-device-row.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,62,230,.12);
}
.mdm-device-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: var(--primary);
  background: rgba(7,62,230,.12);
}
.mdm-device-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.mdm-device-main strong,
.mdm-device-main span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mdm-device-main span { color: var(--text-muted); font-size: 13px; }
.mdm-device-battery {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--success);
  font-weight: 800;
  font-size: 13px;
}
.mdm-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}
.mdm-dot.online { background: var(--success); }
.mdm-dot.offline { background: #94a3b8; }
.mdm-switch { position:relative; display:inline-block; width:40px; height:22px; flex-shrink:0; }
.mdm-switch input { opacity:0; width:0; height:0; position:absolute; }
.mdm-switch span { position:absolute; cursor:pointer; inset:0; background:#ccc; border-radius:22px; transition:.25s; }
.mdm-switch span::before { content:''; position:absolute; height:16px; width:16px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:.25s; }
.mdm-switch input:checked + span { background:var(--primary); }
.mdm-switch input:checked + span::before { transform:translateX(18px); }
.mdm-map-panel {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  min-height: 420px;
}
.mdm-map-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  font-weight: 900;
  border-bottom: 1px solid var(--border);
}
.mdm-map-panel iframe {
  width: 100%;
  height: calc(100% - 48px);
  min-height: 510px;
  border: 0;
  display: block;
}
.mdm-dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, .75fr);
  gap: 16px;
}
.mdm-dashboard-grid .card:last-child {
  grid-column: 1 / -1;
}
.mdm-qr-box {
  display: grid;
  gap: 14px;
  place-items: center;
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.mdm-qr-box svg {
  width: 90px;
  height: 90px;
  color: var(--primary);
}
.mdm-qr-box img {
  width: 220px;
  height: 220px;
  padding: 10px;
  border-radius: var(--radius);
  background: #fff;
  border: 1px solid var(--border);
}
.mdm-qr-box pre {
  width: 100%;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 12px;
}
.hr-console {
  display: grid;
  gap: 16px;
}
.hr-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow-x: auto;
}
.hr-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}
.hr-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.hr-tab svg { width: 16px; height: 16px; }
.hr-filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr)) max-content;
  gap: 10px;
  padding: 14px;
  align-items: center;
}
.hr-grid {
  display: grid;
  grid-template-columns: minmax(260px, .38fr) minmax(0, 1fr);
  gap: 16px;
}
.hr-form {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 18px;
  height: fit-content;
}
.hr-mini-input {
  width: 82px;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
}
.mdm-api-box {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
}
.mdm-api-title {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-muted);
}
.mdm-api-box code {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--primary);
}
.contract-card.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(7,62,230,0.1);
}
.mdm-detail {
  display: grid;
  gap: 12px;
}
.mdm-command-list {
  display: grid;
  gap: 8px;
}
.mdm-command-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
}
.mdm-console {
  --accent: var(--primary);
  --accent-light: var(--primary-bg);
  --bg-secondary: var(--bg);
  --text-secondary: var(--text-muted);
}
@keyframes mdmSpin {
  to { transform: rotate(360deg); }
}
.form-input {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(7,62,230,.12);
}
.modal-container {
  overflow: visible;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  margin: auto 0;
}
.modal-container .modal-body {
  overflow: visible;
}
.modal-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
  background: var(--primary-bg);
}
.modal-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: auto;
  color: var(--text-muted);
  background: transparent;
}
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-btn,
.filter-btn,
.agent-action-btn {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition), transform .1s;
}
.modal-btn:hover,
.filter-btn:hover,
.agent-action-btn:hover {
  border-color: var(--primary-light);
  background: var(--primary-bg);
  color: var(--primary);
}
.modal-btn:active,
.filter-btn:active,
.agent-action-btn:active { transform: translateY(1px); }
.modal-btn:disabled,
.filter-btn:disabled,
.agent-action-btn:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}
.modal-btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.modal-btn-primary:hover { background: var(--primary-dark); color: #fff; }
.modal-btn-secondary { background: var(--bg); }
.modal-btn-danger,
.agent-action-btn.delete {
  border-color: rgba(230,57,70,.22);
  background: #fdecec;
  color: var(--danger);
}
.modal-btn-danger:hover,
.agent-action-btn.delete:hover {
  border-color: var(--danger);
  background: var(--danger);
  color: #fff;
}
.agent-action-btn.edit {
  color: var(--primary);
  background: var(--primary-bg);
}
.agent-action-btn.bloque {
  color: #7c2d12;
  background: #ffedd5;
  border-color: #fed7aa;
}
.mdm-action-trigger {
  min-width: 112px;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.mdm-action-trigger:hover {
  border-color: var(--primary);
  background: var(--primary-bg);
  color: var(--primary);
}
.mdm-action-dots {
  display: inline-flex;
  align-items: center;
  font-size: 20px;
  line-height: 1;
  margin-top: -3px;
}
.mdm-menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 190;
  background: transparent;
}
.mdm-action-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 999;
  min-width: 260px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: var(--shadow-lg);
}
.leaflet-bottom {
    bottom: 0;
    display: none;
}
.leaflet-top, .leaflet-bottom {
    position: absolute;
    z-index: 998;
    pointer-events: none;
}
.mdm-action-item {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  background: transparent;
  color: var(--text);
  text-align: left;
  font-weight: 700;
  font-size: 13px;
}
.mdm-action-item:hover { background: var(--bg); }
.mdm-action-item.delete { color: var(--danger); }
.mdm-action-icon { display: inline-flex; width: 20px; justify-content: center; flex-shrink: 0; }
.mdm-action-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--border);
}
.param-user-modal { max-width: 560px; }
.account-settings {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.account-settings-nav {
  position: sticky;
  top: 16px;
  padding: 18px;
  display: grid;
  gap: 8px;
}
.account-settings-link {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  color: var(--text-muted);
  border-radius: 8px;
  font-weight: 600;
}
.account-settings-link:hover {
  background: var(--primary-bg);
  color: var(--primary);
}
.account-settings-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.account-settings-main {
  display: grid;
  gap: 18px;
}
.account-profile-card {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.account-profile-avatar {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}
.account-profile-title {
  min-width: 0;
  flex: 1;
}
.account-profile-title h2,
.account-panel h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}
.account-profile-title p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-weight: 600;
}
.account-visibility-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}
.account-panel {
  padding: 24px;
}
.account-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.account-input {
  min-height: 46px;
  border-radius: 8px;
}
.account-password-stack {
  display: grid;
  gap: 18px;
  margin-top: 24px;
}
.account-message .alert {
  margin-bottom: 0;
}
.account-save-bar {
  display: flex;
  justify-content: flex-end;
}

/* ============ EMPTY STATE ============ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  text-align: center;
  color: var(--text-muted);
  gap: 12px;
}
.empty-state-icon { font-size: 48px; opacity: 0.5; display:flex; justify-content:center; }
.empty-state-icon svg { width: 48px; height: 48px; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text); }
.empty-state p { font-size: 13px; max-width: 300px; }

/* ============ TABS ============ */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--border); margin-bottom: 20px; }
.tab-item {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color var(--transition), border-color var(--transition);
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============ E-INVOICING SPECIFIC ============ */
.einvoice-timeline {
  position: relative;
  padding-left: 32px;
}
.einvoice-timeline::before {
  content: '';
  position: absolute;
  left: 8px; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--border);
}
.timeline-item { position: relative; margin-bottom: 24px; }
.timeline-dot {
  position: absolute;
  left: -28px; top: 4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
}
.timeline-dot.active { background: var(--primary); border-color: var(--primary); }
.timeline-dot.done { background: var(--success); border-color: var(--success); }

.format-card {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.format-card:hover, .format-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(7,62,230,0.1); }
.format-card-title { font-weight: 600; margin-bottom: 4px; }
.format-card-desc { font-size: 12px; color: var(--text-muted); }

/* ============ UTILITIES ============ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.w-full { width: 100%; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  html, body, #root { min-height: 100%; }
  body {
    min-height: 100dvh;
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    overflow: hidden;
  }
  .app-wrapper {
    min-height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
    height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
  }
  .sidebar {
    position: fixed;
    left: calc(-1 * (var(--sidebar-width) + var(--safe-left)));
    top: var(--safe-top);
    bottom: var(--safe-bottom);
    width: calc(var(--sidebar-width) + var(--safe-left));
    height: calc(100dvh - var(--safe-top) - var(--safe-bottom));
    padding-left: var(--safe-left);
    transition: left var(--transition);
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { left: 0; }
  .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    z-index: 90;
    background: rgba(26,26,46,0.42);
  }
  .sidebar-toggle,
  .mobile-nav-close { display: inline-flex; }
  .sidebar.collapsed {
    width: calc(var(--sidebar-width) + var(--safe-left));
  }
  .sidebar.collapsed .sidebar-logo {
    justify-content: flex-start;
    padding: 20px 16px;
  }
  .sidebar.collapsed .sidebar-logo-text,
  .sidebar.collapsed .sidebar-footer,
  .sidebar.collapsed .mobile-nav-close {
    display: initial;
  }
  .sidebar.collapsed .sidebar-footer { display: block; }
  .sidebar.collapsed .mobile-nav-close { display: inline-flex; }
  .sidebar.collapsed .nav-item-label { display: inline; }
  .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 16px; }
  .sidebar.collapsed .sidebar-section-label { opacity: 1; }
  .mobile-nav-close { margin-left: auto; color: var(--text-sidebar); }
  .header {
    height: auto;
    min-height: var(--header-height);
    padding: 10px max(14px, var(--safe-right)) 10px max(14px, var(--safe-left));
    align-items: flex-start;
  }
  .header-title { font-size: 16px; }
  .header-subtitle { font-size: 11px; line-height: 1.3; }
  .page-content {
    padding: 16px max(16px, var(--safe-right)) max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
  }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .account-settings { grid-template-columns: 1fr; }
  .account-settings-nav { position: static; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .account-profile-card { align-items: flex-start; flex-wrap: wrap; }
  .account-visibility-toggle { margin-left: 82px; }
  .toolbar { align-items: stretch; }
  .toolbar > * { max-width: 100%; }
  .search-box { min-width: 100%; }
  .filter-select { max-width: none; width: 100%; }
  .card { padding: 16px; border-radius: var(--radius); }
  .card-header { align-items: flex-start; gap: 10px; flex-wrap: wrap; }
  .table-wrapper { max-height: none; -webkit-overflow-scrolling: touch; }
  .modal-overlay {
    align-items: flex-start;
    padding: 10px max(10px, var(--safe-right)) max(10px, var(--safe-bottom)) max(10px, var(--safe-left));
  }
  .modal {
    max-width: 100%;
    z-index: 9999;
  }
  .modal-header,
  .modal-body,
  .modal-footer { padding-left: 16px; padding-right: 16px; }
  .modal-footer { flex-wrap: wrap; }
  .detail-grid { grid-template-columns: 1fr; }
  .planning-table { min-width: 720px; max-height: none; }
  .planning-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .month-view-container { overflow-x: auto; }
  .month-header,
  .month-grid { min-width: 640px; }
  .list-item { align-items: flex-start; flex-direction: column; gap: 8px; }
  .list-item-time { min-width: 0; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .account-settings-nav { grid-template-columns: 1fr; }
  .account-form-grid { grid-template-columns: 1fr; }
  .account-profile-card { display: grid; grid-template-columns: 52px 1fr; }
  .account-profile-avatar { width: 52px; height: 52px; }
  .account-visibility-toggle { grid-column: 1 / -1; margin-left: 0; justify-content: space-between; }
  .account-panel { padding: 18px; }
  .db-kpi-row { grid-template-columns: 1fr !important; }
  .db-donut-wrap,
  .db-contrats { align-items: flex-start; flex-direction: column; gap: 12px; }
  .mdm-grid { grid-template-columns: 1fr; }
  .mdm-header,
  .mdm-filters,
  .mdm-kpis,
  .mdm-map-layout,
  .mdm-dashboard-grid,
  .hr-filters,
  .hr-grid {
    grid-template-columns: 1fr;
  }
  .mdm-topbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .btn { white-space: normal; justify-content: center; }
  .modal-footer .btn { flex: 1 1 120px; }
}

/* ============ SPINNER ============ */
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ INVOICE PREVIEW ============ */
.invoice-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  font-size: 13px;
  max-width: 800px;
}
.invoice-preview-header { display: flex; justify-content: space-between; margin-bottom: 32px; }
.invoice-table th { background: var(--primary-bg); }
.invoice-totals { margin-left: auto; max-width: 300px; margin-top: 16px; }
.invoice-total-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.invoice-total-row.grand { font-size: 16px; font-weight: 700; border-bottom: none; padding-top: 10px; }

/* ====================== CUSTOM SELECT ====================== */
.form-arrow {
  position: absolute;
  top: 50%;
  right: 0.75rem;
  transform: translateY(-50%);
  z-index: 10;
  font-size: 0.75rem;
  line-height: 1;
  color: var(--text-muted);
  pointer-events: none;
}
.custom-dropdown {
  position: relative;
  min-width: 160px;
}
.dropdown-select {
  position: relative;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  cursor: pointer;
  user-select: none;
  width: 100%;
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg-card);
  transition: all 0.2s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.dropdown-select:hover { border-color: var(--primary); background: var(--primary-bg); }
.dropdown-menu {
  position: fixed;
  min-width: 180px;
  z-index: 9999;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.dropdown-menu-search {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
}
.dropdown-menu-search:focus { background: var(--bg-card); }
.dropdown-menu-inner { max-height: 220px; overflow-y: auto; }
.dropdown-menu-item {
  padding: 0.5rem 0.75rem;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
}
.dropdown-menu-item:hover { background: var(--primary-bg); }
.dropdown-menu-item.is-select { background: var(--primary); color: white; }
.dropdown-menu-item.is-select:hover { background: var(--primary-dark); }
/* Mobile */
.custom-dropdown-mobile { position: relative; cursor: pointer; }
.dropdown-select-mobile {
  padding: 0.5rem 2rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.modal-overlay.mobile-selector-overlay {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mobile-selector-modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.25s ease-out;
  box-shadow: var(--shadow-lg);
}
.mobile-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}
.mobile-selector-title { font-size: 15px; font-weight: 700; color: var(--text); }
.mobile-selector-close {
  width: 30px; height: 30px;
  border: none; background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-size: 16px; cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
}
.mobile-selector-close:hover { background: rgba(230,57,70,0.1); color: var(--danger); }
.mobile-selector-search {
  margin: 12px 16px 6px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  outline: none;
  box-sizing: border-box;
  width: calc(100% - 32px);
}
.mobile-selector-search:focus { border-color: var(--primary); }
.mobile-selector-list { flex: 1; overflow-y: auto; padding: 6px 0; }
.mobile-selector-item {
  padding: 12px 18px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.mobile-selector-item:active { background: var(--primary-bg); }
.mobile-selector-item.selected { background: var(--primary); color: white; }
.mobile-selector-empty { text-align: center; padding: 32px 16px; color: var(--text-muted); font-size: 13px; }
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ====================== DASHBOARD ====================== */
.dashboard {
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.db-soft-top {
  display: grid;
  grid-template-columns: minmax(460px, 1fr) minmax(360px, 1fr);
  gap: 22px;
  align-items: stretch;
}
.db-soft-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.db-soft-kpi {
  min-height: 150px;
  border-radius: 8px;
  padding: 22px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 3px 12px rgba(26,26,46,0.12);
}
.db-soft-kpi.accent {
  background: var(--bg-sidebar-active);
  color: #fff;
}
.db-soft-kpi.dark {
  background: #242529;
  color: #fff;
}
.db-soft-icon {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  color: #242529;
  font-size: 20px;
  box-shadow: 0 8px 22px rgba(0,0,0,0.16);
}
.db-soft-kpi-body {
  position: absolute;
  left: 22px;
  bottom: 22px;
}
.db-soft-value {
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
}
.db-soft-label {
  margin-top: 8px;
  font-size: 15px;
  font-weight: 600;
}
.db-soft-delta {
  position: absolute;
  right: 20px;
  bottom: 56px;
  max-width: 120px;
  color: rgba(255,255,255,0.92);
  font-size: 14px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.db-soft-review,
.db-projects-card,
.db-orders-card {
  border-radius: 8px;
  box-shadow: 0 3px 13px rgba(26,26,46,0.10);
}
.db-soft-review {
  min-height: 320px;
  padding: 24px;
  display: flex;
  flex-direction: column;
}
.db-soft-title {
  color: var(--text);
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 28px;
}
.db-soft-progress-list {
  display: grid;
  gap: 20px;
}
.db-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.db-progress-head strong {
  color: var(--text-muted);
  font-size: 15px;
}
.db-progress-track {
  height: 5px;
  border-radius: 999px;
  background: #dedfe5;
  overflow: hidden;
}
.db-progress-fill {
  height: 100%;
  border-radius: inherit;
}
.db-progress-sub {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
}
.db-soft-note {
  margin-top: auto;
  padding-top: 24px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.45;
}
.db-soft-note strong {
  color: var(--text);
}
.db-contract-bars {
  display: flex;
  height: 6px;
  gap: 3px;
  margin-top: 14px;
  overflow: hidden;
  border-radius: 999px;
  background: #dedfe5;
}
.db-contract-bars div {
  min-width: 2px;
}
.db-soft-bottom {
  display: grid;
  grid-template-columns: minmax(520px, 2fr) minmax(320px, 1fr);
  gap: 22px;
}
.db-projects-card,
.db-orders-card {
  padding: 24px;
}
.db-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.db-section-head h3 {
  font-size: 19px;
  line-height: 1.1;
  margin: 0 0 10px;
}
.db-section-head p {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
}
.db-project-table {
  display: grid;
  overflow-x: auto;
}
.db-project-row {
  min-width: 660px;
  display: grid;
  grid-template-columns: minmax(270px, 1fr) 120px 130px 190px;
  align-items: center;
  gap: 18px;
  padding: 17px 2px;
  border-bottom: 1px solid var(--border);
}
.db-project-row:last-child {
  border-bottom: 0;
}
.db-project-head {
  padding-top: 4px;
  color: #9a9aa5;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.db-project-name {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}
.db-project-name strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 14px;
}
.db-project-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.db-project-progress {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-weight: 700;
}
.db-project-track {
  height: 6px;
  border-radius: 999px;
  background: #e1e3e8;
  overflow: hidden;
}
.db-project-track div {
  height: 100%;
  border-radius: inherit;
}
.db-empty {
  padding: 28px 0;
  color: var(--text-muted);
}
.db-timeline {
  position: relative;
  display: grid;
  gap: 24px;
  padding-left: 4px;
}
.db-timeline::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 20px;
  bottom: 20px;
  width: 2px;
  background: #d9dbe1;
}
.db-timeline-item {
  position: relative;
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 14px;
  align-items: start;
}
.db-timeline-icon {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  font-size: 15px;
  font-weight: 800;
}
.db-timeline-icon.green { color: #38a92f; }
.db-timeline-icon.blue { color: #1976e8; }
.db-timeline-icon.orange { color: #f48a10; }
.db-timeline-icon.red { color: #ef4444; }
.db-timeline-icon.dark { color: #242529; }
.db-timeline-item strong {
  display: block;
  margin-top: 1px;
  color: var(--text);
  font-size: 14px;
}
.db-timeline-item p {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
}
@media (max-width: 1180px) {
  .db-soft-top,
  .db-soft-bottom {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 640px) {
  .db-soft-kpis {
    grid-template-columns: 1fr;
  }
  .db-soft-kpi {
    min-height: 132px;
  }
  .db-soft-review,
  .db-projects-card,
  .db-orders-card {
    padding: 18px;
  }
}

/* ====================== PLANNING VIEW ====================== */
.planning-container { flex:1; overflow:auto; }
.planning-table { background:var(--bg-card); border-radius:var(--radius-lg); overflow-x:auto; border:1px solid var(--border); box-shadow:var(--shadow); min-width:800px; 
    max-height: calc(100vh - 230px);}
.planning-body { display: block; }
.time-header { display:grid; background:var(--bg); border-bottom:1px solid var(--border); text-align:center; font-size:13px; font-weight:600; color:var(--text-muted); position:sticky; top:0; z-index:12; }
.time-header-cell { padding:12px 4px; border-right:1px solid var(--border); }
.time-header-cell:last-child { border-right:none; }
.chantier-row { display:grid; min-height:109px; border-bottom:1px solid var(--border); position:relative; }
.chantier-info { padding:12px 16px; border-right:1px solid var(--border); background:var(--bg); position:sticky; left:0; z-index:2; }
.chantier-nom { font-weight:600; font-size:14px; line-height:1.3; }
.chantier-ecart { font-size:11px; color:var(--text-muted); margin-top:4px; }
.chantier-details-btn { margin-top:8px; font-size:11px; padding:4px 10px; background:var(--bg-card); border:1px solid var(--border); border-radius:4px; cursor:pointer; color:var(--text-muted); transition:all .2s; display:inline-flex; align-items:center; gap:4px; }
.chantier-details-btn:hover { background:var(--primary-bg); border-color:var(--primary); }
.time-slots { position:relative; min-height:82px; }
.event-card { position:absolute; top:10px; height:62px; background-color:#dbeafe; border-left:5px solid #3b82f6; border-radius:8px; padding:7px 10px; box-shadow:0 2px 8px rgba(0,0,0,.1); font-size:12px; color:#1e40af; overflow:hidden; z-index:10; cursor:pointer; transition:all .2s ease; min-width:60px; }
.event-card.event-declaree { background-color:#dcfce7; border-left-color:#22c55e; color:#166534; }
.event-card.event-corrigee { background-color:#bbf7d0; border-left-color:#166534; color:#14532d; }
.event-card.event-nonEffectuee,.event-card.event-red { background-color:#fee2e2; border-left-color:#ef4444; color:#991b1b; }
.event-card.event-en_cours { background-color:#fef3c7; border-left-color:#f59e0b; color:#92400e; }
.event-card:hover { transform:scaleY(1.02); box-shadow:0 4px 12px rgba(0,0,0,.15); z-index:20; }
.event-time { font-weight:700; font-size:11px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.event-personne { margin-top:3px; line-height:1.3; font-size:10px; font-weight:500; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.event-recurrent-badge { position:absolute; top:5px; right:8px; font-size:10px; background:rgba(0,0,0,.08); padding:2px 5px; border-radius:4px; display:flex; align-items:center; justify-content:center; }
.event-recurrent-badge svg { width: 11px; height: 11px; }
.event-prevue-badge { position:absolute; bottom:5px; right:6px; font-size:9px; font-weight:700; background:#dbeafe; color:#1d4ed8; padding:1px 5px; border-radius:4px; }
.event-non-prevue-badge { position:absolute; top:4px; right:5px; font-size:10px; font-weight:800; background:#f97316; color:#fff; width:16px; height:16px; border-radius:50%; display:flex; align-items:center; justify-content:center; box-shadow:0 1px 3px rgba(0,0,0,.2); }
.event-en-cours-badge { position:absolute; top:4px; left:5px; width:10px; height:10px; border-radius:50%; background:#22c55e; animation:pulse-green 1.5s infinite; }
.event-non-pointe-badge { position:absolute; bottom:4px; left:5px; font-size:9px; font-weight:700; color:white; background:#dc2626; width:14px; height:14px; border-radius:50%; display:flex; align-items:center; justify-content:center; }
.event-dots { display:flex; gap:5px; margin-top:6px; }
.event-dot { width:7px; height:7px; border-radius:50%; }
@keyframes pulse-green { 0%{box-shadow:0 0 0 0 rgba(34,197,94,.5)} 70%{box-shadow:0 0 0 6px rgba(34,197,94,0)} 100%{box-shadow:0 0 0 0 rgba(34,197,94,0)} }
.month-view-container { padding-bottom:20px; }
.month-header { display:grid; grid-template-columns:repeat(7,1fr); background:var(--bg); border-bottom:1px solid var(--border); }
.month-day-name { padding:10px; text-align:center; font-size:12px; font-weight:600; color:var(--text-muted); }
.month-grid { display:grid; grid-template-columns:repeat(7,1fr); }
.month-cell { min-height:100px; padding:8px; border-right:1px solid var(--border); border-bottom:1px solid var(--border); cursor:pointer; transition:background .15s; }
.month-cell:hover { background:var(--primary-bg); }
.month-cell.other-month { opacity:.4; }
.month-cell-date { font-size:13px; font-weight:600; margin-bottom:4px; }
.month-cell-events { display:flex; flex-direction:column; gap:2px; }
.month-event { padding:2px 6px; border-radius:4px; font-size:11px; display:flex; gap:4px; align-items:center; cursor:pointer; overflow:hidden; }
.month-event.prevue { background:#dbeafe; color:#1e40af; }
.month-event.declaree { background:#dcfce7; color:#166534; }
.month-event.corrigee { background:#bbf7d0; color:#14532d; }
.month-event.nonEffectuee { background:#fee2e2; color:#991b1b; }
.month-event-time { flex-shrink:0; font-weight:600; }
.month-event-title { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.month-event-more { font-size:11px; color:var(--text-muted); padding:2px 4px; }
.list-view-container { padding:8px 0; display:flex; flex-direction:column; gap:6px; }
.list-item { background:var(--bg-card); border-radius:var(--radius); padding:12px 16px; display:flex; align-items:center; gap:16px; cursor:pointer; border:1px solid var(--border); transition:border-color .15s; }
.list-item:hover { border-color:var(--primary); }
.list-item.declaree { border-left:4px solid #22c55e; }
.list-item.corrigee { border-left:4px solid #166534; }
.list-item.nonEffectuee { border-left:4px solid #ef4444; }
.list-item.prevue { border-left:4px solid #3b82f6; }
.list-item-time { font-size:13px; font-weight:700; white-space:nowrap; min-width:120px; }
.list-item-content { flex:1; }
.list-item-title { font-size:14px; font-weight:600; }
.list-item-subtitle { font-size:12px; color:var(--text-muted); }
.list-item-badges { display:flex; align-items:center; gap:6px; }
.recurrent-badge { font-size:11px; padding:2px 8px; border-radius:12px; background:var(--primary-bg); color:var(--primary); font-weight:600; display:inline-flex; align-items:center; gap:4px; }
.recurrent-badge svg { width: 12px; height: 12px; }
.event-absent-badge { font-size:10px; color:#b91c1c; font-weight:600; margin-top:1px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; display:flex; align-items:center; gap:3px; }
.absent-agents-bar { background:#fef2f2; border:1px solid #fecaca; border-radius:8px; padding:7px 14px; display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:6px; }
.absent-bar-label { font-size:11px; font-weight:700; color:#991b1b; white-space:nowrap; display:flex; align-items:center; gap:4px; }
.absent-chip { display:inline-flex; align-items:center; gap:4px; background:#fee2e2; color:#991b1b; border-radius:999px; padding:2px 9px; font-size:11px; font-weight:600; }
.event-tooltip { position:fixed; background:var(--bg-card); border:1px solid var(--border); border-radius:var(--radius); padding:10px 14px; box-shadow:var(--shadow-lg); z-index:2000; min-width:220px; max-width:280px; pointer-events:none; }
.tooltip-title { font-size:13px; font-weight:700; margin-bottom:6px; }
.tooltip-detail { display:flex; gap:8px; font-size:12px; margin-bottom:4px; }
.tooltip-label { color:var(--text-muted); min-width:60px; }
.tooltip-status { font-weight:600; }
.tooltip-status.prevue { color:#3b82f6; }
.tooltip-status.declaree { color:#22c55e; }
.tooltip-status.corrigee { color:#166534; }
.tooltip-status.nonEffectuee { color:#ef4444; }
.empty-state { text-align:center; padding:60px 20px; color:var(--text-muted); font-size:14px; }
.pv-day-btn { padding:5px 10px; border:1px solid var(--border); border-radius:6px; font-size:12px; cursor:pointer; background:transparent; color:var(--text-muted); transition:all .15s; white-space:nowrap; }
.pv-day-btn.active { background:var(--primary); color:white; border-color:var(--primary); }
.planning-hours-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-card);
}
.planning-hours-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
}
.planning-time-input {
  width: 94px;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
  color: var(--text);
  background: var(--bg);
}

/* ===== LOGIN PAGE ===== */
.login-root {
  min-height:100vh;
  display:grid;
  grid-template-columns:minmax(360px, 1fr) minmax(480px, .94fr);
  gap:28px;
  padding:24px;
  background:#fff;
}
.login-form-panel {
  display:flex;
  align-items:center;
  justify-content:center;
  min-height:calc(100vh - 48px);
}
.login-signin-form {
  width:min(420px, 100%);
  display:grid;
  gap:18px;
}
.login-signin-title {
  margin:0;
  color:#171719;
  font-size:34px;
  font-weight:900;
  letter-spacing:0;
}
.login-signin-sub {
  width:min(320px, 100%);
  margin:0 0 18px;
  color:var(--text-muted);
  font-size:22px;
  line-height:1.45;
  font-weight:500;
}
.login-input {
  min-height:64px;
  padding:0 18px;
  border-radius:10px;
  font-size:16px;
}
.login-remember { display:flex; align-items:center; gap:14px; margin:2px 0 24px; }
.login-remember-label { font-size:16px; color:#171719; }
.toggle-switch { position:relative; display:inline-block; width:40px; height:22px; flex-shrink:0; }
.toggle-switch input { opacity:0; position:absolute; inset:0; width:100%; height:100%; margin:0; cursor:pointer; z-index:2; }
.toggle-slider { position:absolute; cursor:pointer; inset:0; background:#ccc; border-radius:22px; transition:.25s; }
.toggle-slider::before { content:''; position:absolute; height:16px; width:16px; left:3px; bottom:3px; background:#fff; border-radius:50%; transition:.25s; }
.toggle-switch input:checked + .toggle-slider { background:var(--primary); }
.toggle-switch input:checked + .toggle-slider::before { transform:translateX(18px); }
.toggle-switch input:focus-visible + .toggle-slider { box-shadow:0 0 0 3px rgba(7,62,230,.2); }
.toggle-switch input:disabled + .toggle-slider { opacity:.5; cursor:not-allowed; }
.login-btn-primary {
  width:100%;
  min-height:64px;
  border:none;
  border-radius:10px;
  background:var(--primary);
  color:#fff;
  box-shadow:0 12px 22px rgba(7,62,230,.28);
  font-size:18px;
  font-weight:900;
  letter-spacing:0;
}
.login-btn-primary:hover:not(:disabled) { background:var(--primary-dark); }
.login-btn-primary:disabled { opacity:.7; }
.login-signup-text {
  margin:18px 0 0;
  text-align:center;
  color:var(--text-muted);
  font-size:16px;
}
.login-signup-link {
  border:0;
  background:transparent;
  color:var(--primary);
  font:inherit;
  font-weight:900;
  cursor:pointer;
}
.login-visual-panel {
  min-height:calc(100vh - 48px);
  position:relative;
  overflow:hidden;
  border-radius:14px;
  display:grid;
  place-items:center;
  background:
    radial-gradient(680px 480px at 55% 45%, rgba(255,255,255,.16), transparent 58%),
    linear-gradient(135deg, var(--primary), var(--primary-dark));
}
.login-psc-panel {
  background:#fff;
  border:1px solid rgba(217,214,238,.75);
}
.login-psc-picture {
  position:absolute;
  inset:0;
  display:block;
}
.login-psc-image {
  width:100%;
  height:100%;
  object-fit:cover;
  object-position:center;
  user-select:none;
  pointer-events:none;
}
.login-psc-image.is-missing {
  display:none;
}
.login-topo {
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  opacity:.72;
}
.login-visual-content {
  position:relative;
  z-index:1;
  width:min(620px, 82%);
  display:grid;
  justify-items:center;
  text-align:center;
  color:#fff;
  padding:40px 0;
}
.login-chat-asset {
  position:relative;
  width:280px;
  height:210px;
  margin-bottom:70px;
  filter:drop-shadow(0 34px 34px rgba(35,20,68,.28));
}
.login-chat-bubble {
  position:absolute;
  inset:22px 16px 36px;
  border-radius:34px;
  background:linear-gradient(145deg,#fff 0%,#f5f5f6 52%,#d8d8dc 100%);
  transform:perspective(760px) rotateY(-12deg) rotateX(4deg) rotateZ(5deg);
  box-shadow:inset -22px -18px 28px rgba(0,0,0,.08), inset 18px 18px 22px rgba(255,255,255,.9);
}
.login-chat-bubble::before {
  content:'';
  position:absolute;
  width:74px;
  height:55px;
  left:22px;
  bottom:-34px;
  background:linear-gradient(135deg,#fff,#e7e7ea);
  clip-path:polygon(0 0, 100% 0, 10% 100%);
}
.login-chat-bubble span {
  position:absolute;
  top:68px;
  width:38px;
  height:46px;
  border-radius:50%;
  background:linear-gradient(135deg,#f391ff 0%,#b825e4 80%);
  box-shadow:inset 7px 0 10px rgba(255,255,255,.45);
}
.login-chat-bubble span:nth-child(1) { left:64px; }
.login-chat-bubble span:nth-child(2) { left:116px; }
.login-chat-bubble span:nth-child(3) { left:168px; }
.login-visual-title {
  margin:0 0 18px;
  color:#fff;
  font-size:31px;
  font-weight:900;
  letter-spacing:0;
}
.login-visual-sub {
  margin:0;
  max-width:620px;
  color:rgba(255,255,255,.96);
  font-size:23px;
  line-height:1.45;
  font-weight:600;
}
@media(max-width:980px){
  .login-root {
    grid-template-columns:1fr;
    gap:0;
    padding:0;
    background:#fff;
  }
  .login-visual-panel {
    order:1;
    min-height:96px;
    margin:14px;
  }
  .login-psc-picture {
    display:grid;
    place-items:center;
    padding:16px;
  }
  .login-psc-image {
    width:min(170px, 48vw);
    height:72px;
    object-fit:contain;
  }
  .login-form-panel {
    order:2;
    min-height:auto;
    padding:42px 22px 56px;
    align-items:flex-start;
  }
  .login-signin-form { max-width:430px; }
  .login-signin-title { font-size:30px; }
  .login-signin-sub { font-size:18px; margin-bottom:10px; }
  .login-input { min-height:54px; font-size:15px; }
  .login-btn-primary { min-height:56px; font-size:16px; }
  .login-chat-asset { width:220px; height:165px; margin-bottom:34px; }
  .login-chat-bubble span { top:52px; width:30px; height:36px; }
  .login-chat-bubble span:nth-child(1) { left:52px; }
  .login-chat-bubble span:nth-child(2) { left:94px; }
  .login-chat-bubble span:nth-child(3) { left:136px; }
  .login-visual-title { font-size:24px; }
  .login-visual-sub { font-size:16px; }
}
@media(max-width:520px){
  .login-visual-panel {
    min-height:82px;
    border-radius:12px;
  }
  .login-psc-picture { padding:10px; }
  .login-psc-image {
    width:min(145px, 44vw);
    height:62px;
  }
  .login-visual-content { width:88%; padding:28px 0; }
  .login-chat-asset { width:174px; height:132px; margin-bottom:22px; }
  .login-chat-bubble { border-radius:24px; }
  .login-chat-bubble::before { width:54px; height:40px; bottom:-25px; }
  .login-chat-bubble span { top:42px; width:23px; height:29px; }
  .login-chat-bubble span:nth-child(1) { left:42px; }
  .login-chat-bubble span:nth-child(2) { left:76px; }
  .login-chat-bubble span:nth-child(3) { left:110px; }
  .login-visual-title { font-size:21px; }
  .login-visual-sub { font-size:14px; }
}

/* ===== LOCK SCREEN ===== */
.lock-root { display:flex; min-height:100vh; overflow:hidden; padding:18px; background:#fff; gap:18px; }
.lock-left {
  flex:0 0 50%; background:#fff;
  display:flex; align-items:center; justify-content:center;
  padding:40px 48px;
}
@media(max-width:700px){
  .lock-root { flex-direction:column; padding:0; }
  .lock-left { flex:none; width:100%; height:60vh; padding:32px 24px; }
  .lock-right { flex:1; }
}
.lock-form { width:100%; max-width:380px; display:flex; flex-direction:column; align-items:center; gap:14px; }
.lock-avatar { display:none; }
.lock-username { font-size:25px; font-weight:900; color:#1a1a2e; text-align:center; }
.lock-subtitle { font-size:16px; color:var(--text-muted); text-align:center; margin-top:-6px; max-width:380px; line-height:1.55; }
.lock-form .form-control { width:100%; text-align:left; min-height:44px; }
.lock-btn-unlock {
  width:100%; background:#111; color:#fff; border:none;
  padding:13px; border-radius:10px;
  font-size:15px; font-weight:700; transition:background .2s; margin-top:4px;
}
.lock-btn-unlock:hover:not(:disabled) { background:#333; }
.lock-btn-unlock:disabled { opacity:.7; }
.lock-right {
  flex:1; background:#171719;
  position:relative; display:flex; align-items:center; justify-content:center; overflow:hidden;
  border-radius:12px;
}
.lock-topo {
  position:absolute; inset:0; pointer-events:none; opacity:.6;
}
.lock-right-content { position:relative; z-index:1; text-align:center; padding:40px; max-width:460px; }
.lock-icon-wrapper { margin-bottom:36px; }
.lock-icon-svg { width:190px; height:225px; filter:drop-shadow(0 18px 42px rgba(0,0,0,0.58)); }
.lock-quote { font-size:26px; font-weight:900; color:#fff; line-height:1.35; margin-bottom:14px; }
.lock-quote-sub { font-size:18px; font-weight:600; color:rgba(255,255,255,0.92); line-height:1.65; }
