/* Smile & Care — système de design.
   Mise en page : barre latérale « carte » + colonne principale (barre supérieure translucide, zone de travail).
   Style doux : fond bleu-gris, cartes blanches à ombres diffuses, accent bleu-vert en dégradé, secondaire orange. */
:root {
  --bg: #edf3f6; --bg-tint-1: rgb(20 160 180 / .12); --bg-tint-2: rgb(255 140 80 / .07);
  --surface: #ffffff; --surface-2: #f3f7f9; --surface-3: #e7eef2; --glass: rgb(255 255 255 / .74);
  --line: #dfe8ed; --line-strong: #cbd8e0;
  --fg: #12283a; --fg-2: #33495c; --muted: #647788;
  --accent: #0a7f96; --accent-2: #19a7b8; --accent-ink: #ffffff; --accent-soft: #e1f4f6; --accent-glow: rgb(10 127 150 / .34);
  --grad: linear-gradient(135deg, #2cc0c9 0%, #0a8fa6 48%, #086a85 100%);
  --grad-warm: linear-gradient(135deg, #ffbe7a 0%, #f07a3a 100%);
  --grad-green: linear-gradient(135deg, #63dba6 0%, #12a06c 100%);
  --grad-rose: linear-gradient(135deg, #ff9db5 0%, #e5484d 100%);
  --grad-violet: linear-gradient(135deg, #a996ff 0%, #6c4cf1 100%);
  --ok: #0f9b67; --ok-soft: #e1f6ec; --warn: #b86e00; --warn-soft: #fff1da; --crit: #d2383e; --crit-soft: #ffe8e9; --info: #2f6fd6; --info-soft: #e6effd;
  --shadow-xs: 0 1px 2px rgb(18 40 58 / .05);
  --shadow-sm: 0 1px 2px rgb(18 40 58 / .04), 0 4px 12px -4px rgb(18 40 58 / .08);
  --shadow: 0 2px 6px rgb(18 40 58 / .03), 0 18px 40px -18px rgb(18 40 58 / .16);
  --shadow-pop: 0 24px 60px -18px rgb(18 40 58 / .28), 0 2px 8px rgb(18 40 58 / .06);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --r: 18px; --r-md: 14px; --r-sm: 10px; --side-w: 252px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b141b; --bg-tint-1: rgb(20 160 180 / .16); --bg-tint-2: rgb(255 120 60 / .06);
  --surface: #13202a; --surface-2: #192934; --surface-3: #213440; --glass: rgb(15 26 34 / .74);
  --line: #233743; --line-strong: #2f4654;
  --fg: #eaf4f8; --fg-2: #c3d4de; --muted: #8fa5b3;
  --accent: #3cc4d2; --accent-2: #6fd9e3; --accent-ink: #06222b; --accent-soft: #123840; --accent-glow: rgb(60 196 210 / .3);
  --ok: #45d39a; --ok-soft: #10332a; --warn: #ffb547; --warn-soft: #3a2a10; --crit: #ff7a7f; --crit-soft: #3f1a1f; --info: #84a8ff; --info-soft: #18244a;
  --shadow-xs: 0 1px 2px rgb(0 0 0 / .3); --shadow-sm: 0 1px 2px rgb(0 0 0 / .3), 0 6px 16px -8px rgb(0 0 0 / .5);
  --shadow: 0 1px 0 rgb(255 255 255 / .03) inset, 0 20px 44px -22px rgb(0 0 0 / .7); --shadow-pop: 0 28px 70px -20px rgb(0 0 0 / .8);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 85% -10%, var(--bg-tint-1), transparent 60%), radial-gradient(900px 500px at -10% 110%, var(--bg-tint-2), transparent 60%), var(--bg);
  background-attachment: fixed; color: var(--fg); font-family: var(--font); font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; text-wrap: balance; color: var(--fg); }
h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
h3 { font-size: 14px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.strong { font-weight: 700; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.ico { flex: none; display: block; }
.r { text-align: right; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ======================= Cadre ======================= */
.app-frame { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 16px 0 16px 16px; display: flex; }
.side-card { flex: 1; display: flex; flex-direction: column; gap: 12px; background: var(--surface); border-radius: 22px; box-shadow: var(--shadow); padding: 18px 12px; overflow-y: auto; border: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--fg); padding: 2px 8px 6px; letter-spacing: -0.01em; }
.brand:hover { text-decoration: none; }
.mark { width: 36px; height: 36px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; box-shadow: 0 8px 18px -6px var(--accent-glow); flex: none; }
.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-group .eyebrow { padding: 0 12px 6px; font-size: 10.5px; }
.nav-link { display: flex; align-items: center; gap: 12px; padding: 7px 12px; border-radius: 12px; color: var(--fg-2); font-weight: 600; font-size: 13.5px; }
.nav-link .ico { color: var(--muted); transition: color .15s; }
.nav-link:hover { background: var(--surface-2); text-decoration: none; color: var(--fg); }
.nav-link:hover .ico { color: var(--accent); }
.nav-link[aria-current="page"] { background: var(--grad); color: #fff; box-shadow: 0 10px 22px -10px var(--accent-glow); }
.nav-link[aria-current="page"] .ico { color: #fff; }
.nav-badge { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); }
.nav-link[aria-current="page"] .nav-badge { background: rgb(255 255 255 / .25); color: #fff; }
.side-foot { margin-top: auto; border-radius: 16px; padding: 14px; background: var(--grad); color: #fff; display: grid; gap: 4px; position: relative; overflow: hidden; }
.side-foot::after { content: ""; position: absolute; width: 140px; height: 140px; right: -50px; top: -60px; border-radius: 50%; background: rgb(255 255 255 / .14); }
.side-foot strong { font-size: 13.5px; } .side-foot span { font-size: 12px; opacity: .9; }
.main-col { min-width: 0; display: flex; flex-direction: column; }

.topbar { position: sticky; top: 0; z-index: 20; padding: 16px 24px 10px; }
.topbar-inner { display: flex; align-items: center; gap: 10px; background: var(--glass); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); border: 1px solid var(--line); border-radius: 18px; padding: 8px 10px 8px 12px; box-shadow: var(--shadow-sm); }
.search { position: relative; flex: 1 1 360px; min-width: 160px; max-width: 520px; margin-right: auto; }
.search-box { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid transparent; border-radius: 12px; padding: 0 10px; transition: border-color .15s, box-shadow .15s, background .15s; }
.search-box:focus-within { background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-box .ico { color: var(--muted); }
.search-box input { border: 0; background: transparent; padding: 9px 0; width: 100%; outline: none; box-shadow: none; border-radius: 0; }
.popover { position: absolute; top: calc(100% + 8px); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-pop); padding: 8px; z-index: 40; min-width: 260px; max-height: 70vh; overflow-y: auto; animation: pop .14s ease-out; }
.search .popover { left: 0; right: 0; }
.pop-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--fg); width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; }
.pop-item:hover, .pop-item.on { background: var(--surface-2); text-decoration: none; }
.pop-item .pop-txt { min-width: 0; display: grid; } .pop-item .pop-txt span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pop-empty { padding: 14px; color: var(--muted); text-align: center; }
.pop-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.icon-btn { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); color: var(--fg-2); cursor: pointer; box-shadow: var(--shadow-xs); transition: transform .12s, color .12s, box-shadow .12s; flex: none; }
.icon-btn:hover { color: var(--accent); transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.dot-badge { position: absolute; top: -4px; right: -4px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--grad-warm); color: #fff; font-size: 10.5px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--surface); }
.menu-wrap { position: relative; }
.menu-wrap .popover { right: 0; }
.avatar-btn { display: flex; align-items: center; gap: 10px; padding: 4px 8px 4px 4px; border-radius: 14px; border: 1px solid transparent; background: transparent; cursor: pointer; }
.avatar-btn:hover { background: var(--surface-2); }
.avatar { width: 36px; height: 36px; border-radius: 12px; background: var(--grad); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; box-shadow: 0 6px 14px -6px var(--accent-glow); flex: none; }
.avatar.lg { width: 56px; height: 56px; border-radius: 18px; font-size: 19px; }
.avatar-meta { display: grid; text-align: left; line-height: 1.25; }
.avatar-meta strong { font-size: 13px; } .avatar-meta span { font-size: 11.5px; color: var(--muted); }
.burger { display: none; }

main { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-content: start; padding: 8px 24px 48px; max-width: 1400px; width: 100%; }
main > * { animation: rise .28s ease-out both; }
@keyframes rise { from { opacity: .001; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes pop { from { opacity: 0; transform: translateY(-4px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { main > *, .popover { animation: none; } }

@media (max-width: 960px) {
  .app-frame { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 50; transform: translateX(-105%); transition: transform .22s ease; padding: 12px; }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgb(12 20 29 / .4); z-index: 45; backdrop-filter: blur(2px); }
  .burger { display: grid; }
  .topbar { padding: 10px 12px 6px; }
  main { padding: 8px 16px 40px; }
  .avatar-meta { display: none; }
  .search { flex: 1 1 0; min-width: 0; }
  .avatar-btn { padding: 0; }
  h1 { font-size: 20px; }
}
@media (max-width: 560px) {
  .page-title .avatar.lg { width: 44px; height: 44px; font-size: 15px; border-radius: 14px; }
}

/* ======================= Composants ======================= */
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.page-title { display: flex; align-items: center; gap: 14px; min-width: 0; }
.page-title p { color: var(--muted); }
.title-ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); border: 1px solid var(--line); flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.actions.end { justify-content: flex-end; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; display: grid; gap: 16px; min-width: 0; box-shadow: var(--shadow); align-content: start; }
.panel.flush { padding: 0; gap: 0; overflow: hidden; }
.panel.flush > .panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.panel.flush > .pad { padding: 16px 20px; }
.panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.panel-head h2 { display: flex; align-items: center; gap: 8px; }
.panel-head h2 .ico { color: var(--accent); }
.cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.cols.even { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.cols.side { grid-template-columns: 320px minmax(0, 1fr); }
.stack { display: grid; gap: 20px; min-width: 0; align-content: start; }
@media (max-width: 1100px) { .cols, .cols.even, .cols.side { grid-template-columns: minmax(0, 1fr); } }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 20px; }
.facts > div { min-width: 0; overflow-wrap: anywhere; display: grid; gap: 2px; align-content: start; }
.facts dt, .fact-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; }
dl { margin: 0; }
.empty { display: grid; justify-items: center; gap: 8px; padding: 28px 16px; color: var(--muted); text-align: center; }
.empty .ico { width: 34px; height: 34px; opacity: .6; }

/* Les conteneurs en grille ne s'élargissent jamais au-delà de leur parent : un tableau large défile dans son cadre. */
.panel, .stack, .form, .dialog-body, .tl-card { grid-template-columns: minmax(0, 1fr); }

/* Indicateurs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpis.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1240px) { .kpis.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .kpis.four { grid-template-columns: minmax(0, 1fr); } }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; display: grid; gap: 6px; align-content: start; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; color: var(--fg); }
a.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow-pop); text-decoration: none; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--grad); box-shadow: 0 8px 16px -8px var(--accent-glow); }
.kpi-ico.warm { background: var(--grad-warm); box-shadow: 0 8px 16px -8px rgb(240 122 58 / .5); }
.kpi-ico.green { background: var(--grad-green); box-shadow: 0 8px 16px -8px rgb(18 160 108 / .5); }
.kpi-ico.rose { background: var(--grad-rose); box-shadow: 0 8px 16px -8px rgb(229 72 77 / .5); }
.kpi-ico.violet { background: var(--grad-violet); box-shadow: 0 8px 16px -8px rgb(108 76 241 / .5); }
.kpi .val { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.kpi .val small { font-size: 14px; font-weight: 700; color: var(--muted); }
.kpi-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.trend { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.trend.up { background: var(--ok-soft); color: var(--ok); } .trend.down { background: var(--crit-soft); color: var(--crit); } .trend.flat { background: var(--surface-2); color: var(--muted); }

/* Onglets segmentés */
.tabs { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-xs); width: fit-content; max-width: 100%; }
.tabs a, .tabs button { padding: 7px 12px; color: var(--muted); font-weight: 600; border-radius: 10px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; border: 0; background: transparent; cursor: pointer; }
.tabs a:hover, .tabs button:hover { color: var(--fg); background: var(--surface-2); text-decoration: none; }
.tabs [aria-current="page"], .tabs [aria-selected="true"] { background: var(--grad); color: #fff; box-shadow: 0 8px 16px -10px var(--accent-glow); }
.tabs .count { font-size: 11px; font-weight: 700; background: var(--surface-3); color: var(--fg-2); border-radius: 999px; padding: 0 7px; }
.tabs [aria-current="page"] .count, .tabs [aria-selected="true"] .count { background: rgb(255 255 255 / .25); color: #fff; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tfoot td { border-top: 1px solid var(--line-strong); border-bottom: 0; font-weight: 700; }
th.r, td.r { text-align: right; }
tr.click { cursor: pointer; transition: background .12s; }
tr.click:hover td { background: var(--surface-2); }
.cell-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cell-main > div { min-width: 0; display: grid; }
.mini-avatar { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 11.5px; font-weight: 800; color: var(--accent); background: var(--accent-soft); flex: none; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
@media (max-width: 1240px) { .hide-md { display: none; } }
@media (max-width: 760px) { .hide-sm { display: none; } }

/* Pastilles */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.p-draft { background: var(--surface-3); color: var(--muted); } .p-sent { background: var(--info-soft); color: var(--info); }
.p-partial { background: var(--warn-soft); color: var(--warn); } .p-overdue { background: var(--crit-soft); color: var(--crit); } .p-paid { background: var(--ok-soft); color: var(--ok); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; color: var(--fg-2); font-weight: 600; }
a.chip:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
a.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.chip.env-local { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; }

/* Boutons */
.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 16px; border-radius: 12px; cursor: pointer; font-weight: 700; font-size: 13px; white-space: nowrap; color: var(--fg); display: inline-flex; align-items: center; gap: 8px; box-shadow: var(--shadow-xs); transition: transform .12s, box-shadow .12s, filter .12s, background .12s; }
.btn:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0); }
.btn .ico { width: 16px; height: 16px; }
.btn.primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 10px 22px -10px var(--accent-glow); }
.btn.primary:hover { filter: brightness(1.06) saturate(1.05); }
.btn.ok { background: var(--grad-green); border-color: transparent; color: #fff; }
.btn.warm { background: var(--grad-warm); border-color: transparent; color: #fff; }
.btn.danger { color: var(--crit); border-color: color-mix(in srgb, var(--crit) 40%, transparent); }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 10px; gap: 6px; }
.btn.sm .ico { width: 14px; height: 14px; }
.btn.icon { padding: 7px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; transform: none; }
form.inline { display: inline; }

/* Formulaires */
.form { display: grid; gap: 16px; }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.fields.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fields .wide { grid-column: 1 / -1; }
@media (max-width: 760px) { .fields, .fields.three { grid-template-columns: minmax(0, 1fr); } }
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field > label, .field > .label { font-size: 12.5px; font-weight: 700; color: var(--fg-2); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--crit); font-weight: 600; }
input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="number"], input[type="date"], input[type="datetime-local"], input[type="search"], input[type="time"], input[type="file"], select, textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface); border-radius: 12px; padding: 9px 12px; transition: border-color .15s, box-shadow .15s; min-height: 40px;
}
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
input[readonly], input:disabled, select:disabled { background: var(--surface-2); color: var(--muted); cursor: not-allowed; }
input[type="color"] { width: 48px; height: 40px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.field.invalid input, .field.invalid select, .field.invalid textarea { border-color: var(--crit); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { flex: 1 1 150px; max-width: 240px; }
.filters .field.grow { flex: 2 1 240px; max-width: 420px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* Texte mis en forme : éditeur et affichage */
.rich { border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); overflow: hidden; transition: border-color .15s, box-shadow .15s; }
.rich:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.rich-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.rich-btn { min-width: 32px; height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; color: var(--fg-2); white-space: nowrap; }
.rich-btn:hover { background: var(--surface); border-color: var(--line); color: var(--fg); }
.rich-select { width: auto; min-height: 30px; height: 30px; padding: 0 6px; border-radius: 8px; font-size: 12.5px; }
.rich-swatches { display: inline-flex; align-items: center; gap: 3px; padding: 0 4px; }
.rich-caption { font-size: 11px; color: var(--muted); margin-right: 3px; }
.rich-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line-strong); cursor: pointer; padding: 0; }
.rich-swatch.mark { border-radius: 5px; }
.rich-swatch:hover { transform: scale(1.15); }
.rich-area { padding: 10px 12px; outline: none; max-height: 420px; overflow-y: auto; }
.rich-area.is-empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.rich-area.is-readonly { background: var(--surface-2); color: var(--fg-2); }
.rich-content { overflow-wrap: anywhere; line-height: 1.55; }
.rich-content p, .rich-content div { margin: 0; }
.rich-content ul, .rich-content ol { margin: 4px 0; padding-left: 22px; }
.sheet .rich-content { font-size: 14px; }

/* Droits par utilisateur */
.right-row { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 10px; align-items: center; padding: 6px 8px; border-radius: 10px; border-left: 3px solid var(--line-strong); margin-top: 6px; }
.right-row.is-allowed { border-left-color: var(--ok); }
.right-row.is-custom { background: var(--warn-soft); }
.right-row label { font-size: 13px; }
.right-row select { min-height: 34px; padding: 4px 8px; font-size: 12.5px; }
@media (max-width: 560px) { .right-row { grid-template-columns: minmax(0, 1fr); } }

/* Sélecteur de patient */
.picker { position: relative; }
.picker .popover { left: 0; right: 0; }
.picked { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.picked > div { min-width: 0; display: grid; flex: 1; }

/* Messages */
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-radius: 14px; font-weight: 600; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); } .flash.error { background: var(--crit-soft); color: var(--crit); } .flash.info { background: var(--info-soft); color: var(--info); } .flash.warning { background: var(--warn-soft); color: var(--warn); }
.callout { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; background: var(--warn-soft); color: var(--warn); font-weight: 600; align-items: flex-start; }
.callout.crit { background: var(--crit-soft); color: var(--crit); }
.callout.info { background: var(--accent-soft); color: var(--accent); }

/* Fenêtres de dialogue */
dialog { border: 1px solid var(--line); border-radius: 20px; padding: 0; background: var(--surface); color: var(--fg); box-shadow: var(--shadow-pop); width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); }
dialog.wide { width: min(880px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(12 20 29 / .45); backdrop-filter: blur(3px); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.dialog-body { padding: 20px; display: grid; gap: 16px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 20px 20px; }

/* Pagination */
.pagination { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--line); }
.pg-list { display: flex; gap: 4px; }
.pg { min-width: 34px; height: 34px; padding: 0 8px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); color: var(--fg-2); font-weight: 700; background: var(--surface); }
.pg:hover { text-decoration: none; border-color: var(--accent); color: var(--accent); }
.pg.on { background: var(--grad); color: #fff; border-color: transparent; }
.pg.off { opacity: .4; }

/* Frise du dossier patient */
.timeline { display: grid; gap: 0; }
.tl-item { display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 14px; }
.tl-rail { display: grid; justify-items: center; grid-template-rows: 18px 1fr; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); margin-top: 6px; box-shadow: 0 0 0 4px var(--accent-soft); }
.tl-dot.muted-dot { background: var(--line-strong); box-shadow: 0 0 0 4px var(--surface-3); }
.tl-line { width: 2px; background: var(--line); }
.tl-item:last-child .tl-line { background: transparent; }
.tl-card { padding: 0 0 14px; display: grid; gap: 3px; min-width: 0; }
/* Remarque compacte : un extrait d'une ligne, le texte complet se déplie au clic. */
.remark { font-size: 13px; color: var(--fg-2); margin: 0; }
.remark summary { cursor: pointer; list-style: none; border-radius: 8px; }
.remark summary::-webkit-details-marker { display: none; }
.remark summary:hover .remark-more { text-decoration: underline; }
.remark-more { color: var(--accent); font-weight: 700; white-space: nowrap; font-size: 12.5px; }
.remark .when-open, .remark[open] .when-closed, .remark[open] .remark-excerpt { display: none; }
.remark[open] .when-open { display: inline; }
.remark[open] > .rich-content { margin-top: 6px; padding: 10px 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; color: var(--fg); }
.tl-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

/* Échéancier */
.sched { display: grid; gap: 8px; }
.sched-row { display: grid; grid-template-columns: 34px minmax(90px, 1fr) minmax(130px, 1fr) minmax(130px, 1fr) minmax(120px, 1.4fr) 40px; gap: 8px; align-items: center; }
.sched-head { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.sched-num { width: 30px; height: 30px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-weight: 800; font-size: 12px; }
.sched-row.locked .sched-num { background: var(--ok-soft); color: var(--ok); }
.sched-sum { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12.5px; }
.sched-sum .bad { color: var(--crit); font-weight: 700; } .sched-sum .good { color: var(--ok); font-weight: 700; }
@media (max-width: 760px) { .sched-head { display: none; } .sched-row { grid-template-columns: 34px 1fr 1fr 40px; } .sched-row select, .sched-row input[type="text"] { grid-column: 2 / 4; } }
.money-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.money-row > div { padding: 12px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--line); display: grid; gap: 2px; }
.money-row > div.due { background: var(--warn-soft); border-color: transparent; }
.money-row > div.clear { background: var(--ok-soft); border-color: transparent; }
.money-row strong { font-size: 17px; font-variant-numeric: tabular-nums; }

/* Graphique en barres */
.bars { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; align-items: end; height: 190px; }
.bar-col { display: grid; grid-template-rows: 1fr auto; gap: 6px; height: 100%; min-width: 0; }
.bar-stack { display: flex; align-items: flex-end; justify-content: center; gap: 3px; height: 100%; }
.bar { width: 100%; max-width: 22px; border-radius: 7px 7px 3px 3px; background: var(--grad); min-height: 3px; position: relative; }
.bar.alt { background: var(--grad-warm); }
.bar-label { font-size: 11px; color: var(--muted); text-align: center; white-space: nowrap; overflow: hidden; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--fg-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
/* Un lien vers une section s'arrête sous la barre du haut, pas dessous. */
[id] { scroll-margin-top: 96px; }
/* Répartition : libellé, barre, valeur, part */
.breakdown { display: grid; gap: 10px; }
.breakdown-row { display: grid; grid-template-columns: minmax(110px, 170px) minmax(60px, 1fr) minmax(40px, auto) minmax(64px, auto); gap: 12px; align-items: center; }
.breakdown-row > .num { text-align: right; }
.breakdown-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
@media (max-width: 560px) { .breakdown-row { grid-template-columns: minmax(90px, 1fr) minmax(40px, 1fr) auto; } .breakdown-row > .small { display: none; } }
.meter { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.meter > span { display: block; height: 100%; background: var(--grad); border-radius: 999px; }

/* Agenda */
.agenda { display: grid; grid-template-columns: 56px repeat(var(--days), minmax(0, 1fr)); min-width: 720px; }
.ag-head { position: sticky; top: 0; z-index: 3; background: var(--surface); padding: 10px 6px; text-align: center; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); }
.ag-head.today strong { color: var(--accent); }
.ag-head strong { display: block; font-size: 15px; } .ag-head span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.ag-corner { border-bottom: 1px solid var(--line); }
.ag-hours { position: relative; }
.ag-hour { height: var(--hour-h); font-size: 11px; color: var(--muted); text-align: right; padding: 0 8px; transform: translateY(-7px); }
.ag-day { position: relative; border-left: 1px solid var(--line); background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(color-mix(in srgb, var(--line) 45%, transparent) 1px, transparent 1px); background-size: 100% var(--hour-h), 100% calc(var(--hour-h) / 2); }
.ag-day.today { background-color: color-mix(in srgb, var(--accent-soft) 45%, transparent); }
.ag-day.over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.ag-event { position: absolute; left: 4px; right: 4px; border-radius: 10px; padding: 4px 8px; background: var(--accent-soft); border-left: 4px solid var(--ev, var(--accent)); color: var(--fg); font-size: 12px; line-height: 1.3; overflow: hidden; cursor: grab; box-shadow: var(--shadow-xs); display: block; }
.ag-event:hover { text-decoration: none; box-shadow: var(--shadow-sm); z-index: 2; }
.ag-event strong, .ag-event span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ag-event.done { background: var(--ok-soft); } .ag-event.cancelled { background: var(--surface-3); opacity: .6; text-decoration: line-through; } .ag-event.late { background: var(--warn-soft); }
.ag-event.dragging { opacity: .4; }
.ag-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--crit); z-index: 1; pointer-events: none; }
.ag-now::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--crit); }

/* Page de connexion */
.guest { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.guest-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow-pop); padding: 32px; display: grid; gap: 20px; }
.guest-card .brand { padding: 0; font-size: 18px; }
.guest-card h1 { font-size: 22px; }

/* Impression (reçus, factures, ordonnances) */
.sheet { width: min(820px, 100%); margin: 24px auto; background: #fff; color: #12283a; border-radius: 18px; box-shadow: var(--shadow); padding: 40px; display: grid; gap: 22px; }
.sheet h1 { font-size: 22px; } .sheet h2 { font-size: 14px; }
.sheet-head { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; border-bottom: 2px solid #0a7f96; padding-bottom: 16px; }
.sheet-head img { height: 54px; width: auto; }
.sheet table th { color: #647788; } .sheet td, .sheet th { border-color: #dfe8ed; }
.sheet .total-box { margin-left: auto; width: min(320px, 100%); display: grid; gap: 6px; }
.sheet .total-box div { display: flex; justify-content: space-between; gap: 12px; }
.sheet .total-box .grand { font-size: 17px; font-weight: 800; border-top: 2px solid #12283a; padding-top: 8px; }
.sheet-foot { border-top: 1px solid #dfe8ed; padding-top: 12px; color: #647788; font-size: 12px; text-align: center; }
.print-bar { width: min(820px, 100%); margin: 24px auto 0; display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sign { display: grid; justify-items: end; gap: 46px; }
@media print {
  body { background: #fff; }
  .print-bar, .sidebar, .topbar { display: none !important; }
  .sheet { box-shadow: none; margin: 0; padding: 0; width: 100%; border-radius: 0; }
  @page { margin: 16mm; }
}
