:root {
  --wine: #7a1f3d;
  --wine-dark: #5c1630;
  --gold: #c4a574;
  --cream: #f6f0e8;
  --paper: #fffdf9;
  --ink: #2c1810;
  --muted: #6b5344;
  --line: #eadfce;
  --ok: #2d6a4f;
  --warn: #b45309;
  --danger: #b42318;
  --radius: 16px;
  --tap: 48px;
  --shadow: 0 8px 24px rgba(44, 24, 16, .08);
  font-family: "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--cream);
  color: var(--ink);
  padding-bottom: 88px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: var(--wine);
  color: var(--cream);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.12);
}
.brand-text strong { display: block; font-size: 14px; line-height: 1.15; }
.brand-text small { display: block; opacity: .75; font-size: 11px; }
.topnav { display: none; gap: 8px; }
.topnav a {
  color: var(--cream);
  text-decoration: none;
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 14px;
}
.topnav a.is-active { background: rgba(255,255,255,.16); }

.page { padding: 16px; max-width: 860px; margin: 0 auto; }

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  margin-bottom: 14px;
  font-weight: 600;
}
.flash-ok { background: #d8f3dc; color: var(--ok); }
.flash-err { background: #fde8e8; color: var(--danger); }

.hero-actions { margin-bottom: 16px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--wine); color: #fff; }
.btn-primary:active { background: var(--wine-dark); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-ghost {
  background: transparent;
  color: var(--wine);
  border: 1px solid var(--line);
}
.btn-danger { background: #fde8e8; color: var(--danger); }
.btn[disabled] { opacity: .5; }

.filters {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
.filters .grow { grid-column: 1 / -1; }
.filters .field { margin-bottom: 0; }
input, select, textarea {
  width: 100%;
  min-height: var(--tap);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  background: var(--paper);
  color: inherit;
}
textarea { min-height: 88px; resize: vertical; }
.field, label.field { display: block; margin-bottom: 12px; }
.field > span, label.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card-link { display: block; color: inherit; text-decoration: none; }
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
  align-items: center;
}
.muted { color: var(--muted); font-size: 13px; }
.total { font-weight: 800; }
.total-jour .total { font-size: 22px; color: var(--wine); }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}
.st-en_cours { background: #dbeafe; color: #1e40af; }
.st-pret { background: #d8f3dc; color: var(--ok); }
.st-livree { background: #ede9fe; color: #5b21b6; }
.st-annulee { background: #fde8e8; color: var(--danger); }
.pay-non_payee { background: #fde8e8; color: var(--danger); }
.pay-especes { background: #d8f3dc; color: var(--ok); }
.pay-cb { background: #dbeafe; color: #1e40af; }
.pay-virement { background: #ede9fe; color: #5b21b6; }

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: grid;
  grid-template-columns: 0.9fr 1fr 0.8fr 0.8fr 0.8fr 0.8fr;
  gap: 4px;
  padding: 10px 8px calc(10px + env(safe-area-inset-bottom));
  background: rgba(246, 240, 232, .94);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  border-radius: 14px;
}
.tabbar a span { font-size: 18px; line-height: 1; }
.tabbar a.is-active { color: var(--wine); background: #fff; }
.tabbar-plus { background: var(--wine) !important; color: #fff !important; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.line-card {
  border: 1px dashed var(--gold);
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.line-card h3 {
  margin: 0 0 10px;
  font-size: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chips .muted {
  flex: 1 1 100%;
  margin: 0;
}
.chip {
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--cream);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.chip.is-on {
  background: var(--wine);
  color: #fff;
  border-color: var(--wine);
}
.swatch {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  padding: 0;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.swatch.is-on { box-shadow: 0 0 0 3px var(--wine); }

.stock-hint {
  margin: 0 0 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ok);
}
.stock-hint.is-low { color: var(--warn); }
.stock-hint.is-out { color: var(--danger); }
.stock-low { color: var(--danger); }

.qty-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.qty-ctrl {
  display: grid;
  grid-template-columns: 48px 72px 48px;
  gap: 6px;
  align-items: center;
}
.qty-ctrl input { text-align: center; min-height: 44px; font-weight: 800; }
.qty-ctrl .btn { min-height: 44px; padding: 0; }

.sticky-save {
  position: sticky;
  bottom: 84px;
  display: grid;
  gap: 8px;
  padding-top: 8px;
}

.recap-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  display: inline-block; vertical-align: middle;
  border: 1px solid var(--line);
}

.auth-wrap {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card { width: min(420px, 100%); }

.table-admin { width: 100%; border-collapse: collapse; font-size: 14px; }
.table-admin th, .table-admin td { text-align: left; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.tabs { display: flex; gap: 6px; overflow: auto; padding-bottom: 10px; }
.tabs a {
  white-space: nowrap;
  padding: 8px 12px;
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
}
.tabs a.is-on { background: var(--wine); color: #fff; border-color: var(--wine); }

.broderie-block {
  border: 1px dashed var(--gold);
  border-radius: 14px;
  padding: 12px;
  margin: 10px 0;
  background: var(--cream);
}
.broderie-block h4 {
  margin: 0 0 8px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.font-sample {
  margin: 6px 0 0;
  line-height: 1.2;
  color: var(--ink);
}

.empty {
  text-align: center;
  padding: 40px 12px;
  color: var(--muted);
}

@media print {
  .topbar, .tabbar, .sticky-save, form.card, .flash { display: none !important; }
  body { padding: 0; background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}

@media (min-width: 800px) {
  .topnav { display: flex; }
  .tabbar { display: none; }
  body { padding-bottom: 24px; }
  .sticky-save { bottom: 16px; grid-template-columns: 1fr 1fr; }
}
