/* GS Factures — feuille de style unique. Thème clair / sombre via variables. */
:root {
  --bg: #f6f6f9;
  --surface: #ffffff;
  --surface-2: #f9f9fc;
  --surface-3: #f1f0f7;
  --border: #e6e5ee;
  --border-strong: #d4d2e0;
  --text: #16151f;
  --text-2: #5d5b6e;
  --text-3: #908ea3;
  --accent: #6d28d9;
  --accent-hover: #5b21b6;
  --accent-soft: #f1ebfd;
  --accent-text: #5b21b6;
  --success: #15803d;
  --success-soft: #e8f6ed;
  --warning: #b45309;
  --warning-soft: #fdf3e2;
  --danger: #c2283b;
  --danger-soft: #fdeced;
  --brand-gradient: linear-gradient(90deg, #e6007e, #7c3aed 50%, #2563eb);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgba(20, 18, 40, .04), 0 2px 8px rgba(20, 18, 40, .04);
  --shadow-lg: 0 10px 30px rgba(20, 18, 40, .12);
  --sidebar-w: 236px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0e0d14;
  --surface: #17161f;
  --surface-2: #1c1b26;
  --surface-3: #24222f;
  --border: #2b2937;
  --border-strong: #3a3749;
  --text: #ecebf3;
  --text-2: #aaa8bb;
  --text-3: #75728a;
  --accent: #8b5cf6;
  --accent-hover: #a78bfa;
  --accent-soft: #261c3d;
  --accent-text: #c4b5fd;
  --success: #4ade80;
  --success-soft: #11291b;
  --warning: #fbbf24;
  --warning-soft: #2e2410;
  --danger: #f87171;
  --danger-soft: #331517;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0d14; --surface: #17161f; --surface-2: #1c1b26; --surface-3: #24222f;
    --border: #2b2937; --border-strong: #3a3749; --text: #ecebf3; --text-2: #aaa8bb; --text-3: #75728a;
    --accent: #8b5cf6; --accent-hover: #a78bfa; --accent-soft: #261c3d; --accent-text: #c4b5fd;
    --success: #4ade80; --success-soft: #11291b; --warning: #fbbf24; --warning-soft: #2e2410;
    --danger: #f87171; --danger-soft: #331517; --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text); font-family: var(--font);
  font-size: 14.5px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 .75em; }
small, .small { font-size: 12.5px; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: .92em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.ti { font-size: 1.15em; vertical-align: -.14em; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

/* ---------- Structure ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border);
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; border-radius: 50%; }
.brand b { font-size: 15px; display: block; line-height: 1.2; }
.brand span { font-size: 11.5px; color: var(--text-3); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-2); font-weight: 500; font-size: 14px;
}
.nav a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.nav a .ti { font-size: 18px; }
.nav .count { margin-left: auto; background: var(--danger); color: #fff; border-radius: 99px; font-size: 11px; padding: 0 6px; line-height: 18px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); padding: 14px 10px 4px; font-weight: 600; }
.sidebar-foot { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; gap: 6px; align-items: center; }
.sidebar-foot .who { flex: 1; font-size: 13px; color: var(--text-2); padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 28px; background: var(--bg);
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); }
.search { position: relative; flex: 1; max-width: 420px; }
.search input[type=search] { padding-left: 36px; background: var(--surface); }
.search .ti { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; max-height: 60vh; overflow: auto; z-index: 50;
}
.search-results.open { display: block; }
.search-results a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.search-results a:hover, .search-results a.focus { background: var(--surface-3); text-decoration: none; }
.search-results .grp { font-size: 11px; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 2px; font-weight: 600; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 8px 28px 48px; max-width: 1280px; width: 100%; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin: 6px 0 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--text-2); }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 13px; margin-bottom: 6px; }

/* ---------- Mobile ---------- */
.tabbar { display: none; }
.mobile-only { display: none; }
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 80; transform: translateX(-102%);
    transition: transform .22s ease; box-shadow: var(--shadow-lg); width: 270px;
  }
  body.menu-open .sidebar { transform: none; }
  body.menu-open::after { content: ""; position: fixed; inset: 0; background: rgba(10, 8, 20, .45); z-index: 70; }
  .topbar { padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
  .content { padding: 4px 16px calc(96px + env(safe-area-inset-bottom)); }
  .desktop-only { display: none !important; }
  .mobile-only { display: inline-flex; }
  div.mobile-only { display: block; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a, .tabbar button {
    display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 0 7px; font-size: 11px;
    color: var(--text-3); background: none; border: 0; font-family: inherit; font-weight: 500;
  }
  .tabbar .ti { font-size: 22px; }
  .tabbar a.active { color: var(--accent-text); }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .fab .ti {
    background: var(--accent); color: #fff; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
    margin-top: -18px; box-shadow: 0 6px 16px rgba(109, 40, 217, .35);
  }
  .page-head { margin-bottom: 14px; }
  h1 { font-size: 20px; }
}

/* ---------- Composants ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.card-body { padding: 18px 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.card-head h2, .card-head h3 { font-size: 14.5px; }
.card + .card, .card + .grid, .grid + .card, .grid + .grid { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.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)); }
.g-main { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 700px) { .g2, .g3 { grid-template-columns: minmax(0, 1fr); } .g4 { gap: 10px; } }

.kpi { padding: 16px 18px; }
.kpi .label { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
@media (max-width: 700px) { .kpi { padding: 12px 14px; } .kpi .value { font-size: 19px; } }
.meter { height: 6px; background: var(--surface-3); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter > span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.meter.warn > span { background: var(--warning); }
.meter.danger > span { background: var(--danger); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-weight: 550;
  font-size: 14px; cursor: pointer; line-height: 1.2; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-lg { padding: 12px 18px; font-size: 15px; }
.btn-icon { padding: 7px; width: 36px; height: 36px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-muted { background: var(--surface-3); color: var(--text-2); }
.badge-accent { background: var(--accent-soft); color: var(--accent-text); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 14px; display: flex; gap: 10px; align-items: flex-start; border: 1px solid transparent; }
.alert .ti { font-size: 18px; margin-top: 1px; }
.alert ul { margin: 4px 0 0; padding-left: 18px; }
.alert-success { background: var(--success-soft); color: var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); }
.alert-danger { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--accent-soft); color: var(--accent-text); }
.alert > div { color: var(--text); }
.alert strong { color: inherit; }

/* ---------- Formulaires ---------- */
label { display: block; font-size: 13px; font-weight: 550; color: var(--text-2); margin-bottom: 5px; }
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=time], input[type=password],
input[type=search], input[type=url], input:not([type]), select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface);
  color: var(--text); font: inherit; font-size: 15px; transition: border-color .12s, box-shadow .12s; min-height: 40px;
}
textarea { resize: vertical; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[readonly] { background: var(--surface-2); color: var(--text-2); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); width: 17px; height: 17px; vertical-align: -3px; }
.field { margin-bottom: 14px; }
.field .hint { display: block; color: var(--text-3); margin-top: 4px; font-size: 12.5px; }
.row { display: grid; gap: 0 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 500; color: var(--text); font-size: 14px; cursor: pointer; }
.check small { display: block; color: var(--text-3); font-weight: 400; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.input-group { display: flex; }
.input-group input { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.input-group .addon { display: flex; align-items: center; padding: 0 11px; border: 1px solid var(--border-strong); border-left: 0; border-radius: 0 9px 9px 0; background: var(--surface-2); color: var(--text-2); }
.seg { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg a, .seg label, .seg button { padding: 5px 12px; border-radius: 7px; color: var(--text-2); font-weight: 550; font-size: 13.5px; margin: 0; cursor: pointer; border: 0; background: none; font-family: inherit; }
.seg a:hover { text-decoration: none; color: var(--text); }
.seg .active, .seg input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.seg input { display: none; }
.seg label span { display: block; padding: 5px 12px; border-radius: 7px; }
.seg label { padding: 0; }

/* ---------- Tableaux / listes ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr[data-href] { cursor: pointer; }
.table .strong { font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--border); color: var(--text); }
.list-item:last-child { border-bottom: 0; }
a.list-item:hover { background: var(--surface-2); text-decoration: none; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .title { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-item .meta { display: block; font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 36px; height: 36px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 650; font-size: 13px; flex-shrink: 0; }
.avatar.round { border-radius: 50%; }
.date-chip { width: 44px; flex-shrink: 0; text-align: center; border-radius: 10px; background: var(--surface-3); padding: 4px 0; line-height: 1.1; }
.date-chip b { display: block; font-size: 17px; }
.date-chip span { font-size: 11px; color: var(--text-2); text-transform: uppercase; }
.icon-dot { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; flex-shrink: 0; font-size: 17px; }
.icon-dot.danger { background: var(--danger-soft); color: var(--danger); }
.icon-dot.warning { background: var(--warning-soft); color: var(--warning); }
.icon-dot.success { background: var(--success-soft); color: var(--success); }
.icon-dot.accent { background: var(--accent-soft); color: var(--accent-text); }
.icon-dot.muted { background: var(--surface-3); color: var(--text-2); }
@media (max-width: 700px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: grid; grid-template-columns: 1fr auto; padding: 10px 14px; border-bottom: 1px solid var(--border); gap: 2px 10px; }
  .table.responsive td { padding: 0; border: 0; }
  .table.responsive td.hide-sm { display: none; }
  .list-item { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input[type=search] { max-width: 280px; }
.pagination { display: flex; gap: 6px; justify-content: center; padding: 14px; }
.empty { text-align: center; padding: 42px 20px; color: var(--text-2); }
.empty > .ti { font-size: 34px; color: var(--text-3); display: block; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin-bottom: 4px; }
.empty .btn { margin-top: 10px; }

/* ---------- Détail document ---------- */
.doc-hero { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.doc-hero .amount { font-size: 28px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 13.5px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.timeline li::after { content: ""; position: absolute; left: 8px; top: 16px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline time { display: block; color: var(--text-3); font-size: 12px; }
.pdf-frame { width: 100%; height: 78vh; border: 0; border-radius: var(--radius); background: var(--surface-3); }
.actions-list { display: flex; flex-direction: column; gap: 8px; }
.steps { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 13px; color: var(--text-3); }
.steps .on { color: var(--accent-text); font-weight: 600; }
.steps .done { color: var(--success); }

/* ---------- Éditeur ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.editor-side { position: sticky; top: 76px; }
@media (max-width: 1100px) { .editor { grid-template-columns: minmax(0, 1fr); } .editor-side { position: static; } }
.section-title { display: flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; margin-bottom: 14px; }
.section-title .ti { color: var(--accent-text); }
.lines { display: flex; flex-direction: column; gap: 10px; }
.line { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface); position: relative; }
.line.is-section { background: var(--surface-2); }
.line.is-option { border-style: dashed; }
.line.dragging { opacity: .5; }
.line-grid { display: grid; grid-template-columns: minmax(0, 1fr) 90px 120px 76px 110px; gap: 8px; align-items: start; }
.line-grid .l-total { font-weight: 650; text-align: right; padding-top: 10px; font-variant-numeric: tabular-nums; }
.line textarea { min-height: 38px; font-size: 13.5px; color: var(--text-2); margin-top: 6px; }
.line-tools { display: flex; gap: 4px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.line-tools .spacer { flex: 1; }
.line .handle { cursor: grab; color: var(--text-3); }
.line-grid label { font-size: 11.5px; margin-bottom: 3px; }
@media (max-width: 700px) {
  .line-grid { grid-template-columns: 1fr 1fr; }
  .line-grid .l-label { grid-column: 1 / -1; }
  .line-grid .l-total { grid-column: 1 / -1; padding-top: 0; }
}
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.picker { position: relative; }
.picker-panel {
  position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: min(440px, 92vw); background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 8px; display: none; max-height: 380px; overflow: auto;
}
.picker-panel.open { display: block; }
.picker-panel input { margin-bottom: 6px; }
.picker-item { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-radius: 8px; cursor: pointer; }
.picker-item:hover, .picker-item.focus { background: var(--surface-3); }
.picker-item small { display: block; color: var(--text-3); }
.picker-cat { font-size: 11px; text-transform: uppercase; color: var(--text-3); padding: 8px 10px 2px; font-weight: 600; }
.totals { font-variant-numeric: tabular-nums; }
.totals .t-row { display: flex; justify-content: space-between; padding: 5px 0; color: var(--text-2); }
.totals .t-grand { display: flex; justify-content: space-between; padding: 12px 0 4px; margin-top: 6px; border-top: 1px solid var(--border); font-size: 20px; font-weight: 700; color: var(--text); }
.client-card { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; }
.sticky-bar { display: none; }
@media (max-width: 900px) {
  .sticky-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); z-index: 55;
    background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px; gap: 10px; align-items: center;
  }
  .sticky-bar .total { flex: 1; font-weight: 700; font-size: 18px; }
}

/* ---------- Modale ---------- */
dialog {
  border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-lg); max-height: calc(100vh - 40px);
}
dialog::backdrop { background: rgba(10, 8, 20, .5); }
dialog .card-head { position: sticky; top: 0; background: var(--surface); z-index: 1; }
dialog form.card-body { margin: 0; }
@media (max-width: 700px) { dialog { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 16px 16px 0 0; } }

/* ---------- Menus ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 45;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--text); background: none; border: 0;
  font: inherit; font-size: 14px; text-align: left; cursor: pointer;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu hr { margin: 5px 0; }
.notif-dot { position: relative; }
.notif-dot::after { content: ""; position: absolute; top: 6px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--bg); }

/* ---------- Agenda ---------- */
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal .dow { padding: 8px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal .day { min-height: 104px; padding: 6px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); font-size: 12.5px; }
.cal .day.out { background: var(--surface-2); color: var(--text-3); }
.cal .day.today .n { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 7px; }
.cal .n { font-weight: 600; display: inline-block; margin-bottom: 4px; }
.cal .ev { display: block; padding: 3px 6px; border-radius: 6px; margin-bottom: 3px; font-size: 12px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cal .ev:hover { text-decoration: none; filter: brightness(.96); }
.ev.success { background: var(--success-soft); color: var(--success); }
.ev.warning { background: var(--warning-soft); color: var(--warning); }
.ev.accent { background: var(--accent-soft); color: var(--accent-text); }
.ev.muted { background: var(--surface-3); color: var(--text-2); }
@media (max-width: 700px) { .cal-wrap { display: none; } }

/* ---------- Graphiques simples ---------- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 170px; padding-top: 10px; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; min-width: 0; }
.bars .bar span { display: block; width: 100%; max-width: 34px; background: var(--accent); border-radius: 5px 5px 2px 2px; min-height: 2px; }
.bars .bar.prev span { background: var(--border-strong); }
.bars .bar small { font-size: 11px; color: var(--text-3); }
.bars .bar.current span { background: var(--brand-gradient); }

/* ---------- Pages publiques / connexion ---------- */
.bare { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: min(420px, 100%); }
.auth-card .brand-top { text-align: center; margin-bottom: 18px; }
.auth-card .brand-top img { width: 72px; height: 72px; border-radius: 50%; }
.gradient-line { height: 3px; background: var(--brand-gradient); border-radius: 3px 3px 0 0; }
.public-wrap { max-width: 760px; margin: 0 auto; padding: 20px 16px 60px; }
.public-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.public-head img { width: 48px; height: 48px; border-radius: 50%; }
.sig-pad { width: 100%; height: 190px; border: 1.5px dashed var(--border-strong); border-radius: 12px; background: #fff; touch-action: none; display: block; }
.opt-line { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--border); }
.opt-line .grow { flex: 1; }
.opt-line.off .grow, .opt-line.off .num { color: var(--text-3); }
.opt-line.off .num { text-decoration: line-through; }

.fade-in { animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@media print { .sidebar, .topbar, .tabbar, .no-print { display: none !important; } .content { padding: 0; } }
