:root {
  --bg: #fff8f0; --card: #ffffff; --ink: #2b1d12; --muted: #7c6a5c; --line: #f0e2d3;
  --brand: #f76707; --brand-ink: #ffffff; --sun: #fcc419; --soft: #fff0e0;
  --cash: #2f9e44; --cash-soft: #ebfbee; --twint: #1c7ed6; --twint-soft: #e7f5ff;
  --danger: #e03131; --shadow: 0 1px 2px rgba(80,40,0,.06), 0 4px 14px rgba(80,40,0,.06);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17120e; --card: #221b15; --ink: #f5ece4; --muted: #b3a294; --line: #3a2f26;
    --brand: #ff8a3d; --brand-ink: #1a0f06; --soft: #2e2219;
    --cash: #51cf66; --cash-soft: #1d2e20; --twint: #4dabf7; --twint-soft: #172a3a;
    --danger: #ff6b6b; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { display: grid; place-items: center; height: 80vh; font-size: 48px; }
.hidden { display: none !important; }
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 14px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrapr { flex-wrap: wrap; }
.grow { flex: 1; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); margin-bottom: 12px; }

/* barre du haut */
.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: var(--brand-ink);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px; display: flex; align-items: center; gap: 10px; }
.top .logo { width: 30px; height: 30px; border-radius: 8px; background: #fff3; display: grid; place-items: center; }
.top b { font-size: 17px; }
.top .who { margin-left: auto; font-size: 13px; opacity: .9; text-align: right; }

/* navigation du bas */
nav.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--card);
  border-top: 1px solid var(--line); display: flex; padding-bottom: env(safe-area-inset-bottom); }
nav.tabs button { flex: 1; border: 0; background: none; padding: 8px 2px 10px; font-size: 12px;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
nav.tabs button .ic { font-size: 21px; line-height: 1; }
nav.tabs button.on { color: var(--brand); font-weight: 600; }

/* boutons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer;
  background: var(--soft); color: var(--ink); min-height: 46px; }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn.ghost { background: transparent; border: 1px solid var(--line); }
.btn.big { width: 100%; font-size: 18px; padding: 18px; border-radius: 16px; }
.btn.sm { min-height: 34px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.btn:active { transform: scale(.98); }

/* formulaires */
label.f { display: block; margin-bottom: 12px; font-size: 14px; color: var(--muted); }
label.f input, label.f select, label.f textarea, input.in, select.in {
  display: block; width: 100%; margin-top: 4px; padding: 12px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); font-size: 16px; }
input.in, select.in { display: inline-block; width: auto; padding: 8px 10px; margin: 0; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

/* connexion */
.login { max-width: 380px; margin: 9vh auto 0; padding: 16px; }
.login .sun { width: 84px; height: 84px; margin: 0 auto 10px; display: block; }
.login h1 { text-align: center; }

/* caisse */
.sessionbar { display: flex; align-items: center; gap: 10px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--cash); box-shadow: 0 0 0 4px var(--cash-soft); }
.prod { padding: 12px 14px; }
.prod .ph { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.prod .ph b { font-size: 17px; }
.counter { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.counter .lab { width: 64px; font-weight: 600; font-size: 14px; }
.counter.cash .lab { color: var(--cash); }
.counter.twint .lab { color: var(--twint); }
.counter .q { min-width: 46px; text-align: center; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.counter .amt { margin-left: auto; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 72px; text-align: right; }
.pm { width: 52px; height: 52px; border-radius: 14px; border: 0; font-size: 26px; font-weight: 700; cursor: pointer;
  touch-action: manipulation; user-select: none; }
.cash .pm { background: var(--cash-soft); color: var(--cash); }
.twint .pm { background: var(--twint-soft); color: var(--twint); }
.cash .pm.plus { background: var(--cash); color: #fff; }
.twint .pm.plus { background: var(--twint); color: #fff; }
.pm:active { transform: scale(.92); }
.pm:disabled { opacity: .35; }
.bump { animation: bump .25s; }
@keyframes bump { 50% { transform: scale(1.25); } }

.totals { position: sticky; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 4;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 -4px 20px rgba(0,0,0,.08); display: grid; grid-template-columns: 1fr 1fr 1.2fr; margin-top: 8px; }
.totals div { padding: 10px 12px; }
.totals small { display: block; font-size: 12px; color: var(--muted); }
.totals strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.totals .c strong { color: var(--cash); }
.totals .t strong { color: var(--twint); }
.totals .g { background: var(--soft); border-radius: 0 var(--radius) var(--radius) 0; }
.totals .g strong { font-size: 21px; }

/* récap */
table.rec { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.rec th, table.rec td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: right; }
table.rec th:first-child, table.rec td:first-child { text-align: left; }
table.rec th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
table.rec tr.tot td { font-weight: 700; border-bottom: 0; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; }
.pill.open { background: var(--cash-soft); color: var(--cash); }
.pill.closed { background: var(--soft); color: var(--muted); }
.pill.role { background: var(--soft); color: var(--brand); }

/* liste des sessions */
.item { display: flex; align-items: center; gap: 12px; cursor: pointer; }
.item .date { width: 48px; text-align: center; background: var(--soft); border-radius: 12px; padding: 6px 0; }
.item .date b { display: block; font-size: 20px; line-height: 1; }
.item .date span { font-size: 11px; text-transform: uppercase; color: var(--muted); }
.item .amt { margin-left: auto; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }

/* stats */
.seg { display: flex; background: var(--soft); border-radius: 12px; padding: 3px; gap: 2px; overflow-x: auto; }
.seg button { flex: 1; border: 0; background: none; padding: 8px 10px; border-radius: 9px; font-size: 14px; white-space: nowrap; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: var(--shadow); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
@media (min-width: 560px) { .kpis { grid-template-columns: repeat(4, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.kpi small { color: var(--muted); font-size: 12px; }
.kpi b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpi.c b { color: var(--cash); } .kpi.t b { color: var(--twint); }
.chartbox { position: relative; height: 240px; }
.split { height: 14px; border-radius: 99px; overflow: hidden; display: flex; background: var(--soft); margin: 8px 0 6px; }
.split .c { background: var(--cash); } .split .t { background: var(--twint); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.scroll-x { overflow-x: auto; }

/* modale et toast */
.modal { position: fixed; inset: 0; z-index: 20; background: rgba(20,10,0,.45); display: flex; align-items: flex-end; justify-content: center; }
.modal .sheet { background: var(--card); width: 100%; max-width: 520px; max-height: 90vh; overflow: auto;
  border-radius: 20px 20px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 560px) { .modal { align-items: center; } .modal .sheet { border-radius: 20px; } }
.secret { font: 600 22px/1.3 ui-monospace, Menlo, Consolas, monospace; background: var(--soft); border-radius: 12px;
  padding: 14px; text-align: center; letter-spacing: .06em; user-select: all; word-break: break-all; }
#toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center; }
#toast.on { opacity: 1; }
table.rec { font-size: 14px; }
table.rec th, table.rec td { padding: 8px 4px; white-space: nowrap; }
table.rec td:first-child { white-space: normal; }
