/* Univers : feuille de style de la plateforme web */
:root {
  --brand: #0b6e4f;
  --brand-600: #095c42;
  --brand-50: #e8f4ef;
  --accent: #e8a317;
  --side: #0f2a24;
  --side-2: #163a32;
  --side-text: #c5d6d0;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --line: #e3e7ec;
  --text: #17212b;
  --muted: #64707d;
  --ok: #1a9850;
  --warn: #e08214;
  --danger: #d73027;
  --info: #3b6fb6;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 1px 3px rgba(16, 24, 40, .06);
  --side-w: 248px;
  --top-h: 60px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); z-index: 1100;
  background: var(--side); color: var(--side-text);
  display: flex; flex-direction: column; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: .7rem; height: var(--top-h); padding: 0 1.2rem; border-bottom: 1px solid rgba(255,255,255,.07); }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), #f3c552); color: var(--side); font-weight: 800; font-size: 1.05rem;
}
.brand-name { color: #fff; font-weight: 700; font-size: 1.05rem; line-height: 1.1; }
.brand-sub { font-size: .72rem; color: var(--side-text); opacity: .8; }
.nav { flex: 1; overflow-y: auto; padding: .8rem .7rem 1rem; }
.nav-section { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: #7f9a92; margin: 1rem .6rem .35rem; }
.nav a {
  display: flex; align-items: center; gap: .7rem; padding: .5rem .65rem; border-radius: 7px;
  color: var(--side-text); font-weight: 500; margin-bottom: 2px;
}
.nav a i { font-size: 1.05rem; width: 1.2rem; text-align: center; opacity: .85; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a.active i { opacity: 1; }
.side-foot { padding: .9rem 1.2rem; border-top: 1px solid rgba(255,255,255,.07); font-size: .75rem; color: #7f9a92; }

.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 1000; height: var(--top-h);
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 1rem; padding: 0 1.5rem;
}
.topbar .menu-btn { display: none; }
.crumb { color: var(--muted); font-size: .82rem; }
.crumb a { color: var(--muted); }
.topbar-title { font-weight: 600; font-size: 1rem; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: .6rem; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-50); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: .8rem;
}
.user-chip .who { line-height: 1.15; }
.user-chip .who b { display: block; font-size: .85rem; }
.user-chip .who span { font-size: .74rem; color: var(--muted); }
.content { padding: 1.5rem; flex: 1; }
.content.flush { padding: 0; display: flex; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.4rem; }
.page-head p { margin: .2rem 0 0; color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* ---------- Composants ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: .8rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.card-head h2 { font-size: .95rem; }
.card-head .muted { font-size: .8rem; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: 2fr 1fr; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-kpi.six { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.mb { margin-bottom: 1rem; }

.kpi { padding: 1rem 1.1rem; display: flex; gap: .9rem; align-items: flex-start; }
.kpi-icon { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.kpi-icon.green { background: #e6f4ec; color: var(--ok); }
.kpi-icon.blue { background: #e8eef8; color: var(--info); }
.kpi-icon.amber { background: #fdf2dc; color: #b57a06; }
.kpi-icon.red { background: #fbe9e7; color: var(--danger); }
.kpi-icon.teal { background: var(--brand-50); color: var(--brand); }
.kpi-icon.violet { background: #efeafb; color: #6a4bc4; }
.kpi-value { font-size: 1.45rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi-label { color: var(--muted); font-size: .8rem; }
.kpi-sub { font-size: .75rem; color: var(--muted); margin-top: .15rem; }

.btn, button.btn {
  display: inline-flex; align-items: center; gap: .45rem; height: 36px; padding: 0 .95rem;
  border-radius: 8px; border: 1px solid var(--brand); background: var(--brand); color: #fff;
  font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--brand-600); text-decoration: none; }
.btn.ghost { background: var(--surface); color: var(--text); border-color: var(--line); }
.btn.ghost:hover { background: #f6f8fa; }
.btn.sm { height: 30px; padding: 0 .7rem; font-size: .82rem; }
.icon-btn { background: none; border: 0; font-size: 1.3rem; cursor: pointer; color: var(--text); padding: .25rem; }

.field { display: flex; flex-direction: column; gap: .25rem; font-size: .78rem; color: var(--muted); font-weight: 500; }
.input, select.input, .field input, .field select {
  height: 36px; border: 1px solid var(--line); border-radius: 8px; padding: 0 .7rem;
  background: var(--surface); color: var(--text); font: inherit; min-width: 0;
}
.input:focus, .field input:focus, .field select:focus { outline: 2px solid rgba(11, 110, 79, .25); border-color: var(--brand); }
.filters { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.filters .field { min-width: 150px; }
.search { position: relative; flex: 1; min-width: 220px; }
.search i { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; padding-left: 2.1rem; }

table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; padding: .65rem 1rem; background: #f8fafb; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.table th a { color: inherit; }
.table td { padding: .65rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafcfb; }
.table tfoot td { font-weight: 600; background: #f8fafb; border-top: 1px solid var(--line); }
.table .num, .table th.num { text-align: right; }
.table-wrap { overflow-x: auto; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem !important; }
.empty i { display: block; font-size: 1.8rem; margin-bottom: .4rem; opacity: .5; }

.badge {
  display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px;
  font-size: .74rem; font-weight: 600; white-space: nowrap; background: #eef1f4; color: #47525e;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge.actif, .badge.valid, .badge.livre, .badge.terminee { background: #e6f4ec; color: #137a3f; }
.badge.passif, .badge.rejected, .badge.annule { background: #fbe9e7; color: #b42318; }
.badge.prospect, .badge.new, .badge.planifiee, .badge.a_livrer { background: #e8eef8; color: #2f5b9a; }
.badge.reporte, .badge.en_cours { background: #fdf2dc; color: #9a6405; }
.badge.visite { background: #fdf2dc; color: #9a6405; }
.badge.identification { background: #e8eef8; color: #2f5b9a; }

.progress { height: 6px; border-radius: 999px; background: #edf0f3; overflow: hidden; min-width: 70px; }
.progress span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .75rem 1.1rem; border-top: 1px solid var(--line); font-size: .82rem; color: var(--muted); }
.pagination .pages { display: flex; gap: .3rem; }
.pagination a, .pagination span.current {
  min-width: 32px; height: 32px; display: grid; place-items: center; padding: 0 .5rem;
  border: 1px solid var(--line); border-radius: 7px; color: var(--text); background: var(--surface);
}
.pagination a:hover { text-decoration: none; background: #f6f8fa; }
.pagination span.current { background: var(--brand); border-color: var(--brand); color: #fff; }

.alert { display: flex; gap: .6rem; align-items: center; padding: .75rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid; }
.alert.success { background: #e6f4ec; border-color: #b7e0c7; color: #0f5e31; }
.alert.error { background: #fbe9e7; border-color: #f4c3bd; color: #912018; }
.alert.info { background: #e8eef8; border-color: #c4d4ee; color: #234a80; }

.dl { display: grid; grid-template-columns: 150px 1fr; gap: .55rem 1rem; margin: 0; }
.dl dt { color: var(--muted); font-size: .82rem; }
.dl dd { margin: 0; font-weight: 500; }

.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); padding: 0 1.1rem; }
.tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent; padding: .8rem .8rem; margin-bottom: -1px;
  font: inherit; font-weight: 500; color: var(--muted); cursor: pointer;
}
.tabs button.active { color: var(--brand); border-color: var(--brand); }
.tab-panel[hidden] { display: none; }

.report-text { white-space: pre-wrap; font: 13.5px/1.55 "Inter", system-ui, sans-serif; margin: 0; }
.legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: .35rem; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }

/* ---------- Carte ---------- */
.map-layout { display: flex; flex: 1; min-height: calc(100vh - var(--top-h)); }
.map-panel { width: 320px; flex: none; background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; overflow-y: auto; }
.map-panel .section { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); display: grid; gap: .7rem; }
.map-panel h3 { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.map-panel .field select, .map-panel .field input { width: 100%; }
.map-wrap { position: relative; flex: 1; }
.map-wrap #map { position: absolute; inset: 0; }
#map.boxed { height: 520px; border-radius: var(--radius); }
.stat-row { display: flex; justify-content: space-between; align-items: center; font-size: .85rem; }
.stat-row b { font-variant-numeric: tabular-nums; }
.map-overlay { position: absolute; z-index: 500; background: var(--surface); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.12); padding: .55rem .8rem; font-size: .8rem; }
.map-overlay.tl { top: 12px; left: 56px; }
.map-overlay.bl { bottom: 22px; left: 12px; }
.drawer {
  position: absolute; top: 0; right: 0; bottom: 0; width: 360px; max-width: 100%; z-index: 600;
  background: var(--surface); border-left: 1px solid var(--line); box-shadow: -4px 0 18px rgba(0,0,0,.08);
  transform: translateX(105%); transition: transform .2s ease; display: flex; flex-direction: column;
}
.drawer.open { transform: none; }
.drawer-head { padding: 1rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: .6rem; }
.drawer-body { padding: 1rem 1.1rem; overflow-y: auto; }
.leaflet-popup-content { font: 13px/1.45 "Inter", system-ui, sans-serif; }
.marker-cluster-small, .marker-cluster-medium, .marker-cluster-large { background-color: rgba(11, 110, 79, .25) !important; }
.marker-cluster-small div, .marker-cluster-medium div, .marker-cluster-large div { background-color: rgba(11, 110, 79, .85) !important; color: #fff; font-weight: 600; }
.pin { border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: 11px; }

/* ---------- Connexion ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.login-hero {
  background: radial-gradient(circle at 20% 20%, #1d5c4c 0, transparent 50%), linear-gradient(160deg, #0f2a24, #0b4a39);
  color: #e6efec; padding: 3rem; display: flex; flex-direction: column; justify-content: space-between;
}
.login-hero h1 { font-size: 2.1rem; color: #fff; max-width: 26rem; line-height: 1.2; margin-top: 2rem; }
.login-hero p { max-width: 28rem; color: #b8cdc6; font-size: 1rem; }
.login-hero ul { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: .7rem; }
.login-hero li { display: flex; gap: .7rem; align-items: center; }
.login-hero li i { color: var(--accent); font-size: 1.1rem; }
.login-form { display: grid; place-items: center; padding: 2rem; background: var(--surface); }
.login-form form { width: 100%; max-width: 360px; display: grid; gap: 1rem; }
.login-form .field input { height: 42px; }
.login-form .btn { height: 42px; justify-content: center; }

/* ---------- Responsive ---------- */
.backdrop { display: none; }
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1050; }
  .main { margin-left: 0; }
  .topbar { padding: 0 1rem; }
  .topbar .menu-btn { display: inline-block; }
  .user-chip .who { display: none; }
  .content { padding: 1rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .map-layout { flex-direction: column; }
  .map-panel { width: 100%; max-height: none; border-right: 0; border-bottom: 1px solid var(--line); }
  .map-wrap { min-height: 70vh; }
  .login { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .dl { grid-template-columns: 1fr; gap: .1rem; }
  .dl dd { margin-bottom: .5rem; }
}
@media print {
  .sidebar, .topbar, .actions, .filters { display: none !important; }
  .main { margin: 0; }
  .card { box-shadow: none; }
}

/* ---------- Formulaires ---------- */
.form-page { max-width: 980px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem 1.25rem; }
.form-field { display: flex; flex-direction: column; gap: .3rem; }
.form-field > label { font-size: .8rem; font-weight: 600; color: #3b4652; }
.form-field .input { width: 100%; }
.form-field select[multiple].input { height: auto; padding: .4rem; }
.form-field textarea.input { height: auto; min-height: 90px; padding: .5rem .7rem; }
.form-field input[type=file].input { padding: .4rem; height: auto; }
.form-field small { font-size: .76rem; }
.form-field.check { justify-content: center; }
.check-label { display: inline-flex; align-items: center; gap: .55rem; font-weight: 500; cursor: pointer; }
.check-label input { width: 18px; height: 18px; accent-color: var(--brand); }
.req { color: var(--danger); }
.error-text { color: var(--danger); font-weight: 500; }
.has-error .input { border-color: var(--danger); }
.form-actions { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.btn.danger { background: var(--surface); color: var(--danger); border-color: #f4c3bd; margin-left: auto; }
.btn.danger:hover { background: #fbe9e7; }
.btn.success { background: var(--ok); border-color: var(--ok); }
.subnav { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.subnav a { display: inline-flex; align-items: center; gap: .45rem; padding: .45rem .85rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-weight: 500; }
.subnav a:hover { text-decoration: none; background: #f6f8fa; }
.subnav a.active { background: var(--brand); border-color: var(--brand); color: #fff; }
tr.clickable { cursor: pointer; }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- Itinéraire ---------- */
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg button { flex: 1; border: 0; background: var(--surface); padding: .45rem .3rem; font: inherit; font-size: .78rem; cursor: pointer; color: var(--text); }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.active { background: var(--brand); color: #fff; }
.route-sum { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.route-sum .kpi-value { font-size: 1.35rem; }
.steps { margin: 0; padding-left: 1.2rem; display: grid; gap: .55rem; font-size: .84rem; }
.steps li span { display: block; }
.steps li small { color: var(--muted); }

/* ---------- Tableaux croisés (ventes) ---------- */
.table.pivot td, .table.pivot th { white-space: nowrap; font-variant-numeric: tabular-nums; }
.table.pivot thead th { position: sticky; top: 0; z-index: 1; background: #f6f8fa; }
.table.pivot tfoot th { position: sticky; bottom: 0; background: #f6f8fa; color: var(--text); font-size: .8rem; }
.table.pivot td:first-child, .table.pivot th:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.table.pivot thead th:first-child, .table.pivot tfoot th:first-child { z-index: 2; background: #f6f8fa; }
.step-n { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .75rem; margin-right: .35rem; }
.steps-grid { grid-template-columns: repeat(3, 1fr); align-items: start; }
@media (max-width: 1100px) { .steps-grid { grid-template-columns: 1fr; } }
.table thead th { position: sticky; top: 0; z-index: 1; }
.grid-kpi.six .kpi-value { font-size: 1.3rem; white-space: nowrap; }
.grid-kpi.six .kpi { gap: .7rem; }

/* ---------- Sélecteur d'unité (arbre) ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 30, .45); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 1rem; }
.modal-backdrop.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; width: min(560px, 100%); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem .6rem; }
.modal-head h3 { font-size: 1.05rem; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 1rem; color: var(--muted); }
.modal-search { position: relative; margin: 0 1.2rem; }
.modal-search i { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.modal-search .input { width: 100%; padding-left: 2.2rem; height: 40px; }
.modal-hint { font-size: .78rem; margin: .4rem 1.2rem 0; min-height: 1em; }
.tree { overflow-y: auto; flex: 1; margin: .5rem 1.2rem; border: 1px solid var(--line); border-radius: 8px; min-height: 280px; }
.tree ul { list-style: none; margin: 0; padding: 0; }
.tree-row { display: flex; align-items: center; gap: .35rem; padding: .3rem .4rem; font-size: .88rem; border-radius: 6px; }
.tree-row .tree-name { cursor: pointer; flex: 0 1 auto; }
.tree-row:hover { background: #f3f6f5; }
.tree-row.sel { background: var(--brand-50); outline: 1px solid var(--brand); }
.tree-row.disabled .tree-name { cursor: default; color: var(--muted); }
.caret { width: 18px; flex: none; border: 0; background: none; padding: 0; cursor: pointer; color: var(--muted); font-size: .7rem; }
.caret i { transition: transform .15s; display: inline-block; }
.caret.open i { transform: rotate(90deg); }
.modal-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .8rem 1.2rem 1rem; font-size: .85rem; }
.picker-field { display: flex; gap: .7rem; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: .55rem .75rem; background: var(--surface); min-height: 44px; }
.picker-field .picker-value { flex: 1; line-height: 1.3; font-size: .9rem; }
.form-field.full { grid-column: 1 / -1; }

/* ---------- Saisie GPS ---------- */
.gps-box { display: grid; grid-template-columns: 300px 1fr; gap: 1rem; grid-column: 1 / -1; }
.gps-box .gps-map { height: 340px; border-radius: 8px; border: 1px solid var(--line); }
.gps-box .gps-fields { display: grid; gap: .8rem; align-content: start; }
.gps-status { font-size: .85rem; padding: .6rem .75rem; border-radius: 8px; background: #f3f6f5; color: var(--text); }
.gps-status:empty { display: none; }
.gps-status.ok { background: #e6f4ec; color: #146c3b; }
.gps-status.bad { background: #fbe9e7; color: #a5281c; }
.gps-status.warn { background: #fdf3dc; color: #7a5a00; }
@media (max-width: 900px) { .gps-box { grid-template-columns: 1fr; } }
.dropdown { position: relative; }
.dropdown-menu { display: none; position: absolute; right: 0; top: calc(100% + 4px); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.12); min-width: 230px; z-index: 1500; padding: .35rem; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a { display: flex; gap: .55rem; align-items: center; padding: .5rem .7rem; border-radius: 6px; color: var(--text); font-size: .88rem; }
.dropdown-menu a:hover { background: #f3f6f5; text-decoration: none; }
.subnav .count { font-size: .72rem; opacity: .7; margin-left: .15rem; }
.icon-act { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 6px; color: var(--muted); }
.icon-act:hover { background: #eef2f0; color: var(--brand); text-decoration: none; }
.table-head-bar { display: flex; justify-content: flex-end; padding: .5rem 1.1rem; font-size: .82rem; }

/* Tableau de bord des ventes (reproduction du rapport Power BI) */
.pbi-tabs { display: flex; gap: .25rem; overflow-x: auto; padding-bottom: .4rem; margin-bottom: .75rem; scrollbar-width: thin; }
.pbi-tabs a { flex: 0 0 auto; padding: .42rem .75rem; border-radius: 8px 8px 0 0; border-bottom: 3px solid transparent; font-size: .82rem; color: var(--muted); background: var(--surface); white-space: nowrap; }
.pbi-tabs a:hover { color: var(--text); text-decoration: none; }
.pbi-tabs a.active { color: #750985; border-bottom-color: #750985; font-weight: 600; }
.pbi-wrap { overflow-x: auto; background: #EAEAEA; border-radius: 10px; padding: 8px; }
.pbi-canvas { position: relative; width: 100%; min-width: 1000px; aspect-ratio: 1280 / 720; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.12); font-family: "Segoe UI", Inter, sans-serif; color: #252423; --s: 1; }
.pbi-loading .pbi-canvas { opacity: .55; pointer-events: none; }
.pbi-visual { position: absolute; display: flex; flex-direction: column; padding: calc(4px * var(--s)) calc(6px * var(--s)); box-sizing: border-box; overflow: hidden; }
.pbi-title { font-weight: 700; font-style: italic; font-size: calc(14.5px * var(--s)); color: #580764; line-height: 1.2; flex: 0 0 auto; padding-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbi-body { flex: 1 1 auto; position: relative; min-height: 0; }
.pbi-scroll { overflow: auto; }
.pbi-v-text { overflow: visible; z-index: 1; }
.pbi-textbox .pbi-body > div { font-weight: 700; font-style: italic; line-height: 1.25; }
.pbi-v-slicer { padding-top: 2px; }
.pbi-slicer-label { flex: 0 0 auto; font-weight: 700; font-size: calc(12px * var(--s)); color: #252423; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 2px; }
.pbi-select { width: 100%; font: inherit; font-size: calc(11.5px * var(--s)); border: 1px solid #B3B0AD; border-radius: 2px; padding: 2px 4px; background: #fff; height: calc(24px * var(--s)); min-height: 20px; }
.pbi-slicer-list { overflow: auto; font-size: calc(12px * var(--s)); display: flex; flex-direction: column; gap: 4px; }
.pbi-slicer-list label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.pbi-v-card .pbi-body { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pbi-v-card .pbi-title { text-align: center; color: #804C2F; }
.pbi-card-value { font-weight: 600; color: #252423; line-height: 1.1; white-space: nowrap; }
.pbi-card-label { font-size: calc(12px * var(--s)); color: #605E5C; margin-top: 2px; text-align: center; }
.pbi-gauge { width: 100%; height: 100%; }
.pbi-v-kpi .pbi-body { display: flex; align-items: center; justify-content: center; }
.pbi-kpi-trend { position: absolute !important; inset: 0; }
.pbi-kpi-text { position: relative; text-align: center; }
.pbi-kpi-goal { font-size: calc(11px * var(--s)); color: #605E5C; }
.pbi-drill { position: absolute; top: calc(3px * var(--s)); right: calc(6px * var(--s)); display: flex; gap: 2px; z-index: 2; }
.pbi-drill button { border: 1px solid #E1DFDD; background: #fff; font-size: calc(10px * var(--s)); padding: 1px 6px; border-radius: 2px; cursor: pointer; color: #605E5C; }
.pbi-drill button.on { background: #118DFF; border-color: #118DFF; color: #fff; }
.pbi-funnel { display: flex; flex-direction: column; justify-content: space-around; gap: 3px; }
.pbi-funnel-row { display: grid; grid-template-columns: 26% 1fr; align-items: center; gap: 6px; font-size: calc(11px * var(--s)); }
.pbi-funnel-label { text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #605E5C; }
.pbi-funnel-track { display: flex; justify-content: center; }
.pbi-funnel-bar { display: block; min-width: 46px; text-align: center; color: #252423; padding: 3px 0; font-size: calc(10.5px * var(--s)); white-space: nowrap; }
.pbi-treemap { position: relative; }
.pbi-tile { position: absolute; box-sizing: border-box; border: 1px solid #fff; padding: 3px 5px; color: #fff; font-size: calc(11px * var(--s)); overflow: hidden; display: flex; flex-direction: column; }
.pbi-tile b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pbi-decomp { display: flex; gap: calc(18px * var(--s)); overflow-x: auto; padding-top: 6px; }
.pbi-decomp-col { flex: 0 0 calc(200px * var(--s)); min-width: 150px; display: flex; flex-direction: column; min-height: 0; }
.pbi-decomp-head { font-size: calc(12px * var(--s)); font-weight: 600; color: #605E5C; border-bottom: 1px solid #E1DFDD; padding-bottom: 3px; margin-bottom: 6px; }
.pbi-decomp-list { overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 4px; }
.pbi-decomp-node { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 4px; text-align: left; border: 0; background: none; font: inherit; font-size: calc(11.5px * var(--s)); padding: 2px 0 9px; cursor: pointer; color: #252423; }
.pbi-decomp-node span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pbi-decomp-node i { position: absolute; left: 0; bottom: 0; height: 6px; background: #118DFF; opacity: .55; }
.pbi-decomp-node.on i, .pbi-decomp-node.root i { opacity: 1; }
.pbi-decomp-node.on { font-weight: 700; }
.pbi-matrix table { border-collapse: collapse; width: 100%; font-size: calc(11.5px * var(--s)); }
.pbi-matrix th, .pbi-matrix td { padding: 3px 6px; text-align: right; white-space: nowrap; border-bottom: 1px solid #F3F2F1; }
.pbi-matrix th { white-space: normal; vertical-align: bottom; position: sticky; top: 0; background: #fff; font-weight: 600; color: #252423; border-bottom: 1px solid #C8C6C4; z-index: 1; }
.pbi-matrix thead tr:nth-child(2) th { top: calc(22px * var(--s) + 4px); }
.pbi-matrix th.grp { text-align: center; }
.pbi-matrix .first { text-align: left; position: sticky; left: 0; background: #fff; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.pbi-matrix th.first { z-index: 2; }
.pbi-matrix td.txt { text-align: left; }
.pbi-matrix tr.total td { font-weight: 700; border-top: 1px solid #252423; position: sticky; bottom: 0; background: #fff; }
.pbi-matrix tbody tr:hover td { background: #F3F2F1; }
.pbi-matrix td.empty { text-align: center; color: #605E5C; padding: 1rem; }
.pbi-note { font-size: calc(11px * var(--s)); color: #605E5C; padding: 4px 6px; }
.pbi-v-map .pbi-body, .pbi-v-filledmap .pbi-body { border: 1px solid #E1DFDD; }
.seg-radio { display: flex; gap: 1.2rem; padding: .45rem 0; }
.seg-radio label { display: flex; gap: .35rem; align-items: center; cursor: pointer; font-weight: 500; }
.num-in { max-width: 120px; text-align: right; margin-left: auto; }
.danger-text { color: var(--danger, #c0392b) !important; }

/* Formulaires */
.alert.warn { background: #fdf3dc; border-color: #f1d999; color: #7a5a00; }
.alert code { background: rgba(0,0,0,.06); padding: 0 .3rem; border-radius: 4px; }
.check-list > div { display: flex; flex-wrap: wrap; gap: .35rem 1.1rem; }
.check-list label { display: inline-flex; align-items: center; gap: .45rem; font-weight: 500; cursor: pointer; }
.check-list input { width: 17px; height: 17px; accent-color: var(--brand); }

/* Questions conditionnelles */
[data-show-if][hidden] { display: none !important; }
.cond-q { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1.2rem; margin-bottom: 1rem; }
.cond-q > label:first-child { font-weight: 600; min-width: 260px; }
.cond-block { border-left: 3px solid var(--brand-50); padding-left: 1rem; margin: 0 0 1rem; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .4rem 1rem; }
.check-grid label { display: inline-flex; align-items: center; gap: .45rem; cursor: pointer; }
.check-grid input { width: 17px; height: 17px; accent-color: var(--danger); }

/* Carte d'une unité : points de vente sans GPS regroupés par quartier */
.pdv-bubble { display: flex; align-items: center; justify-content: center; border-radius: 50%; background: rgba(232, 163, 23, .85);
  border: 2px solid #fff; color: #3b2a00; font: 600 11px/1 Inter, sans-serif; box-shadow: 0 1px 3px rgba(0,0,0,.3); cursor: pointer; }
.pdv-bubble.mini { display: inline-flex; width: 18px; height: 18px; font-size: 9px; vertical-align: middle; margin-right: .2rem; }
.legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .3rem; vertical-align: middle; }

/* Rapports mis en forme (même structure que le PDF) */
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); max-width: 1180px; }
.doc-head { display: flex; align-items: center; gap: .9rem; background: var(--brand); color: #fff; padding: .9rem 1.4rem; }
.doc-brand { width: 34px; height: 34px; border-radius: 7px; background: var(--accent); color: #0f2a24; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
.doc-title { font-weight: 700; font-size: 1.15rem; }
.doc-sub { opacity: .85; font-size: .85rem; }
.doc-logo { margin-left: auto; font-weight: 700; letter-spacing: .08em; font-size: .85rem; opacity: .9; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .2rem 1rem; background: var(--brand-50); padding: .8rem 1.4rem; }
.doc-meta span { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.doc-meta b { font-size: .92rem; }
.doc-section { padding: .4rem 1.4rem 1rem; border-top: 1px solid var(--line); }
.doc-section:first-of-type { border-top: 0; }
.doc-section h2 { display: flex; align-items: center; gap: .55rem; color: var(--brand); font-size: 1rem; margin: .9rem 0 .7rem; }
.doc-section h2 span { display: inline-flex; width: 24px; height: 24px; border-radius: 50%; background: var(--brand); color: #fff; font-size: .78rem; align-items: center; justify-content: center; }
.doc-section h3 { font-size: .88rem; margin: .8rem 0 .4rem; }
.doc-kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-bottom: .6rem; }
.doc-kpi { padding: .7rem .9rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.doc-kpi .v { font-size: 1.35rem; font-weight: 700; }
.doc-kpi .l { font-size: .76rem; color: var(--muted); }
.doc-kpi .t { font-size: .75rem; color: var(--muted); margin-top: .25rem; }
.doc-kpi .t.ok b { color: var(--ok); } .doc-kpi .t.warn b { color: var(--warn); } .doc-kpi .t.bad b { color: var(--danger); }
.doc-bar { height: 4px; background: var(--line); border-radius: 2px; margin-top: .3rem; overflow: hidden; }
.doc-bar i { display: block; height: 100%; background: var(--ok); }
.doc-bar i.warn { background: var(--warn); } .doc-bar i.bad { background: var(--danger); }
.doc-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.doc-table th { background: var(--brand); color: #fff; text-align: left; padding: .45rem .6rem; font-weight: 600; font-size: .74rem; }
.doc-table td { padding: .4rem .6rem; border-bottom: 1px solid var(--line); }
.doc-table tbody tr:nth-child(even) td { background: #f6f8fa; }
.doc-table .num { text-align: right; white-space: nowrap; }
.doc-table tfoot td { font-weight: 700; background: var(--brand-50); border-top: 2px solid var(--brand); }
.doc-cellbar { display: inline-block; width: 70px; height: 6px; background: var(--line); border-radius: 3px; margin-right: .5rem; vertical-align: middle; overflow: hidden; }
.doc-cellbar i { display: block; height: 100%; background: #118DFF; }
.doc-empty { color: var(--muted); font-style: italic; }
.doc-text { margin: .2rem 0 .4rem; }
.doc-note { color: var(--muted); font-size: .78rem; font-style: italic; margin: .2rem 0 0; }
@media print {
  .sidebar, .topbar, .page-head .actions, .filters, .no-print { display: none !important; }
  .main { margin: 0 !important; } .content { padding: 0 !important; }
  .doc { box-shadow: none; border: 0; max-width: none; }
  .doc-head, .doc-meta, .doc-table th, .doc-table tfoot td, .doc-section h2 span { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .doc-section { break-inside: avoid-page; }
}

/* Saisie des XLSForm dans Univers */
.xf-form .card-body { display: flex; flex-direction: column; gap: 1rem; }
.xf-q { display: flex; flex-direction: column; gap: .35rem; max-width: 760px; }
.xf-label { font-weight: 600; font-size: .92rem; }
.xf-label .req { color: var(--danger); }
.xf-hint { color: var(--muted); font-size: .8rem; }
.xf-note { background: var(--brand-50); border-radius: 8px; padding: .6rem .8rem; font-size: .9rem; }
.xf-choices { display: flex; flex-wrap: wrap; gap: .4rem .9rem; }
.xf-choices.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); max-height: 320px; overflow: auto; }
.xf-choice { display: inline-flex; align-items: center; gap: .4rem; font-size: .9rem; cursor: pointer; }
.xf-group { border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem 1rem; display: flex; flex-direction: column; gap: 1rem; margin: 0; }
.xf-legend { font-weight: 700; color: var(--brand); padding: 0 .3rem; font-size: .95rem; }
.xf-repeat { display: flex; flex-direction: column; gap: .7rem; }
.xf-items { display: flex; flex-direction: column; gap: .7rem; }
.xf-item { border: 1px dashed var(--line); border-radius: 10px; padding: .7rem .9rem; display: flex; flex-direction: column; gap: .8rem; }
.xf-item-head { display: flex; justify-content: space-between; align-items: center; }
.xf-add { align-self: flex-start; }
.xf-error { color: var(--danger); font-size: .82rem; font-weight: 600; }
.xf-bad .input { border-color: var(--danger); }
.xf-geo { display: grid; grid-template-columns: 260px 1fr; gap: .8rem; }
.xf-geo-side { display: flex; flex-direction: column; gap: .5rem; }
.xf-geo-grid { display: grid; gap: .4rem; font-size: .8rem; color: var(--muted); }
.xf-geo-map { min-height: 230px; border-radius: 8px; border: 1px solid var(--line); }
@media (max-width: 760px) { .xf-geo { grid-template-columns: 1fr; } }
[hidden].xf-q, [hidden].xf-group, [hidden].xf-repeat { display: none !important; }
.small { font-size: .8rem; }
.badge.creation, .badge.connexion, .badge.validation { background: #e6f4ec; color: #137a3f; }
.badge.suppression, .badge.echec_connexion { background: #fbe9e7; color: #b42318; }
.badge.modification, .badge.soumission { background: #fdf2dc; color: #9a6405; }
.badge.export, .badge.rapport, .badge.import, .badge.deconnexion { background: #e8eef8; color: #2f5b9a; }
.audit-diff { font-size: .78rem; margin: 0; }
.audit-diff dt { font-weight: 600; display: inline; }
.audit-diff dd { display: inline; margin: 0 .6rem 0 .25rem; }
.audit-diff del { color: #b42318; }
.audit-diff ins { color: #137a3f; text-decoration: none; }
.card-body > .field + .field, .card-body > label.field { margin-bottom: .7rem; }
[hidden] { display: none !important; }
.nav a.sub { padding-left: 2.1rem; font-size: .86rem; }
.nav a.sub i { font-size: .95rem; }
.picker-modal { width: min(620px, 100%); }
.picker-settings { position: absolute; right: 2.2rem; top: 2rem; z-index: 5; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.15); padding: .7rem .9rem; display: flex; flex-direction: column; gap: .35rem; font-size: .85rem; min-width: 220px; }
.picker-settings[hidden] { display: none; }
.picker-settings hr { border: 0; border-top: 1px solid var(--line); margin: .2rem 0; }
.picker-source { font-size: .72rem; padding: 0 1.2rem .8rem; color: var(--info); }
.tree-row input[type=checkbox] { margin: 0 .2rem 0 0; }
.unit-chip { display: inline-flex; align-items: center; gap: .25rem; background: var(--brand-50); border: 1px solid var(--line); border-radius: 999px; padding: .1rem .2rem .1rem .6rem; margin: .1rem .2rem .1rem 0; font-size: .82rem; }
.unit-chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; line-height: 1; padding: 0 .3rem; }
.unit-picker .picker-value { min-width: 0; }
.tabs a.tab { border-bottom: 2px solid transparent; padding: .8rem .8rem; margin-bottom: -1px; font-weight: 500; color: var(--muted); display: inline-flex; gap: .35rem; align-items: center; white-space: nowrap; }
.tabs a.tab:hover { text-decoration: none; color: var(--text); }
.tabs a.tab.active { color: var(--brand); border-color: var(--brand); }
.tabs a.tab .count { font-size: .72rem; background: #eef1f4; border-radius: 999px; padding: 0 .45rem; color: var(--muted); }
.unit-side { display: grid; grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 900px) { .unit-side { grid-template-columns: 1fr; } .tabs { overflow-x: auto; } }
.diff-before { color: #b42318; text-decoration: line-through; }
.diff-after { color: #137a3f; }
.comment { border-left: 3px solid var(--line); padding: .4rem .8rem; margin: .6rem 0; }
.comment .replies { margin-left: 1.2rem; }
.geo-tools { display: flex; gap: .4rem; flex-wrap: wrap; padding: .6rem 1rem; border-bottom: 1px solid var(--line); align-items: center; }

/* Plan de visite, pointages, Perfect Store */
.plan-tools form { display: flex; gap: .7rem; flex-wrap: wrap; align-items: flex-end; }
.plan-week { display: grid; gap: .8rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.plan-day.today { outline: 2px solid var(--brand); }
.plan-list { list-style: none; margin: 0; padding: .3rem 0; }
.plan-item { display: flex; flex-direction: column; gap: .3rem; padding: .45rem .9rem; border-bottom: 1px solid var(--line); font-size: .85rem; }
.plan-item:last-child { border-bottom: 0; }
.plan-item.faite { background: #f4faf6; }
.plan-item.manquee { background: #fdf6f5; }
.plan-item.off { opacity: .75; font-style: italic; }
.plan-main { display: flex; gap: .5rem; align-items: flex-start; min-width: 0; }
.plan-main .badge { min-width: 1.6rem; justify-content: center; }
.plan-btns { display: flex; gap: .15rem; align-items: center; padding-left: 2.1rem; }
.plan-btns .icon-btn { width: 24px; height: 24px; font-size: .75rem; }
.plan-move { font-size: .72rem; padding: 0 .1rem; height: 24px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.small { font-size: .78rem; }
.selfie { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.score-bar { display: inline-block; width: 70px; height: 6px; border-radius: 3px; background: #edf0f3; margin-right: .5rem; vertical-align: middle; overflow: hidden; }
.score-bar span { display: block; height: 100%; background: var(--brand); }
.must-have { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .2rem .8rem; margin-top: .4rem; }
.must-have label { display: flex; gap: .4rem; align-items: center; font-weight: 400; font-size: .85rem; }
.must-have input[type=checkbox], .field .must-have input[type=checkbox] { width: auto; height: auto; min-height: 0; margin: 0; flex: none; }
