/* ═══════════════════════════════════════════════════════════════
   Electro-Shop Recouvrement — Design system (section 6)
   Charte : bleu principal, blanc, rouge (urgences uniquement),
   gris très clair, vert (payé), orange (échéance proche), jaune.
   ═══════════════════════════════════════════════════════════════ */
:root {
    --blue: #1d4ed8; --blue-dark: #1e40af; --blue-soft: #dbeafe;
    --navy: #0b1220; --navy-2: #111a2e; --navy-3: #1a2540;
    --red: #dc2626; --red-soft: #fee2e2;
    --green: #16a34a; --green-soft: #dcfce7;
    --orange: #ea580c; --orange-soft: #ffedd5;
    --yellow: #ca8a04; --yellow-soft: #fef9c3;
    --purple: #7c3aed; --purple-soft: #ede9fe;
    --bg: #f4f6fb; --card: #ffffff;
    --text: #0f172a; --muted: #64748b; --line: #e2e8f0;
    --radius: 14px; --shadow: 0 1px 3px rgba(15, 23, 42, .07), 0 8px 24px rgba(15, 23, 42, .05);
    --sidebar-w: 250px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0; background: var(--bg); color: var(--text);
    font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", Arial, sans-serif;
}
a { color: inherit; text-decoration: none; }
.link { color: var(--blue); font-weight: 600; }
.link:hover { text-decoration: underline; }
img { max-width: 100%; }

/* ── Structure ── */
.app { display: flex; min-height: 100vh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 0 26px; }
.content { flex: 1; }
.footer { padding: 18px 0 90px; color: var(--muted); font-size: 12.5px; display: flex; justify-content: space-between; }

/* ── Barre latérale ── */
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: linear-gradient(180deg, var(--navy), var(--navy-2));
    color: #cbd5e1; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 22px 18px; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-bolt { font-size: 26px; filter: drop-shadow(0 0 6px rgba(29, 78, 216, .8)); }
.brand-bolt.big { font-size: 44px; }
.brand-logo { width: 38px; height: 38px; border-radius: 9px; object-fit: cover; }
.brand-logo.big { width: 64px; height: 64px; border-radius: 14px; }
.brand-text { line-height: 1.15; }
.brand-text strong { color: #fff; font-size: 14.5px; letter-spacing: .4px; display: block; }
.brand-text strong::first-letter { color: #fff; }
.brand-text span { font-size: 10.5px; letter-spacing: 2.5px; color: #93a4c3; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 12px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 11px 13px; margin-bottom: 3px;
    border-radius: 10px; font-size: 14.2px; font-weight: 500; color: #b6c2d9; transition: .15s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; box-shadow: 0 4px 14px rgba(29, 78, 216, .4); }
.nav-ico { width: 20px; text-align: center; font-size: 15px; }
.nav-sep { margin: 16px 13px 7px; font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.5px; color: #64748b; }
.nav-badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-user-info { flex: 1; line-height: 1.2; min-width: 0; }
.sidebar-user-info strong { color: #fff; font-size: 13.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-info span { font-size: 11.5px; color: #93a4c3; }

/* ── Barre supérieure ── */
.topbar { display: flex; align-items: center; gap: 18px; padding: 20px 0 14px; flex-wrap: wrap; }
.page-title { margin: 0; font-size: 23px; font-weight: 800; letter-spacing: -.3px; }
.page-subtitle { margin: 2px 0 0; color: var(--muted); font-size: 13.5px; }
.topbar-search { flex: 1; max-width: 420px; margin-left: auto; }
.topbar-search input {
    width: 100%; padding: 10px 16px; border: 1px solid var(--line); border-radius: 99px;
    background: var(--card); font-size: 14px;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 13px; color: var(--muted); background: var(--card); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; }
.bell { position: relative; font-size: 18px; }
.bell-badge {
    position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff;
    font-size: 10px; font-weight: 700; border-radius: 99px; padding: 1px 5px; min-width: 16px; text-align: center;
}

/* ── Cartes / KPI ── */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card.narrow { max-width: 560px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); background: var(--card); display: flex; flex-direction: column; gap: 5px; }
.kpi-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; opacity: .75; }
.kpi-value { font-size: 25px; font-weight: 800; letter-spacing: -.5px; }
.kpi-note { font-size: 12.5px; opacity: .8; }
.kpi-dark { background: linear-gradient(135deg, #0f1b33, #17305e); color: #fff; }
.kpi-green { background: linear-gradient(135deg, #f0fdf4, #dcfce7); color: #14532d; }
.kpi-orange { background: linear-gradient(135deg, #fff7ed, #ffedd5); color: #7c2d12; }
.kpi-purple { background: linear-gradient(135deg, #f5f3ff, #ede9fe); color: #4c1d95; }
.kpi-red { background: linear-gradient(135deg, #fef2f2, #fee2e2); color: #7f1d1d; }
.kpi-inline { background: var(--card); border: 1px solid var(--line); padding: 9px 16px; border-radius: 10px; font-size: 14px; }
.mini-kpis { display: flex; gap: 22px; flex-wrap: wrap; }
.mini-kpis > div { display: flex; flex-direction: column; }
.mini-kpis span { font-size: 12px; color: var(--muted); }
.mini-kpis strong { font-size: 21px; }

/* ── Dispositions ── */
.dash-cols { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.dash-side { position: sticky; top: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

/* ── Boutons ── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    border: 1px solid transparent; border-radius: 10px; padding: 10px 17px; min-height: 44px;
    font-size: 14px; font-weight: 600; cursor: pointer; transition: .15s; white-space: nowrap;
}
.btn-sm { padding: 6px 12px; min-height: 34px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { filter: brightness(1.07); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger-soft { background: var(--red-soft); color: var(--red); }
.btn-dark { background: var(--navy); color: #fff; }
.btn-light { background: #fff; color: var(--text); border-color: var(--line); }
.btn-light:hover { background: #f8fafc; }
#push-toggle.is-active { background: var(--green-soft, #dcfce7); color: var(--green, #16a34a); border-color: transparent; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-icon {
    background: var(--card); border: 1px solid var(--line); border-radius: 10px;
    width: 40px; height: 40px; min-height: 40px; cursor: pointer; font-size: 15px;
    display: inline-flex; align-items: center; justify-content: center;
}
.sidebar .btn-icon { background: transparent; border-color: rgba(255,255,255,.15); color: #cbd5e1; }

/* ── Badges ── */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 3px 11px; font-size: 12px; font-weight: 700; }
.badge-red { background: var(--red); color: #fff; }
.badge-red-soft { background: var(--red-soft); color: var(--red); }
.badge-green { background: var(--green-soft); color: #15803d; }
.badge-blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-yellow { background: var(--yellow-soft); color: var(--yellow); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: #e2e8f0; color: #475569; }

/* ── Tableaux ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
    text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .8px;
    color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 13px 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8fafc; }
.cell-client { display: flex; align-items: center; gap: 11px; }
.cell-actions { white-space: nowrap; display: flex; gap: 6px; align-items: center; }
.cell-note { max-width: 260px; font-size: 13px; }
.row-reversed td { opacity: .55; text-decoration: line-through; }
.row-reversed td .badge, .row-reversed td small { text-decoration: none; }
.text-red { color: var(--red); } .text-green { color: var(--green); } .text-blue { color: var(--blue); }
.muted { color: var(--muted); font-size: 13.5px; }
.empty { color: var(--muted); text-align: center; padding: 22px 10px; font-size: 14px; }

/* ── Avatars ── */
.avatar {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0; color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700;
    background: var(--blue);
}
.av-0 { background: #1d4ed8; } .av-1 { background: #16a34a; } .av-2 { background: #7c3aed; }
.av-3 { background: #ea580c; } .av-4 { background: #0e7490; }

/* ── Formulaires ── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.form-grid .span-2, .form-grid .form-actions { grid-column: span 2; }
.form-stack { display: flex; flex-direction: column; gap: 8px; }
.form-stack label { font-size: 12.5px; font-weight: 700; color: #334155; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 700; color: #334155; }
input, select, textarea {
    font: inherit; padding: 10px 13px; min-height: 44px; border: 1px solid var(--line);
    border-radius: 10px; background: #fff; color: var(--text); width: 100%;
}
textarea { min-height: 60px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--blue-soft); border-color: var(--blue); }
input[type="checkbox"], input[type="radio"] { width: 18px; height: 18px; min-height: 0; }
input[type="range"] { min-height: 0; padding: 0; border: none; }
input[type="color"] { padding: 3px; height: 44px; }
input[type="file"] { padding: 8px; }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; font-weight: 500; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.boxed { background: #f8fafc; border: 1px dashed var(--line); border-radius: 12px; padding: 16px; margin-bottom: 16px; }
.inline { display: inline; }
.inline-row { display: flex; gap: 8px; }
.inline-row select { flex: 1; }
.inline-delivery { display: flex; gap: 6px; align-items: center; }
.section-title { font-size: 15px; margin: 8px 0 10px; }
.item-row { display: grid; grid-template-columns: 2fr 1fr 64px 1fr 1fr 1.2fr; gap: 8px; margin-bottom: 8px; }
.tiny-col { width: 70px; }
.seg { display: flex; gap: 8px; flex-wrap: wrap; }
.seg-item input { position: absolute; opacity: 0; }
.seg-item span {
    display: inline-block; padding: 10px 18px; border: 1.5px solid var(--line); border-radius: 10px;
    font-weight: 600; cursor: pointer; background: #fff;
}
.seg-item input:checked + span { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }

/* ── Divers composants ── */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.toolbar-filters input, .toolbar-filters select { width: auto; min-width: 130px; }
.toolbar-filters input[type="search"] { min-width: 220px; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; padding-bottom: 2px; }
.tab {
    padding: 9px 16px; border-radius: 99px; font-size: 13.5px; font-weight: 600;
    color: var(--muted); white-space: nowrap; border: 1px solid transparent;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--navy); color: #fff; }
.flash { border-radius: 12px; padding: 13px 18px; margin-bottom: 14px; font-size: 14px; }
.flash ul { margin: 6px 0 0; padding-left: 18px; }
.flash-success { background: var(--green-soft); color: #14532d; border: 1px solid #bbf7d0; }
.flash-error { background: var(--red-soft); color: #7f1d1d; border: 1px solid #fecaca; }
.flash-warning { background: var(--yellow-soft); color: #713f12; border: 1px solid #fde68a; }
.flash-info { background: var(--blue-soft); color: #1e3a8a; border: 1px solid #bfdbfe; }
.impersonation-banner {
    position: sticky; top: 0; z-index: 60;
    display: flex; align-items: center; justify-content: center;
    gap: 14px; flex-wrap: wrap; text-align: center;
    background: #f59e0b; color: #1a1a1a; font-weight: 600; font-size: 14px;
    padding: 10px 16px;
}
.impersonation-banner form { margin: 0; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 11px 4px; border-bottom: 1px solid #eef2f7; }
.row-item:last-of-type { border-bottom: none; }
.row-grow { flex: 1; min-width: 0; }
.row-grow small { color: var(--muted); display: block; }

/* -- Selecteur de mode d'affichage (lineaire / grille / mobile) -- */
.view-switch { display: inline-flex; gap: 2px; background: #f1f5f9; border-radius: 10px; padding: 3px; }
.vs-btn {
    display: inline-flex; align-items: center; gap: 5px; border: none; background: transparent;
    padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted);
    cursor: pointer; min-height: 0;
}
.vs-btn span:first-child { font-size: 14px; line-height: 1; }
.vs-btn:hover { color: var(--text); }
.vs-btn[aria-pressed="true"] { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(15,23,42,.12); }
@media (max-width: 640px) { .vs-label { display: none; } .vs-btn { padding: 8px 10px; } }

/* -- Conteneur multi-vues (listview) : lineaire / grille / mobile --
   Par defaut (avant execution du JS ou navigateur sans JS) : la vue
   grille (tableau) est affichee sur grand ecran, et la vue mobile
   (cartes) est affichee automatiquement sous 860px -- l'utilisateur
   garde ensuite la main via le selecteur, memorise cote serveur. */
.listview .lv-linear, .listview .lv-mobile { display: none; }
.listview .lv-grid { display: block; }
.listview.mode-linear .lv-grid, .listview.mode-linear .lv-mobile { display: none; }
.listview.mode-linear .lv-linear { display: block; }
.listview.mode-grid .lv-linear, .listview.mode-grid .lv-mobile { display: none; }
.listview.mode-grid .lv-grid { display: block; }
.listview.mode-mobile .lv-grid, .listview.mode-mobile .lv-linear { display: none; }
.listview.mode-mobile .lv-mobile { display: block; }
@media (max-width: 860px) {
    .listview:not(.mode-linear):not(.mode-grid):not(.mode-mobile) .lv-grid { display: none; }
    .listview:not(.mode-linear):not(.mode-grid):not(.mode-mobile) .lv-mobile { display: block; }
}
.lv-linear-item .badge { flex-shrink: 0; }
.lv-amount { flex-shrink: 0; white-space: nowrap; }

/* -- Cartes mobiles (mode "mobile") -- */
.lv-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.lv-card:last-child { margin-bottom: 0; }
.lv-card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.lv-card-head .row-grow small { color: var(--muted); }
.lv-card-head .badge { margin-left: auto; flex-shrink: 0; }
.lv-card-dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 14px; margin: 0 0 14px; font-size: 14px; }
.lv-card-dl dt { color: var(--muted); font-weight: 600; }
.lv-card-dl dd { margin: 0; text-align: right; }
.lv-card-actions { display: flex; flex-direction: column; gap: 8px; }
.cal-ico { font-size: 20px; }
.feed-item { display: flex; gap: 11px; padding: 9px 0; border-bottom: 1px solid #eef2f7; font-size: 13.5px; }
.feed-item:last-child { border-bottom: none; }
.feed-item p { margin: 1px 0; color: #475569; }
.feed-item small { color: var(--muted); }
.feed-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--blue); margin-top: 6px; flex-shrink: 0; }
.legend { list-style: none; margin: 12px 0 0; padding: 0; font-size: 13.5px; }
.legend li { display: flex; align-items: center; gap: 9px; padding: 5px 0; }
.legend strong { margin-left: auto; }
.legend-total { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 9px !important; font-weight: 600; }
.dot { width: 11px; height: 11px; border-radius: 50%; }
.dot-red { background: var(--red); } .dot-orange { background: #f59e0b; } .dot-green { background: var(--green); }
.dl { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; margin: 0; font-size: 14px; }
.dl dt { color: var(--muted); font-weight: 600; }
.dl dd { margin: 0; }
.collapse { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.collapse summary { cursor: pointer; font-weight: 700; color: var(--blue); font-size: 14px; padding: 6px 0; }
.collapse form { margin-top: 10px; }
.ref-item { padding: 10px 4px; border-bottom: 1px solid #eef2f7; display: flex; flex-direction: column; gap: 3px; }
.ref-item:last-of-type { border-bottom: none; }
.ref-item small { color: var(--muted); }
.ref-item .btn { align-self: flex-start; margin-top: 5px; }
.note-item { border: 1px solid var(--line); border-radius: 12px; padding: 13px 16px; margin-bottom: 11px; }
.note-item p { margin: 7px 0 4px; }
.note-head { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.note-head small { color: var(--muted); margin-left: auto; }
.note-history { margin-top: 7px; font-size: 12.5px; color: var(--muted); }
.note-history pre { white-space: pre-wrap; background: #f8fafc; padding: 9px; border-radius: 8px; }
.progress { height: 9px; background: #e2e8f0; border-radius: 99px; overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), #22c55e); border-radius: 99px; transition: width .4s; }
.prio { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.prio-low { background: #94a3b8; } .prio-normal { background: var(--blue); }
.prio-high { background: #f59e0b; } .prio-critical { background: var(--red); }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 16px 0 4px; }
.page-btn { padding: 8px 15px; border: 1px solid var(--line); border-radius: 9px; font-size: 13.5px; font-weight: 600; background: #fff; }
.page-btn.disabled { opacity: .4; }
.page-info { font-size: 13px; color: var(--muted); }
.contact-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mini-cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; font-size: 12.5px; }
.cal-h { color: var(--muted); font-weight: 700; font-size: 11px; padding: 4px 0; }
.cal-d { position: relative; padding: 8px 0; border-radius: 8px; }
.cal-d.today { background: var(--blue); color: #fff; font-weight: 700; }
.cal-d.has { background: var(--orange-soft); font-weight: 700; }
.cal-d.today.has { background: var(--blue); }
.cal-d i { position: absolute; top: 1px; right: 3px; font-size: 9px; font-style: normal; color: var(--red); font-weight: 800; }

/* ── Chronologie (section 41) ── */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 18px; }
.tl-dot {
    position: absolute; left: -26px; top: 4px; width: 15px; height: 15px; border-radius: 50%;
    background: var(--blue); border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line);
}
.tl-green { background: var(--green); } .tl-red { background: var(--red); }
.tl-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.tl-head small { color: var(--muted); }
.tl-body p { margin: 3px 0; font-size: 14px; color: #334155; }
.tl-diff summary { font-size: 12.5px; color: var(--blue); cursor: pointer; }
.diff-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.diff-cols pre { background: #f8fafc; border-radius: 8px; padding: 8px; font-size: 11.5px; white-space: pre-wrap; margin: 3px 0 0; }

/* ── Alerte popup (sections 14.5-14.7) ── */
.alert-overlay {
    position: fixed; inset: 0; background: rgba(11, 18, 32, .55); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; z-index: 200; padding: 18px;
}
.alert-overlay[hidden] { display: none; }

.overlay {
    position: fixed; inset: 0; background: rgba(11, 18, 32, .55); backdrop-filter: blur(3px);
    display: flex; align-items: center; justify-content: center; z-index: 200; padding: 18px;
}
.overlay[hidden] { display: none; }
.modal {
    background: #fff; border-radius: 18px; width: 560px; max-width: 100%; max-height: 92vh;
    overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.35); padding: 22px;
    animation: pop .25s ease;
}
.xclose {
    background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer;
    color: var(--muted); padding: 4px 8px; border-radius: 8px;
}
.xclose:hover { background: #f1f5f9; color: var(--text); }

.alert-popup {
    background: #fff; border-radius: 18px; width: 480px; max-width: 100%; max-height: 92vh;
    overflow-y: auto; box-shadow: 0 24px 60px rgba(0,0,0,.35); border-top: 6px solid var(--red);
    animation: pop .25s ease;
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } }
.alert-popup-head { display: flex; gap: 13px; align-items: flex-start; padding: 18px 20px 8px; }
.alert-popup-head h2 { margin: 0; font-size: 17px; color: var(--red); }
.alert-popup-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.alert-popup-head .btn-icon { margin-left: auto; }
.alert-pulse { font-size: 26px; animation: ring 1.2s ease infinite; display: inline-block; }
.alert-pulse.big { font-size: 40px; }
@keyframes ring { 0%, 100% { transform: rotate(0); } 10% { transform: rotate(18deg); } 20% { transform: rotate(-14deg); } 30% { transform: rotate(9deg); } 40% { transform: rotate(-5deg); } 50% { transform: rotate(0); } }
.alert-popup-body { padding: 8px 20px; }
.alert-case { border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; margin-bottom: 10px; }
.alert-case .ac-head { display: flex; align-items: center; gap: 11px; margin-bottom: 8px; }
.alert-case h3 { margin: 0; font-size: 15.5px; }
.alert-case .ac-amount { font-size: 21px; font-weight: 800; color: var(--red); }
.alert-case dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 8px 0 0; font-size: 13px; }
.alert-case dt { color: var(--muted); } .alert-case dd { margin: 0; font-weight: 600; }
.alert-case .ac-actions { display: flex; gap: 7px; flex-wrap: wrap; margin-top: 11px; }
.alert-popup-actions { display: flex; gap: 9px; padding: 10px 20px 14px; flex-wrap: wrap; }
.alert-popup-actions .btn { flex: 1; }
.alert-mute { width: 100%; border: none; background: #f1f5f9; padding: 12px; font-size: 13px; color: var(--muted); cursor: pointer; border-radius: 0 0 18px 18px; }

/* ── Cartes sombres ── */
.card-alert-dark { background: linear-gradient(135deg, #1c1023, #38101c); color: #fecaca; text-align: center; }
.card-alert-dark h3 { color: #fff; margin: 9px 0 5px; font-size: 17px; }
.card-alert-dark p { font-size: 13px; margin: 0 0 13px; color: #fca5a5; }

/* ── Authentification ── */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: radial-gradient(1000px 600px at 20% 0%, #16295c, var(--navy)); padding: 20px;
}
.auth-card { background: #fff; border-radius: 20px; padding: 34px 30px; width: 420px; max-width: 100%; box-shadow: 0 25px 70px rgba(0,0,0,.45); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 19px; margin: 10px 0 4px; letter-spacing: .5px; }
.auth-brand .accent { color: var(--red); }
.auth-brand p { color: var(--muted); font-size: 13.5px; margin: 0; }
.auth-form { display: flex; flex-direction: column; gap: 9px; }
.auth-form label { font-size: 12.5px; font-weight: 700; color: #334155; margin-top: 5px; }
.auth-alt { display: block; text-align: center; margin-top: 17px; color: var(--blue); font-weight: 600; font-size: 14px; }
.pin-input { text-align: center; font-size: 24px; letter-spacing: 12px; }

/* ── Barre mobile ── */
.mobile-bar {
    position: fixed; bottom: 0; left: 0; right: 0; background: var(--card); z-index: 100;
    display: none; border-top: 1px solid var(--line); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    justify-content: space-around; align-items: center;
}
.mobile-bar a { display: flex; flex-direction: column; align-items: center; gap: 1px; font-size: 10.5px; color: var(--muted); padding: 5px 10px; border-radius: 10px; min-width: 56px; }
.mobile-bar a span { font-size: 19px; }
.mobile-bar a.active { color: var(--blue); font-weight: 700; }
.mobile-add {
    background: var(--blue); color: #fff !important; border-radius: 50% !important;
    width: 52px; height: 52px; min-width: 0 !important; justify-content: center;
    margin-top: -22px; box-shadow: 0 6px 18px rgba(29, 78, 216, .5);
}
.mobile-add span { font-size: 26px !important; }
.only-mobile { display: none; }

/* ── Responsive (section 26) ── */
@media (max-width: 1100px) {
    .dash-cols { grid-template-columns: 1fr; }
    .dash-side { position: static; }
}
@media (max-width: 860px) {
    .only-mobile { display: inline-flex; }
    .mobile-bar { display: flex; }
    .sidebar {
        position: fixed; z-index: 150; left: 0; transform: translateX(-100%);
        transition: transform .22s ease; box-shadow: 0 0 60px rgba(0,0,0,.4);
    }
    .sidebar.open { transform: translateX(0); }
    .main { padding: 0 14px; }
    .topbar { padding-top: 12px; }
    .topbar-search { order: 5; max-width: none; width: 100%; }
    .page-title { font-size: 19px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2, .form-grid .form-actions { grid-column: span 1; }
    .item-row { grid-template-columns: 1fr 1fr; }
    .kpi-value { font-size: 21px; }
    .toolbar-filters input[type="search"] { min-width: 0; flex: 1; }
    .table { font-size: 13px; }
    .cell-actions { flex-wrap: wrap; }
    .diff-cols { grid-template-columns: 1fr; }
    .footer { padding-bottom: 100px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .grid-2 { grid-template-columns: 1fr; gap: 14px; }
    .card { padding: 16px; }
    .card-head-actions { width: 100%; justify-content: space-between; }
    .view-switch { order: 2; }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .kpi { padding: 15px 16px; }
    .lv-card-dl { font-size: 13.5px; }
}
@media (min-width: 861px) {
    .only-mobile { display: none !important; }
}
@media print {
    .sidebar, .topbar-search, .mobile-bar, .toolbar, .footer, .btn, .alert-overlay { display: none !important; }
    .main { padding: 0; }
    .card { box-shadow: none; border: 1px solid var(--line); }
}

/* ── Vente initiale et responsabilités / versements détaillés ── */
.sale-box {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 0;
    border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
    margin-bottom: 20px; background: var(--card); box-shadow: var(--shadow);
}
.sale-box > div { padding: 13px 16px; border-right: 1px solid #eef2f7; }
.sale-box > div:last-child { border-right: none; }
.sale-box small {
    display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .7px;
    color: var(--muted); font-weight: 700; margin-bottom: 4px;
}
.sale-box b { font-size: 14.5px; }
.who { display: inline-flex; align-items: center; gap: 7px; }
.who .avatar { width: 26px; height: 26px; font-size: 11px; }
.amount-minus { color: var(--red); font-weight: 800; white-space: nowrap; }
.amount-equals { color: var(--green); font-weight: 800; white-space: nowrap; }
.row-click { cursor: pointer; }
.row-click:hover td { background: #f0f6ff !important; }
.section-label {
    font-size: 13px; margin: 0 0 8px; color: var(--muted);
    text-transform: uppercase; letter-spacing: .8px; font-weight: 700;
}
