/* Compta Studio — interface inspirée de macOS / iOS. */
:root {
  --accent: #b4783c;
  --accent-soft: color-mix(in srgb, var(--accent) 14%, transparent);
  --blue: #007aff; --green: #34c759; --orange: #ff9500; --red: #ff3b30; --purple: #af52de; --teal: #30b0c7; --gray: #8e8e93;
  --bg: #f5f5f7;
  --bg-elevated: #ffffff;
  --surface: #ffffff;
  --sidebar: rgba(236, 236, 240, .72);
  --material: rgba(255, 255, 255, .72);
  --label: #1d1d1f;
  --label-2: #6e6e73;
  --label-3: #aeaeb2;
  --separator: rgba(60, 60, 67, .12);
  --fill: rgba(118, 118, 128, .12);
  --fill-2: rgba(118, 118, 128, .08);
  --shadow-1: 0 0 0 .5px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.06);
  --shadow-2: 0 0 0 .5px rgba(0,0,0,.05), 0 8px 30px rgba(0,0,0,.08);
  --shadow-3: 0 0 0 .5px rgba(0,0,0,.08), 0 24px 70px rgba(0,0,0,.22);
  --seg-thumb: #ffffff;
  --radius: 12px;
  --spring: cubic-bezier(.32, .72, 0, 1);
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  --font-rounded: ui-rounded, "SF Pro Rounded", -apple-system, sans-serif;
  color-scheme: light dark;
}
/* Thème : automatique (système), ou forcé par <html data-theme="light|dark"> (bouton soleil / lune). */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: color-mix(in srgb, var(--accent) 24%, transparent);
    --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --purple: #bf5af2; --teal: #40c8e0;
    --bg: #1c1c1e;
    --bg-elevated: #2c2c2e;
    --surface: #242426;
    --sidebar: rgba(40, 40, 42, .72);
    --material: rgba(30, 30, 32, .72);
    --label: #f5f5f7;
    --label-2: #a1a1a6;
    --label-3: #636366;
    --separator: rgba(84, 84, 88, .55);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .16);
    --shadow-1: 0 0 0 .5px rgba(255,255,255,.08), 0 1px 3px rgba(0,0,0,.3);
    --shadow-2: 0 0 0 .5px rgba(255,255,255,.08), 0 8px 30px rgba(0,0,0,.4);
    --shadow-3: 0 0 0 .5px rgba(255,255,255,.1), 0 24px 70px rgba(0,0,0,.6);
    --seg-thumb: #636366;
  }
}
:root[data-theme="dark"] {
    --accent-soft: color-mix(in srgb, var(--accent) 24%, transparent);
    --blue: #0a84ff; --green: #30d158; --orange: #ff9f0a; --red: #ff453a; --purple: #bf5af2; --teal: #40c8e0;
    --bg: #1c1c1e;
    --bg-elevated: #2c2c2e;
    --surface: #242426;
    --sidebar: rgba(40, 40, 42, .72);
    --material: rgba(30, 30, 32, .72);
    --label: #f5f5f7;
    --label-2: #a1a1a6;
    --label-3: #636366;
    --separator: rgba(84, 84, 88, .55);
    --fill: rgba(118, 118, 128, .24);
    --fill-2: rgba(118, 118, 128, .16);
    --shadow-1: 0 0 0 .5px rgba(255,255,255,.08), 0 1px 3px rgba(0,0,0,.3);
    --shadow-2: 0 0 0 .5px rgba(255,255,255,.08), 0 8px 30px rgba(0,0,0,.4);
    --shadow-3: 0 0 0 .5px rgba(255,255,255,.1), 0 24px 70px rgba(0,0,0,.6);
    --seg-thumb: #636366;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--label); font: 13px/1.45 var(--font); -webkit-font-smoothing: antialiased; letter-spacing: -.003em; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: var(--accent); text-decoration: none; }
svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
::selection { background: var(--accent-soft); }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; border-radius: 6px; }
[hidden] { display: none !important; }

/* ---------- Structure ---------- */
.app { display: grid; grid-template-columns: 264px 1fr; height: 100vh; height: 100dvh; }
.sidebar { position: relative; z-index: 3; display: flex; flex-direction: column; min-height: 0; padding: 14px 10px 10px; background: var(--sidebar); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px); border-right: .5px solid var(--separator); }
.sidebar-top { display: grid; gap: 12px; padding: 0 4px 10px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--label); padding: 6px; border-radius: 10px; transition: background .2s; }
.brand:hover { background: var(--fill-2); }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--accent); color: #fff; font: 600 16px var(--font-rounded); overflow: hidden; flex: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.1); }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text small { color: var(--label-2); font-size: 11px; }
.search-field { display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border: 0; border-radius: 8px; background: var(--fill); color: var(--label-2); cursor: pointer; text-align: left; transition: background .2s; }
.search-field:hover { background: color-mix(in srgb, var(--fill) 160%, transparent); }
.search-field span { flex: 1; }
kbd { font: 500 11px var(--font); color: var(--label-3); padding: 1px 5px; border-radius: 4px; background: var(--fill-2); }
.sidebar-nav, .sidebar-recipients { display: grid; gap: 1px; }
.sidebar-recipients { overflow-y: auto; min-height: 0; flex: 1; align-content: start; padding-bottom: 8px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; border-radius: 7px; color: var(--label); font-weight: 500; transition: background .2s, color .2s; }
.nav-item svg { font-size: 17px; color: var(--accent); }
.nav-item:hover { background: var(--fill-2); }
.nav-item.active { background: var(--fill); }
.nav-item .count { margin-left: auto; font: 500 11px var(--font); color: var(--label-2); font-variant-numeric: tabular-nums; }
.nav-item .dot { width: 10px; height: 10px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15); }
.nav-item span.label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-section-title { display: flex; align-items: center; justify-content: space-between; padding: 16px 10px 4px; color: var(--label-2); font-size: 11px; font-weight: 600; }
.sidebar-foot { display: flex; align-items: center; gap: 8px; padding: 10px 6px 2px; border-top: .5px solid var(--separator); }
.user-name { flex: 1; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; overflow-y: auto; overflow-x: hidden; outline: none; scroll-behavior: smooth; }
.view { min-height: 100%; }
.tabbar { display: none; }

/* ---------- Barre d'outils de page ---------- */
.toolbar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 28px; background: var(--material); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-bottom: .5px solid transparent; transition: border-color .2s; }
.main.scrolled .toolbar { border-bottom-color: var(--separator); }
.toolbar h1 { margin: 0; font: 700 15px var(--font-display); letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .spacer { flex: 1; }
.toolbar .back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); font-weight: 500; padding: 4px 6px 4px 0; }
.toolbar .back svg { font-size: 18px; }
.page { padding: 8px 28px 64px; max-width: 1240px; margin: 0 auto; }
.page-wide { max-width: none; }
.large-title { margin: 6px 0 2px; font: 700 30px/1.15 var(--font-display); letter-spacing: -.025em; }
.subtitle { margin: 0 0 22px; color: var(--label-2); font-size: 14px; }

/* ---------- Contrôles ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: var(--surface); color: var(--label); font-weight: 500; white-space: nowrap; cursor: pointer; box-shadow: var(--shadow-1); transition: transform .15s var(--spring), background .2s, opacity .2s, box-shadow .2s; -webkit-user-select: none; user-select: none; }
.btn:hover { background: color-mix(in srgb, var(--surface) 92%, var(--label)); }
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn svg { font-size: 15px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px color-mix(in srgb, var(--accent) 40%, transparent), inset 0 .5px 0 rgba(255,255,255,.2); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-plain { background: transparent; box-shadow: none; color: var(--accent); }
.btn-plain:hover { background: var(--accent-soft); }
.btn-tinted { background: var(--accent-soft); color: var(--accent); box-shadow: none; }
.btn-tinted:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; height: 40px; font-size: 15px; border-radius: 10px; }
.btn-lg { height: 36px; padding: 0 16px; font-size: 14px; border-radius: 10px; }
.icon-btn { display: inline-grid; place-items: center; width: 28px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--label-2); cursor: pointer; font-size: 16px; transition: background .2s, color .2s, transform .15s; }
.icon-btn:hover { background: var(--fill); color: var(--label); }
.icon-btn:active { transform: scale(.92); }
.icon-btn.small { width: 20px; height: 20px; font-size: 14px; border-radius: 5px; }

.segmented { position: relative; display: inline-flex; padding: 2px; border-radius: 9px; background: var(--fill); isolation: isolate; }
.segmented button { position: relative; z-index: 1; height: 26px; padding: 0 12px; border: 0; background: none; border-radius: 7px; font-weight: 500; color: var(--label); cursor: pointer; white-space: nowrap; transition: color .2s; }
.segmented button .n { margin-left: 4px; color: var(--label-2); font-size: 11px; font-variant-numeric: tabular-nums; }
.segmented .thumb { position: absolute; z-index: 0; top: 2px; bottom: 2px; border-radius: 7px; background: var(--seg-thumb); box-shadow: 0 0 0 .5px rgba(0,0,0,.04), 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); transition: transform .35s var(--spring), width .35s var(--spring); }
.segmented.small button { height: 22px; padding: 0 9px; font-size: 12px; }

.field { display: grid; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--label-2); }
.field > span em { font-style: normal; color: var(--label-3); font-weight: 400; }
.input, .field input:not([type=checkbox]):not([type=color]):not([type=file]), .field select, .field textarea {
  width: 100%; height: 32px; padding: 0 10px; border: 0; border-radius: 8px; background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--separator); outline: none; transition: box-shadow .2s, background .2s; }
.field textarea { height: auto; min-height: 64px; padding: 8px 10px; resize: vertical; line-height: 1.4; }
.field select, select.input { appearance: none; -webkit-appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%238e8e93' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='m5 6.5 3-3 3 3M5 9.5l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 7px center; background-size: 14px; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { background-color: var(--bg-elevated); box-shadow: inset 0 0 0 .5px var(--separator), 0 0 0 3.5px color-mix(in srgb, var(--accent) 35%, transparent); }
.input-affix { position: relative; }
.input-affix input { padding-right: 46px !important; }
.input-affix i { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--label-3); font-size: 12px; pointer-events: none; }
.grid { display: grid; gap: 12px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.full { grid-column: 1 / -1; }
input[type=color] { width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%; background: none; cursor: pointer; }
input[type=color]::-webkit-color-swatch-wrapper { padding: 0; }
input[type=color]::-webkit-color-swatch { border: 0; border-radius: 50%; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.2); }

.switch { position: relative; display: inline-block; width: 38px; height: 23px; flex: none; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--fill); transition: background .25s; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 19px; height: 19px; border-radius: 50%; background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.18), 0 0 0 .5px rgba(0,0,0,.04); transition: transform .3s var(--bounce); }
.switch input:checked + i { background: var(--green); }
.switch input:checked + i::after { transform: translateX(15px); }
.switch input:focus-visible + i { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 1px; }

/* ---------- Cartes & listes groupées ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px 0; }
.card-head h2, .section-title { margin: 0; font: 600 15px var(--font-display); letter-spacing: -.01em; }
.card-head .spacer { flex: 1; }
.section-title { margin: 28px 2px 10px; display: flex; align-items: center; gap: 8px; }
.section-title .spacer { flex: 1; }
.group { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-1); overflow: clip; }
.row { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; color: var(--label); position: relative; transition: background .15s; }
.row + .row::before { content: ""; position: absolute; top: 0; right: 0; left: 16px; border-top: .5px solid var(--separator); }
.row.has-icon + .row.has-icon::before { left: 58px; }
a.row:hover, .row.clickable:hover { background: var(--fill-2); cursor: pointer; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .meta { color: var(--label-2); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .amount { font-variant-numeric: tabular-nums; font-weight: 500; text-align: right; white-space: nowrap; }
.row .chev { color: var(--label-3); font-size: 14px; }
.inspector { display: grid; gap: 14px; padding: 16px 18px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 30px; }
.toggle-row small { display: block; color: var(--label-2); font-size: 11.5px; }

.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--c, var(--gray)); color: #fff; font: 600 13px var(--font-rounded); flex: none; text-transform: uppercase; background-image: linear-gradient(180deg, rgba(255,255,255,.22), rgba(255,255,255,0)); }
.avatar.small { width: 24px; height: 24px; font-size: 11px; background-color: var(--accent); }
.avatar.lg { width: 64px; height: 64px; font-size: 26px; }
.avatar.square { border-radius: 9px; }
.avatar.lg.square { border-radius: 16px; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 99px; font-size: 11px; font-weight: 600; white-space: nowrap; color: var(--b, var(--gray)); background: color-mix(in srgb, var(--b, var(--gray)) 14%, transparent); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.b-draft { --b: var(--gray); } .b-sent { --b: var(--blue); } .b-paid { --b: var(--green); } .b-overdue { --b: var(--red); } .b-partial { --b: var(--orange); } .b-cancelled { --b: var(--label-3); }
.kind { display: inline-flex; font-size: 11px; color: var(--label-2); padding: 1px 7px; border-radius: 5px; background: var(--fill-2); font-weight: 500; }

/* ---------- Tableau de bord ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { position: relative; padding: 16px 18px; overflow: hidden; }
.kpi .k-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; color: #fff; background: var(--c); font-size: 16px; margin-bottom: 12px; }
.kpi small { display: block; color: var(--label-2); font-weight: 500; }
.kpi strong { display: block; margin-top: 2px; font: 700 24px var(--font-rounded); letter-spacing: -.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi strong i { font-style: normal; font-size: 13px; font-weight: 600; color: var(--label-2); margin-left: 3px; }
.kpi .trend { margin-top: 4px; font-size: 12px; color: var(--label-2); }
.dash-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; margin-top: 14px; }
.dash-grid > * { min-width: 0; }
.chart { padding: 6px 18px 14px; }
.chart svg { width: 100%; height: 220px; stroke: none; overflow: visible; }
.chart .bar { fill: var(--accent); transform-origin: bottom; transform-box: fill-box; animation: grow .9s var(--spring) both; animation-delay: calc(var(--i) * 40ms); }
.chart .bar-paid { fill: color-mix(in srgb, var(--accent) 35%, transparent); }
.chart .bar-hit { fill: transparent; cursor: pointer; }
.chart .bar-hit:hover + .bar { filter: brightness(1.1); }
.chart text { fill: var(--label-2); font-size: 10.5px; font-family: var(--font); }
.chart .grid-line { stroke: var(--separator); stroke-width: .5; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--label-2); }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 5px; background: var(--accent); }
.legend i.light { background: color-mix(in srgb, var(--accent) 35%, transparent); }
@keyframes grow { from { transform: scaleY(0); } }
.quick { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.quick button { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); cursor: pointer; text-align: left; font-weight: 500; transition: transform .2s var(--spring), box-shadow .2s; }
.quick button:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.quick button:active { transform: scale(.97); }
.quick .q-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: #fff; background: var(--c); font-size: 16px; }
.quick small { display: block; color: var(--label-2); font-weight: 400; font-size: 11.5px; }
.bar-track { height: 6px; border-radius: 99px; background: var(--fill-2); overflow: hidden; margin-top: 6px; }
.bar-track span { display: block; height: 100%; border-radius: inherit; background: var(--c, var(--accent)); transform-origin: left; animation: growx 1s var(--spring) both; }
@keyframes growx { from { transform: scaleX(0); } }
.activity-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--fill-2); color: var(--accent); font-size: 15px; flex: none; }

/* ---------- Liste des documents ---------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.filters .search { position: relative; flex: 1; min-width: 200px; max-width: 320px; }
.filters .search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); color: var(--label-3); }
.filters .search input { padding-left: 30px !important; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th { position: sticky; top: 52px; z-index: 1; padding: 8px 12px; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--label-2); background: var(--surface); border-bottom: .5px solid var(--separator); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: .5px solid var(--separator); white-space: nowrap; }
.table tbody tr { cursor: pointer; transition: background .12s; }
.table tbody tr:hover { background: var(--fill-2); }
.table tbody tr.selected { background: var(--accent-soft); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .check { width: 36px; padding-right: 0; }
.table .who { display: flex; align-items: center; gap: 10px; }
.table .who .avatar { width: 26px; height: 26px; font-size: 11px; }
.table .doc-num { font-weight: 600; font-variant-numeric: tabular-nums; }
.table .muted { color: var(--label-2); }
.checkbox { appearance: none; -webkit-appearance: none; width: 16px; height: 16px; margin: 0; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--label-3); cursor: pointer; display: grid; place-items: center; transition: background .15s, box-shadow .15s; }
.checkbox:checked { background: var(--accent); box-shadow: none; }
.checkbox:checked::after { content: ""; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.batch-bar { position: fixed; left: 50%; bottom: 24px; z-index: 20; display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; border-radius: 14px; background: var(--material); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); box-shadow: var(--shadow-3); transform: translate(-50%, 0); animation: rise .45s var(--spring); }
.batch-bar strong { margin-right: 8px; }
@keyframes rise { from { transform: translate(-50%, 140%); } }
.list-foot { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; color: var(--label-2); font-size: 12px; font-variant-numeric: tabular-nums; }

/* ---------- Éditeur ---------- */
.editor { display: grid; grid-template-columns: minmax(420px, 1fr) minmax(360px, 46%); min-height: calc(100vh - 52px); }
.editor-form { padding: 18px 24px 80px; display: grid; gap: 16px; align-content: start; min-width: 0; }
.editor-preview { position: sticky; top: 52px; height: calc(100vh - 52px); padding: 18px; border-left: .5px solid var(--separator); background: color-mix(in srgb, var(--bg) 70%, var(--fill)); overflow: hidden; display: flex; flex-direction: column; gap: 10px; }
.editor-preview .preview-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--label-2); font-size: 12px; font-weight: 500; }
.paper-stage { flex: 1; min-height: 0; overflow: auto; border-radius: 10px; }
.paper-scale { transform-origin: top left; }
.paper-scale .inv { box-shadow: 0 2px 6px rgba(0,0,0,.06), 0 20px 50px rgba(0,0,0,.12); border-radius: 2px; transition: background .3s; }
.lines { display: grid; gap: 0; }
.line-head, .line { display: grid; grid-template-columns: 22px minmax(0, 1fr) 70px 104px 76px 96px 28px; gap: 8px; align-items: center; }
.line-head { padding: 0 2px 6px; font-size: 11px; font-weight: 600; color: var(--label-2); }
.line-head span:nth-child(n+3) { text-align: right; }
.line { padding: 6px 2px; border-top: .5px solid var(--separator); animation: fadein .35s var(--spring) both; }
.line input, .line select { height: 30px !important; }
.line .num-input { text-align: right; }
.line .line-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.line .grip { cursor: grab; color: var(--label-3); display: grid; place-items: center; }
.line.dragging { opacity: .4; }
.line.drop-target { box-shadow: 0 -2px 0 var(--accent); }
.line-desc { grid-column: 2 / -2; }
.lines { container-type: inline-size; }
@container (max-width: 560px) {
  .line-head { display: none; }
  .line { grid-template-columns: 22px repeat(3, minmax(0, 1fr)) 28px; grid-template-areas: "g l l l d" "g q p v d" "g s s t d"; row-gap: 6px; padding: 10px 2px; }
  .line .grip { grid-area: g; align-self: start; padding-top: 6px; }
  .line .c-label { grid-area: l; } .line .c-qty { grid-area: q; } .line .c-price { grid-area: p; } .line .c-vat { grid-area: v; }
  .line .line-total { grid-area: t; align-self: center; }
  .line [data-a=del-line] { grid-area: d; align-self: start; }
  .line .line-desc { grid-area: s; }
}
.line-desc input { height: 26px !important; font-size: 12px; color: var(--label-2); }
.picker { position: relative; }
.catalog-pop { position: absolute; z-index: 30; top: calc(100% + 6px); left: 0; width: min(440px, 90vw); max-height: 360px; overflow: auto; padding: 6px; border-radius: 12px; background: var(--bg-elevated); box-shadow: var(--shadow-3); animation: pop .25s var(--spring); }
.catalog-pop .grp { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--label-2); }
.catalog-pop button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 7px; background: none; cursor: pointer; text-align: left; }
.catalog-pop button:hover, .catalog-pop button.on { background: var(--accent); color: #fff; }
.catalog-pop button:hover small, .catalog-pop button.on small { color: rgba(255,255,255,.8); }
.catalog-pop button span { flex: 1; min-width: 0; }
.catalog-pop small { display: block; color: var(--label-2); font-size: 11.5px; }
.catalog-pop .price { font-variant-numeric: tabular-nums; font-weight: 500; }
.totals-card { display: grid; gap: 6px; padding: 14px 18px; font-variant-numeric: tabular-nums; }
.totals-card div { display: flex; justify-content: space-between; color: var(--label-2); }
.totals-card .grand { margin-top: 4px; padding-top: 10px; border-top: .5px solid var(--separator); color: var(--label); font: 700 20px var(--font-rounded); }
.recipient-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--fill-2); }
.recipient-chip .grow { flex: 1; min-width: 0; }
.recipient-chip small { color: var(--label-2); display: block; font-size: 11.5px; }
.hint { display: flex; align-items: center; gap: 6px; color: var(--label-2); font-size: 11.5px; }
.hint svg { color: var(--accent); }
.payments .row { min-height: 40px; }

/* ---------- Destinataires ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.r-card { display: flex; flex-direction: column; gap: 12px; padding: 16px; color: var(--label); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-1); transition: transform .3s var(--spring), box-shadow .3s; position: relative; overflow: hidden; }
.r-card::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: var(--c); opacity: .9; }
.r-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
.r-card:active { transform: scale(.98); }
.r-card .top { display: flex; align-items: center; gap: 12px; }
.r-card .top strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-card .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.r-card .stats div { padding: 8px 10px; border-radius: 9px; background: var(--fill-2); }
.r-card .stats small { display: block; font-size: 11px; color: var(--label-2); }
.r-card .stats b { font: 600 14px var(--font-rounded); font-variant-numeric: tabular-nums; }
.r-card .archived { position: absolute; top: 12px; right: 12px; }
.r-card.new { align-items: center; justify-content: center; min-height: 170px; color: var(--accent); background: transparent; box-shadow: inset 0 0 0 1.5px var(--separator); border: 0; cursor: pointer; font-weight: 500; }
.r-card.new::before { display: none; }
.r-card.new svg { font-size: 28px; }
.hero { display: flex; align-items: center; gap: 18px; margin: 4px 0 20px; }
.hero h1 { margin: 0; font: 700 28px var(--font-display); letter-spacing: -.02em; }
.hero p { margin: 2px 0 0; color: var(--label-2); }
.hero .stats-inline { display: flex; gap: 22px; margin-left: auto; }
.hero .stats-inline div { text-align: right; }
.hero .stats-inline small { display: block; color: var(--label-2); font-size: 11.5px; }
.hero .stats-inline b { font: 700 18px var(--font-rounded); font-variant-numeric: tabular-nums; }
.tabs-row { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }

/* ---------- Studio de modèle ---------- */
.studio { display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 18px; align-items: start; }
.studio-side { display: grid; gap: 14px; position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow-y: auto; padding: 2px 4px 20px 2px; }
.studio-stage { min-height: 70vh; padding: 24px; border-radius: 16px; background: color-mix(in srgb, var(--bg) 60%, var(--fill)); display: flex; justify-content: center; overflow: hidden; }
.layouts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.layouts button { display: grid; gap: 5px; justify-items: center; padding: 0; border: 0; background: none; cursor: pointer; font-size: 11px; color: var(--label-2); }
.layouts .thumb { width: 100%; aspect-ratio: 210 / 297; border-radius: 6px; background: #fff; box-shadow: var(--shadow-1); position: relative; overflow: hidden; transition: transform .25s var(--spring), box-shadow .2s; }
.layouts button:hover .thumb { transform: translateY(-2px); }
.layouts button.on .thumb { box-shadow: 0 0 0 2px var(--accent); }
.layouts button.on { color: var(--accent); font-weight: 600; }
.thumb i { position: absolute; display: block; border-radius: 1px; background: #d1d1d6; }
.thumb i.a { background: var(--t, var(--accent)); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.swatch { width: 24px; height: 24px; border-radius: 50%; border: 0; background: var(--s); cursor: pointer; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15); transition: transform .2s var(--bounce); }
.swatch:hover { transform: scale(1.12); }
.swatch.on { box-shadow: 0 0 0 2px var(--bg-elevated), 0 0 0 4px var(--s); }
.logo-drop { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 10px; background: var(--fill-2); border: 1.5px dashed transparent; transition: border-color .2s, background .2s; }
.logo-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.logo-drop img, .logo-drop .ph { width: 48px; height: 48px; border-radius: 9px; object-fit: contain; background: #fff; box-shadow: var(--shadow-1); flex: none; }
.logo-drop .ph { display: grid; place-items: center; color: var(--label-3); font-size: 20px; background: var(--surface); }
.disclosure { border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); overflow: hidden; }
.disclosure > summary { display: flex; align-items: center; gap: 8px; padding: 12px 16px; cursor: pointer; list-style: none; font-weight: 600; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border: solid var(--label-3); border-width: 0 1.6px 1.6px 0; transform: rotate(-45deg); transition: transform .3s var(--spring); }
.disclosure[open] > summary::after { transform: rotate(45deg); }
.disclosure > summary svg { color: var(--accent); font-size: 16px; }
.disclosure .inspector { padding-top: 0; animation: fadein .3s var(--spring); }

/* ---------- Catalogue ---------- */
.price-tag { font: 600 14px var(--font-rounded); font-variant-numeric: tabular-nums; }
.tags { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 10.5px; padding: 1px 6px; border-radius: 4px; background: var(--fill-2); color: var(--label-2); font-weight: 500; }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

/* ---------- Automatisations ---------- */
.auto-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.auto-card { display: flex; gap: 12px; padding: 14px 16px; }
.auto-card .a-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #fff; background: var(--c); font-size: 17px; flex: none; }
.auto-card strong { display: block; }
.auto-card p { margin: 2px 0 0; color: var(--label-2); font-size: 12px; }

/* ---------- Société mère ---------- */
.settings { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.settings-side { position: sticky; top: 64px; display: grid; gap: 12px; }
.pattern-preview { font: 600 13px ui-monospace, "SF Mono", Menlo, monospace; color: var(--accent); }

/* ---------- Couches : feuilles, alertes, menus, palette, toasts ---------- */
.backdrop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.28); animation: fade .25s ease both; }
.backdrop.closing { animation: fade .2s ease reverse both; }
.sheet { width: min(560px, 100%); max-height: min(88vh, 900px); display: flex; flex-direction: column; border-radius: 14px; background: var(--bg-elevated); box-shadow: var(--shadow-3); animation: sheet .5s var(--spring) both; overflow: hidden; }
.sheet.wide { width: min(760px, 100%); }
.backdrop.closing .sheet { animation: sheet .25s ease reverse both; }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px 6px; }
.sheet-head h2 { margin: 0; font: 700 17px var(--font-display); flex: 1; }
.sheet-body { padding: 10px 20px 16px; overflow-y: auto; display: grid; gap: 14px; }
.sheet-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: .5px solid var(--separator); }
.sheet-foot .left { margin-right: auto; }
.alert { width: min(280px, 100%); padding: 20px 16px 16px; border-radius: 14px; text-align: center; background: var(--material); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px); box-shadow: var(--shadow-3); animation: pop .35s var(--bounce) both; }
.alert h3 { margin: 0 0 4px; font-size: 14px; }
.alert p { margin: 0 0 16px; color: var(--label-2); font-size: 12.5px; }
.alert .actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.alert .btn { height: 30px; }
.alert .btn-destructive { background: var(--red); color: #fff; box-shadow: none; }
.menu { position: fixed; z-index: 60; min-width: 220px; padding: 5px; border-radius: 10px; background: var(--material); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px); box-shadow: var(--shadow-3); animation: pop .22s var(--spring) both; transform-origin: top right; }
.menu button { display: flex; align-items: center; gap: 9px; width: 100%; height: 28px; padding: 0 9px; border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left; }
.menu button:hover { background: var(--accent); color: #fff; }
.menu button.danger { color: var(--red); }
.menu button.danger:hover { background: var(--red); color: #fff; }
.menu hr { margin: 4px 8px; border: 0; border-top: .5px solid var(--separator); }
.menu kbd { margin-left: auto; background: none; }
.palette-backdrop { place-items: start center; padding-top: 14vh; background: rgba(0,0,0,.18); }
.palette { width: min(620px, 100%); border-radius: 14px; background: var(--material); backdrop-filter: saturate(180%) blur(40px); -webkit-backdrop-filter: saturate(180%) blur(40px); box-shadow: var(--shadow-3); overflow: hidden; animation: pop .3s var(--spring) both; }
.palette-input { display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: .5px solid var(--separator); }
.palette-input svg { font-size: 20px; color: var(--label-2); }
.palette-input input { flex: 1; height: 54px; border: 0; background: none; outline: none; font-size: 19px; font-weight: 300; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-list .grp { padding: 8px 12px 4px; font-size: 11px; font-weight: 600; color: var(--label-2); }
.palette-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-radius: 8px; background: none; cursor: pointer; text-align: left; }
.palette-list button.on { background: var(--accent); color: #fff; }
.palette-list button.on small, .palette-list button.on .pi { color: rgba(255,255,255,.85); }
.palette-list button .pt { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-list small { color: var(--label-2); font-size: 12px; }
.palette-list .pi { color: var(--accent); font-size: 16px; }
.palette-empty { padding: 26px; text-align: center; color: var(--label-2); }
.toasts { position: fixed; z-index: 80; top: 14px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 9px; padding: 9px 16px 9px 12px; border-radius: 99px; background: var(--material); backdrop-filter: saturate(180%) blur(30px); -webkit-backdrop-filter: saturate(180%) blur(30px); box-shadow: var(--shadow-2); font-weight: 500; animation: toast .5s var(--spring) both; pointer-events: auto; }
.toast.out { animation: toast .3s ease reverse both; }
.toast .ti { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; color: #fff; background: var(--green); font-size: 12px; }
.toast.error .ti { background: var(--red); }

/* ---------- États ---------- */
.empty { display: grid; justify-items: center; gap: 6px; padding: 54px 20px; text-align: center; color: var(--label-2); }
.empty .e-icon { display: grid; place-items: center; width: 56px; height: 56px; border-radius: 16px; background: var(--accent-soft); color: var(--accent); font-size: 26px; margin-bottom: 6px; }
.empty strong { color: var(--label); font-size: 15px; }
.empty .btn { margin-top: 10px; }
.loading { display: grid; place-items: center; min-height: 60vh; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid var(--fill); border-top-color: var(--label-2); animation: spin .8s linear infinite; }
.skeleton { border-radius: 8px; background: linear-gradient(90deg, var(--fill-2), var(--fill), var(--fill-2)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

/* ---------- Animations ---------- */
.enter { animation: enter .55s var(--spring) both; }
.stagger > * { animation: enter .6s var(--spring) both; animation-delay: calc(min(var(--i, 0), 14) * 35ms); }
@keyframes enter { from { opacity: 0; transform: translateY(10px) scale(.995); filter: blur(2px); } }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } }
@keyframes fade { from { opacity: 0; } }
@keyframes sheet { from { opacity: 0; transform: translateY(28px) scale(.97); } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes toast { from { opacity: 0; transform: translateY(-24px) scale(.9); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 50% { transform: scale(1.06); } }
.flash { animation: pulse .4s var(--bounce); }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .28s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; } }

/* ---------- Connexion ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; overflow: hidden; }
.auth-glow { position: fixed; inset: -30%; z-index: -1; background: radial-gradient(40% 40% at 30% 30%, color-mix(in srgb, var(--accent) 35%, transparent), transparent 70%), radial-gradient(35% 35% at 75% 70%, color-mix(in srgb, var(--blue) 22%, transparent), transparent 70%); filter: blur(40px); animation: drift 18s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translate(4%, -3%) rotate(8deg); } }
.auth-card { width: min(380px, 100%); padding: 36px 30px 24px; border-radius: 22px; text-align: center; background: var(--material); backdrop-filter: saturate(180%) blur(40px); -webkit-backdrop-filter: saturate(180%) blur(40px); box-shadow: var(--shadow-3); animation: sheet .7s var(--spring) both; }
.auth-mark { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 16px; border-radius: 18px; background: var(--accent); color: #fff; font: 600 32px var(--font-rounded); overflow: hidden; box-shadow: 0 8px 24px color-mix(in srgb, var(--accent) 40%, transparent); }
.auth-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; }
.auth-card h1 { margin: 0; font: 700 24px var(--font-display); letter-spacing: -.02em; }
.auth-intro { margin: 4px 0 20px; color: var(--label-2); }
.auth-form { display: grid; gap: 8px; }
.auth-form input { height: 40px; padding: 0 14px; border: 0; border-radius: 10px; background: var(--fill-2); box-shadow: inset 0 0 0 .5px var(--separator); outline: none; font-size: 15px; transition: box-shadow .2s; }
.auth-form input:focus { box-shadow: inset 0 0 0 .5px var(--separator), 0 0 0 3.5px color-mix(in srgb, var(--accent) 35%, transparent); }
.auth-form .btn { margin-top: 8px; }
.auth-error { margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); font-weight: 500; }
.auth-demo { display: grid; gap: 4px; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); text-align: left; font-size: 12px; }
.auth-demo span { font-weight: 600; color: var(--accent); }
.auth-demo code { font: 12px ui-monospace, "SF Mono", Menlo, monospace; -webkit-user-select: all; user-select: all; }
.auth-foot { margin: 22px 0 0; color: var(--label-3); font-size: 11.5px; }

/* ---------- Adaptatif ---------- */
@media (max-width: 1180px) {
  .editor { grid-template-columns: 1fr; }
  .editor-preview { position: relative; top: 0; height: 80vh; border-left: 0; border-top: .5px solid var(--separator); }
  .studio, .settings { grid-template-columns: 1fr; }
  .studio-side, .settings-side { position: static; max-height: none; }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .tabbar { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); background: var(--material); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px); border-top: .5px solid var(--separator); }
  .tabbar a { display: grid; justify-items: center; gap: 2px; color: var(--label-3); font-size: 10px; font-weight: 500; }
  .tabbar a svg { font-size: 22px; }
  .tabbar a.active { color: var(--accent); }
  .toolbar { padding: 10px 16px; }
  .page { padding: 8px 16px 48px; }
  .kpis, .quick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-form { padding: 14px 16px 60px; }
  .hero { flex-wrap: wrap; }
  .hero .stats-inline { margin-left: 0; width: 100%; justify-content: space-between; }
  .hero .stats-inline div { text-align: left; }
  .hide-sm, .table .hide-sm { display: none; }
  .layouts { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 520px) {
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .large-title { font-size: 26px; }
  .filters .search { max-width: none; }
}
@media print {
  body > *:not(#app) { display: none !important; }
}

/* La feuille A4 (794 px) ne doit jamais élargir sa colonne avant la mise à l'échelle. */
.settings > *, .studio > *, .editor > *, .settings-side > * { min-width: 0; }
.paper-fit, #coStage { overflow: hidden; }
.palette, .menu, .alert { background: color-mix(in srgb, var(--bg-elevated) 90%, transparent); }
.dash-grid .grid { grid-template-columns: minmax(0, 1fr); }
.card-head { flex-wrap: wrap; }
.toolbar h1 { min-width: 0; flex: 0 1 auto; }
.segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
.segmented::-webkit-scrollbar { display: none; }
@media (max-width: 860px) {
  #listWrap { overflow-x: auto; }
  .table th { position: static; }
  .toolbar .badge, .toolbar .back { display: none; }
}
#segWrap { min-width: 0; max-width: 100%; }

/* ===================== Couleurs ===================== */
:root { --yellow: #ffcc00; --indigo: #5856d6; --pink: #ff2d55; --mint: #00c7be; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --yellow: #ffd60a; --indigo: #5e5ce6; --pink: #ff375f; --mint: #63e6e2; } }
:root[data-theme="dark"] { --yellow: #ffd60a; --indigo: #5e5ce6; --pink: #ff375f; --mint: #63e6e2; }
body { background: radial-gradient(1200px 500px at 100% -10%, color-mix(in srgb, var(--accent) 9%, transparent), transparent 60%), radial-gradient(900px 400px at 0% 110%, color-mix(in srgb, var(--indigo) 7%, transparent), transparent 60%), var(--bg); background-attachment: fixed; }
.nav-item .ni { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; background: var(--c, var(--accent)); color: #fff; flex: none; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.08); background-image: linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,0)); }
.nav-item .ni svg { font-size: 14px; color: #fff; }
.nav-item.active { background: color-mix(in srgb, var(--c, var(--accent)) 16%, transparent); }
.nav-item.active .label { color: var(--c, var(--accent)); font-weight: 600; }
.tabbar a.active { color: var(--c, var(--accent)); }
.kpis .kpi:nth-child(1) { --c: var(--accent); } .kpis .kpi:nth-child(2) { --c: var(--green); } .kpis .kpi:nth-child(3) { --c: var(--blue); } .kpis .kpi:nth-child(4) { --c: var(--purple); }
.kpi { background: linear-gradient(140deg, color-mix(in srgb, var(--c) 17%, var(--surface)) 0%, var(--surface) 65%); }
.kpi::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--c) 28%, transparent), transparent 70%); pointer-events: none; }
.kpi strong { color: color-mix(in srgb, var(--c) 55%, var(--label)); }
.r-card::before { height: 46px; opacity: 1; background: linear-gradient(120deg, color-mix(in srgb, var(--c) 32%, transparent), color-mix(in srgb, var(--c) 6%, transparent)); }
.r-card .top { position: relative; }
.hero .avatar.lg { box-shadow: 0 8px 24px color-mix(in srgb, var(--c) 35%, transparent); }
.section-title svg, .card-head h2 svg { color: var(--accent); }
.large-title { background: linear-gradient(90deg, var(--label) 40%, color-mix(in srgb, var(--accent) 80%, var(--label))); -webkit-background-clip: text; background-clip: text; color: transparent; }
.large-title.greet { display: flex; align-items: center; gap: 12px; }
.large-title.greet .avatar { display: none; -webkit-text-fill-color: #fff; color: #fff; font-size: 14px; }
.badge { font-weight: 600; }
.b-sent { --b: var(--blue); } .b-paid { --b: var(--green); } .b-partial { --b: var(--orange); } .b-overdue { --b: var(--red); }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* Pastilles de clients avec logo */
.avatar.logo { background: #fff; padding: 3px; overflow: hidden; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.12); background-image: none; }
.avatar.logo img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.avatar.xs { width: 20px; height: 20px; font-size: 9px; border-radius: 6px; }
.avatar.xs:not(.square) { border-radius: 50%; }
.avatar.xs.logo { padding: 1.5px; }
.avatar.small.logo { padding: 2px; }

/* Profil dans la barre latérale */
.user-link { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; padding: 4px 6px; margin: -4px 0; border-radius: 8px; color: var(--label); transition: background .2s; }
.user-link:hover, .user-link.active { background: var(--fill-2); }
.user-text { display: grid; min-width: 0; line-height: 1.2; }
.user-text small { color: var(--label-2); font-size: 11px; }

/* Bulles d'aide « ? » */
.tip { display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 3px; padding: 0; border: 0; border-radius: 50%; vertical-align: 1px; background: color-mix(in srgb, var(--blue) 16%, transparent); color: var(--blue); font: 700 10px var(--font-rounded); cursor: help; transition: transform .2s var(--bounce), background .2s; -webkit-text-fill-color: var(--blue); }
.tip:hover, .tip[aria-expanded] { background: var(--blue); color: #fff; -webkit-text-fill-color: #fff; transform: scale(1.15); }
.tip-pop { position: fixed; z-index: 90; max-width: 290px; padding: 10px 12px; border-radius: 10px; background: #1d1d1f; color: #f5f5f7; font-size: 12.5px; line-height: 1.5; box-shadow: var(--shadow-3); animation: pop .25s var(--spring) both; }
.tip-pop::before { content: ""; position: absolute; left: calc(var(--arrow) - 6px); width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.tip-pop.below::before { top: -5px; } .tip-pop.above::before { bottom: -5px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tip-pop { background: #f5f5f7; color: #1d1d1f; } }
:root[data-theme="dark"] .tip-pop { background: #f5f5f7; color: #1d1d1f; }

/* Cartes « Comment ça marche » */
.guide { display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px; margin-bottom: 16px; background: linear-gradient(120deg, color-mix(in srgb, var(--blue) 12%, var(--surface)), color-mix(in srgb, var(--purple) 8%, var(--surface))); animation: enter .5s var(--spring) both; }
.guide.closing { animation: fade .25s ease reverse both; }
.guide .grow { flex: 1; min-width: 0; }
.guide strong { display: block; margin-bottom: 4px; }
.guide ol { margin: 0; padding-left: 18px; color: var(--label-2); line-height: 1.6; }
.guide-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none; color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); font-size: 16px; }
.studio-side .guide, .editor-form .guide { margin-bottom: 0; }

/* Pour bien démarrer */
.onboarding { margin-bottom: 14px; }
.step-check { display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--label-3); color: #fff; font-size: 13px; flex: none; }
.row.done .step-check { background: var(--green); box-shadow: none; }
.row.done .title { color: var(--label-2); text-decoration: line-through; }

/* Visite guidée */
.tour { position: fixed; inset: 0; z-index: 95; }
.tour.closing { animation: fade .25s ease reverse both; }
.tour-hole { position: fixed; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0,0,0,.55), 0 0 0 3px var(--accent); transition: all .45s var(--spring); pointer-events: none; }
.tour-pop { position: fixed; width: min(320px, calc(100vw - 20px)); padding: 16px; border-radius: 14px; background: var(--bg-elevated); box-shadow: var(--shadow-3); transition: left .45s var(--spring), top .45s var(--spring); }
.tour-pop.in { animation: pop .35s var(--spring) both; }
.tour-pop strong { display: block; font: 700 16px var(--font-display); margin: 2px 0 4px; }
.tour-pop p { margin: 0 0 14px; color: var(--label-2); line-height: 1.55; }
.tour-count { font-size: 11px; font-weight: 600; color: var(--accent); }
.tour-actions { display: flex; gap: 6px; align-items: center; }
.tour-actions .spacer { flex: 1; }

/* Bouton d'aide flottant */
.help-fab { position: fixed; z-index: 15; right: 20px; bottom: 20px; width: 44px; height: 44px; border: 0; border-radius: 50%; color: #fff; font: 700 20px var(--font-rounded); cursor: pointer; background: linear-gradient(135deg, var(--blue), var(--purple)); box-shadow: 0 8px 24px color-mix(in srgb, var(--purple) 40%, transparent); transition: transform .25s var(--bounce); }
.help-fab:hover { transform: scale(1.08) rotate(-6deg); }
.help-fab:active { transform: scale(.94); }
.help-hero { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; padding: 18px; }
.help-hero .a-icon { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; color: #fff; background: var(--c); font-size: 17px; margin-bottom: 8px; }
.help-hero p { margin: 4px 0 0; color: var(--label-2); font-size: 12.5px; }

/* Barre « Modifications non enregistrées » */
.save-bar { position: fixed; z-index: 40; left: 50%; bottom: 22px; display: flex; align-items: center; gap: 10px; width: min(560px, calc(100vw - 24px)); padding: 8px 8px 8px 16px; border-radius: 14px; font-weight: 500; background: color-mix(in srgb, var(--bg-elevated) 92%, transparent); backdrop-filter: saturate(180%) blur(24px); -webkit-backdrop-filter: saturate(180%) blur(24px); box-shadow: var(--shadow-3), 0 0 0 1px color-mix(in srgb, var(--orange) 40%, transparent); transform: translateX(-50%); animation: rise .5s var(--spring) both; }
.save-bar.out { animation: rise .28s ease reverse both; }
.save-bar .grow { flex: 1; }
.pulse-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 0 color-mix(in srgb, var(--orange) 60%, transparent); animation: ping 1.6s infinite; }
@keyframes ping { 70% { box-shadow: 0 0 0 8px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
kbd.on-accent { background: rgba(255,255,255,.2); color: rgba(255,255,255,.9); }
@media (max-width: 860px) {
  .help-fab { bottom: calc(76px + env(safe-area-inset-bottom)); right: 14px; width: 40px; height: 40px; }
  .save-bar { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .save-bar kbd { display: none; }
  .large-title.greet .avatar { display: inline-grid; margin-left: auto; }
  .help-hero { grid-template-columns: 1fr; }
}
.editor-form > *, .studio-side > *, .settings > form > * { min-width: 0; }
.disclosure > summary { flex-wrap: wrap; row-gap: 4px; }
@media (max-width: 520px) { .guide { flex-wrap: wrap; } .guide .btn { margin-left: auto; } }

/* Cartes d'indicateurs : sobres, sans dégradé, avec la courbe des 12 derniers mois. */
.kpi { background: var(--surface); padding: 16px 18px 12px; display: flex; flex-direction: column; }
.kpi::after { display: none; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kpi-head small { color: var(--label-2); font-weight: 500; }
.kpi .k-icon { width: 26px; height: 26px; margin: 0; border-radius: 8px; font-size: 15px; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.kpi strong { margin-top: 6px; color: var(--label); font-size: 26px; }
.kpi .trend { margin-top: 2px; }
.spark { display: block; width: 100%; height: 46px; margin-top: 12px; overflow: visible; }
.spark-line { fill: none; stroke: var(--c); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; vector-effect: non-scaling-stroke; stroke-dasharray: 1; stroke-dashoffset: 1; animation: draw 1.2s var(--spring) .15s forwards; }
.spark-base { stroke: var(--separator); stroke-width: 1; stroke-dasharray: 3 4; vector-effect: non-scaling-stroke; }
.spark-axis { display: flex; justify-content: space-between; margin-top: 4px; font-size: 10.5px; color: var(--label-3); }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* Bouton de thème */
.theme-btn svg { font-size: 16px; }
.theme-btn .t-sun, .theme-btn .t-moon, .theme-btn .t-auto { display: none; }
:root[data-theme="light"] .theme-btn .t-sun, :root[data-theme="dark"] .theme-btn .t-moon, :root:not([data-theme]) .theme-btn .t-auto { display: block; }
html.theme-anim, html.theme-anim * { transition: background-color .35s ease, color .35s ease, border-color .35s ease !important; }

/* Carte « À déclarer » */
.declare #declBody { display: grid; gap: 12px; padding: 12px 18px 16px; }
.decl-period { color: var(--label-2); font-size: 12px; }
.decl-block { display: grid; gap: 6px; padding: 12px; border-radius: 10px; background: var(--fill-2); }
.decl-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.decl-title strong { font: 700 16px var(--font-rounded); font-variant-numeric: tabular-nums; }
.decl-row { display: flex; justify-content: space-between; gap: 10px; color: var(--label-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.decl-row.muted { color: var(--label-3); }
.rate-chip { display: inline-block; min-width: 38px; margin-right: 8px; padding: 1px 6px; border-radius: 5px; text-align: center; font-size: 11px; font-weight: 600; color: var(--purple); background: color-mix(in srgb, var(--purple) 12%, transparent); }
.decl-export { height: 34px; font-size: 13px; }
.dl-seg { min-width: 0; max-width: 100%; }
@media (max-width: 860px) { .dl-list { overflow-x: auto; } }

/* Avatars utilisateurs : photo ou emoji */
.avatar.photo { padding: 0; overflow: hidden; background: var(--fill); }
.avatar.photo img { width: 100%; height: 100%; object-fit: cover; }
.avatar.emoji { background: color-mix(in srgb, var(--c) 22%, var(--surface)); background-image: none; font-size: 18px; line-height: 1; }
.avatar.emoji.small { font-size: 13px; }
.avatar.emoji.lg { font-size: 34px; }
.avatar.xl { width: 120px; height: 120px; font-size: 44px; }
.avatar.emoji.xl { font-size: 64px; }
.avatar-edit { position: relative; padding: 0; border: 0; background: none; cursor: pointer; border-radius: 50%; }
.avatar-edit .cam { position: absolute; right: -2px; bottom: -2px; display: grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--bg-elevated); color: var(--accent); box-shadow: var(--shadow-2); font-size: 14px; transition: transform .2s var(--bounce); }
.avatar-edit:hover .cam { transform: scale(1.12); }
.avatar-studio { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 20px; align-items: start; }
.avatar-preview { display: grid; place-items: center; padding: 14px 0; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-pick { aspect-ratio: 1; border: 0; border-radius: 10px; background: var(--fill-2); font-size: 22px; cursor: pointer; transition: transform .2s var(--bounce), background .2s; }
.emoji-pick:hover { transform: scale(1.1); }
.emoji-pick.on { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
@media (max-width: 560px) { .avatar-studio { grid-template-columns: 1fr; } .emoji-grid { grid-template-columns: repeat(4, 1fr); } }

/* Bouton d'aide : pastille sobre, sans dégradé */
.help-fab { display: inline-flex; align-items: center; gap: 8px; width: auto; height: 38px; padding: 0 14px 0 5px; border-radius: 99px; color: var(--label); font: 600 13px var(--font); background: var(--bg-elevated); box-shadow: var(--shadow-2); }
.help-fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-3); }
.help-fab:active { transform: scale(.96); }
.help-fab .hf-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 17px; }
.help-fab .hf-icon svg { stroke-width: 2; }
@media (max-width: 860px) { .help-fab { width: 40px; height: 40px; padding: 0; justify-content: center; } .help-fab .hf-label { display: none; } }

/* Vue « Par client » (arborescence) */
.dl-view { margin-left: auto; }
.dl-view .segmented button { display: inline-flex; align-items: center; gap: 5px; }
.dl-view svg { font-size: 13px; }
.table tr.grp-row { background: var(--fill-2); }
.table tr.grp-row:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); }
.table tr.grp-row td { border-bottom-color: var(--separator); padding-top: 9px; padding-bottom: 9px; }
.grp-chev { display: inline-grid; place-items: center; width: 18px; color: var(--label-3); font-size: 13px; transition: transform .3s var(--spring); }
.grp-row.open .grp-chev { transform: rotate(90deg); color: var(--accent); }
.table tr.child td:nth-child(2) { position: relative; padding-left: 52px; }
.tree-line { position: absolute; left: 26px; top: 0; bottom: 50%; width: 16px; border-left: 1.5px solid var(--separator); border-bottom: 1.5px solid var(--separator); border-bottom-left-radius: 6px; }
.table tr.child + tr.child .tree-line { top: -1px; }
@media (max-width: 860px) { .dl-view { margin-left: 0; } }

/* En-tête : recherche et compte en haut à droite */
.top-divider { width: 1px; height: 22px; margin: 0 2px; background: var(--separator); }
.top-search { display: inline-flex; align-items: center; gap: 7px; height: 30px; min-width: 210px; padding: 0 8px 0 10px; border: 0; border-radius: 8px; background: var(--fill); color: var(--label-2); cursor: pointer; text-align: left; transition: background .2s, box-shadow .2s; }
.top-search:hover { background: color-mix(in srgb, var(--fill) 150%, transparent); }
.top-search span { flex: 1; }
.top-search svg { font-size: 15px; }
.top-avatar { display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px 2px 2px; border: 0; border-radius: 99px; background: transparent; cursor: pointer; transition: background .2s; }
.top-avatar:hover { background: var(--fill-2); }
.top-avatar .avatar.small { width: 28px; height: 28px; font-size: 12px; }
.top-avatar .chev-down { display: inline-grid; color: var(--label-3); font-size: 11px; transform: rotate(90deg); }

/* Bas du menu latéral : Aide, Support, Déconnexion */
.sidebar-top { padding-bottom: 12px; }
.sidebar-foot { display: grid; gap: 1px; padding: 8px 0 2px; }
.foot-item { display: flex; align-items: center; gap: 9px; height: 30px; padding: 0 10px; border: 0; border-radius: 7px; background: none; color: var(--label-2); font-weight: 500; text-align: left; cursor: pointer; transition: background .2s, color .2s; }
.foot-item svg { font-size: 16px; }
.foot-item:hover { background: var(--fill-2); color: var(--label); }
.foot-item.danger:hover { color: var(--red); background: color-mix(in srgb, var(--red) 10%, transparent); }

/* Support */
.support-card { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 12px; background: var(--fill-2); }
.support-card small { display: block; color: var(--label-2); }
.support-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--accent); background: var(--accent-soft); font-size: 18px; flex: none; }

@media (max-width: 1100px) { .top-search { min-width: 0; } .top-search span, .top-search kbd { display: none; } }
@media (max-width: 860px) { .top-divider { display: none; } .top-avatar .chev-down { display: none; } }
@media (max-width: 520px) { #edHead [data-a="print"], #edHead .top-search { display: none; } .toolbar { gap: 6px; } }

/* Crédit AOURIK Digital */
.made-by { display: block; margin-top: 8px; padding: 8px 10px 2px; border-top: .5px solid var(--separator); color: var(--label-3); font-size: 11px; text-align: center; transition: color .2s; }
.made-by strong { font-weight: 600; color: var(--label-2); }
.made-by:hover, .made-by:hover strong { color: var(--accent); }
.made-by .heart { display: inline-block; color: var(--red); animation: beat 1.6s ease-in-out infinite; }
@keyframes beat { 0%, 60%, 100% { transform: scale(1); } 30% { transform: scale(1.25); } }
.auth-card .made-by { border-top: 0; margin-top: 4px; padding-top: 0; }
.avatar-edit .avatar.lg.square + .cam { right: -6px; bottom: -6px; }
a.avatar-edit { display: inline-block; flex: none; }
.logo-card .logo-drop .avatar.lg { width: 56px; height: 56px; font-size: 22px; }

/* Clients du menu latéral : épinglés + récents */
.sidebar-section-title a { color: inherit; }
.sidebar-section-title a:hover { color: var(--accent); }
.side-sub { display: flex; align-items: center; gap: 5px; padding: 8px 10px 3px; color: var(--label-3); font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.side-sub svg { font-size: 11px; }
.pin-btn { display: inline-grid; place-items: center; width: 22px; height: 22px; margin-left: auto; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--label-3); cursor: pointer; opacity: 0; transition: opacity .15s, background .15s, color .15s; flex: none; }
.pin-btn svg { font-size: 13px; }
.client-item:hover .pin-btn, .pin-btn:focus-visible { opacity: 1; }
.pin-btn:hover { background: var(--fill); color: var(--label); }
.pin-btn.on { color: var(--accent); }
.client-item .pin-btn.on { opacity: .9; }
.nav-item.see-all { color: var(--label-2); font-weight: 500; margin-top: 4px; }
.nav-item.see-all svg { font-size: 12px; color: var(--label-3); }
.nav-item.see-all .count { margin-left: auto; margin-right: 2px; }
.r-card .card-pin { position: absolute; top: 10px; right: 10px; opacity: .55; z-index: 1; background: var(--surface); }
.r-card:hover .card-pin, .r-card .card-pin.on { opacity: 1; }
@media (hover: none) { .pin-btn { opacity: .7; } }

/* Clients : bascule Grille / Liste */
.view-switch { margin-left: auto; }
.view-switch .segmented button { display: inline-flex; align-items: center; gap: 5px; }
.view-switch svg { font-size: 13px; }
.client-list { overflow: clip; }
.client-list .table tbody tr { cursor: pointer; }
.client-list .who .avatar { width: 30px; height: 30px; font-size: 11px; }
.client-list .who strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-list .pin-btn { opacity: .35; }
.client-list tr:hover .pin-btn, .client-list .pin-btn.on { opacity: 1; }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover, .table th.sorted { color: var(--label); }
.sort-dir { margin-left: 4px; color: var(--accent); }
.muted-row td { opacity: .55; }
@media (max-width: 860px) { .view-switch { margin-left: 0; } .client-list { overflow-x: auto; } }

/* Sélecteur de période */
.dash-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.period-btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 0; border-radius: 10px; background: var(--surface); color: var(--label); font-weight: 600; cursor: pointer; box-shadow: var(--shadow-1); transition: box-shadow .2s, transform .15s var(--spring); }
.period-btn:hover { box-shadow: var(--shadow-2); }
.period-btn:active { transform: scale(.97); }
.period-btn > svg { color: var(--accent); font-size: 16px; }
.period-btn .chev-down { display: inline-grid; color: var(--label-3); font-size: 11px; transform: rotate(90deg); }
.period-pop { position: fixed; z-index: 70; display: grid; grid-template-columns: 230px 250px; width: min(480px, calc(100vw - 20px)); border-radius: 14px; background: var(--bg-elevated); box-shadow: var(--shadow-3); overflow: hidden; animation: pop .25s var(--spring) both; }
.pp-list { display: grid; align-content: start; gap: 2px; padding: 8px; border-right: .5px solid var(--separator); }
.pp-list button { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 7px 10px; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.pp-list button small { grid-column: 1; color: var(--label-2); font-size: 11px; }
.pp-list button svg { grid-row: 1 / span 2; grid-column: 2; color: var(--accent); }
.pp-list button:hover { background: var(--fill-2); }
.pp-list button.on { background: var(--accent-soft); }
.pp-list button.on span { color: var(--accent); font-weight: 600; }
.pp-custom { display: grid; gap: 10px; align-content: start; padding: 14px; }
.pp-custom strong { display: flex; align-items: center; gap: 6px; }
.pp-custom strong svg { color: var(--accent); }
.pp-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-quick .tag { border: 0; cursor: pointer; }
.pp-quick .tag:hover { background: var(--accent-soft); color: var(--accent); }
.delta { font-weight: 500; }
.delta.up { color: var(--green); } .delta.down { color: var(--red); } .delta.flat { color: var(--label-3); }
.quick a.quick-link { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-1); color: var(--label); font-weight: 500; transition: transform .2s var(--spring), box-shadow .2s; animation: enter .6s var(--spring) both; animation-delay: calc(var(--i) * 35ms); }
.quick a.quick-link:hover { transform: translateY(-2px); box-shadow: var(--shadow-2); }
.quick a.quick-link small { display: block; color: var(--label-2); font-weight: 400; font-size: 11.5px; }
@media (max-width: 560px) { .period-pop { grid-template-columns: 1fr; } .pp-list { border-right: 0; border-bottom: .5px solid var(--separator); } }

/* Couleur de l'interface */
.accent-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 10px; }
.accent-pick { display: grid; justify-items: center; gap: 5px; padding: 6px 2px; border: 0; border-radius: 10px; background: none; cursor: pointer; color: var(--label-2); transition: background .2s; }
.accent-pick:hover { background: var(--fill-2); }
.accent-pick .dot { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--s); color: #fff; font-size: 15px; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.15); transition: transform .25s var(--bounce), box-shadow .2s; }
.accent-pick:hover .dot { transform: scale(1.08); }
.accent-pick.on .dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--s); }
.accent-pick.on small { color: var(--label); font-weight: 600; }
.accent-pick small { font-size: 11px; }
.accent-preview { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px; border-radius: 10px; background: var(--fill-2); pointer-events: none; }

/* Infobulle du graphique */
.chart { position: relative; }
.chart-tip { position: absolute; z-index: 5; width: 210px; padding: 10px 12px; border-radius: 12px; background: var(--bg-elevated); box-shadow: var(--shadow-3); font-size: 12px; pointer-events: none; transform: translateY(-100%); animation: pop .18s var(--spring) both; display: grid; gap: 5px; font-variant-numeric: tabular-nums; }
.chart-tip strong { font-size: 12.5px; text-transform: capitalize; margin-bottom: 2px; }
.chart-tip div { display: flex; justify-content: space-between; gap: 10px; color: var(--label-2); }
.chart-tip div span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tip b { color: var(--label); font-weight: 600; }
.chart-tip .sw { width: 8px; height: 8px; border-radius: 2px; background: var(--accent); }
.chart-tip .sw.light { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.chart-tip .bar-track { display: block; margin-top: 0; }
.chart-tip .tip-rate { margin-top: 3px; padding-top: 6px; border-top: .5px solid var(--separator); }
.chart .bar { transition: opacity .2s; }
.chart.hovering g:not(.hover) .bar { opacity: .35; }
.chart g.hover .bar-hit { fill: color-mix(in srgb, var(--accent) 8%, transparent); }

/* ===================== Établissements ===================== */
.brand.riad-switch { width: 100%; border: 0; background: none; cursor: pointer; text-align: left; font: inherit; box-shadow: inset 0 0 0 1px transparent; transition: background .2s, box-shadow .2s; }
.brand.riad-switch:hover { background: var(--fill-2); box-shadow: inset 0 0 0 1px var(--separator); }
.brand.riad-switch .brand-text { flex: 1; }
.brand-mark svg { font-size: 16px; color: #fff; }
.switch-chev { display: grid; place-items: center; color: var(--label-3); font-size: 15px; }
.riad-pop { position: fixed; z-index: 70; width: 290px; max-height: 70vh; overflow: auto; padding: 6px; border-radius: 14px; background: var(--bg-elevated); box-shadow: var(--shadow-3); animation: pop .22s var(--spring) both; }
.rp-title { padding: 8px 10px 4px; font-size: 11px; font-weight: 600; color: var(--label-2); text-transform: uppercase; letter-spacing: .04em; }
.riad-pop button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border: 0; border-radius: 9px; background: none; cursor: pointer; text-align: left; color: var(--label); }
.riad-pop button:hover { background: var(--fill-2); }
.riad-pop button.on { background: var(--accent-soft); }
.riad-pop button > svg { margin-left: auto; color: var(--accent); }
.riad-pop button[data-rp] > svg { margin-left: 0; color: var(--label-2); font-size: 16px; width: 28px; }
.rp-name { flex: 1; min-width: 0; }
.rp-name strong { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rp-name small { display: block; color: var(--label-2); font-size: 11.5px; }
.rp-sep { height: 1px; margin: 5px 8px; background: var(--separator); }
.avatar.all-mark { background: var(--label); color: var(--bg); }
.avatar.all-mark svg { font-size: 13px; }
.riad-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 8px 2px 2px; border-radius: 99px; font-size: 11.5px; font-weight: 600; color: var(--label); background: color-mix(in srgb, var(--c) 12%, transparent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.riad-chip img, .riad-chip i { width: 18px; height: 18px; border-radius: 50%; flex: none; object-fit: cover; background: #fff; }
.riad-chip i { display: grid; place-items: center; font-style: normal; font-size: 10px; color: #fff; background: var(--c); }
.riad-section { display: flex; align-items: center; gap: 10px; margin: 26px 2px 4px; padding-bottom: 8px; border-bottom: .5px solid var(--separator); }
.riad-section strong { font: 600 16px var(--font-display); }
.riad-section .spacer { flex: 1; }
.riad-section:first-child { margin-top: 4px; }
.riad-bar { display: block; width: 100%; padding: 0; border: 0; background: none; text-align: left; color: inherit; cursor: pointer; font: inherit; }
.riad-bar:hover strong, .riad-bar:hover span { color: var(--label); }
.riad-bar small { color: var(--label-3); }
.r-card .stats.three { grid-template-columns: repeat(3, 1fr); }
.tag.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.riad-card.is-archived { opacity: .6; }
.avatar.xs.square { border-radius: 5px; }

/* Arbre des établissements dans le menu latéral */
.tree-all svg { color: var(--label-2); }
.tree-all.on { background: var(--fill); font-weight: 600; }
.tree-node { margin-top: 1px; }
.tree-head { cursor: pointer; padding-right: 4px; }
.tree-node.current > .tree-head { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.tree-node.current > .tree-head .label { font-weight: 600; }
.tree-chev { display: grid; place-items: center; width: 22px; height: 22px; margin-left: auto; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--label-3); cursor: pointer; transition: transform .25s var(--spring), background .15s; flex: none; }
.tree-chev:hover { background: var(--fill); color: var(--label); }
.tree-chev svg { font-size: 12px; }
.tree-node.open .tree-chev { transform: rotate(90deg); }
.tree-children { display: none; margin: 1px 0 6px 19px; padding-left: 8px; border-left: 1.5px solid var(--separator); }
.tree-node.open .tree-children { display: grid; gap: 1px; animation: fadein .25s var(--spring); }
.tree-leaf { height: 27px; font-weight: 400; color: var(--label-2); }
.tree-leaf svg { font-size: 14px; color: var(--label-3); }
.tree-leaf.active { background: var(--fill); color: var(--label); font-weight: 600; }
.tree-leaf.active svg { color: var(--accent); }
.sidebar-recipients { padding-top: 2px; }
.riad-card .riad-del { position: absolute; top: 8px; right: 8px; z-index: 2; opacity: 0; background: var(--surface); box-shadow: var(--shadow-1); }
.riad-card:hover .riad-del, .riad-del:focus-visible { opacity: 1; }
.riad-del:hover { color: var(--red); }
.client-list .riad-del { opacity: .5; }
.client-list tr:hover .riad-del { opacity: 1; }
@media (hover: none) { .riad-card .riad-del { opacity: .8; } }
.client-list tr.child td:first-child { position: relative; padding-left: 52px; }
.client-list tr.child .who .avatar { width: 26px; height: 26px; font-size: 10px; }

/* Pagination de l'échéancier */
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 8px 18px 6px; font-size: 12px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.pager .icon-btn:disabled { opacity: .35; pointer-events: none; }

/* ---------- Menu latéral (refonte) ---------- */
.sidebar-top { padding-bottom: 4px; }
.side-title { display: flex; align-items: center; gap: 6px; padding: 16px 10px 6px; color: var(--label-3); font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.side-title > span:first-child, .side-title > a:first-child { flex: 1; }
.side-title a { display: inline-flex; align-items: center; gap: 6px; color: inherit; transition: color .2s; }
.side-title a:hover { color: var(--accent); }
.side-title .n { padding: 1px 6px; border-radius: 99px; background: var(--fill); color: var(--label-2); font-size: 10px; letter-spacing: 0; }
.side-add { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 6px; background: none; color: var(--label-2); cursor: pointer; transition: background .2s, color .2s; }
.side-add svg { font-size: 13px; }
.side-add:hover { background: var(--fill); color: var(--accent); }
.side-back { flex: none !important; gap: 4px !important; padding: 2px 6px 2px 4px; border-radius: 6px; text-transform: none; letter-spacing: 0; font-size: 11.5px; font-weight: 500; color: var(--label-2) !important; transition: background .2s, color .2s; }
.side-back svg { font-size: 11px; }
.side-back:hover { background: var(--fill); color: var(--accent) !important; }
.sidebar-nav, .sidebar-recipients { gap: 2px; }
.sidebar .nav-item { height: 32px; border-radius: 9px; }
.sidebar .nav-item .ni { width: 24px; height: 24px; border-radius: 7px; background-image: none; }
.sidebar .nav-item .ni svg { font-size: 14px; }
.sidebar .nav-item .ni.soft { background: color-mix(in srgb, var(--c) 15%, transparent); box-shadow: none; }
.sidebar .nav-item .ni.soft svg { color: var(--c); }
.sidebar .nav-item.active { background: var(--bg-elevated); box-shadow: 0 1px 2px rgba(0,0,0,.06), 0 0 0 .5px var(--separator); }
.sidebar .nav-item.active .label { color: var(--label); }
.sidebar .nav-item.active .ni.soft { background: var(--c); }
.sidebar .nav-item.active .ni.soft svg { color: #fff; }
.sidebar .nav-item .count { padding: 1px 7px; border-radius: 99px; background: var(--fill-2); }
.sidebar .nav-item.active .count { background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); color: var(--c, var(--accent)); }
.sidebar .tree-head { height: 34px; }
.sidebar .tree-head .avatar { width: 24px; height: 24px; border-radius: 7px; }
.sidebar .tree-node.open > .tree-head { background: var(--fill-2); }
.sidebar .tree-children { margin: 2px 0 6px 21px; padding-left: 8px; }
.sidebar .tree-leaf { height: 28px; font-weight: 500; color: var(--label); }
.sidebar .tree-leaf .ni { width: 20px; height: 20px; border-radius: 6px; }
.sidebar .tree-leaf .ni svg { font-size: 12px; }
.sidebar .tree-leaf.active { color: var(--label); }
/* Les libellés longs se tronquent au lieu d'élargir le menu (et de le faire défiler horizontalement). */
.sidebar-nav, .sidebar-recipients, .tree-node.open .tree-children { grid-template-columns: minmax(0, 1fr); }
.sidebar-recipients { overflow-x: hidden; }
.sidebar .nav-item .label { flex: 1; min-width: 0; }

/* Arborescence des tableaux : trait vertical continu entre les lignes d'un même groupe. */
.table tr.child .tree-line::after { content: ""; position: absolute; left: -1.5px; top: 100%; height: calc(100% + 2px); border-left: 1.5px solid var(--separator); display: none; }
.table tr.child:has(+ tr.child:not([hidden])) .tree-line::after { display: block; }
.sidebar .tree-children { margin-left: 16px; padding-left: 6px; }
.sidebar .tree-leaf { gap: 8px; padding: 0 8px; }

/* Chiffres clés en tête de fiche */
.hero .stats-inline { display: flex; gap: 10px; margin-left: auto; }
.hero .stats-inline .hs { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 14px 10px 10px; border-radius: 14px; background: var(--bg-elevated); box-shadow: 0 1px 2px rgba(0,0,0,.05), 0 0 0 .5px var(--separator); text-align: left; transition: transform .25s var(--spring), box-shadow .25s; }
.hero .stats-inline .hs:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(0,0,0,.07), 0 0 0 .5px var(--separator); }
.hs-ic { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--c); flex: none; }
.hs-ic svg { font-size: 17px; }
.hero .stats-inline .hs small { display: block; color: var(--label-2); font-size: 11px; font-weight: 500; }
.hero .stats-inline .hs b { display: block; font: 700 17px var(--font-rounded); font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--label); }
.hero .stats-inline .hs:nth-child(2) b { color: var(--c); }
.hs em { display: block; font-style: normal; font-size: 10.5px; color: var(--label-3); margin-top: 1px; }
.hs-bar { display: block; height: 4px; margin-top: 5px; border-radius: 99px; background: var(--fill); overflow: hidden; }
.hs-bar i { display: block; height: 100%; border-radius: inherit; background: var(--green); }
@media (max-width: 860px) {
  .hero .stats-inline { margin-left: 0; width: 100%; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .hero .stats-inline .hs { flex-direction: column; align-items: flex-start; gap: 6px; padding: 10px; }
  .hero .stats-inline .hs b { font-size: 14px; white-space: normal; }
}
.hero .stats-inline .hs div { text-align: left; min-width: 0; }
