/* freshresellstore — mobile d'abord, thèmes clair et sombre (automatique ou choisi) */

@font-face { font-family: "Instrument Sans"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/instrument-sans-latin-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/instrument-sans-latin-500-normal.woff2") format("woff2"); }
@font-face { font-family: "Instrument Sans"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/instrument-sans-latin-600-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/bricolage-grotesque-latin-700-normal.woff2") format("woff2"); }
@font-face { font-family: "Bricolage Grotesque"; font-weight: 800; font-style: normal; font-display: swap; src: url("/fonts/bricolage-grotesque-latin-800-normal.woff2") format("woff2"); }

:root {
  color-scheme: light;
  --bg: #eef0f7;
  --surface: #ffffff;
  --surface-2: #f5f6fb;
  --ink: #171a2e;
  --muted: #5d627d;
  --line: #dcdfec;
  --accent: #4f3bd8;
  --accent-ink: #ffffff;
  --accent-soft: #e9e6fb;
  --pos: #0b7f58;
  --neg: #c4264e;
  --warn: #9a5200;
  --warn-soft: #fdf0dc;
  --neg-soft: #fde8ee;
  --scrim: rgba(16, 17, 40, 0.5);

  --display: "Bricolage Grotesque", "Instrument Sans", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --r-panel: 14px;
  --r-control: 11px;
  --r-sheet: 22px;
  --nav-h: 64px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #101128;
    --surface: #191b3a;
    --surface-2: #202348;
    --ink: #eceefb;
    --muted: #9ea3c8;
    --line: #2d3060;
    --accent: #9a8bff;
    --accent-ink: #14123a;
    --accent-soft: #2a2766;
    --pos: #3fd9a0;
    --neg: #ff7a99;
    --warn: #f5b04c;
    --warn-soft: #3a2c12;
    --neg-soft: #3d1a2a;
    --scrim: rgba(0, 0, 0, 0.62);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101128;
  --surface: #191b3a;
  --surface-2: #202348;
  --ink: #eceefb;
  --muted: #9ea3c8;
  --line: #2d3060;
  --accent: #9a8bff;
  --accent-ink: #14123a;
  --accent-soft: #2a2766;
  --pos: #3fd9a0;
  --neg: #ff7a99;
  --warn: #f5b04c;
  --warn-soft: #3a2c12;
  --neg-soft: #3d1a2a;
  --scrim: rgba(0, 0, 0, 0.62);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 16px/1.45 var(--body);
  font-variant-numeric: tabular-nums;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.boot { padding: 48px 20px; text-align: center; color: var(--muted); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- structure ---------- */
.shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  margin-top: calc(-1 * env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; font: 800 19px/1 var(--display); letter-spacing: -0.01em; }
.brand-logo { width: 38px; height: 38px; border-radius: 11px; background: #fff; border: 1px solid var(--line); flex: none; }
.brand small { font: 500 13px/1 var(--body); color: var(--muted); margin-left: 8px; letter-spacing: 0; }
.main { max-width: 760px; margin: 0 auto; padding: 4px 16px calc(var(--nav-h) + 110px + env(safe-area-inset-bottom)); }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--nav-h); padding: 6px 2px; color: var(--muted);
  font-size: 12px; font-weight: 500; text-decoration: none;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tab[aria-current="page"] { color: var(--accent); font-weight: 600; }
.tab[aria-current="page"] .ico { background: var(--accent-soft); }
.tab .ico { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 999px; }
.tab:hover { text-decoration: none; }

@media (min-width: 900px) {
  .tabs {
    top: 0; right: auto; bottom: 0; width: 212px;
    display: flex; flex-direction: column; justify-content: flex-start; gap: 4px;
    padding: 76px 12px 12px; border-top: 0; border-right: 1px solid var(--line);
  }
  .tab { flex-direction: row; justify-content: flex-start; gap: 12px; min-height: 46px; padding: 0 12px; border-radius: var(--r-control); font-size: 15px; }
  .tab .ico { width: 28px; height: 28px; background: none !important; }
  .tab[aria-current="page"] { background: var(--accent-soft); }
  .topbar { padding-left: 228px; }
  .main { margin-left: 212px; max-width: none; padding-left: 40px; padding-right: 40px; padding-bottom: 120px; }
  .main > .page { max-width: 780px; margin: 0 auto; }
  .fab { bottom: 28px !important; }
}

/* ---------- typographie ---------- */
.page > h1 { font: 800 28px/1.1 var(--display); letter-spacing: -0.015em; margin: 8px 0 14px; }
.h2 { font: 700 18px/1.2 var(--display); letter-spacing: -0.005em; margin: 26px 0 10px; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.h2 small { font: 400 14px/1.2 var(--body); color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.crumb { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; color: var(--muted); font-size: 14px; }

/* ---------- bilan : le ticket ---------- */
.bilan {
  position: relative; background: var(--surface); padding: 18px 18px 20px;
  margin-bottom: 14px; border-radius: 14px 14px 0 0;
}
.bilan::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -7px; height: 7px;
  background: radial-gradient(circle at 50% 100%, transparent 5px, var(--surface) 5.5px) 0 0 / 14px 7px repeat-x;
}
.bilan .row { display: flex; align-items: baseline; gap: 8px; padding: 5px 0; }
.bilan .row .label { color: var(--muted); }
.bilan .row .dots { flex: 1; min-width: 12px; border-bottom: 2px dotted var(--line); transform: translateY(-4px); }
.bilan .row .amount { font-weight: 500; white-space: nowrap; }
.bilan .row.sum { margin-top: 6px; padding-top: 10px; border-top: 1.5px solid var(--ink); }
.bilan .row.sum .label { color: var(--ink); font-weight: 600; }
.bilan .row.sum .amount { font-weight: 600; }
.bilan .row.final { align-items: flex-end; margin-top: 8px; padding-top: 12px; border-top: 1.5px solid var(--ink); }
.bilan .row.final .label { font: 700 20px/1.1 var(--display); color: var(--ink); }
.bilan .row.final .dots { display: none; }
.bilan .row.final .amount { margin-left: auto; font: 800 38px/1 var(--display); letter-spacing: -0.02em; }
.bilan .note { margin-top: 10px; font-size: 13.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bilan .hint { color: var(--warn); font-weight: 500; }

/* ---------- listes ---------- */
.panel { background: var(--surface); border-radius: var(--r-panel); overflow: hidden; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li + li { border-top: 1px solid var(--line); }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 16px; min-height: 56px; color: inherit; text-decoration: none; background: none; border: 0; text-align: left; cursor: pointer;
}
.item:hover { background: var(--surface-2); text-decoration: none; }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 600; }
.item .s { color: var(--muted); font-size: 13.5px; margin-top: 1px; }
.item .end { text-align: right; white-space: nowrap; }
.item .end .big { font: 700 17px/1.2 var(--display); }
.item .end .s { margin-top: 1px; }
.chev { color: var(--muted); flex: none; }

.chip { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--accent-soft); color: var(--accent); vertical-align: 1px; white-space: nowrap; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }
.chip.bad { background: var(--neg-soft); color: var(--neg); }
.chip.ok { background: color-mix(in srgb, var(--pos) 16%, transparent); color: var(--pos); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 5px; }

.banner { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r-panel); background: var(--warn-soft); color: var(--warn); margin-bottom: 12px; font-size: 14.5px; }
.banner a { color: inherit; font-weight: 600; text-decoration: underline; }
.banner.bad { background: var(--neg-soft); color: var(--neg); }

.empty { padding: 28px 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font: 700 17px/1.2 var(--display); margin-bottom: 4px; }

/* tableau (clients d'un live, ventes) */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th:first-child, .tbl td:first-child { padding-left: 14px; }
.tbl th:last-child, .tbl td:last-child { padding-right: 14px; }
.tbl th.num, .tbl td.num { text-align: right; }
.tbl td { padding: 11px 8px; border-top: 1px solid var(--line); vertical-align: top; }
.tbl tr:first-child td { border-top: 0; }
.tbl td.name { font-weight: 600; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl tfoot td { border-top: 1.5px solid var(--ink); font-weight: 600; }
.tbl a.name { font-weight: 600; color: var(--ink); }

/* barres des mois */
.bar { display: block; height: 4px; border-radius: 4px; background: var(--pos); margin-top: 6px; min-width: 2px; width: 0; }
.bar.neg { background: var(--neg); }

details.fold > summary { list-style: none; cursor: pointer; padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; font-weight: 600; min-height: 52px; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary::after { content: "＋"; color: var(--muted); }
details.fold[open] > summary::after { content: "－"; }

/* ---------- boutons & champs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn.danger { color: var(--neg); border-color: color-mix(in srgb, var(--neg) 40%, var(--line)); }
.btn.ghost { border-color: transparent; background: none; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: progress; }
.btn.icon { min-width: 44px; padding: 0; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 4px 0 14px; }
.actions .btn { flex: 1 1 auto; }

.fab {
  position: fixed; right: 16px; z-index: 4;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  min-height: 54px; padding: 0 22px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
}
.fab svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.field > small { display: block; color: var(--muted); font-size: 13px; margin-top: 5px; }
.input {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-size: 16px; /* 16px minimum : évite le zoom automatique d'iOS */
}
.input:focus { outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent); border-color: var(--accent); }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 20px) 21px, calc(100% - 15px) 21px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stepper { display: flex; gap: 8px; }
.stepper .input { text-align: center; }
.stepper .btn { min-width: 48px; padding: 0; font-size: 22px; }
.error { color: var(--neg); font-size: 14px; margin: 0 0 12px; min-height: 0; }
.suffix { position: relative; }
.suffix .input { padding-right: 38px; }
.suffix::after { content: "€"; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ---------- compléments ---------- */
.gap { margin: 4px 0 14px; }
.gap-s { margin: 0 0 12px; }
.gap-top { margin-top: 14px; }
.page > p.muted { margin-bottom: 12px; }
.panel + p.muted { margin-top: 10px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.item strong { min-width: 1.6ch; text-align: center; font-size: 17px; }
.crumb svg, .chev svg, .drop svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.drop svg { width: 30px; height: 30px; }
.live-card .t { font-weight: 600; margin-bottom: 2px; }
.live-card .field { margin: 10px 0 0; }
.live-card p.small { margin-top: 6px; }
.tbl tbody tr:hover { background: var(--surface-2); }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }
.panel .banner, .panel .empty { margin: 0; }

/* ---------- feuille (dialog) ---------- */
.sheet {
  border: 0; padding: 0; background: var(--surface); color: var(--ink);
  width: 100%; max-width: 560px; max-height: 92dvh; margin: auto auto 0; overflow: auto;
  border-radius: var(--r-sheet) var(--r-sheet) 0 0;
}
.sheet::backdrop { background: var(--scrim); }
.sheet[open] { animation: rise 0.2s ease-out; }
@keyframes rise { from { transform: translateY(24px); opacity: 0.4; } to { transform: none; opacity: 1; } }
.sheet-in { padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 16px; }
.sheet-head h2 { font: 800 21px/1.15 var(--display); letter-spacing: -0.01em; }
.sheet-foot { display: flex; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.sheet-foot .btn { flex: 1 1 140px; }
@media (min-width: 700px) {
  .sheet { margin: auto; border-radius: var(--r-sheet); }
}

.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(var(--nav-h) + 24px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 999px; font-weight: 500; max-width: 90vw; text-align: center;
}
@media (min-width: 900px) { .toast { bottom: 28px; } }

/* ---------- connexion ---------- */
.login { max-width: 400px; margin: 0 auto; padding: calc(56px + env(safe-area-inset-top)) 20px 40px; }
.login-logo { display: block; width: 96px; height: 96px; border-radius: 24px; background: #fff; border: 1px solid var(--line); margin-bottom: 18px; }
.login h1 { font: 800 34px/1.05 var(--display); letter-spacing: -0.02em; margin-bottom: 6px; }
.login .lead { color: var(--muted); margin-bottom: 28px; }
.login-note { color: var(--muted); font-size: 13.5px; margin-top: 18px; }

/* ---------- import ---------- */
.drop {
  display: grid; place-items: center; gap: 6px; text-align: center; padding: 34px 18px;
  border: 2px dashed var(--line); border-radius: var(--r-panel); background: var(--surface); cursor: pointer;
}
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop strong { font: 700 18px/1.2 var(--display); }
.live-card { padding: 14px 16px; }
.live-card + .live-card { border-top: 1px solid var(--line); }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; font-size: 15px; }
.kv span:first-child { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
