/* =============================================
   IMMOGEST – Styles principaux
   Base de données partagée multi-postes
   ============================================= */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #64748b;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #d97706;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --info: #0891b2;
  --info-light: #ecfeff;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #2563eb;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
  --header-height: 64px;
  --transition: all .2s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; scroll-behavior: smooth; }

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

/* ========== PAGE CONNEXION ========== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #1e3a5f 50%, #1e293b 100%);
  padding: 20px;
}
.auth-card {
  background: var(--bg-card);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  text-align: center;
  margin-bottom: 28px;
}
.auth-logo i {
  font-size: 2.5rem;
  color: var(--primary);
  display: block;
  margin-bottom: 8px;
}
.auth-logo h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text);
}
.auth-logo p {
  color: var(--text-muted);
  font-size: .875rem;
  margin-top: 4px;
}
.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 24px;
  gap: 4px;
}
.auth-tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
}
.auth-tab.active {
  background: var(--bg-card);
  color: var(--primary);
  box-shadow: var(--shadow);
}
.auth-form { display: none; }
.auth-form.active { display: block; }
.auth-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid #fecaca;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 16px;
}
.auth-success {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: .875rem;
  margin-bottom: 16px;
}
.btn-auth {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-top: 4px;
}
.btn-auth:hover { background: var(--primary-dark); }
.auth-hint {
  text-align: center;
  margin-top: 14px;
  font-size: .8rem;
  color: var(--text-muted);
}

/* ========== LAYOUT APP ========== */
.app {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width .25s ease;
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .sidebar-title,
.sidebar.collapsed .user-info,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .sidebar-nav .nav-item { justify-content: center; padding: 12px 0; }

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header i { font-size: 1.4rem; color: var(--primary); flex-shrink: 0; }
.sidebar-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  flex: 1;
}
.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-text);
  cursor: pointer; font-size: 1rem; padding: 4px; flex-shrink: 0;
  transition: color .2s;
}
.sidebar-toggle:hover { color: #fff; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700;
  flex-shrink: 0;
}
.user-info { overflow: hidden; }
.user-info span {
  display: block; color: #fff; font-size: .85rem;
  font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-info small {
  display: block; color: var(--sidebar-text);
  font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: var(--transition);
  position: relative;
  white-space: nowrap;
}
.nav-item i { width: 18px; flex-shrink: 0; font-size: .95rem; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: var(--sidebar-text-active); }
.nav-divider { border-top: 1px solid rgba(255,255,255,.08); margin: 8px 0; }
.nav-badge {
  background: var(--danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 99px;
  margin-left: auto;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  transition: margin-left .25s ease;
  padding: 28px;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

/* ========== PAGE HEADER ========== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.page-header-left h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}
.page-header-left p {
  font-size: .875rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ========== CARDS ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card-title i { color: var(--primary); }

/* ========== 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-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.stat-icon.blue { background: #eff6ff; color: #2563eb; }
.stat-icon.green { background: #f0fdf4; color: #16a34a; }
.stat-icon.orange { background: #fff7ed; color: #ea580c; }
.stat-icon.red { background: #fef2f2; color: #dc2626; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.cyan { background: #ecfeff; color: #0891b2; }
.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}
.stat-label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #b45309; }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }
.btn-icon {
  width: 32px; height: 32px; padding: 0;
  justify-content: center;
  border-radius: 6px;
}

/* ========== TABLES ========== */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  font-size: .875rem;
}
thead th {
  background: var(--bg);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ========== BADGES / STATUS ========== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-secondary { background: #f1f5f9; color: var(--secondary); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ========== FORMS ========== */
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: .875rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-group label i { color: var(--primary); margin-right: 4px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color .2s;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control:disabled { background: var(--bg); color: var(--text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.input-password { position: relative; }
.input-password .form-control { padding-right: 42px; }
.toggle-pw {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: .9rem;
}

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}
.modal-box.modal-lg { max-width: 760px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 600; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.2rem; padding: 4px;
  border-radius: 4px; transition: color .2s;
}
.modal-close:hover { color: var(--danger); }
.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ========== TOAST ========== */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 999;
}
.toast {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--primary);
  display: flex; align-items: center; gap: 10px;
  font-size: .875rem;
  min-width: 280px;
  max-width: 380px;
  animation: slideIn .25s ease;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast i { font-size: 1rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
  to { transform: translateX(120%); opacity: 0; }
}
.toast.removing { animation: slideOut .25s ease forwards; }

/* ========== ALERTES PAIEMENTS ========== */
.alert-banner {
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: .875rem;
  font-weight: 500;
}
.alert-banner.danger { background: var(--danger-light); color: var(--danger); border: 1px solid #fecaca; }
.alert-banner.warning { background: var(--warning-light); color: var(--warning); border: 1px solid #fde68a; }
.alert-banner.success { background: var(--success-light); color: var(--success); border: 1px solid #bbf7d0; }
.alert-banner.info { background: var(--info-light); color: var(--info); border: 1px solid #a5f3fc; }
.alert-banner i { font-size: 1.1rem; flex-shrink: 0; }
.alert-banner .alert-content { flex: 1; }
.alert-banner .alert-title { font-weight: 700; margin-bottom: 2px; }

/* ========== ALERTES LISTE ========== */
.alertes-list { display: flex; flex-direction: column; gap: 10px; }
.alerte-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
}
.alerte-item.urgent { border-left: 4px solid var(--danger); }
.alerte-item.warning { border-left: 4px solid var(--warning); }
.alerte-item.info { border-left: 4px solid var(--primary); }
.alerte-icon { font-size: 1.2rem; flex-shrink: 0; }
.alerte-icon.urgent { color: var(--danger); }
.alerte-icon.warning { color: var(--warning); }
.alerte-icon.info { color: var(--primary); }
.alerte-text strong { display: block; font-size: .875rem; }
.alerte-text small { color: var(--text-muted); font-size: .8rem; }

/* ========== BIENS GRID ========== */
.biens-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}
.bien-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: var(--transition);
}
.bien-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.bien-card-header {
  background: linear-gradient(135deg, #1e293b, #334155);
  padding: 20px;
  position: relative;
  color: #fff;
}
.bien-card-icon { font-size: 2rem; margin-bottom: 8px; opacity: .8; }
.bien-card-name { font-size: 1rem; font-weight: 600; }
.bien-card-addr { font-size: .8rem; opacity: .7; margin-top: 2px; }
.bien-card-status { position: absolute; top: 14px; right: 14px; }
.bien-card-body { padding: 16px; }
.bien-info-row {
  display: flex; justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: .83rem;
}
.bien-info-row:last-child { border-bottom: none; }
.bien-info-label { color: var(--text-muted); }
.bien-info-value { font-weight: 600; }
.bien-card-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ========== DEPENSES ========== */
.depenses-resume-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.depense-categorie-card {
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--border);
  text-align: center;
}
.depense-categorie-card .cat-icon {
  font-size: 1.5rem;
  margin-bottom: 8px;
  display: block;
}
.depense-categorie-card .cat-montant {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
}
.depense-categorie-card .cat-label {
  font-size: .78rem;
  color: var(--text-muted);
}
.depense-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px;
  font-size: .85rem;
}
.depense-bar-label { width: 120px; flex-shrink: 0; color: var(--text-muted); }
.depense-bar-track {
  flex: 1; height: 8px; background: var(--bg);
  border-radius: 99px; overflow: hidden;
}
.depense-bar-fill {
  height: 100%; border-radius: 99px;
  background: var(--primary);
  transition: width .4s ease;
}
.depense-bar-value { width: 80px; text-align: right; font-weight: 600; }

/* ========== QUITTANCES ========== */
.quittance-preview {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  max-width: 650px;
  margin: 0 auto;
  font-family: 'Inter', sans-serif;
}
.quittance-preview .q-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  border-bottom: 2px solid #1e293b;
  padding-bottom: 20px;
}
.quittance-preview .q-logo { font-size: 1.4rem; font-weight: 800; color: #1e293b; }
.quittance-preview .q-title { text-align: center; margin-bottom: 28px; }
.quittance-preview .q-title h3 {
  font-size: 1.3rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: #1e293b;
}
.quittance-preview .q-section {
  background: #f8fafc;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.quittance-preview .q-section h4 {
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #64748b;
  margin-bottom: 8px;
}
.quittance-preview .q-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
  font-size: .9rem;
  border-bottom: 1px solid #e2e8f0;
}
.quittance-preview .q-row:last-child { border-bottom: none; }
.quittance-preview .q-total {
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
  background: #1e293b;
  color: #fff;
  border-radius: 8px;
  font-weight: 700;
  font-size: 1rem;
  margin-top: 16px;
}
.quittance-preview .q-signature {
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px dashed #e2e8f0;
  font-size: .85rem;
  color: #64748b;
}

/* ========== FILTERS BAR ========== */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  background: var(--bg-card);
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.filters-bar .form-control { min-width: 160px; flex: 1; max-width: 260px; }
.search-input { position: relative; flex: 1; max-width: 300px; }
.search-input input {
  width: 100%; padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--bg-card);
  transition: border-color .2s;
  font-family: inherit;
}
.search-input input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.search-input i {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem;
}

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: .35; }
.empty-state h3 { font-size: 1.1rem; color: var(--text); margin-bottom: 6px; }
.empty-state p { font-size: .875rem; }

/* ========== TABS ========== */
.page-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 5px;
  margin-bottom: 20px;
}
.page-tab {
  flex: 1;
  padding: 9px 14px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.page-tab:hover { background: var(--bg); color: var(--text); }
.page-tab.active { background: var(--primary); color: #fff; }
.page-tab-panel { display: none; }
.page-tab-panel.active { display: block; }

/* ========== PROGRESS ========== */
.progress-bar {
  height: 8px;
  background: var(--bg);
  border-radius: 99px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width .4s ease;
}
.progress-fill.green { background: var(--success); }
.progress-fill.orange { background: var(--warning); }
.progress-fill.red { background: var(--danger); }

/* ========== LOADING ========== */
.loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== MISC ========== */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.gap-2 { gap: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 240px;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
    width: 240px;
  }
  .sidebar.collapsed { transform: translateX(-100%); }
  .main-content { margin-left: 0 !important; padding: 16px; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .modal-box { max-width: 100%; margin: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .biens-grid { grid-template-columns: 1fr; }
  .page-tabs { flex-wrap: wrap; }
  .mobile-menu-btn {
    display: flex;
    position: fixed; top: 14px; left: 14px;
    z-index: 150;
    background: var(--sidebar-bg);
    color: #fff; border: none;
    width: 40px; height: 40px;
    border-radius: 8px;
    align-items: center; justify-content: center;
    cursor: pointer; font-size: 1.1rem;
    box-shadow: var(--shadow-md);
  }
}
@media (min-width: 769px) {
  .mobile-menu-btn { display: none; }
}

/* ========== CONNEXION MULTI-POSTES INDICATOR ========== */
.sync-indicator {
  position: fixed;
  bottom: 80px;
  right: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 6px 14px;
  font-size: .75rem;
  color: var(--text-muted);
  box-shadow: var(--shadow);
  z-index: 50;
}
.sync-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s infinite;
}
.sync-dot.offline { background: var(--danger); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ========== CHART CONTAINERS ========== */
.chart-container {
  position: relative;
  height: 260px;
  width: 100%;
}

/* ========== GRID LAYOUT ========== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
@media (max-width: 1024px) {
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 640px) {
  .grid-3 { grid-template-columns: 1fr; }
}
