/* =====================================================================
   Livraisons — design system (single stylesheet, no build step)
   1 tokens · 2 base · 3 layout & nav · 4 components · 5 screens · 6 print
   Rule: screens compose components; add a component here before adding
   one-off styles in a template.
   ===================================================================== */

@font-face {
  font-family: "Space Grotesk";
  src: url("fonts/space-grotesk-latin.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}

/* ---------- 1. tokens ---------- */
:root {
  /* neutrals (warm paper) */
  --bg: #F6F3ED; --surface: #FFFFFF; --surface-2: #FCFAF6; --line: #E6E0D6; --line-2: #D9D1C4;
  --ink: #16181C; --ink-2: #3B3A36; --muted: #6F695F; --faint: #8E877C;   /* AA contrast on --bg */
  /* brand + semantic */
  --primary: #2D6FA8; --primary-ink: #1F5584; --primary-soft: #E7F0F8;
  --paid: #0F7A56; --paid-2: #42C08E; --paid-soft: #E3F4EC;
  --owed: #A93D16; --owed-soft: #FBEAE2;
  --discount: #8F6205; --discount-soft: #FBF1DA;
  --danger: #B42318; --danger-soft: #FDECEA;
  /* type scale */
  --font: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --t-xs: .75rem; --t-sm: .8125rem; --t-md: .9375rem; --t-lg: 1.125rem; --t-xl: 1.375rem; --t-2xl: 1.75rem;
  /* space, radius, elevation */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px;
  --r-sm: 8px; --r: 12px; --r-lg: 16px; --r-full: 999px;
  --shadow: 0 1px 2px rgba(22,24,28,.05), 0 1px 1px rgba(22,24,28,.03);
  --shadow-lg: 0 12px 32px rgba(22,24,28,.16), 0 2px 6px rgba(22,24,28,.06);
  --focus: 0 0 0 3px rgba(45,111,168,.35);
  --tap: 44px;
  --nav-h: 64px; --side-w: 232px;
}

/* ---------- 2. base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: var(--t-md); line-height: 1.45; color: var(--ink);
  background: var(--bg); font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
[hidden] { display: none !important; }   /* component display rules must never beat the hidden attribute */
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--muted); } .faint { color: var(--faint); }
.t-paid { color: var(--paid); } .t-owed { color: var(--owed); } .t-discount { color: var(--discount); }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
@media (max-width: 639px) { .hide-sm { display: none !important; } }
@media (min-width: 640px) { .only-sm { display: none !important; } }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2;
        stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 16px; height: 16px; }

/* ---------- 3. layout & navigation ---------- */
.app { min-height: 100dvh; }
.main { padding: var(--s4) var(--s4) calc(var(--nav-h) + var(--s8) + env(safe-area-inset-bottom)); max-width: 1120px; margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s3) var(--s4); background: rgba(246,243,237,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: var(--t-lg); font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { display: inline-flex; width: var(--tap); height: var(--tap); margin: -10px 0 -10px -12px;
  align-items: center; justify-content: center; color: var(--ink); border-radius: var(--r-full); }
.brand { display: flex; align-items: center; gap: var(--s2); font-weight: 700; font-size: var(--t-lg); color: var(--ink); }
.brand .logo { width: 30px; height: 30px; border-radius: 9px; background: var(--ink); color: #fff; display: grid; place-items: center; font-size: 15px; }

/* bottom tab bar (phones) */
.tabbar {
  position: fixed; inset: auto 0 0 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(22,24,28,.04);
}
.tabbar a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--muted); font-size: 11px; font-weight: 600; text-decoration: none; position: relative; }
.tabbar a[aria-current="page"] { color: var(--primary); }
.tabbar a[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px;
  border-radius: 0 0 3px 3px; background: var(--primary); }
.tabbar .fab svg.i { width: 26px; height: 26px; }
.tabbar .fab span.dot { width: 48px; height: 36px; border-radius: var(--r-full); background: var(--primary); color: #fff;
  display: grid; place-items: center; box-shadow: 0 4px 12px rgba(45,111,168,.35); }
.tabbar .fab[aria-current="page"]::before { display: none; }

/* sidebar (desktop) */
.sidebar { display: none; }
@media (min-width: 1024px) {
  .tabbar { display: none; }
  .sidebar { display: flex; flex-direction: column; gap: var(--s1); position: fixed; inset: 0 auto 0 0; width: var(--side-w);
    padding: var(--s5) var(--s3); background: var(--surface); border-right: 1px solid var(--line); z-index: 30; }
  .sidebar .brand { padding: 0 var(--s3) var(--s5); }
  .sidebar a.nav { display: flex; align-items: center; gap: var(--s3); padding: 10px var(--s3); border-radius: var(--r-sm);
    color: var(--ink-2); font-weight: 600; text-decoration: none; }
  .sidebar a.nav:hover { background: var(--surface-2); }
  .sidebar a.nav[aria-current="page"] { background: var(--primary-soft); color: var(--primary-ink); }
  .sidebar .sep { height: 1px; background: var(--line); margin: var(--s3) var(--s3); }
  .sidebar .foot { margin-top: auto; padding: var(--s3); font-size: var(--t-sm); color: var(--muted); }
  .with-side { padding-left: var(--side-w); }
  .main { padding: var(--s6) var(--s8) var(--s8); }
  .topbar { padding: var(--s4) var(--s8); }
}

/* ---------- 4. components ---------- */

/* buttons: primary / secondary / ghost / danger / success; sizes: default (44px), sm, lg; block */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: var(--tap);
  padding: 0 var(--s4); border-radius: var(--r); border: 1px solid transparent; font: inherit; font-weight: 600;
  font-size: var(--t-md); cursor: pointer; text-decoration: none !important; white-space: nowrap;
  background: var(--primary); color: #fff; transition: background .15s, transform .05s, box-shadow .15s;
}
.btn:hover { background: var(--primary-ink); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-2); box-shadow: var(--shadow); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.ghost:hover { background: var(--primary-soft); }
.btn.danger { background: var(--danger); } .btn.danger:hover { background: #8f1c13; }
.btn.danger.secondary { background: var(--surface); color: var(--danger); border-color: #F1C8C3; }
.btn.success { background: var(--paid); } .btn.success:hover { background: #0b5f43; }
.btn.sm { min-height: 34px; padding: 0 var(--s3); font-size: var(--t-sm); border-radius: var(--r-sm); }
.btn.lg { min-height: 56px; font-size: var(--t-lg); border-radius: var(--r-lg); }
.btn.block { display: flex; width: 100%; }
.btn.icon { padding: 0; width: var(--tap); }
.btn .spin { display: none; }
.btn.is-busy .spin { display: inline-block; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent;
  animation: spin .7s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* cards */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.card.pad { padding: var(--s4); }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line); }
.card-h h2 { font-size: var(--t-md); font-weight: 700; }
.section-title { display: flex; align-items: center; gap: var(--s2); font-size: var(--t-sm); font-weight: 700;
  text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: var(--s6) 0 var(--s2); }
.section-title .count { background: var(--line); color: var(--ink-2); border-radius: var(--r-full); padding: 0 8px; font-size: var(--t-xs); }

/* KPI cards */
.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); } }
@media (min-width: 1024px) { .kpis.wide { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); } }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s3) var(--s4); box-shadow: var(--shadow); overflow: hidden; min-width: 0; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--tone, var(--ink)); }
.kpi .lab { font-size: var(--t-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.kpi .val { display: block; margin-top: 2px; font-size: var(--t-xl); font-weight: 700; line-height: 1.15; color: var(--tone-ink, var(--ink));
  overflow-wrap: anywhere; }
.kpi .val small { font-size: var(--t-sm); font-weight: 600; color: var(--muted); margin-left: 3px; }
.kpi .sub { display: block; margin-top: 4px; font-size: var(--t-xs); color: var(--muted); }
@media (max-width: 639px) { .kpis > .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; } }
.kpi.hero .val { font-size: var(--t-2xl); }
.tone-ink { --tone: var(--ink); }
.tone-paid { --tone: var(--paid); --tone-ink: var(--paid); }
.tone-owed { --tone: var(--owed); --tone-ink: var(--owed); }
.tone-discount { --tone: var(--discount); --tone-ink: var(--discount); }
.tone-volume { --tone: var(--discount); }
.tone-primary { --tone: var(--primary); }
.gauge { display: block; height: 6px; border-radius: var(--r-full); background: var(--paid-soft); margin-top: 8px; overflow: hidden; }
.gauge > i { display: block; height: 100%; background: linear-gradient(90deg, var(--paid), var(--paid-2)); border-radius: inherit; }

/* badges (status + financial) */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-full);
  font-size: var(--t-xs); font-weight: 700; white-space: nowrap; background: var(--line); color: var(--ink-2); }
.badge.paid { background: var(--paid-soft); color: var(--paid); }
.badge.owed { background: var(--owed-soft); color: var(--owed); }
.badge.discount, .badge.warn { background: var(--discount-soft); color: var(--discount); }
.badge.info { background: var(--primary-soft); color: var(--primary-ink); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.lg { height: 30px; padding: 0 12px; font-size: var(--t-sm); }
.amount-owed { display: inline-block; background: var(--owed-soft); color: var(--owed); font-weight: 700; padding: 2px 8px; border-radius: var(--r-sm); }

/* forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .label { font-size: var(--t-sm); font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: var(--t-xs); color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 0 var(--s3); font: inherit; font-size: 16px; /* 16px: no iOS zoom */
  color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r);
  transition: border-color .15s, box-shadow .15s; appearance: none; -webkit-appearance: none;
}
textarea.input { padding: var(--s3); min-height: 90px; }
select.input { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2379736A' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 40px; }
.input::placeholder { color: var(--faint); opacity: 1; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.input.money { text-align: right; font-weight: 600; }
.input-wrap { position: relative; }
.input-wrap .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: var(--t-sm); pointer-events: none; }
.input-wrap .input { padding-right: 44px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s3); }
.form-error { color: var(--danger); font-size: var(--t-sm); font-weight: 600; }
.field-error { margin: 2px 0 0; color: var(--danger); font-size: var(--t-sm); font-weight: 600; line-height: 1.3; }
.input { scroll-margin: 96px 0 140px; }   /* focused/errored fields land clear of the sticky header and save bar */
.check { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary); }
.stepper { display: flex; align-items: stretch; border: 1px solid var(--line-2); border-radius: var(--r); background: var(--surface); overflow: hidden; }
.stepper button { width: 44px; border: 0; background: var(--surface-2); font: inherit; font-size: 22px; color: var(--ink-2); cursor: pointer; }
.stepper button:active { background: var(--line); }
.stepper .input { border: 0; border-radius: 0; text-align: center; font-weight: 700; font-size: 20px; min-width: 0; padding: 0; }
.stepper:focus-within { border-color: var(--primary); box-shadow: var(--focus); }
.stepper .input:focus { box-shadow: none; }
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--line); border-radius: var(--r); overflow-x: auto; }
.segmented a, .segmented button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px;
  padding: 0 var(--s3); border: 0; border-radius: 9px; background: transparent; font: inherit; font-size: var(--t-sm);
  font-weight: 600; color: var(--ink-2); cursor: pointer; white-space: nowrap; text-decoration: none; }
.segmented .on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.segmented em { font-style: normal; color: var(--ink-2); font-weight: 500; }
.search { position: relative; flex: 1; min-width: 180px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; }

/* data table + mobile list */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: var(--t-md); }
table.data th { text-align: left; font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); padding: 10px var(--s4); border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
table.data td { padding: 12px var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data .n { text-align: right; white-space: nowrap; }
table.data th.n { text-align: right; }
table.data tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--line-2); }
table.data a.name { color: var(--ink); font-weight: 600; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list-item { display: flex; align-items: center; gap: var(--s3); padding: 12px var(--s4); min-height: 60px; color: var(--ink);
  text-decoration: none !important; }
a.list-item:hover { background: var(--surface-2); }
.list-item .main-col { 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: var(--t-sm); color: var(--muted); overflow-wrap: anywhere; }
.list-item .end { text-align: right; white-space: nowrap; }
.list-item .chev { color: var(--faint); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.paid { background: var(--paid); } .dot.owed { background: var(--owed); } .dot.warn { background: var(--discount); }

/* empty / loading / error states */
.state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--s2); padding: var(--s8) var(--s4); color: var(--muted); }
.state .ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--surface-2);
  border: 1px solid var(--line); color: var(--faint); margin-bottom: var(--s2); }
.state .ico svg.i { width: 26px; height: 26px; }
.state b { color: var(--ink); font-size: var(--t-lg); }
.state.error .ico { background: var(--danger-soft); color: var(--danger); border-color: #F1C8C3; }
.skeleton { background: linear-gradient(90deg, var(--line) 25%, var(--surface-2) 50%, var(--line) 75%); background-size: 200% 100%;
  animation: sk 1.2s infinite; border-radius: var(--r-sm); height: 14px; }
@keyframes sk { to { background-position: -200% 0; } }

/* alerts / callouts */
.alert { display: flex; gap: var(--s3); padding: var(--s3) var(--s4); border-radius: var(--r); border: 1px solid; font-size: var(--t-md); }
.alert svg.i { margin-top: 1px; }
.alert.info { background: var(--primary-soft); border-color: #C9DCEE; color: var(--primary-ink); }
.alert.success { background: var(--paid-soft); border-color: #BEE3D1; color: #0b5f43; }
.alert.warn { background: var(--discount-soft); border-color: #EFD9A6; color: #7c5506; }
.alert.error { background: var(--danger-soft); border-color: #F1C8C3; color: var(--danger); }
.alert b { display: block; }
.banner { background: var(--danger); color: #fff; padding: 10px var(--s4); font-size: var(--t-sm); font-weight: 600; text-align: center; }
.banner a { color: #fff; text-decoration: underline; }

/* toasts (aria-live) */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s2); width: min(92vw, 440px); pointer-events: none; }
@media (min-width: 1024px) { .toasts { bottom: auto; top: 20px; left: auto; right: 20px; transform: none; } }
.toast { pointer-events: auto; display: flex; align-items: flex-start; gap: var(--s3); padding: 12px var(--s4); border-radius: var(--r);
  background: var(--ink); color: #fff; box-shadow: var(--shadow-lg); font-size: var(--t-md); animation: toast-in .2s ease-out; }
.toast.success svg.i { color: var(--paid-2); } .toast.error { background: var(--danger); } .toast.warning svg.i { color: #F0C85A; }
.toast.out { opacity: 0; transform: translateY(8px); transition: .25s; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* dialog + bottom sheet (native <dialog>) */
dialog.sheet { border: 0; padding: 0; background: var(--surface); color: var(--ink); width: min(100%, 480px); max-height: 90dvh;
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
dialog.sheet::backdrop { background: rgba(22,24,28,.45); backdrop-filter: blur(2px); }
dialog.sheet[open] { animation: sheet-in .2s ease-out; }
@media (max-width: 639px) {
  dialog.sheet { margin: auto 0 0 0; width: 100%; max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
@keyframes sheet-in { from { opacity: 0; transform: translateY(24px); } }
.sheet-body { padding: var(--s5) var(--s5) var(--s4); }
.sheet-body h2 { font-size: var(--t-lg); margin-bottom: var(--s2); }
.sheet-body ul { margin: var(--s3) 0 0; padding-left: 20px; color: var(--ink-2); }
.sheet-actions { display: flex; gap: var(--s2); padding: var(--s3) var(--s5) var(--s5); }
.sheet-actions .btn { flex: 1; }
.grabber { width: 40px; height: 4px; border-radius: 4px; background: var(--line-2); margin: 10px auto 0; }
@media (min-width: 640px) { .grabber { display: none; } }

/* disclosure (details) */
details.disclosure { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
details.disclosure > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: var(--s2);
  min-height: 52px; padding: 0 var(--s4); font-weight: 600; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary .chev { margin-left: auto; transition: transform .2s; color: var(--muted); }
details.disclosure[open] > summary .chev { transform: rotate(180deg); }
details.disclosure > .body { padding: 0 var(--s4) var(--s4); }

/* page header: title + date navigator */
.pagehead { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s4); }
.datenav { display: flex; align-items: center; gap: var(--s1); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-full); padding: 4px; box-shadow: var(--shadow); }
.datenav a.arrow { display: grid; place-items: center; width: 40px; height: 40px; border-radius: var(--r-full); color: var(--ink); }
.datenav a.arrow:hover { background: var(--surface-2); text-decoration: none; }
.datenav label { position: relative; display: flex; flex-direction: column; align-items: center; min-width: 128px; padding: 0 var(--s2); cursor: pointer; line-height: 1.15; }
.datenav label b { font-size: var(--t-md); }
.datenav label span { font-size: var(--t-xs); color: var(--muted); }
.datenav input[type=date] { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.datenav .today { font-size: var(--t-xs); font-weight: 700; color: var(--primary); padding: 0 10px; }

/* sticky action bar (bottom) */
.actionbar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10; display: flex; gap: var(--s2);
  padding: var(--s3) 0; margin-top: var(--s4); background: linear-gradient(transparent, var(--bg) 30%); }
.actionbar .btn { flex: 1; }
@media (min-width: 1024px) { .actionbar { bottom: 0; } }

/* ---------- 5. screens ---------- */
/* Le jour */
.day-total { display: flex; justify-content: space-between; align-items: baseline; }
.client-cell { display: flex; align-items: center; gap: var(--s2); }
.sortbar { display: flex; align-items: center; gap: var(--s2); }
.sortbar select.input { min-height: 36px; font-size: var(--t-sm); width: auto; padding-right: 34px; background-position: right 8px center; }

/* Saisie — Un client */
.capture { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.capture .btn svg.i { width: 20px; height: 20px; }
.hidden-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip: rect(0 0 0 0); }
.total-live { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) var(--s4);
  border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-2); min-height: 56px; }
.total-live b { font-size: var(--t-xl); }
.total-live .muted { font-size: var(--t-sm); }

/* Saisie — Tournée (whole round, one save) */
.tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px var(--s2); padding: 10px var(--s3); }
.tr-name { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px var(--s2); min-width: 0; }
.tr-name .name { color: var(--ink); font-weight: 700; }
.tr-meta { display: flex; flex-wrap: wrap; gap: 2px var(--s2); font-size: var(--t-sm); }
.tr-done { display: inline-flex; align-items: center; gap: 3px; color: var(--paid); font-weight: 600; }
.tr-f { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tr-f > span { font-size: var(--t-xs); color: var(--muted); font-weight: 600; }
.tr-f .input { min-height: 44px; padding: 0 8px; text-align: center; font-weight: 600; }
.tr-f .input.money { text-align: right; }
.tr-f .input:disabled { background: repeating-linear-gradient(135deg, var(--surface-2), var(--surface-2) 6px, var(--line) 6px, var(--line) 12px); border-color: var(--line); }
.tr-amount { grid-column: 1 / -1; justify-self: end; font-size: var(--t-sm); font-weight: 700; color: var(--ink-2); min-height: 0; }
.tr-amount:empty { display: none; }
.tr.filled { background: var(--primary-soft); }
.tr.inactive .tr-name .name { color: var(--muted); }
.tr-head-row { font-size: var(--t-xs); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted);
  background: var(--surface-2); border-bottom: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; }
@media (min-width: 640px) {
  .tr { grid-template-columns: minmax(0, 1fr) 76px 76px 84px 104px 96px; align-items: center; padding: 8px var(--s4); }
  .tr-name { grid-column: auto; flex-direction: column; gap: 0; }
  .tr-f > span { display: none; }
  .tr-amount { grid-column: auto; text-align: right; }
  .tr-amount:empty { display: block; }
  .tr-head-row .n { text-align: right; }
}
.roundbar { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); z-index: 10; display: flex; align-items: center;
  gap: var(--s3); margin-top: var(--s3); padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.roundbar-sum { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.roundbar-sum b { font-size: var(--t-lg); }
.roundbar-sum .muted { font-size: var(--t-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (min-width: 1024px) { .roundbar { bottom: var(--s3); } }

/* fiche client: history timeline */
.hl { display: flex; align-items: baseline; gap: var(--s3); padding: 10px var(--s4); }
.hl .hd { color: var(--muted); font-size: var(--t-sm); flex: none; width: 64px; }
.hl .main-col { flex: 1; min-width: 0; }
.hl .amount { font-weight: 600; white-space: nowrap; text-align: right; }
.hl.credit .amount { color: var(--paid); }
.hl.discount .amount { color: var(--discount); }
.hl .cumul { display: none; font-size: var(--t-xs); color: var(--muted); }
.show-cumul .hl .cumul { display: block; }
details.more > summary { list-style: none; border-top: 1px solid var(--line); border-radius: 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more[open] > summary { display: none; }
.hist-more > li { border-top: 1px solid var(--line); }
.breakdown { display: flex; flex-wrap: wrap; gap: 6px; }
.breakdown span { background: var(--owed-soft); color: var(--owed); border-radius: var(--r-sm); padding: 4px 8px; font-size: var(--t-sm); font-weight: 600; }
.breakdown span em { font-style: normal; font-weight: 500; margin-left: 4px; }
.share { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.btn.wa { background: #157A43; } .btn.wa:hover { background: #10663a; }
pre.message { white-space: pre-wrap; font: inherit; font-size: var(--t-sm); background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: var(--s3); margin: 0; max-height: 320px; overflow: auto; }

/* corrections */
.corr-row { display: grid; grid-template-columns: minmax(0, 1fr) 64px 64px 72px 84px 48px; gap: 6px; align-items: center;
  padding: 8px var(--s3); border-bottom: 1px solid var(--line); }
.corr-row.pay { grid-template-columns: minmax(0, 1fr) 110px 48px; }
.corr-row.head { font-size: var(--t-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-weight: 700; }
.corr-row .input { min-height: 44px; padding: 0 6px; text-align: right; font-size: 15px; }
.corr-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.corr-row .tot { text-align: right; font-weight: 700; font-size: var(--t-sm); }
.corr-row .x { min-width: 44px; min-height: 44px; border-radius: var(--r-sm); border: 0; background: transparent; color: var(--muted);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 4px; font: inherit; font-size: var(--t-xs); font-weight: 700; }
.corr-row .x:hover { background: var(--danger-soft); color: var(--danger); }
.corr-row.changed { background: var(--primary-soft); }
.corr-flag { display: none; font-style: normal; margin-left: 6px; padding: 1px 6px; border-radius: var(--r-full);
  background: var(--danger); color: #fff; font-size: var(--t-xs); font-weight: 700; white-space: nowrap; }
.corr-row.deleted { background: var(--danger-soft); }
.corr-row.deleted .corr-flag { display: inline-block; }
.corr-row.deleted .tot { text-decoration: line-through; color: var(--danger); }
.corr-row.deleted .input { opacity: .45; }
.corr-row.deleted .x { color: var(--ink); background: var(--surface); border: 1px solid var(--line-2); padding: 0 8px; grid-column: auto; }
.corr-row.deleted .x svg { display: none; }
@media (max-width: 479px) {
  .corr-row { grid-template-columns: minmax(0, 1fr) 50px 50px 58px 48px; }
  .corr-row .tot { display: none; }
  .corr-row.pay { grid-template-columns: minmax(0, 1fr) 96px 48px; }
  .corr-row.deleted .x { padding: 0 4px; font-size: 11px; }
}

/* cheques */
.cheque { padding: var(--s3) var(--s4); border-bottom: 1px solid var(--line); }
.cheque:last-child { border-bottom: 0; }
.cheque.settled { background: var(--surface-2); }
.cheque.settled .top b, .cheque.settled .top small { color: var(--muted) !important; }
.cheque .top { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.cheque .top b { font-size: var(--t-lg); }
.cheque .meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: var(--t-sm); color: var(--muted); margin-top: 4px; align-items: center; }
.cheque .acts { display: flex; gap: var(--s2); margin-top: var(--s3); align-items: center; flex-wrap: wrap; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: var(--s4); }
.login .card { width: min(100%, 380px); padding: var(--s6); }

/* two-column on desktop */
@media (min-width: 1024px) { .cols { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: var(--s6); align-items: start; } }

/* ---------- 6. print ---------- */
@media print {
  .tabbar, .sidebar, .topbar, .toasts, .no-print, .actionbar { display: none !important; }
  .with-side { padding: 0; } .main { padding: 0; max-width: none; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; }
}

/* compact help ("?" in the top bar, opens on tap) — instructions never take space from the task */
.hint { position: relative; }
.hint > summary { list-style: none; display: grid; place-items: center; width: var(--tap); height: var(--tap); margin: -6px -8px;
  border-radius: var(--r-full); color: var(--muted); cursor: pointer; }
.hint > summary::-webkit-details-marker { display: none; }
.hint[open] > summary { background: var(--primary-soft); color: var(--primary-ink); }
.hint .pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 40; width: min(300px, 82vw); padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-lg);
  font-size: var(--t-sm); color: var(--ink-2); }
.tr-err { grid-column: 1 / -1; }
@media (min-width: 640px) { .tr-err { grid-column: 2 / -1; } }
/* Un client preview: each amount labelled */
.preview { margin: 0; padding: var(--s3) var(--s4); border-radius: var(--r); background: var(--surface-2); border: 1px dashed var(--line-2); }
.preview > div { display: flex; justify-content: space-between; align-items: baseline; gap: var(--s3); padding: 2px 0; }
.preview dt { font-size: var(--t-sm); color: var(--ink-2); }
.preview dd { margin: 0; font-size: var(--t-lg); font-weight: 700; }
.roundbar-sum b { font-size: var(--t-md); }
