:root {
  --primary: #3E6FF3;
  --primary-dark: #2F5BD9;
  --primary-light: #EAF0FE;
  --bg: #F4F6FB;
  --card-bg: #ffffff;
  --card-bg2:#F4F6FB;
  --sidebar-bg: #ffffff;
  --text: #2B2B3D;
  --text-muted: #8A8FA3;
  --border: #EEF0F5;
  --border2:#F4F6FB;
  --success: #22C55E;
  --success-light: #E7F8EE;
  --warning: #F59E0B;
  --warning-light: #FEF3E2;
  --danger: #EF4444;
  --danger-light: #FDEAEA;
  --info: #14B8A6;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow-card: 0 4px 20px rgba(31, 41, 61, 0.06);
  --shadow-card-hover: 0 8px 28px rgba(31, 41, 61, 0.09);
  --sidebar-w: 250px;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding-top: 4px;
  font-size: 15px;
}

/* Fine liseré coloré en haut de l'écran */
body::before {
  content: '';
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 0px;
  background: linear-gradient(90deg, var(--primary), #8CB2FF);
  z-index: 3000;
}

a { text-decoration: none; color: var(--primary); }

/* ---------- Layout d'authentification ---------- */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: linear-gradient(135deg, #EEF3FF 0%, var(--bg) 60%);
}
.auth-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-card-hover);
}
.auth-card h1 {
  font-size: 22px;
  margin-bottom: 4px;
}
.auth-card p.subtitle {
  color: var(--text-muted);
  margin-top: 0;
  margin-bottom: 28px;
  font-size: 14px;
}

/* ---------- App layout ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--text);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  transition: transform .25s ease;
}
.sidebar .brand {
  padding: 24px 22px 18px;
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.sidebar .brand .brand-mark {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light);
  border-radius: 9px;
  font-size: 16px;
}
.sidebar .brand .brand-logo {
  max-width: 100%;
  max-height: 52px;
  object-fit: contain;
}
.sidebar nav { padding: 6px 14px; flex: 1; overflow-y: auto; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  font-size: 14px;
  font-weight: 600;
}
.sidebar nav a:hover { background: #F7F8FC; color: var(--text); }
.sidebar nav a.active { background: var(--primary-light); color: var(--primary); }

/* ---------- Icônes SVG (remplacent les émojis) ---------- */
.icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; vertical-align: middle; }
.sidebar .brand .icon { width: 26px; height: 26px; color: var(--primary); }
.topbar #menuToggle .icon { width: 22px; height: 22px; }
.topbar-logout .icon { width: 18px; height: 18px; display: block; }
.stat-icon .icon { width: 20px; height: 20px; color: var(--primary); }
.stat-icon.success .icon { color: var(--success); }
.stat-icon.warning .icon { color: #B45309; }
.stat-icon.danger .icon { color: var(--danger); }

.main-area { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 14px 28px;
  background: var(--card-bg2);
  border-bottom: 1px solid var(--border2);
  gap: 14px;
}
.topbar #menuToggle {
  display: none;
  background: none;
  border: none;
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  /* Zone tactile d'au moins 44x44 px (recommandation mobile). */
  padding: 0;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-left: -8px;
  border-radius: 10px;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.topbar #menuToggle:active { background: var(--primary-light); }
/* L'icône ne capte pas le clic : l'évènement vise toujours le <button>. */
.topbar #menuToggle .icon,
.topbar #menuToggle svg * { pointer-events: none; }
.topbar-title { display: none; font-weight: 700; font-size: 15px; }
.topbar-logo {
  display: none;
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: #fff;
  border: 1px solid var(--border, #e5e7eb);
  flex-shrink: 0;
}
.topbar-spacer { flex: 1; }
.topbar-user { display: flex; align-items: center; gap: 10px; }
.topbar-user-info { text-align: right; line-height: 1.25; }
.topbar-user-info .name { display: block; font-weight: 700; font-size: 13.5px; color: var(--text); }
.topbar-user-info .role { display: block; font-size: 10.5px; color: var(--text-muted); letter-spacing: .04em; }
.topbar-logout {
  color: var(--text-muted);
  font-size: 17px;
  padding: 7px;
  border-radius: 50%;
  background: #F7F8FC;
  line-height: 1;
  margin-left: 4px;
}
.topbar-logout:hover { background: var(--danger-light); color: var(--danger); }

.content { padding: 28px 32px; flex: 1; }

.app-footer {
  padding: 14px 32px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.app-footer a { color: var(--text-muted); text-decoration: underline; }
.app-footer a:hover { color: var(--primary); }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 22px;
}
.page-header h1 { font-size: 22px; margin: 0; font-weight: 800; }
.page-header p { color: var(--text-muted); margin: 4px 0 0; font-size: 14px; }

/* ---------- Cartes / composants ---------- */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 22px;
  border: none;
  box-shadow: var(--shadow-card);
  margin-bottom: 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius);
  padding: 20px;
  transition: box-shadow .15s ease, transform .15s ease;
}
a.stat-card:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.stat-card .label { color: var(--text-muted); font-size: 13px; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 4px; }
.stat-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  font-size: 18px;
  margin-bottom: 12px;
  background: var(--primary-light);
}
.stat-icon.success { background: var(--success-light); }
.stat-icon.warning { background: var(--warning-light); }
.stat-icon.danger { background: var(--danger-light); }

table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td {
  padding: 12px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
table.table th { color: var(--text-muted); font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
table.table tbody tr:hover { background: #FAFBFD; }
.table-responsive { overflow-x: auto; }

.badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.badge-nouveau { background: var(--primary-light); color: var(--primary-dark); }
.badge-en-cours { background: var(--warning-light); color: #B45309; }
.badge-resolu { background: var(--success-light); color: #15803D; }
.badge-ferme { background: #F1F2F6; color: #5B5F73; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  transition: background .15s ease;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: var(--primary-light); border-color: transparent; color: var(--primary-dark); }
.btn-outline:hover { background: #DCE6FE; color: var(--primary-dark); }
.btn-filter : { margin-bottom: 10px; }
.btn-sm { padding: 7px 15px; font-size: 13px; }
.btn-success { background: var(--success); }
.btn-success:hover { background: #16A34A; }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #DC2626; }
.btn-block { width: 100%; justify-content: center; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 700; color: var(--text); }
.form-control, select.form-control, textarea.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  background: #FAFBFD;
  color: var(--text);
}
.form-control:focus { outline: none; border-color: var(--primary); background-color: #fff; box-shadow: 0 0 0 3px var(--primary-light); }

/* ---------- Listes déroulantes (select) : flèche personnalisée ---------- */
select.form-control {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8FA3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
  cursor: pointer;
}
select.form-control:focus {
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233E6FF3' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}

/* ---------- Cases à cocher ---------- */
input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--primary);
  cursor: pointer;
  vertical-align: middle;
  flex-shrink: 0;
}

/* ---------- Champs de date / heure ---------- */
input[type="date"].form-control,
input[type="datetime-local"].form-control,
input[type="time"].form-control {
  color-scheme: light;
  cursor: pointer;
}
input[type="date"].form-control::-webkit-calendar-picker-indicator,
input[type="datetime-local"].form-control::-webkit-calendar-picker-indicator,
input[type="time"].form-control::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(0.5) sepia(1) saturate(4) hue-rotate(190deg);
  border-radius: 4px;
  padding: 3px;
}
input[type="date"].form-control::-webkit-calendar-picker-indicator:hover,
input[type="datetime-local"].form-control::-webkit-calendar-picker-indicator:hover,
input[type="time"].form-control::-webkit-calendar-picker-indicator:hover {
  background: var(--primary-light);
}

.search-input-wrap { position: relative; }
.search-input-wrap .search-input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  display: flex;
  pointer-events: none;
}
.search-input-wrap .form-control { padding-left: 38px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }

/* ---------- Sélecteur de lots (recherche + sélection multiple) ---------- */
.lot-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.lot-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border-radius: 20px;
  padding: 5px 6px 5px 12px;
  font-size: 12.5px;
  font-weight: 700;
}
.lot-chip button {
  background: rgba(0,0,0,0.08);
  border: none;
  color: var(--primary-dark);
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.lot-dropdown-list {
  max-height: 100px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 4px 12px;
  background: #FAFBFD;
}
.lot-dropdown-list .cf-lot-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 2px;
  font-weight: 400;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.lot-dropdown-list .cf-lot-item:last-child { border-bottom: none; }

.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px; }
.alert-success { background: var(--success-light); color: #15803D; }
.alert-danger { background: var(--danger-light); color: #B91C1C; }
.alert-info { background: var(--primary-light); color: var(--primary-dark); }

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }

.tag-priorite { font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 20px; }
.tag-basse { background: #F1F2F6; color: #5B5F73; }
.tag-normale { background: var(--primary-light); color: var(--primary-dark); }
.tag-haute { background: var(--warning-light); color: #B45309; }
.tag-urgente { background: var(--danger-light); color: #B91C1C; }

.thread-item { border-left: 3px solid var(--primary-light); padding: 10px 0 10px 16px; margin-bottom: 4px; }
.thread-item .meta { font-size: 12.5px; color: var(--text-muted); margin-bottom: 3px; }

.receipt-box {
  max-width: 640px;
  margin: 0 auto;
  background-color: #fff;
  background-image: none;
  background-repeat: no-repeat;
  background-position: center 55%;
  background-size: 65% auto;
  border: none;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius);
  padding: 36px;
  position: relative;
}
.receipt-box .r-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--text); padding-bottom: 16px; margin-bottom: 20px; }
.receipt-box .r-title { font-size: 20px; font-weight: 800; }
.receipt-box table { width: 100%; border-collapse: collapse; margin: 18px 0; }
.receipt-box table td { padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.receipt-box .r-total { font-size: 18px; font-weight: 800; text-align: right; margin-top: 10px; }

.receipt-cachet-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-top: 22px;
}
.receipt-cachet-row > div:first-child { flex: 1; }
.receipt-cachet { text-align: center; flex-shrink: 0; }
.receipt-cachet img { width: 120px; height: auto; transform: rotate(-6deg); opacity: 0.9; }
.receipt-cachet-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
  transform: rotate(-6deg);
}

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
  body::before { display: none; }
  .receipt-box { border: none; box-shadow: none; }
}

/* ---------- Cartes copropriétaires (mobile) ---------- */
.desktop-only-table { display: block; }
.coowner-cards { display: none; }

.coowner-card {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.coowner-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.coowner-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #8CB2FF);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex-shrink: 0;
}
.coowner-card-name { font-weight: 700; font-size: 15.5px; line-height: 1.3; }
.coowner-card-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }
.coowner-card-header .badge { margin-left: auto; flex-shrink: 0; }

.coowner-card-amount {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 12px;
}
.coowner-card-amount .label { font-size: 12.5px; color: var(--text-muted); }
.coowner-card-amount .amount { font-size: 18px; font-weight: 800; }

.coowner-card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
  margin-bottom: 14px;
}
.coowner-card-grid .item-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.coowner-card-grid .item-value { font-size: 13.5px; word-break: break-word; }
.coowner-card-grid .item-value.full { grid-column: 1 / -1; }

/* ---------- Cartes mobiles génériques (lots, dépenses, demandes, paiements, annonces) ---------- */
.mobile-cards { display: none; }

.mcard {
  background: var(--card-bg);
  border: none;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.mcard-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 8px; }
.mcard-title { font-weight: 700; font-size: 15px; line-height: 1.35; }
.mcard-sub { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.mcard-header .badge, .mcard-header .tag-priorite { flex-shrink: 0; }

.mcard-body { font-size: 13.5px; color: var(--text); margin: 8px 0; }

.mcard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; margin: 10px 0; font-size: 13.5px; }
.mcard-grid .item-label { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--text-muted); margin-bottom: 2px; }
.mcard-grid .item-value { word-break: break-word; }
.mcard-grid .item-value.full { grid-column: 1 / -1; }

.mcard-amount {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
}
.mcard-amount .label { font-size: 12.5px; color: var(--text-muted); }
.mcard-amount .amount { font-size: 17px; font-weight: 800; }

.mcard-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.mcard-actions > a, .mcard-actions > form, .mcard-actions > button { flex: 1; min-width: 100px; }
.mcard-actions form { display: flex; }
.mcard-actions .btn { width: 100%; }

/* ---------- Photo de profil ---------- */
.avatar-photo {
  width: 44px; height: 44px; border-radius: 50%;
  object-fit: cover; flex-shrink: 0; background: var(--primary-light);
}
.avatar-photo.lg { width: 96px; height: 96px; }
.avatar-upload-row { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }

/* ---------- Fenêtres modales ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(30, 35, 55, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(20,20,50,0.22);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--text-muted); padding: 4px; }
.modal-close:hover { color: var(--text); }
.modal-error { display: none; }
.modal-error.show { display: block; }

/* ---------- Tableau de bord financier : graphiques en barres CSS ---------- */
.finance-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-bottom: 24px; }
.finance-kpi { background: var(--card-bg); border: none; box-shadow: var(--shadow-card); border-radius: var(--radius); padding: 20px; }
.finance-kpi .label { color: var(--text-muted); font-size: 13px; }
.finance-kpi .value { font-size: 24px; font-weight: 800; margin-top: 4px; }
.finance-kpi .variation { font-size: 12.5px; font-weight: 700; margin-top: 6px; display: inline-flex; align-items: center; gap: 4px; }
.finance-kpi .variation.up { color: var(--success); }
.finance-kpi .variation.down { color: var(--danger); }
.finance-kpi .variation.neutral { color: var(--text-muted); }
.variation-arrow { width: 11px; height: 11px; vertical-align: middle; }

.bar-legend { display: flex; gap: 18px; font-size: 12.5px; color: var(--text-muted); margin-bottom: 14px; flex-wrap: wrap; }
.bar-legend .dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: middle; }

/* ---------- Calendrier des travaux ---------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-weekday {
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  padding-bottom: 6px;
}
.calendar-day {
  min-height: 84px;
  background: #FAFBFD;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  overflow: hidden;
}
.calendar-day.empty { background: transparent; border: none; }
.calendar-day.today { border-color: var(--primary); background: var(--primary-light); }
.calendar-day-num { font-size: 12px; font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.calendar-day.today .calendar-day-num { color: var(--primary); }
.calendar-event {
  font-size: 10.5px;
  font-weight: 600;
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.calendar-event-a_faire { background: #94a3b8; }
.calendar-event-en_cours { background: var(--primary); }
.calendar-event-termine { background: var(--success); }
.calendar-event-more { font-size: 10px; color: var(--text-muted); }

@media (max-width: 700px) {
  .calendar-grid { grid-template-columns: repeat(7, 1fr); gap: 3px; }
  .calendar-day { min-height: 56px; padding: 3px; }
  .calendar-weekday { font-size: 9px; }
  .calendar-day-num { font-size: 10px; }
  .calendar-event { font-size: 8.5px; padding: 1px 3px; }
}

.bar-chart-wrap { overflow-x: auto; }
.bar-chart { display: flex; align-items: flex-end; gap: 10px; height: 180px; padding: 10px 4px 0; }
.bar-chart.days { gap: 4px; min-width: 620px; }
.bar-group { flex: 1; min-width: 22px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar-pair { display: flex; align-items: flex-end; gap: 3px; height: 100%; width: 100%; justify-content: center; }
.bar-pair .bar { width: 12px; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart.days .bar-pair .bar { width: 6px; }
.bar-pair .bar.current { background: var(--primary); }
.bar-pair .bar.previous { background: var(--primary-light); }
.bar-pair .bar.depenses { background: var(--danger); }
.bar-group .bar-label { font-size: 10.5px; color: var(--text-muted); margin-top: 6px; white-space: nowrap; }

@media (max-width: 700px) {
  .desktop-only-table { display: none; }
  .mobile-cards { display: block; }
  .coowner-cards { display: block; }
  .finance-kpis { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .bar-chart { min-width: 520px; }
}

@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    z-index: 1000;
    height: 100vh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .topbar #menuToggle { display: inline-flex; }
  .topbar-title { display: block; }
  .topbar-logo { display: block; }
  .topbar-user-info { display: none; }
  .content { padding: 18px; }
  .app-footer { padding: 14px 18px; }
  .page-header h1 { font-size: 19px; }
  .page-header { flex-direction: column; align-items: stretch; }
  .page-header > a.btn, .page-header > div + a.btn { align-self: stretch; text-align: center; }
  .card { padding: 16px; }
}

/* Tableaux -> cartes empilées sur petit écran (utiliser class="table responsive-cards") */
@media (max-width: 700px) {
  table.responsive-cards thead { display: none; }
  table.responsive-cards, table.responsive-cards tbody,
  table.responsive-cards tr, table.responsive-cards td { display: block; width: 100%; }
  table.responsive-cards tr {
    margin-bottom: 14px;
    border: none;
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-sm);
    padding: 4px 14px;
    background: #fff;
  }
  table.responsive-cards td {
    border: none;
    border-bottom: 1px solid #F1F2F6;
    padding: 9px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    text-align: right;
    font-size: 14px;
  }
  table.responsive-cards td:last-child { border-bottom: none; }
  table.responsive-cards td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-align: left;
    flex-shrink: 0;
  }
  table.responsive-cards td:empty::before { content: none; }
  table.responsive-cards td[data-label=""] { justify-content: center; }
  table.responsive-cards td[data-label=""]::before { content: none; }

  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .btn { width: 100%; justify-content: center; }
  .btn.btn-sm { width: auto; }
  form[style*="display:inline"] { display: inline-block !important; }
}

/* =====================================================================
   Autocomplétion (assets/js/autocomplete.js)
   ===================================================================== */
.ac-panel {
  position: fixed;
  z-index: 3500;
  display: none;
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 34px rgba(31, 41, 61, 0.16);
  padding: 6px;
  min-width: 220px;
}
.ac-panel.open { display: block; }

.ac-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 11px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.35;
}
.ac-item.active, .ac-item:hover { background: var(--primary-light); }
.ac-item-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ac-item-label { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-item-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
}
.ac-item-tag {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--primary-light);
  border-radius: 20px;
  padding: 3px 9px;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ac-item mark { background: rgba(62, 111, 243, 0.18); color: inherit; border-radius: 3px; padding: 0 1px; }
.ac-item.active mark { background: rgba(62, 111, 243, 0.3); }
.ac-empty { padding: 14px 12px; font-size: 13.5px; color: var(--text-muted); text-align: center; }

/* =====================================================================
   Calendrier / sélecteur de date (assets/js/datepicker.js)
   ===================================================================== */
.dp-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238A8FA3' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='3' y='4.5' width='18' height='16' rx='2'/%3E%3Cline x1='3' y1='9.5' x2='21' y2='9.5'/%3E%3Cline x1='8' y1='2.5' x2='8' y2='6.5'/%3E%3Cline x1='16' y1='2.5' x2='16' y2='6.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 17px 17px;
  padding-right: 40px;
}

.dp-panel {
  position: fixed;
  z-index: 3600;
  width: 300px;
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(31, 41, 61, 0.22);
  overflow: hidden;
  user-select: none;
}

.dp-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--border);
}
.dp-title { font-size: 15.5px; font-weight: 700; color: var(--text); }
.dp-nav {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  border: none;
  border-radius: 12px;
  background: #F4F6FB;
  color: var(--text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.dp-nav:hover { background: var(--primary-light); color: var(--primary-dark); }

.dp-body { padding: 12px 12px 6px; }
.dp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.dp-wd {
  text-align: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  padding: 4px 0 8px;
}
.dp-day {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  height: 34px;
  border-radius: 11px;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
}
.dp-day:hover { background: var(--primary-light); color: var(--primary-dark); }
.dp-day.dp-out { color: #C7CBD8; font-weight: 500; }
.dp-day.dp-today { color: var(--primary); text-decoration: underline; text-underline-offset: 3px; }
.dp-day.dp-selected,
.dp-day.dp-selected:hover {
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 4px 12px rgba(62, 111, 243, 0.4);
}

.dp-foot {
  display: flex;
  gap: 6px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
}
.dp-btn {
  flex: 1;
  border: none;
  background: #F4F6FB;
  color: var(--text);
  border-radius: 12px;
  padding: 9px 4px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.dp-btn:hover { background: var(--primary-light); color: var(--primary-dark); }

/* =====================================================================
   Statuts de paiement : en cours (orange), réglé (vert), rejeté (rouge)
   ===================================================================== */
.badge-pay-encours { background: var(--warning-light); color: #B45309; }
.badge-pay-regle   { background: var(--success-light); color: #15803D; }
.badge-pay-rejete  { background: var(--danger-light);  color: #B91C1C; }

/* Petite pastille de couleur en tête de ligne / de carte */
.pay-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.pay-dot-encours { background: var(--warning); }
.pay-dot-regle   { background: var(--success); }
.pay-dot-rejete  { background: var(--danger); }

tr.pay-row-rejete td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
tr.pay-row-encours td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
tr.pay-row-regle td:first-child { box-shadow: inset 3px 0 0 var(--success); }
tr.pay-row-rejete { opacity: .75; }

/* Pied de liste « Voir plus » */
.list-more {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 16px;
  text-align: center;
}
.list-more .list-more-info { font-size: 13px; color: var(--text-muted); }

/* Barre de filtres compacte */
.filter-bar { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; align-items: end; }
.filter-bar .form-group { margin-bottom: 0; }

@media (max-width: 480px) {
  .dp-panel { width: calc(100vw - 24px); max-width: 320px; }
  .filter-bar { grid-template-columns: 1fr; }
}

/* Choix du statut de paiement dans le formulaire (boutons radio stylés) */
.statut-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.statut-choice {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: #FAFBFD;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
}
.statut-choice input { margin: 0 6px 0 0; width: 15px; height: 15px; flex-shrink: 0; }
.statut-choice-encours input { accent-color: var(--warning); }
.statut-choice-regle input   { accent-color: var(--success); }
.statut-choice-rejete input  { accent-color: var(--danger); }
.statut-choice-encours:has(input:checked) { border-color: var(--warning); background: var(--warning-light); color: #B45309; }
.statut-choice-regle:has(input:checked)   { border-color: var(--success); background: var(--success-light); color: #15803D; }
.statut-choice-rejete:has(input:checked)  { border-color: var(--danger);  background: var(--danger-light);  color: #B91C1C; }
/* Repli pour les navigateurs sans :has() */
.statut-choice.is-checked.statut-choice-encours { border-color: var(--warning); background: var(--warning-light); color: #B45309; }
.statut-choice.is-checked.statut-choice-regle   { border-color: var(--success); background: var(--success-light); color: #15803D; }
.statut-choice.is-checked.statut-choice-rejete  { border-color: var(--danger);  background: var(--danger-light);  color: #B91C1C; }

@media (max-width: 480px) {
  .statut-choices { grid-template-columns: 1fr; }
}

/* Libellés masqués sur très petits écrans (ex: navigation du calendrier). */
@media (max-width: 520px) {
  .hide-xs { display: none; }
}

/* =====================================================================
   Barre de filtres et tri des tableaux (page Lots)
   ===================================================================== */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
  align-items: end;
}
.filter-grid .form-group { margin-bottom: 0; }

.filter-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.filter-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 400;
  font-size: 14px;
  color: var(--text-muted);
  cursor: pointer;
}
.filter-check input { accent-color: var(--primary); }
.filter-resume {
  margin: 14px 0 0;
  font-size: 13.5px;
  color: var(--text-muted);
}

/* En-têtes de colonnes cliquables */
.th-sort { padding: 0 !important; }
.th-sort a {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 16px;
  color: inherit;
  white-space: nowrap;
}
.th-sort a:hover { color: var(--primary); }
.th-sort.is-sorted a { color: var(--primary); }
.th-arrow { font-size: 9px; letter-spacing: -.05em; }

/* Colonnes de montants : chiffres alignés */
.table-lots td.num, .table-lots th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.table-lots tfoot td {
  border-top: 2px solid var(--border);
  background: var(--bg);
  font-size: 13.5px;
}

@media (max-width: 720px) {
  .filter-grid { grid-template-columns: 1fr; }
  /* Le champ de recherche occupe deux colonnes en grand écran : sur mobile,
     cette consigne créerait une deuxième colonne implicite et tasserait les
     listes déroulantes. */
  .filter-grid > .form-group { grid-column: auto !important; }
  .filter-actions { flex-direction: column; align-items: stretch; }
}

/* =====================================================================
 * PILOTAGE DES DÉPENSES (admin/pilotage_depenses.php)
 * ===================================================================== */
.badge-nature-charge  { background: var(--primary-light); color: var(--primary-dark); }
.badge-nature-imprevu { background: var(--warning-light); color: #B45309; }
.badge-nature-travaux { background: #E6F7F5; color: #0F766E; }

/* Choix de la nature dans le formulaire de dépense (réutilise .statut-choice) */
.nature-choice-charge_courante input { accent-color: var(--primary); }
.nature-choice-imprevu input { accent-color: var(--warning); }
.nature-choice-travaux input { accent-color: var(--info); }
.nature-choice-charge_courante:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.nature-choice-imprevu:has(input:checked) { border-color: var(--warning); background: var(--warning-light); color: #B45309; }
.nature-choice-travaux:has(input:checked) { border-color: var(--info); background: #E6F7F5; color: #0F766E; }

.pilot-kpis { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.kpi-sub { color: var(--text-muted); font-size: 12px; margin-top: 4px; }
.nature-kpi { color: var(--text); border: 2px solid transparent; transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease; }
.nature-kpi:hover { box-shadow: var(--shadow-card-hover); transform: translateY(-2px); }
.nature-kpi.is-active { border-color: var(--nature); }
.variation-inline { font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.variation-inline.up { color: var(--success); }
.variation-inline.down { color: var(--danger); }

.pilot-title { margin: 0 0 14px; font-size: 16px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.pilot-sub { margin: 4px 0 0; font-size: 12.5px; color: var(--text-muted); }
.pilot-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.pilot-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.pilot-grid-2 > .card { margin-bottom: 20px; }
.aging-grid { grid-template-columns: minmax(0, 1fr); gap: 0; }
.pilot-scroll { max-height: 420px; overflow-y: auto; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Sélecteur segmenté */
.seg { display: inline-flex; background: #F4F6FB; border-radius: 999px; padding: 4px; gap: 2px; }
.seg a { padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700; color: var(--text-muted); }
.seg a.active { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 4px rgba(31,41,61,.08); }

/* Barres de progression */
.progress { position: relative; height: 8px; background: #EEF0F5; border-radius: 999px; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary); max-width: 100%; }
.progress-marker { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--text); opacity: .55; border-radius: 2px; transform: translateX(-1px); }
.progress-inline { display: flex; align-items: center; gap: 10px; font-size: 12.5px; font-weight: 700; }
.progress-inline .progress { flex: 1; min-width: 90px; }

/* Barres horizontales + anneau */
.pilot-split { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 28px; align-items: center; }
.hbar-row { display: grid; grid-template-columns: 150px 1fr 80px; gap: 12px; align-items: center; margin-bottom: 10px; font-size: 13px; }
.hbar-label { text-align: right; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { height: 22px; background: #F4F6FB; border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; min-width: 3px; }
.hbar-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; justify-content: center; }
.donut { width: 190px; height: 190px; border-radius: 50%; position: relative; flex-shrink: 0; }
.donut-center { position: absolute; inset: 24%; background: #fff; border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center span { font-size: 18px; font-weight: 800; }
.donut-center small { font-size: 11px; color: var(--text-muted); }
.donut-legend { display: flex; flex-direction: column; gap: 7px; font-size: 12.5px; min-width: 170px; }
.donut-legend > div { display: flex; align-items: center; gap: 8px; }
.donut-legend .lg-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 160px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.bar-legend .dot.dash { width: 16px; height: 0; border-top: 2px dashed var(--text-muted); border-radius: 0; }

/* Tableau « payé par prestataire » */
.heat-table td.num { border-bottom: 2px solid #fff; }
.mini-kpi { border: 1.5px solid var(--border); border-radius: var(--radius-sm); padding: 8px 16px; text-align: center; }
.mini-kpi span { display: block; font-size: 12px; color: var(--text-muted); }
.mini-kpi strong { font-size: 19px; font-weight: 800; }

/* Trésorerie */
.treso-table td { padding: 10px 4px; font-size: 13.5px; }
.treso-table tr.treso-sub td { background: #FAFBFD; border-bottom: 1.5px solid var(--border); }
.treso-cover { margin-top: 14px; background: var(--primary-light); border-radius: var(--radius-sm); padding: 12px 16px; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; align-items: center; }
.treso-cover span { font-size: 13px; font-weight: 700; color: var(--primary-dark); }
.treso-cover strong { font-size: 20px; color: var(--primary-dark); grid-row: span 2; }
.treso-cover small { font-size: 11.5px; color: var(--text-muted); }
.vbars { display: flex; gap: 16px; align-items: flex-end; height: 150px; }
.vbar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.vbar-val { font-size: 11.5px; font-weight: 700; margin-bottom: 4px; }
.vbar-track { flex: 1; width: 100%; max-width: 46px; display: flex; align-items: flex-end; }
.vbar { width: 100%; background: linear-gradient(180deg, #6C8EF5, var(--primary)); border-radius: 6px 6px 0 0; min-height: 2px; }

/* Budget */
.budget-table tfoot td, .aging-table tfoot td { font-weight: 800; border-top: 2px solid var(--border); border-bottom: none; }
.budget-reprise { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: #FAFBFD; border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 14px; font-size: 13px; font-weight: 600; }
.budget-section-title { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.budget-line { display: grid; grid-template-columns: 1fr 170px; gap: 10px; align-items: center; margin-bottom: 8px; }
.budget-line label { font-size: 13.5px; font-weight: 600; }
.budget-line .form-control { padding: 8px 12px; }
.budget-total { text-align: right; margin: 6px 0 14px; font-size: 14px; }

/* Évolution mensuelle (barres empilées) */
.stack-chart { position: relative; display: flex; align-items: flex-end; gap: 8px; height: 270px; padding-top: 10px; min-width: 420px; }
.stack-group { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.stack-col { width: 70%; max-width: 30px; display: flex; flex-direction: column-reverse; border-radius: 5px 5px 0 0; overflow: hidden; min-height: 2px; background: #EEF0F5; }
.stack-col > div { width: 100%; }
.stack-budget-line { position: absolute; left: 0; right: 0; border-top: 2px dashed var(--text-muted); opacity: .6; pointer-events: none; }
.stack-group .bar-label, .vbar-col .bar-label { height: 16px; font-size: 10.5px; color: var(--text-muted); margin-top: 6px; white-space: nowrap; }
.vbar-col .bar-label { font-size: 12px; font-weight: 600; }

/* Imprévus */
.imp-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.imp-stats > div { background: var(--warning-light); border-radius: var(--radius-sm); padding: 10px; text-align: center; }
.imp-stats span { display: block; font-size: 11px; color: #B45309; }
.imp-stats strong { font-size: 16px; }
.imp-list { max-height: 300px; overflow-y: auto; }
.imp-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.imp-item:last-child { border-bottom: none; }
.imp-title { font-weight: 700; font-size: 13.5px; }
.imp-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.imp-amount { font-weight: 800; font-size: 13.5px; margin-bottom: 3px; white-space: nowrap; }

/* Analyse automatique */
.insights { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 10px; }
.insight { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius-sm); font-size: 13.5px; line-height: 1.45; }
.insight-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.insight-danger  { background: var(--danger-light); color: #991B1B; }
.insight-danger .insight-dot { background: var(--danger); }
.insight-warning { background: var(--warning-light); color: #92400E; }
.insight-warning .insight-dot { background: var(--warning); }
.insight-info    { background: var(--primary-light); color: var(--primary-dark); }
.insight-info .insight-dot { background: var(--primary); }
.insight-success { background: var(--success-light); color: #166534; }
.insight-success .insight-dot { background: var(--success); }

/* Échéancier (aging) */
.aging-table th { background: #F7F8FC; }
.aging-table td.aging-zero { color: #C3C7D4; }
.aging-table td.aging-courant { color: var(--text); font-weight: 600; }
.aging-table td.aging-1_30 { color: #B45309; font-weight: 700; }
.aging-table td.aging-31_60, .aging-table td.aging-61_90 { color: #DC2626; font-weight: 700; }
.aging-table td.aging-90_plus { color: #fff; background: var(--danger); font-weight: 800; }

@media (max-width: 1100px) {
  .pilot-grid-2, .aging-grid, .pilot-split { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .pilot-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pilot-kpis .finance-kpi { padding: 14px; }
  .pilot-kpis .finance-kpi .value { font-size: 16px; }
  .pilot-kpis .stat-icon { width: 32px; height: 32px; margin-bottom: 8px; }
  .pilot-kpis .kpi-sub { font-size: 11px; }
  .hbar-row { grid-template-columns: 100px 1fr 64px; gap: 8px; font-size: 12px; }
  .imp-stats { grid-template-columns: repeat(2, 1fr); }
  .budget-line { grid-template-columns: 1fr 130px; }
  .donut { width: 160px; height: 160px; }
  .aging-table td.aging-90_plus { background: var(--danger-light); color: #B91C1C; }
  .heat-table td.num { border-bottom: 1px solid #F1F2F6; background: none !important; color: var(--text) !important; }
  table.responsive-cards tfoot, table.responsive-cards tfoot tr { display: block; width: 100%; }
  table.responsive-cards tfoot tr { background: var(--primary-light); box-shadow: none; }
  table.responsive-cards tfoot td { display: flex; width: 100%; border-top: none; }
  .pilot-scroll { max-height: none; }
}

/* =====================================================================
   Champs de saisie — reprise du style
   ---------------------------------------------------------------------
   Placé après les règles d'origine : ce bloc les complète (repos, survol,
   focus, désactivé, erreur) sans rien casser ailleurs.
   ===================================================================== */
.form-control,
select.form-control,
textarea.form-control {
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: var(--card-bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14.5px;
  line-height: 1.45;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  -webkit-appearance: none;
  appearance: none;
}

/* Le survol annonce que le champ est actionnable */
.form-control:hover:not(:disabled):not(:read-only),
select.form-control:hover:not(:disabled),
textarea.form-control:hover:not(:disabled):not(:read-only) {
  border-color: #C7D2E8;
}

/* Le focus est net et visible au clavier comme à la souris */
.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
  outline: none;
  border-color: var(--primary);
  /* background-color et non le raccourci background : celui-ci remettrait à
     zéro l'image, la taille et la répétition de la flèche des listes
     déroulantes, qui se retrouverait dessinée en série. */
  background-color: var(--card-bg);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* Texte d'invite plus discret que la valeur saisie */
.form-control::placeholder,
textarea.form-control::placeholder {
  color: var(--text-faint, #9AA3B5);
  opacity: 1;
}

/* Champ inactif : visiblement hors service, sans devenir illisible */
.form-control:disabled,
select.form-control:disabled,
textarea.form-control:disabled {
  background-color: var(--bg);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
}
.form-control[readonly] {
  background-color: var(--bg);
  border-style: dashed;
}

/* Saisie invalide signalée après coup, jamais pendant la frappe */
.form-control:not(:placeholder-shown):invalid,
textarea.form-control:not(:placeholder-shown):invalid {
  border-color: var(--danger);
}
.form-control:not(:placeholder-shown):invalid:focus {
  box-shadow: 0 0 0 3px var(--danger-light);
}

/* Listes déroulantes : flèche redessinée, place réservée à droite */
select.form-control {
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 16px 16px;
  cursor: pointer;
}
select.form-control:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233E6FF3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,9 12,15 18,9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  background-size: 16px 16px;
}
select.form-control:disabled { background-image: none; }
select.form-control option { color: var(--text); background: var(--card-bg); }

/* Zones de texte : redimensionnables en hauteur seulement */
textarea.form-control {
  resize: vertical;
  min-height: 84px;
}

/* Champs numériques : chiffres alignés, sans flèches parasites */
.form-control[type="number"] {
  font-variant-numeric: tabular-nums;
  -moz-appearance: textfield;
}
.form-control[type="number"]::-webkit-outer-spin-button,
.form-control[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Champs date et heure : icône du navigateur cliquable sur toute la zone */
.form-control[type="date"],
.form-control[type="time"],
.form-control[type="datetime-local"] {
  cursor: pointer;
  min-height: 44px;
}
.form-control[type="date"]::-webkit-calendar-picker-indicator,
.form-control[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  opacity: .6;
  transition: opacity .15s ease;
}
.form-control[type="date"]:hover::-webkit-calendar-picker-indicator,
.form-control[type="time"]:hover::-webkit-calendar-picker-indicator { opacity: 1; }

/* Champ de recherche avec son icône : la place lui est réservée */
.search-input-wrap .form-control { padding-left: 40px; }
.search-input-wrap:focus-within .search-input-icon { color: var(--primary); }
.search-input-icon { transition: color .15s ease; }

/* Champ de fichier */
.form-control[type="file"] {
  padding: 8px 12px;
  cursor: pointer;
  line-height: 1.8;
}
.form-control[type="file"]::file-selector-button {
  margin-inline-end: 12px;
  padding: 7px 14px;
  border: 0;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.form-control[type="file"]::file-selector-button:hover { background: #DCE6FD; }

/* Cases à cocher et boutons radio à la bonne taille */
input[type="checkbox"], input[type="radio"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Libellés : un cran moins lourds, la valeur saisie doit primer */
.form-group label {
  font-weight: 600;
  letter-spacing: .005em;
  color: var(--text);
}

/* Pastille de périodicité d'une tâche répétitive */
.badge-recurrence {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
  vertical-align: middle;
}

/* =====================================================================
   Cloche des rappels (bandeau) — administration uniquement
   ===================================================================== */
.bell-wrap { position: relative; flex-shrink: 0; }

.bell-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.bell-btn:hover { color: var(--primary); border-color: var(--primary); }
.bell-btn .icon { width: 20px; height: 20px; }

.bell-count {
  position: absolute;
  top: -6px;
  inset-inline-end: -6px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 19px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--card-bg);
}

.bell-menu {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  inset-inline-end: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card-hover);
  z-index: 2500;
  overflow: hidden;
}
.bell-menu.open { display: block; }

.bell-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.bell-head strong { font-size: 14.5px; }
.bell-head-count { font-size: 12px; font-weight: 700; color: var(--danger); }

.bell-empty { padding: 26px 16px; text-align: center; color: var(--text-muted); font-size: 13.5px; margin: 0; }

.bell-list { list-style: none; margin: 0; padding: 0; max-height: 340px; overflow-y: auto; }
.bell-item { border-bottom: 1px solid var(--border); }
.bell-item:last-child { border-bottom: none; }
.bell-item a {
  display: block;
  padding: 11px 16px 11px 13px;
  color: var(--text);
  border-inline-start: 3px solid transparent;
}
.bell-item a:hover { background: var(--bg); }
.bell-item-title {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
  margin-bottom: 3px;
}
.bell-item-meta { display: block; font-size: 12px; color: var(--text-muted); }
.bell-retard a     { border-inline-start-color: var(--danger); }
.bell-aujourdhui a { border-inline-start-color: var(--warning); }
.bell-proche a     { border-inline-start-color: var(--primary); }

.bell-all {
  display: block;
  padding: 12px 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border-top: 1px solid var(--border);
  background: var(--bg);
}

/* Compteur dans le menu latéral */
.nav-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  margin-inline-start: 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}

/* =====================================================================
   Rappels & tâches
   ===================================================================== */
.echeance { font-size: 12.5px; font-weight: 600; }
.echeance-retard     { color: var(--danger); }
.echeance-aujourdhui { color: #B45309; }
.echeance-proche     { color: var(--primary); }
.echeance-plus_tard  { color: var(--text-muted); font-weight: 400; }
.echeance-terminee   { color: var(--success); }

.tache-row td { vertical-align: top; }
.tache-row.tache-retard td:first-child { box-shadow: inset 3px 0 0 var(--danger); }
.tache-row.tache-aujourdhui td:first-child { box-shadow: inset 3px 0 0 var(--warning); }
.tache-row.tache-terminee { opacity: .6; }
.tache-row.tache-terminee strong { text-decoration: line-through; }

.tache-desc { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; max-width: 42ch; }

/* Case à cocher ronde pour clore une tâche d'un clic */
.tache-check {
  width: 22px;
  height: 22px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  padding: 0;
  position: relative;
  flex-shrink: 0;
}
.tache-check:hover { border-color: var(--success); }
.tache-check.is-done { background: var(--success); border-color: var(--success); }
.tache-check.is-done::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.mcard.tache-retard { border-inline-start: 3px solid var(--danger); }
.mcard.tache-aujourdhui { border-inline-start: 3px solid var(--warning); }
.mcard.tache-terminee { opacity: .65; }

@media (max-width: 720px) {
  .bell-menu { width: 300px; }
}

/* ---------- 1. Champ fermé ---------- */
select.form-control {
  min-height: 44px;
  padding-right: 42px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background-position: right 14px center;
  box-shadow: 0 1px 2px rgba(31, 41, 61, 0.04);
}
select.form-control:hover:not(:disabled) {
  border-color: #BFCBEA;
  background-color: #FCFDFF;
}
select.form-control:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
/* Options de la liste native (Firefox / Safari) */
select.form-control option {
  font-weight: 500;
  padding: 8px 12px;
}
select.form-control option:checked {
  color: var(--primary-dark);
  font-weight: 700;
}

/* ---------- 2. Liste ouverte personnalisée ---------- */
@supports (appearance: base-select) {
  select.form-control,
  select.form-control::picker(select) {
    appearance: base-select;
  }

  /* On garde la flèche en background-image, on masque celle du navigateur */
  select.form-control::picker-icon { display: none; }

  /* Flèche vers le haut quand la liste est ouverte */
  select.form-control:open {
    border-color: var(--primary);
    background-color: var(--card-bg);
    box-shadow: 0 0 0 3px var(--primary-light);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233E6FF3' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6,15 12,9 18,15'/%3E%3C/svg%3E");
  }

  /* Le panneau */
  select.form-control::picker(select) {
    margin-top: 6px;
    min-width: anchor-size(width);
    max-height: 300px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid #E3E8F2;
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    box-shadow: 0 12px 32px rgba(31, 41, 61, 0.14), 0 2px 6px rgba(31, 41, 61, 0.06);
    opacity: 1;
    transform: translateY(0);
    transition: opacity .14s ease, transform .14s ease,
                overlay .14s allow-discrete, display .14s allow-discrete;
  }
  @starting-style {
    select.form-control:open::picker(select) {
      opacity: 0;
      transform: translateY(-4px);
    }
  }

  /* Les options */
  select.form-control option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 9px;
    color: var(--text);
    background: transparent;
    font-size: 14.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color .1s ease, color .1s ease;
  }
  select.form-control option:hover,
  select.form-control option:focus-visible {
    outline: none;
    background: var(--bg);
  }
  select.form-control option:checked {
    background: var(--primary-light);
    color: var(--primary-dark);
    font-weight: 700;
  }
  select.form-control option:disabled {
    color: var(--text-muted);
    cursor: not-allowed;
    background: transparent;
  }

  /* Coche à droite de l'option sélectionnée */
  select.form-control option::checkmark {
    order: 1;
    margin-left: auto;
    content: "";
    width: 16px;
    height: 16px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232F5BD9' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5,12.5 10,17 19,7'/%3E%3C/svg%3E") no-repeat center / contain;
  }

  /* Barre de défilement discrète si la liste est longue */
  select.form-control::picker(select)::-webkit-scrollbar { width: 8px; }
  select.form-control::picker(select)::-webkit-scrollbar-thumb {
    background: #D5DCEA;
    border-radius: 8px;
    border: 2px solid var(--card-bg);
  }
}

@media (prefers-reduced-motion: reduce) {
  select.form-control::picker(select) { transition: none; }
}
/* ---------- Fiche copropriétaire : sections en cadre ---------- */
.fiche-section-header { margin-bottom: 14px; align-items: flex-start; }
.fiche-section-header h3 { margin: 0; display: flex; align-items: center; gap: 8px; }
.fiche-section-header h3 svg { width: 18px; height: 18px; color: var(--primary); flex-shrink: 0; }
.fiche-section-header .fiche-section-sub { margin: 4px 0 0; color: var(--text-muted); font-size: 13px; }
.fiche-section .mobile-cards .mcard { box-shadow: none; border: 1px solid var(--border); margin-bottom: 10px; }
.fiche-section .mobile-cards .mcard:last-child { margin-bottom: 0; }
.fiche-section .mobile-cards .mcard.tache-retard { border-inline-start: 3px solid var(--danger); }
.fiche-section .mobile-cards .mcard.tache-aujourdhui { border-inline-start: 3px solid var(--warning); }
.thread-actions { font-size: 12.5px; margin-top: 4px; }

@media (max-width: 700px) {
  .fiche-section { padding: 16px; }
  .fiche-section-header { flex-direction: row; flex-wrap: wrap; gap: 10px; }
  .fiche-section-header > .btn { width: 100%; justify-content: center; }
  .fiche-section .thread-item { padding-left: 12px; }
}

/* ===== Gestion des résidences : barre d'occupation des lots ===== */
.gr-occupation { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.gr-bar { flex: 1; height: 8px; background: var(--border); border-radius: 999px; overflow: hidden; }
.gr-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.gr-bar span.warning { background: var(--warning); }
.gr-bar span.danger { background: var(--danger); }
.gr-occ-text { font-weight: 600; font-size: 13px; white-space: nowrap; }

/* ===== Onglets de page (Rôles & accès) ===== */
.page-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin: 0 0 18px; overflow-x: auto; }
.page-tab {
  display: inline-flex; align-items: center; gap: 7px; padding: 10px 14px; border: none; background: none;
  color: var(--text-muted); font: inherit; font-weight: 600; font-size: 14px; cursor: pointer; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.page-tab .icon { width: 17px; height: 17px; }
.page-tab:hover { color: var(--text); }
.page-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.page-tab-count { background: var(--primary-light); color: var(--primary); border-radius: 999px; padding: 1px 8px; font-size: 12px; }

/* ===== Matrice des accès par rôle ===== */
table.perms-table th, table.perms-table td { padding: 8px 10px; }
table.perms-table .perms-col-label { min-width: 200px; }
table.perms-table .perms-col-role { text-align: center; min-width: 110px; text-transform: none; letter-spacing: 0; font-size: 12.5px; color: var(--text); }
.perms-role-count { font-weight: 400; color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.perms-all { display: inline-flex; align-items: center; gap: 4px; font-weight: 400; font-size: 11.5px; color: var(--text-muted); margin-top: 4px; cursor: pointer; }
table.perms-table tr.perms-module td { background: #F7F8FB; font-weight: 700; font-size: 13px; }
table.perms-table tbody tr.perms-module:hover { background: #F7F8FB; }
table.perms-table .perms-label { padding-left: 24px; color: var(--text); }
table.perms-table .perms-cell { text-align: center; }
table.perms-table input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); vertical-align: middle; }
table.perms-table input[type=checkbox]:disabled { cursor: not-allowed; opacity: .55; }
table.perms-table th:first-child, table.perms-table td:first-child { position: sticky; left: 0; background: var(--card-bg); z-index: 1; }
table.perms-table tr.perms-module td:first-child { background: #F7F8FB; }
.perms-actions { display: flex; justify-content: flex-end; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.perms-dirty { display: none; color: var(--warning); font-size: 13px; font-weight: 600; margin-right: auto; }
.perms-dirty.show { display: inline; }
@media (max-width: 640px) {
  table.perms-table .perms-col-label { min-width: 150px; }
  table.perms-table .perms-col-role { min-width: 90px; }
  .perms-actions .btn { width: 100%; }
}
