/* ─── Socaleg theme — Moderne SaaS ─────────────────────────────── */
:root {
  --bg: #f5f5fb;
  --bg2: #ededf7;
  --surface: #ffffff;
  --border: #e0e0ef;
  --text: #18182e;
  --muted: #6b6b95;
  --light: #9c9cbf;
  --accent: #4f46e5;
  --accent-light: rgba(79,70,229,0.08);
  --accent-2: #0ea5e9;
  --success: #10b981;
  --success-light: rgba(16,185,129,0.10);
  --warn: #f59e0b;
  --warn-light: rgba(245,158,11,0.10);
  --danger: #ef4444;
  --danger-light: rgba(239,68,68,0.10);
  --sidebar: #1e1b4b;
  --sidebar-text: #c4c4f0;
  --shadow-card: 0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(79,70,229,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  font-size: 16px; color: var(--text); background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, h5 { font-family: 'Plus Jakarta Sans', system-ui, sans-serif; font-weight: 700; margin: 0; line-height: 1.25; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
i.fa, i.fa-solid, i.fa-regular, i.fa-brands { color: inherit; }

/* ─── Layout shell ─── */
.app-shell { display: flex; min-height: 100vh; }
.app-main  { flex: 1; display: flex; flex-direction: column; min-width: 0; margin-left: 240px; }
.app-content { flex: 1; padding: 30px 36px; }

/* ─── Sidebar ─── */
/* Sidebar fixée à gauche : le copyright reste visible quand on scrolle.
   Si elle est plus haute que l'écran, son contenu interne scrolle (overflow-y). */
.sidebar {
  width: 240px; background: var(--sidebar); color: #fff;
  display: flex; flex-direction: column; flex-shrink: 0;
  position: fixed; top: 0; left: 0; height: 100vh; overflow-y: auto;
  z-index: 50;
}
/* Quand la sidebar est repliée → le contenu remonte (margin-left réduit) */
html.sb-collapsed .app-main, .app-shell:has(.sidebar.collapsed) .app-main { margin-left: 70px; }
/* Transition douce sur le décalage du contenu en suivant la sidebar */
.app-main { transition: margin-left 0.22s ease; }
.sidebar-logo { padding: 22px 22px 18px; border-bottom: 1px solid rgba(255,255,255,0.08); display: flex; align-items: center; gap: 12px; }
/* Logo mark — SVG image; the gradient lives in the SVG itself */
.sidebar-logo .logo-mark { width: 42px; height: 42px; display: block; flex-shrink: 0; }
.sidebar-logo .name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 19px; letter-spacing: 0.5px; text-transform: uppercase; }
.sidebar-logo .sub  { font-size: 10.5px; color: var(--sidebar-text); opacity: 0.72; margin-top: 2px; letter-spacing: -0.05px; white-space: nowrap; }

.sidebar-nav { flex: 1; padding: 14px 12px; }
.sidebar-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; margin-bottom: 3px; border-radius: 8px;
  color: var(--sidebar-text); font-size: 14.5px; font-weight: 400;
  border-left: 3px solid transparent; text-decoration: none;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar-nav a.active {
  background: rgba(79,70,229,0.18); color: #fff; font-weight: 600;
  border-left-color: var(--accent);
}
.sidebar-nav a .icon { width: 20px; text-align: center; font-size: 15px; opacity: 0.85; }
.sidebar-nav a.active .icon { opacity: 1; color: var(--accent); }

.sidebar-rgpd-badge {
  margin: 14px; padding: 10px 14px; border-radius: 9px;
  background: rgba(16,185,129,0.16); display: flex; align-items: center; gap: 10px;
}
.sidebar-rgpd-badge .ic { color: var(--success); font-size: 16px; }
.sidebar-rgpd-badge .l1 { font-size: 12px; font-weight: 600; color: var(--success); }
.sidebar-rgpd-badge .l2 { font-size: 11px; color: var(--sidebar-text); margin-top: 2px; }

.sidebar-copyright {
  padding: 12px 18px 16px; font-size: 11.5px; color: rgba(255,255,255,0.5);
  border-top: 1px solid rgba(255,255,255,0.05); line-height: 1.55;
}

/* Bouton « Réduire le menu » au bas de la sidebar */
.sidebar-collapse-btn {
  border: 0; background: transparent; color: var(--sidebar-text);
  display: flex; align-items: center; gap: 12px;
  margin: 6px 12px 4px; padding: 10px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer; text-align: left;
  border-top: 1px solid rgba(255,255,255,0.06);
  border-radius: 0; padding-top: 14px;
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar-collapse-btn i { width: 20px; text-align: center; font-size: 14px; }

/* ─── Sidebar repliée (icônes seulement) — desktop uniquement ──────────── */
.sidebar.collapsed,
html.sb-collapsed .sidebar { width: 70px; transition: width 0.22s ease; }

.sidebar.collapsed .sidebar-logo,
html.sb-collapsed .sidebar .sidebar-logo { padding: 18px 12px; justify-content: center; }

.sidebar.collapsed .sidebar-logo > div,
html.sb-collapsed .sidebar .sidebar-logo > div { display: none; }

.sidebar.collapsed .sidebar-nav a,
html.sb-collapsed .sidebar .sidebar-nav a { justify-content: center; padding: 11px 8px; }

.sidebar.collapsed .sidebar-nav a .lbl,
html.sb-collapsed .sidebar .sidebar-nav a .lbl { display: none; }

.sidebar.collapsed .sidebar-nav a.active,
html.sb-collapsed .sidebar .sidebar-nav a.active { border-left-width: 0; background: rgba(79,70,229,0.28); }

.sidebar.collapsed .sidebar-rgpd-badge,
html.sb-collapsed .sidebar .sidebar-rgpd-badge { padding: 10px; justify-content: center; }

.sidebar.collapsed .sidebar-rgpd-badge > div,
html.sb-collapsed .sidebar .sidebar-rgpd-badge > div { display: none; }

.sidebar.collapsed .sidebar-copyright,
html.sb-collapsed .sidebar .sidebar-copyright { display: none; }

.sidebar.collapsed .sidebar-collapse-btn,
html.sb-collapsed .sidebar .sidebar-collapse-btn { justify-content: center; }

.sidebar.collapsed .sidebar-collapse-btn .lbl,
html.sb-collapsed .sidebar .sidebar-collapse-btn .lbl { display: none; }

.sidebar.collapsed .sidebar-collapse-btn i,
html.sb-collapsed .sidebar .sidebar-collapse-btn i { transform: rotate(180deg); }

/* ─── Top bar ─── */
.topbar {
  height: 60px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 28px; gap: 14px;
}
.topbar .breadcrumb { flex: 1; display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.topbar .breadcrumb .crumb        { color: var(--muted); }
.topbar .breadcrumb .crumb.current{ color: var(--text); font-weight: 600; }
.topbar .breadcrumb .sep          { color: var(--light); font-size: 13px; }
.topbar .global-search {
  background: var(--bg2); border: 1px solid var(--border); border-radius: 22px;
  padding: 7px 16px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px;
  width: 240px;
}
.topbar .global-search input { border: 0; background: transparent; flex: 1; outline: none; font-size: 13px; color: var(--text); }
.topbar .user-pill {
  width: 38px; height: 38px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-weight: 700; font-size: 14.5px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.topbar .user-menu { position: relative; }
.topbar .user-dropdown {
  position: absolute; right: 0; top: 100%; margin-top: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.10); min-width: 220px; padding: 7px; z-index: 50;
  display: none;
}
.topbar .user-dropdown a {
  display: block; padding: 10px 14px; color: var(--text); font-size: 14px; border-radius: 6px;
}
.topbar .user-dropdown a:hover { background: var(--bg2); text-decoration: none; }
.topbar .user-dropdown .meta { padding: 10px 14px 12px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.topbar .user-dropdown .meta .name { font-weight: 600; font-size: 14.5px; }
.topbar .user-dropdown .meta .email { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

/* ─── Page header ─── */
.page-header { margin-bottom: 26px; display: flex; align-items: flex-end; gap: 18px; }
.page-header .titles { flex: 1; }
.page-header h1 { font-size: 28px; font-weight: 800; }
.page-header .subtitle { font-size: 14.5px; color: var(--muted); margin-top: 6px; }

/* ─── Cards ─── */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-card); padding: 22px;
}
.card-tight { padding: 16px 18px; }
.kpi-card { border-top: 3px solid var(--accent); }
.kpi-card .kpi-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600; }
.kpi-card .kpi-value { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 28px; font-weight: 800; color: var(--accent); margin-top: 6px; line-height: 1.1; }
.kpi-card .kpi-sub   { font-size: 12.5px; color: var(--light); margin-top: 4px; }

/* Avatars */
.avatar-gmail { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Pills / badges */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 11px; border-radius: 99px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.pill-ok    { color: var(--success); background: var(--success-light); }
.pill-warn  { color: var(--warn);    background: var(--warn-light); }
.pill-error { color: var(--danger);  background: var(--danger-light); }
.pill-info  { color: var(--accent);  background: var(--accent-light); }
.pill-mute  { color: var(--muted);   background: var(--bg2); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 1.5px solid transparent; cursor: pointer; line-height: 1.2;
  font-family: inherit; transition: filter .12s, background .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { filter: brightness(1.06); color: #fff; }
.btn-outline { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.btn-outline:hover { background: var(--accent-light); color: var(--accent); }
.btn-ghost   { background: var(--surface); color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg2); color: var(--text); }
.btn-danger  { background: var(--danger-light); color: var(--danger); border-color: rgba(239,68,68,0.45); }
.btn-sm { padding: 7px 13px; font-size: 13px; gap: 6px; }

/* Inputs */
.form-input {
  width: 100%; padding: 11px 14px; border-radius: 9px;
  border: 1.5px solid var(--border); background: var(--surface);
  font-family: inherit; font-size: 14.5px; color: var(--text); outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.5px; margin-bottom: 7px; display: block; text-transform: uppercase; }
.form-hint  { font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Status / segmented */
.segmented {
  display: inline-flex; gap: 4px; background: var(--surface);
  border: 1.5px solid var(--border); border-radius: 9px; padding: 4px;
}
.segmented button {
  padding: 7px 14px; border: 0; background: transparent; cursor: pointer;
  border-radius: 7px; font-size: 13px; font-weight: 600; color: var(--muted); font-family: inherit;
}
.segmented button.active { background: var(--accent); color: #fff; }

/* Year selector with dropdown for older years */
.year-selector { position: relative; }
.year-selector .year-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: 0 8px 24px rgba(0,0,0,0.10); padding: 5px;
  min-width: 130px; display: none; z-index: 30;
}
.year-selector .year-dropdown a {
  display: block; padding: 8px 12px; font-size: 13px; color: var(--text);
  border-radius: 6px;
}
.year-selector .year-dropdown a:hover { background: var(--bg2); text-decoration: none; }
.year-selector .year-dropdown a.current { background: var(--accent-light); color: var(--accent); font-weight: 600; }

/* Table */
.dt {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-card);
}
.dt thead th {
  background: var(--bg2); padding: 12px 16px; font-size: 11.5px; font-weight: 700;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; text-align: left;
  border-bottom: 1px solid var(--border);
}
.dt tbody td { padding: 13px 16px; border-bottom: 1px solid var(--border); font-size: 13.5px; vertical-align: middle; }
.dt tbody tr:hover { background: var(--accent-light); cursor: pointer; }
.dt tbody tr:last-child td { border-bottom: none; }
.dt .progress { height: 6px; background: var(--bg2); border-radius: 99px; overflow: hidden; min-width: 80px; }
.dt .progress > div { height: 100%; background: var(--success); border-radius: 99px; }
.dt .progress.warn  > div { background: var(--warn); }
.dt .progress.error > div { background: var(--danger); }
.dt .name-cell { display: flex; align-items: center; gap: 11px; min-width: 0; }
.dt .name-cell .name { font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* DSN calendar (12 months strip) */
.dsn-cal { display: flex; gap: 4px; }
.dsn-cal .month {
  flex: 1; text-align: center; padding: 8px 0; border-radius: 6px;
  background: var(--bg2); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--light);
}
.dsn-cal .month.received { background: var(--success-light); border-color: rgba(16,185,129,0.3); color: var(--success); }
.dsn-cal .month.expected { background: var(--warn-light);    border-color: rgba(245,158,11,0.3); color: var(--warn); }
.dsn-cal .month .lbl { font-weight: 700; font-size: 12px; }
.dsn-cal .month .ind { margin-top: 3px; font-size: 12px; }

/* Tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 26px; }
.tabs button {
  padding: 12px 22px; background: transparent; border: 0; cursor: pointer;
  font-family: inherit; font-size: 14.5px; color: var(--muted); font-weight: 500;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px;
}
.tabs button.active { color: var(--accent); font-weight: 600; border-bottom-color: var(--accent); }

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,25,0.55);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-backdrop.show { display: flex; }
.modal-card {
  background: var(--surface); border-radius: var(--radius); padding: 30px;
  width: 500px; max-width: calc(100% - 40px); box-shadow: 0 24px 60px rgba(0,0,0,0.18);
}
.modal-card h3 { font-size: 19px; margin-bottom: 8px; }
.modal-card .modal-sub { color: var(--muted); font-size: 14px; margin-bottom: 22px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--border); background: var(--surface);
  border-radius: var(--radius); padding: 44px; text-align: center;
  cursor: pointer; transition: background .15s, border-color .15s;
}
.drop-zone:hover, .drop-zone.dragover { border-color: var(--accent); background: var(--accent-light); }
.drop-zone .ic { font-size: 44px; margin-bottom: 14px; color: var(--accent); }
.drop-zone h3 { font-family: 'Plus Jakarta Sans', sans-serif; font-size: 19px; margin-bottom: 6px; }

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  background: linear-gradient(135deg, #f5f5fb 0%, #e7e7f6 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: 0 20px 60px rgba(15,15,40,0.12);
  width: 460px; max-width: 100%; padding: 40px 36px;
}
.auth-card .logo {
  display: flex; align-items: center; gap: 14px; margin-bottom: 28px;
}
.auth-card .logo .logo-mark { width: 54px; height: 54px; display: block; flex-shrink: 0; }
.auth-card .logo .name { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 800; font-size: 24px; }
.auth-card .logo .tag  { font-size: 13px; color: var(--muted); margin-top: 2px; }
.auth-card h1 { font-size: 24px; margin-bottom: 8px; }
.auth-card p.lead { color: var(--muted); font-size: 14.5px; margin-bottom: 24px; }
.auth-card .form-group { margin-bottom: 16px; }
.auth-card .alert {
  padding: 12px 16px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px;
  background: var(--danger-light); color: var(--danger); border: 1px solid rgba(239,68,68,0.25);
}
.auth-card .alert.ok {
  background: var(--success-light); color: var(--success); border-color: rgba(16,185,129,0.25);
}
.auth-card .switch { text-align: center; margin-top: 22px; font-size: 13.5px; color: var(--muted); }

/* Charts */
.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 130px; }
.bar-chart .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; }
.bar-chart .bar .v   { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.bar-chart .bar .col { width: 100%; background: var(--accent); border-radius: 5px 5px 0 0; min-height: 5px; transition: height .3s; }
.bar-chart .bar .lbl { font-size: 11.5px; color: var(--light); }

.donut-legend { display: flex; flex-direction: column; gap: 8px; }
.donut-legend .row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; }
.donut-legend .row .swatch { width: 12px; height: 12px; border-radius: 4px; }
.donut-legend .row .lbl { color: var(--muted); flex: 1; }
.donut-legend .row .val { font-weight: 700; font-size: 14px; }

/* Service grid */
.service-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.service-card { padding: 20px; position: relative; overflow: hidden; }
.service-card.active { border-color: rgba(79,70,229,0.35); }
.service-card.active::before {
  content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px; background: var(--accent);
}
.service-card .icon-bubble {
  width: 44px; height: 44px; border-radius: 11px; background: var(--bg2);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  color: var(--muted);
}
.service-card.active .icon-bubble { background: var(--accent-light); color: var(--accent); }
.service-card .title { font-family: 'Plus Jakarta Sans', sans-serif; font-weight: 700; font-size: 15px; margin: 12px 0 6px; }
.service-card .desc  { font-size: 13px; color: var(--muted); margin-bottom: 14px; line-height: 1.55; }
.service-card .cta {
  width: 100%; padding: 9px; border-radius: 8px; text-align: center;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--accent); color: #fff; border: 0;
}
.service-card.active .cta { background: var(--success-light); color: var(--success); }

/* Rights matrix */
.rights-matrix table { width: 100%; }
.rights-matrix th { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; padding: 10px 0; border-bottom: 2px solid var(--border); text-align: center; }
.rights-matrix th:first-child, .rights-matrix td:first-child { text-align: left; }
.rights-matrix td { padding: 11px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; text-align: center; }
.rights-checkbox {
  width: 26px; height: 26px; border-radius: 6px;
  border: 1.5px solid var(--border); background: var(--bg2);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--light); font-weight: 700; font-size: 13px;
}
.rights-checkbox.on { border-color: rgba(79,70,229,0.5); background: var(--accent-light); color: var(--accent); }

/* Toast */
.toast {
  position: fixed; bottom: 26px; right: 26px; z-index: 200;
  background: var(--text); color: #fff; padding: 14px 20px; border-radius: 9px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); opacity: 0; transform: translateY(8px);
  transition: opacity .15s, transform .15s;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok    { background: var(--success); }
.toast.error { background: var(--danger); }

/* Utility */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-muted { color: var(--muted); }
.text-light { color: var(--light); }
.fw-700 { font-weight: 700; }
.fs-11 { font-size: 12px; } .fs-12 { font-size: 13px; } .fs-13 { font-size: 13.5px; }
.mt-0 { margin-top: 0; } .mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }
.mb-0 { margin-bottom: 0; } .mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-20 { margin-bottom: 20px; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { grid-template-columns: repeat(3,1fr); gap: 18px; }
.grid-4 { grid-template-columns: repeat(4,1fr); gap: 16px; }
.grid-5 { grid-template-columns: repeat(5,1fr); gap: 14px; }
.hide { display: none !important; }

/* ─── Hamburger button + offcanvas backdrop ──────────────────────────── */
.sidebar-toggle {
  display: none; /* affiché en mobile via media query */
  border: 0; background: transparent; padding: 6px 10px;
  font-size: 18px; color: var(--text); cursor: pointer; border-radius: 8px;
}
.sidebar-toggle:hover { background: var(--bg2); }
.sidebar-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.45); z-index: 90;
}
.sidebar-backdrop.show { display: block; }

/* ─── Responsive : tablette (≤ 1100px) ──────────────────────────────── */
@media (max-width: 1100px) {
  .app-content { padding: 22px 22px; }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  /* Les grilles inline (style="display:grid; grid-template-columns:…")
     deviennent 1col en stack pour éviter que les colonnes hardcodées
     (ex: 360px) ou les sous-grilles (déclarant 1fr 1fr) ne débordent. */
  [style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header h1 { font-size: 24px; }
}

/* ─── Responsive : tablette (≤ 1100px) — suite ──────────────────────── */
@media (max-width: 1100px) {
  /* Toutes les barres flex wrap automatiquement (search + filters + count) */
  .flex { flex-wrap: wrap; }
  /* Le segmented (filter par statut/rôle) wrap aussi */
  .segmented { flex-wrap: wrap; }
  .segmented button { flex: 1 1 auto; }
  /* L'input search dans une barre flex prend toute la largeur sur sa ligne */
  .flex > [style*="flex:1"], .flex > [style*="flex: 1"] { min-width: 100%; }
}

/* ─── Responsive : mobile (≤ 900px) ─────────────────────────────────── */
@media (max-width: 900px) {
  /* Sidebar en off-canvas — translateX(-100%) par défaut */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 260px;
    z-index: 100; transform: translateX(-100%); transition: transform 0.22s ease-out;
    box-shadow: 0 0 30px rgba(0,0,0,0.25);
  }
  .sidebar.open { transform: translateX(0); }
  /* En mobile, la sidebar est offcanvas → l'app-main reprend toute la largeur */
  .app-main { margin-left: 0 !important; }
  /* Sur mobile, le bouton collapse n'a pas de sens (offcanvas) */
  .sidebar-collapse-btn { display: none; }
  /* Si la sidebar était .collapsed sur desktop, on annule en mobile (full width) */
  .sidebar.collapsed,
  html.sb-collapsed .sidebar { width: 260px; }
  .sidebar.collapsed .sidebar-logo > div,
  .sidebar.collapsed .sidebar-nav a .lbl,
  .sidebar.collapsed .sidebar-rgpd-badge > div,
  .sidebar.collapsed .sidebar-copyright,
  html.sb-collapsed .sidebar .sidebar-logo > div,
  html.sb-collapsed .sidebar .sidebar-nav a .lbl,
  html.sb-collapsed .sidebar .sidebar-rgpd-badge > div,
  html.sb-collapsed .sidebar .sidebar-copyright { display: revert; }
  .sidebar-toggle { display: inline-flex; align-items: center; }
  .app-main { width: 100%; }

  .topbar {
    padding: 10px 14px; gap: 10px; flex-wrap: wrap;
  }
  .topbar .breadcrumb { font-size: 13px; gap: 4px; }
  .topbar .global-search { order: 99; flex: 1 0 100%; max-width: none; }
  /* Le bouton page-action déborde — on le cache en mobile, l'utilisateur passe par les Quick Actions du dashboard */
  .topbar > .btn { display: none; }

  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .app-content { padding: 16px 14px; }
  .page-header { margin-bottom: 16px; }
  .page-header h1 { font-size: 20px; }

  /* Tables : scroll horizontal au lieu d'overflow caché.
     Cible les listings standalone (companies, users). Le `white-space: nowrap`
     est utile pour qu'une ligne reste sur une seule ligne avec un scroll
     horizontal — sinon les colonnes s'écraseraient. */
  .dt { display: block; overflow-x: auto; white-space: nowrap; }
  .dt thead th, .dt tbody td { padding: 10px 12px; font-size: 12.5px; }

  /* Mais les tables imbriquées dans une card (cotisations, RGPD logs, etc.)
     doivent wrapper normalement — sinon `nowrap` force la cellule à toute la
     longueur du texte, ce qui propage le min-content vers tous les ancêtres
     flex/grid et fait déborder la page. La card elle-même contient la
     largeur, on n'a pas besoin de scroll horizontal interne. */
  .card .dt { display: table; overflow-x: visible; white-space: normal; }

  /* Tabs : scroll horizontal */
  .tabs { overflow-x: auto; white-space: nowrap; gap: 4px; padding-bottom: 4px; }
  .tabs button { font-size: 12.5px; padding: 8px 12px; flex-shrink: 0; }

  /* Cartes & dashboard hero : un peu plus compact */
  .card { padding: 16px 16px; }
  .dash-hero { padding: 14px 16px; gap: 12px; }
  .dash-hero h1 { font-size: 18px; }
  .dash-hero .meta { font-size: 12px; }
  .kpi-pro .value { font-size: 24px; }

  /* Modale : full-screen */
  .modal-card { width: 100% !important; max-width: 100% !important; border-radius: 0 !important; max-height: 100vh !important; }

  /* Empêcher les enfants flex/grid de gonfler au-delà du parent (cause classique d'overflow) */
  .grid > *, .flex > * { min-width: 0; }
  /* Cards : le contenu wrap, jamais déborde */
  .card { overflow: hidden; word-break: break-word; }
  .card pre, .card code { white-space: pre-wrap; word-break: break-all; }

  /* Calendrier DSN : 6 mois par ligne au lieu de 12 sur une seule ligne */
  .dsn-cal { flex-wrap: wrap; }
  .dsn-cal .month { flex: 1 1 calc((100% / 6) - 4px); min-width: 0; padding: 6px 0; }
  .dsn-cal .month .lbl { font-size: 11px; }

  /* Liens des établissements frères & similaires : wrap ok */
  #info-siblings a { flex-wrap: wrap; }
  #info-siblings a > div:nth-child(2) { flex: 1 1 calc(100% - 60px); }

  /* Hero company : avatar + bloc nom/meta/pills + year-selector empilés */
  #hero > .flex { flex-wrap: wrap; }
  #hero > .flex > div { min-width: 0; }
  #hero > .flex > .flex-1 { flex: 1 1 100%; order: 2; } /* nom + meta + pills sur sa propre ligne */
  #hero > .flex > #hero-avatar { order: 1; }
  #hero > .flex > .flex.gap-8 { order: 3; flex: 1 1 100%; }
  #hero #hero-name { font-size: 18px !important; word-break: break-word; }
  #hero #hero-meta { word-break: break-word; }
}

/* ─── Responsive : table RGPD compacte (≤ 700px) ────────────────────── */
@media (max-width: 700px) {
  /* Masque la colonne IP (dernière) — peu utile au quotidien sur mobile */
  .dt-rgpd th:last-child, .dt-rgpd td:last-child { display: none; }
  .dt-rgpd { white-space: normal; }
  .dt-rgpd .pill { font-size: 10.5px; padding: 2px 8px; }
}

/* ─── Responsive : petit mobile (≤ 480px) ───────────────────────────── */
@media (max-width: 480px) {
  .topbar .global-search { display: none; }
  .topbar { padding: 8px 12px; }
  .page-header h1 { font-size: 18px; }
  .dash-hero .ic { width: 42px; height: 42px; font-size: 18px; }
  /* Import : les 3 source-cards (Manual file / Payroll / Net-Entreprises) chacune sur sa ligne */
  .flex > .card-tight { flex: 1 1 100% !important; }
}
