:root {
  /* Violet — la couleur de marque de la plateforme */
  --v-50:  #f5f2ff;
  --v-100: #ebe4ff;
  --v-200: #d6c8ff;
  --v-300: #b79dff;
  --v-400: #9a75f7;
  --v-500: #7c4dee;
  --v-600: #6733d8;
  --v-700: #5326ad;

  --bg: #f6f4fd;
  --panel: #ffffff;
  --line: #e9e5f5;
  --line-soft: #f1eefa;
  --text: #16112b;
  --text-soft: #493f68;
  --muted: #7b7195;

  --green: #12a06a;
  --green-bg: #e8f8f1;
  --amber: #d9962a;
  --amber-bg: #fdf3e3;
  --red: #e0483c;
  --red-bg: #fdecea;
  --sky: #3aa0d9;
  --sky-bg: #e9f5fc;

  --side-1: #150f2e;
  --side-2: #1e1440;

  --radius: 16px;
  --radius-sm: 11px;
  --shadow-sm: 0 1px 2px rgba(38, 20, 89, .06), 0 4px 14px rgba(38, 20, 89, .05);
  --shadow-md: 0 10px 34px rgba(60, 30, 130, .10);
  --glow: 0 8px 26px rgba(124, 77, 238, .34);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
/* Jeu de lumière — halos violets fixes derrière toute l'interface */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(680px 420px at 82% -8%, rgba(154, 117, 247, .22), transparent 62%),
    radial-gradient(520px 380px at 100% 46%, rgba(214, 200, 255, .30), transparent 66%),
    radial-gradient(600px 400px at 24% 108%, rgba(124, 77, 238, .10), transparent 64%);
}
.hidden { display: none !important; }
button { font-family: inherit; cursor: pointer; }
h1 { font-size: 25px; font-weight: 680; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 15.5px; font-weight: 650; margin: 0; letter-spacing: -.01em; }

input, select, textarea {
  font-family: inherit; font-size: 14px; width: 100%;
  background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 12px; transition: .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--v-400);
  box-shadow: 0 0 0 3.5px rgba(124, 77, 238, .13);
}
label { display: block; font-size: 12px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
.select { width: auto; padding: 8px 12px; font-size: 13px; background: #fff; }
.search { min-width: 190px; }

/* --- Boutons --- */
.btn-primary {
  background: linear-gradient(135deg, var(--v-400) 0%, var(--v-600) 100%);
  color: #fff; border: none; border-radius: 10px; padding: 9px 16px;
  font-size: 13.5px; font-weight: 600; box-shadow: var(--glow); transition: .16s;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(124, 77, 238, .42); }
.btn-soft {
  background: #fff; border: 1px solid var(--line); color: var(--text-soft);
  border-radius: 10px; padding: 8px 13px; font-size: 13px; font-weight: 500; transition: .15s;
}
.btn-soft:hover { border-color: var(--v-300); color: var(--v-600); box-shadow: 0 4px 14px rgba(124, 77, 238, .14); }
.btn-danger { background: #fff; border: 1px solid var(--line); color: var(--red); border-radius: 10px; padding: 9px 14px; font-size: 13px; }
.btn-danger:hover { border-color: var(--red); background: var(--red-bg); }
.link-btn { background: none; border: none; color: var(--v-600); font-size: 13px; font-weight: 550; padding: 4px; }
.link-btn:hover { text-decoration: underline; }

/* --- Login --- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; position: relative; z-index: 1; }
.login-card {
  background: rgba(255,255,255,.86); backdrop-filter: blur(16px);
  border: 1px solid #fff; border-radius: 22px;
  padding: 40px 34px; width: 100%; max-width: 372px;
  box-shadow: 0 24px 70px rgba(60, 30, 130, .18);
  display: flex; flex-direction: column; gap: 13px; text-align: center; align-items: center;
}
.login-title { font-size: 21px; font-weight: 700; letter-spacing: .2em; margin-top: 4px; }
.login-sub { font-size: 12.5px; color: var(--muted); letter-spacing: .06em; margin-bottom: 10px; }
.login-card input, .login-card button { width: 100%; }
.login-error { color: var(--red); font-size: 13px; min-height: 16px; }

/* --- Coque --- */
.shell { display: flex; min-height: 100vh; position: relative; z-index: 1; }

/* --- Sidebar --- */
.sidebar {
  width: 244px; flex-shrink: 0; position: sticky; top: 0; align-self: flex-start;
  height: 100vh; display: flex; flex-direction: column;
  background: linear-gradient(168deg, var(--side-2) 0%, var(--side-1) 62%, #120c26 100%);
  color: #cfc6e8; overflow: hidden;
}
.sidebar::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(340px 220px at 12% 2%, rgba(154, 117, 247, .40), transparent 68%),
    radial-gradient(280px 260px at 96% 82%, rgba(124, 77, 238, .22), transparent 70%);
}
.sidebar > * { position: relative; z-index: 1; }
.logo-block { display: flex; align-items: center; gap: 12px; padding: 22px 20px; }
.logo-mark {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: linear-gradient(140deg, var(--v-300), var(--v-600));
  box-shadow: 0 6px 20px rgba(124, 77, 238, .55), inset 0 1px 0 rgba(255,255,255,.45);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 750; font-size: 17px;
}
.logo-mark.lg { width: 52px; height: 52px; border-radius: 15px; font-size: 23px; }
.logo-name { font-size: 14.5px; font-weight: 700; letter-spacing: .17em; color: #fff; }
.logo-tag { font-size: 9.5px; letter-spacing: .17em; color: #8d80b4; margin-top: 3px; }

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 20px; }
.nav-section {
  font-size: 10px; letter-spacing: .17em; color: #6f6394;
  padding: 20px 10px 8px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%;
  background: none; border: none; color: #b6abd4;
  padding: 10px 12px; border-radius: 10px; font-size: 13.5px; font-weight: 500;
  text-align: left; transition: .15s; position: relative; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(154,117,247,.30), rgba(154,117,247,.08));
  color: #fff; box-shadow: inset 0 0 0 1px rgba(183,157,255,.28);
}
.nav-item.active::before {
  content: ''; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--v-300); box-shadow: 0 0 12px var(--v-400);
}
.nav-ico { width: 17px; text-align: center; font-size: 14px; opacity: .9; }
.nav-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.nav-item .nav-amount { margin-left: auto; font-size: 11px; color: #8479ab; font-variant-numeric: tabular-nums; }
.nav-item.active .nav-amount { color: #d9cffb; }

.side-foot { padding: 16px 22px 20px; border-top: 1px solid rgba(255,255,255,.07); }
.side-foot-label { font-size: 10px; letter-spacing: .14em; color: #6f6394; }
.side-foot-value { font-size: 14px; color: #fff; font-weight: 600; margin-top: 4px; }

/* --- Zone principale --- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 14px 30px; background: rgba(255,255,255,.82); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar-title { font-size: 14px; font-weight: 620; letter-spacing: .06em; }
.topbar-title .sep { color: var(--v-400); margin: 0 4px; }
.topbar-right { display: flex; align-items: center; gap: 9px; }
.user-name { font-size: 13px; color: var(--muted); }
.badge-admin {
  font-size: 10px; font-weight: 700; letter-spacing: .1em; color: var(--v-600);
  background: var(--v-50); border: 1px solid var(--v-100); padding: 3px 8px; border-radius: 6px;
}

.content { padding: 26px 30px 60px; max-width: 1560px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head-actions { display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 550;
  color: var(--v-600); background: rgba(255,255,255,.7); border: 1px solid var(--v-100);
  padding: 7px 13px; border-radius: 99px; box-shadow: 0 2px 10px rgba(124,77,238,.10);
}

/* --- KPIs --- */
.kpis { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 19px; position: relative; overflow: hidden; box-shadow: var(--shadow-sm); transition: .18s;
}
.kpi::before {
  content: ''; position: absolute; top: -55px; right: -45px; width: 175px; height: 155px;
  background: radial-gradient(circle at 50% 50%, var(--tint), transparent 68%); pointer-events: none;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: center; gap: 11px; position: relative; }
.kpi-ico {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; background: var(--ico-bg); color: var(--ico); flex-shrink: 0;
}
.kpi-label { font-size: 10.5px; letter-spacing: .13em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.kpi-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 13px; position: relative; }
.kpi-value { font-size: 26px; font-weight: 680; letter-spacing: -.03em; line-height: 1.1; }
.kpi-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.spark { display: flex; align-items: flex-end; gap: 3px; height: 38px; flex-shrink: 0; }
.spark i { width: 5px; border-radius: 2px; background: var(--bar); display: block; }

/* --- Panneaux --- */
.row-2 { display: grid; grid-template-columns: 1fr 1.32fr; gap: 15px; margin-bottom: 18px; }
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); overflow: hidden; margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 17px 20px 15px;
}
.panel-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--muted); }
.panel-actions { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.panel-icon {
  width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; flex-shrink: 0;
}
.panel-icon.violet { background: var(--v-50); color: var(--v-500); }
.panel-icon.amber { background: var(--amber-bg); color: var(--amber); }

/* --- Anneau --- */
.donut-wrap { display: flex; align-items: center; gap: 22px; padding: 4px 20px 24px; flex-wrap: wrap; }
#donut svg { width: 178px; height: 178px; display: block; filter: drop-shadow(0 8px 18px rgba(124,77,238,.20)); }
.legend { display: grid; gap: 9px; flex: 1; min-width: 190px; }
.legend.inline { display: flex; flex-wrap: wrap; gap: 13px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-row i { width: 9px; height: 9px; border-radius: 3px; flex-shrink: 0; }
.legend-row .lg-name { color: var(--text-soft); }
.legend-row .lg-val { margin-left: auto; font-weight: 600; font-variant-numeric: tabular-nums; }
.legend-row .lg-pct { color: var(--muted); font-size: 12px; width: 42px; text-align: right; }

/* --- Progression --- */
.progress-list { padding: 4px 20px 22px; display: grid; gap: 17px; }
.pr-row { display: grid; gap: 8px; }
.pr-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.pr-name { font-weight: 600; }
.pr-code { font-size: 11px; color: var(--muted); margin-left: 6px; letter-spacing: .08em; }
.pr-val { font-variant-numeric: tabular-nums; }
.pr-val b { font-weight: 650; }
.pr-val span { color: var(--muted); }
.bar-track { height: 8px; border-radius: 99px; background: var(--v-50); overflow: hidden; }
.bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--v-300), var(--v-500));
  box-shadow: 0 0 14px rgba(124, 77, 238, .45);
}

/* --- Sections --- */
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin: 26px 0 14px; flex-wrap: wrap; }
.section-title { font-size: 18px; font-weight: 660; letter-spacing: -.02em; }

/* --- Cartes marques --- */
.brand-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(275px, 1fr)); gap: 15px; margin-bottom: 4px; }
.bcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; cursor: pointer; transition: .18s; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.bcard::before {
  content: ''; position: absolute; top: -60px; right: -50px; width: 170px; height: 150px;
  background: radial-gradient(circle, var(--tint), transparent 68%); pointer-events: none;
}
.bcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--v-200); }
.bcard-top { display: flex; align-items: center; gap: 12px; position: relative; }
.bcard-ico {
  width: 38px; height: 38px; border-radius: 11px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 15px; color: #fff; flex-shrink: 0; letter-spacing: -.02em;
}
.bcard-ico:not(:empty) { font-size: 14px; }
.bcard-name { font-size: 15px; font-weight: 650; }
.bcard-code { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bcard-arrow { margin-left: auto; color: var(--v-400); font-size: 16px; }
.bcard-bar { margin: 16px 0 14px; }
.bcard-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.bstat { border-radius: 10px; padding: 9px 4px; text-align: center; border: 1px solid transparent; }
.bstat-v { font-size: 13px; font-weight: 680; letter-spacing: -.02em; white-space: nowrap; }
.bstat-l { font-size: 8.5px; letter-spacing: .06em; color: var(--muted); margin-top: 3px; font-weight: 600; white-space: nowrap; }
.bstat.violet { background: var(--v-50); border-color: var(--v-100); } .bstat.violet .bstat-v { color: var(--v-600); }
.bstat.amber { background: var(--amber-bg); border-color: #f7e6c8; } .bstat.amber .bstat-v { color: var(--amber); }
.bstat.red { background: var(--red-bg); border-color: #f8d5d1; } .bstat.red .bstat-v { color: var(--red); }
.bstat.plain { background: #f8f7fc; border-color: var(--line-soft); }

/* --- Alertes --- */
.alert-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.alert-head { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--line-soft); }
.alert-head h2 { font-size: 14px; }
.alert-count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 99px; }
.alert-box.red .alert-count { background: var(--red-bg); color: var(--red); }
.alert-box.amber .alert-count { background: var(--amber-bg); color: var(--amber); }
.alert-row {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  padding: 12px 20px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; cursor: pointer; transition: .13s;
}
.alert-row:last-child { border-bottom: none; }
.alert-row:hover { background: var(--v-50); }
.alert-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.alert-amt { font-weight: 620; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --- Graphique --- */
.chart-wrap { padding: 6px 18px 20px; overflow-x: auto; }
#chart svg { display: block; width: 100%; height: auto; min-width: 640px; }
.gridline { stroke: var(--line-soft); stroke-width: 1; }
.axis-text { fill: var(--muted); font-size: 11px; }
.bar:hover { opacity: .8; }

/* --- Tableaux --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 11px 20px; background: #faf9fe;
  border-top: 1px solid var(--line-soft); border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
td { padding: 13px 20px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr { cursor: pointer; transition: .13s; }
tbody tr:hover { background: var(--v-50); }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dim { color: var(--muted); }
.sub-line { font-size: 12px; color: var(--muted); margin-top: 2px; }
.bpill { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-weight: 550; }
.bpill i { width: 8px; height: 8px; border-radius: 50%; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 99px; font-size: 11px; font-weight: 650; white-space: nowrap; }
.pill.paid { background: var(--green-bg); color: var(--green); }
.pill.sent { background: var(--v-50); color: var(--v-600); }
.pill.partial { background: var(--amber-bg); color: var(--amber); }
.pill.overdue { background: var(--red-bg); color: var(--red); }
.pill.draft { background: #f2f0f8; color: var(--muted); }
.pill.cancelled { background: #f2f0f8; color: var(--muted); text-decoration: line-through; }
.empty { padding: 48px 20px; text-align: center; color: var(--muted); font-size: 14px; }

/* --- FAB --- */
.fab {
  position: fixed; right: 26px; bottom: 26px; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: none; color: #fff; font-size: 26px; line-height: 1;
  background: linear-gradient(140deg, var(--v-400), var(--v-600));
  box-shadow: 0 10px 30px rgba(124, 77, 238, .5), inset 0 1px 0 rgba(255,255,255,.4);
  transition: .18s;
}
.fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 16px 40px rgba(124, 77, 238, .62); }

/* --- Drawer --- */
.drawer { position: fixed; inset: 0; z-index: 60; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(22, 17, 43, .38); backdrop-filter: blur(3px); }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(530px, 100%);
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: -20px 0 60px rgba(38, 20, 89, .18);
  overflow-y: auto; padding: 26px; animation: slide .22s ease;
}
@keyframes slide { from { transform: translateX(28px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 18px; }
.drawer-title { font-size: 20px; font-weight: 680; letter-spacing: -.02em; }
.drawer-sub { color: var(--muted); font-size: 13px; margin-top: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.close-x { background: #fff; border: 1px solid var(--line); color: var(--muted); font-size: 17px; line-height: 1; padding: 6px 11px; border-radius: 9px; }
.close-x:hover { color: var(--text); border-color: var(--v-300); }
.dgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.dbox { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; box-shadow: var(--shadow-sm); }
.dbox-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.dbox-value { font-size: 18px; font-weight: 650; margin-top: 6px; letter-spacing: -.02em; }
.dbox-value.sm { font-size: 15px; }
.section-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); font-weight: 600;
  margin: 24px 0 11px; display: flex; justify-content: space-between; align-items: center;
}
.pay-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius-sm); margin-bottom: 8px; font-size: 13.5px; box-shadow: var(--shadow-sm);
}
.mini { background: #fff; border: 1px solid var(--line); color: var(--text-soft); border-radius: 8px; padding: 6px 11px; font-size: 12px; font-weight: 550; }
.mini:hover { border-color: var(--v-300); color: var(--v-600); }
.mini.danger:hover { color: var(--red); border-color: var(--red); }
.drawer-actions { display: flex; gap: 9px; margin-top: 26px; flex-wrap: wrap; }
.note { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 13px 15px; font-size: 13.5px; color: var(--text-soft); white-space: pre-wrap; }

/* --- Modale --- */
.modal { position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(22, 17, 43, .42); backdrop-filter: blur(3px); }
.modal-card {
  position: relative; background: var(--bg); border: 1px solid var(--line);
  border-radius: 20px; box-shadow: 0 30px 80px rgba(38, 20, 89, .28);
  width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; padding: 26px;
}
.modal-card h3 { margin: 0 0 20px; font-size: 18px; font-weight: 660; letter-spacing: -.02em; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 24px; }
.form-error { color: var(--red); font-size: 13px; margin-top: 12px; min-height: 16px; }

/* --- Toast --- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 22px; font-size: 14px; box-shadow: var(--shadow-md); z-index: 100;
}
.toast.err { border-color: var(--red); color: var(--red); }

.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 30px 20px 10px; }

@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .row-2 { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: .2s; }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(38,20,89,.3); }
  .content { padding: 20px 16px 60px; }
  .topbar { padding: 12px 16px; }
  .kpis { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .donut-wrap { justify-content: center; }
}

/* --- Éditeur d'identité de société --- */
.tpl-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 9px; }
.tpl {
  display: block; cursor: pointer; padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1.5px solid var(--line); background: #fff; transition: .15s;
}
.tpl:hover { border-color: var(--v-300); }
.tpl.on { border-color: var(--v-500); background: var(--v-50); box-shadow: 0 4px 16px rgba(124,77,238,.16); }
.tpl input { display: none; }
.tpl-name { display: block; font-weight: 620; font-size: 13.5px; }
.tpl-desc { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }

.cur-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.cur {
  display: inline-flex; align-items: center; cursor: pointer;
  padding: 8px 14px; border-radius: 99px; border: 1.5px solid var(--line);
  background: #fff; font-size: 13px; font-weight: 550; transition: .15s;
}
.cur:hover { border-color: var(--v-300); }
.cur.on { border-color: var(--v-500); background: var(--v-50); color: var(--v-600); }
.cur input { display: none; }

.logo-row { display: flex; align-items: center; gap: 12px; }
.logo-preview {
  width: 66px; height: 46px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; font-size: 11px;
}
.logo-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-actions { display: flex; gap: 7px; flex-wrap: wrap; }

/* Le sélecteur de couleur mérite d'être une vraie pastille, pas un champ texte */
input[type="color"] { height: 42px; padding: 4px; cursor: pointer; }
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch { border: none; border-radius: 6px; }

/* --- Aperçu de facture --- */
.modal-card.preview-card { max-width: 880px; padding: 22px; }
.preview-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.preview-sub { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.preview-stage {
  background: linear-gradient(160deg, #efeaf9, #e4defa);
  border: 1px solid var(--line); border-radius: 12px;
  padding: 18px; overflow: auto; max-height: 58vh; display: flex; justify-content: center;
}
.preview-sheet { width: 675px; height: 954px; flex-shrink: 0; }
.preview-sheet iframe {
  width: 794px; height: 1123px; border: 0; background: #fff; display: block;
  transform: scale(.85); transform-origin: top left;
  box-shadow: 0 12px 40px rgba(38, 20, 89, .22);
}

/* Ligne de calcul HT / TVA / TTC sous le montant */
.vat-line {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  background: var(--v-50); border: 1px solid var(--v-100); border-radius: var(--radius-sm);
  padding: 11px 14px; font-size: 13px; color: var(--text-soft);
}
.vat-line b { color: var(--text); font-weight: 650; margin-left: 5px; font-variant-numeric: tabular-nums; }
.vat-line .ttc { margin-left: auto; color: var(--v-600); font-weight: 600; }
.vat-line .ttc b { color: var(--v-600); }

.bcard-report {
  margin-left: auto; background: #fff; border: 1px solid var(--line); color: var(--v-500);
  width: 26px; height: 26px; border-radius: 8px; font-size: 12px; line-height: 1; padding: 0;
}
.bcard-report:hover { border-color: var(--v-400); background: var(--v-50); }
.bcard-arrow { margin-left: 8px; }
#reportBtn:disabled { opacity: .45; cursor: not-allowed; }

.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 20px; border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted);
}
.pager-actions { display: flex; gap: 7px; }

/* --- Lignes de détail dans le formulaire --- */
.items-editor { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px 13px; background: #fbfaff; }
.items-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.item-row { display: grid; grid-template-columns: 1fr 70px 110px 32px; gap: 7px; margin-bottom: 7px; }
.item-row input { padding: 8px 10px; font-size: 13px; }
.item-row .it-del { padding: 0; height: 100%; }
@media (max-width: 700px) { .item-row { grid-template-columns: 1fr 1fr; } }

.drawer-table { width: 100%; font-size: 13px; }
.drawer-table td { padding: 8px 0; border-bottom: 1px solid var(--line-soft); }
.drawer-table tr:last-child td { border-bottom: none; }

/* --- Assistant conversationnel --- */
.ask-fab {
  position: fixed; right: 26px; bottom: 92px; z-index: 40;
  width: 54px; height: 54px; border-radius: 50%; border: none; color: #fff; font-size: 21px; line-height: 1;
  background: linear-gradient(140deg, #2fd0c5, var(--v-500));
  box-shadow: 0 10px 30px rgba(47, 208, 197, .42), inset 0 1px 0 rgba(255,255,255,.4);
  transition: .18s;
}
.ask-fab:hover { transform: translateY(-2px) scale(1.04); }

.chat {
  position: fixed; right: 22px; bottom: 22px; z-index: 70;
  width: min(430px, calc(100vw - 32px)); height: min(620px, calc(100vh - 44px));
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 26px 70px rgba(38, 20, 89, .28);
  display: flex; flex-direction: column; overflow: hidden;
  animation: chatIn .18s ease;
}
@keyframes chatIn { from { transform: translateY(14px); opacity: 0 } to { transform: none; opacity: 1 } }
.chat-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  padding: 15px 17px; border-bottom: 1px solid var(--line-soft);
  background: linear-gradient(120deg, var(--v-50), #eafaf8);
}
.chat-title { font-weight: 660; font-size: 15px; }
.chat-model { font-size: 10px; font-weight: 600; color: var(--v-600); background: #fff; border: 1px solid var(--v-100); padding: 2px 7px; border-radius: 99px; margin-left: 6px; }
.chat-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 11px; }
.bubble { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, var(--v-400), var(--v-600)); color: #fff; border-bottom-right-radius: 5px; }
.bubble.ai { align-self: flex-start; background: #f6f4fd; border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.bubble.err { align-self: flex-start; background: var(--red-bg); border: 1px solid #f8d5d1; color: var(--red); }
.bubble.thinking { align-self: flex-start; color: var(--muted); font-style: italic; background: none; }
.bubble-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chat-suggests { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 14px 10px; }
.suggest {
  background: #fff; border: 1px solid var(--line); color: var(--text-soft);
  border-radius: 99px; padding: 6px 12px; font-size: 12px;
}
.suggest:hover { border-color: var(--v-300); color: var(--v-600); }
.chat-input { display: flex; gap: 7px; padding: 12px 14px; border-top: 1px solid var(--line-soft); align-items: center; }
.chat-input input { border-radius: 99px; padding: 10px 15px; }
.chat-input .btn-primary { border-radius: 50%; width: 38px; height: 38px; padding: 0; flex-shrink: 0; font-size: 16px; }
.mic {
  background: #fff; border: 1px solid var(--line); border-radius: 50%;
  width: 38px; height: 38px; flex-shrink: 0; font-size: 15px; line-height: 1;
}
.mic:hover { border-color: var(--v-300); }
.mic.on { background: var(--red-bg); border-color: var(--red); animation: pulse 1.1s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(224,72,60,.12) } }
@media (max-width: 640px) { .chat { right: 8px; left: 8px; bottom: 8px; width: auto; height: min(78vh, 620px); } }

.login-hint {
  font-size: 12.5px; color: var(--v-600); background: var(--v-50);
  border: 1px solid var(--v-100); border-radius: 99px; padding: 6px 14px; margin-bottom: 4px;
}

/* --- Vue Locations --- */
.loc-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 6px; font-size: 12.5px; }
.villa-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.villa-card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow-sm); transition: .15s;
}
.villa-card.busy { border-color: var(--v-200); }
.villa-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.villa-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.villa-name { font-weight: 620; font-size: 14px; }
.villa-meta { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.villa-rev { font-size: 19px; font-weight: 680; margin-top: 11px; letter-spacing: -.02em; }
.villa-rev span { font-size: 12px; color: var(--muted); font-weight: 500; }
#locationsPanel .table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }
.villa-rev .plus { font-size: 12px; color: var(--muted); font-weight: 400; margin: 0 2px; }

/* --- Regroupement par client / villa --- */
tr.group-head { cursor: pointer; background: #faf9fe; }
tr.group-head:hover { background: var(--v-50); }
tr.group-head td { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line-soft); padding: 11px 20px; }
tr.group-head b { font-size: 14px; }
tr.group-head .fold { color: var(--v-500); margin-right: 8px; font-size: 11px; }
tr.group-head .group-count {
  margin-left: 10px; font-size: 11px; color: var(--muted);
  background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 2px 9px;
}

tr.group-head .group-name { font-weight: 750; letter-spacing: -.01em; }

/* --- Sélecteur de mois --- */
.period-picker { position: relative; }
.period-btn { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-weight: 550; text-transform: capitalize; }
.period-btn .caret { color: var(--muted); font-size: 10px; }
.period-pop {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 40;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 13px; width: 268px;
}
.period-year { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.period-year span { font-weight: 650; font-size: 14px; font-variant-numeric: tabular-nums; }
.period-months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.period-months button {
  background: #fff; border: 1px solid var(--line); color: var(--text-soft);
  border-radius: 9px; padding: 8px 0; font-size: 12.5px; font-weight: 550; text-transform: capitalize; transition: .13s;
}
.period-months button:hover { border-color: var(--v-300); color: var(--v-600); }
.period-months button.on { background: linear-gradient(135deg, var(--v-400), var(--v-600)); color: #fff; border-color: transparent; }
.period-months button:disabled { opacity: .35; cursor: not-allowed; }
.period-quick { display: flex; gap: 6px; margin-top: 11px; }
.period-quick button { flex: 1; }
.period-quick button.on { background: var(--v-50); border-color: var(--v-300); color: var(--v-600); }

/* --- Sélecteur de villa dans le formulaire de dépense --------------------- */
.villa-field { display: flex; flex-direction: column; gap: 7px; }
.villa-pick { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.villa-btn { white-space: nowrap; }
.villa-chosen { font-size: 13.5px; font-weight: 550; color: var(--text); }
.villa-chosen.dim { font-weight: 400; color: var(--muted); }
.villa-clear {
  background: #fff; border: 1px solid var(--line); color: var(--muted);
  border-radius: 8px; padding: 2px 8px; font-size: 15px; line-height: 1.2; cursor: pointer;
}
.villa-clear:hover { border-color: var(--red); color: var(--red); }
.villa-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
  margin-top: 2px; padding: 10px; max-height: 240px; overflow-y: auto;
  background: var(--v-50); border: 1px solid var(--line); border-radius: 12px;
}
.villa-chip {
  display: flex; flex-direction: column; gap: 2px; text-align: left; cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 9px 11px; transition: .13s;
}
.villa-chip:hover { border-color: var(--v-300); box-shadow: 0 4px 14px rgba(124, 77, 238, .14); }
.villa-chip.on { border-color: var(--v-500); background: var(--v-100); }
.villa-chip-name { font-size: 13.5px; font-weight: 580; color: var(--text); }
.villa-chip-sub { font-size: 11.5px; color: var(--muted); }
.villa-empty { grid-column: 1 / -1; font-size: 13px; color: var(--muted); padding: 4px 2px; }
.villa-tag {
  display: inline-block; background: var(--v-50); border: 1px solid var(--v-100);
  color: var(--v-700); border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 550;
}

/* --- Fiche villa : frais du mois et relevé propriétaire ------------------- */
.villa-actions { display: flex; gap: 6px; margin-top: 10px; }
.villa-actions .mini { flex: 1; justify-content: center; }
.villa-card { cursor: default; }

.month-nav { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.month-label { font-weight: 600; font-size: 14px; text-transform: capitalize; }

/* Le panneau est étroit : la saisie tient en quatre lignes lisibles, pouce compris. */
.frais-form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.frais-form #fLabel, .frais-form .btn-primary { grid-column: 1 / -1; }
.frais-form input, .frais-form select {
  background: #fff; border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 9px 11px; font-size: 13.5px; width: 100%; font-family: inherit;
}
.frais-form input:focus, .frais-form select:focus { outline: none; border-color: var(--v-400); box-shadow: 0 0 0 3px var(--v-100); }
.frais-form .btn-primary { white-space: nowrap; padding: 9px 14px; }
.frais-table td:first-child, .drawer-table td:first-child { padding-right: 10px; white-space: nowrap; }

.frais-table td { vertical-align: middle; }
.frais-table tr.frais-total td { font-weight: 650; border-top: 1px solid var(--line); border-bottom: 0; color: var(--amber); }
.villa-frais { font-size: 12px; color: var(--muted); margin-top: 8px; }
.villa-frais.on { color: var(--amber); }
.villa-frais b { font-weight: 650; }

/* Séjour à cheval sur deux mois : signalé sans être compté. */
.encours { margin-top: 10px; background: var(--v-50); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.encours-k { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.encours-l { font-size: 13px; color: var(--text-soft); margin-top: 6px; line-height: 1.55; }
.guest-line { margin-top: 3px; font-size: 12px; }
.guest-name { color: var(--text-soft); font-weight: 550; }
.link-mini { background: none; border: 0; padding: 0; font-size: 12px; color: var(--v-500); cursor: pointer; font-family: inherit; }
.link-mini:hover { text-decoration: underline; }
