:root {
  --terracotta: #C4623A;
  --terracotta-dark: #A44E2C;
  --beige: #F3E9DC;
  --beige-dark: #E6D6C2;
  --marron: #5A3A29;
  --marron-soft: #8A6B58;
  --white: #FFFCF8;
  --ok: #5E8B5A;
  --warn: #D98B2B;
  --danger: #B3372B;
  --radius: 14px;
  --shadow: 0 2px 8px rgba(90, 58, 41, .12);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--beige);
  color: var(--marron);
  font-family: -apple-system, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  padding-top: env(safe-area-inset-top);
}
.hidden { display: none !important; }
.muted { color: var(--marron-soft); }
.error { color: var(--danger); min-height: 1.2em; margin: .3em 0; }
button, input, select, textarea { font: inherit; color: inherit; }

/* Connexion */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: var(--white); border-radius: 20px; padding: 28px; width: 100%; max-width: 380px; box-shadow: var(--shadow); }
.login-card h1 { margin: 0; font-size: 28px; }
.login-card h1 span { color: var(--terracotta); font-weight: 400; }

/* Structure */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--marron); color: var(--beige);
  display: flex; align-items: center; justify-content: center; height: 54px; padding-top: env(safe-area-inset-top); }
.topbar h1 { margin: 0; font-size: 18px; font-weight: 600; letter-spacing: .3px; }
.icon-btn { position: absolute; left: 6px; background: none; border: 0; color: var(--beige); font-size: 34px; width: 48px; height: 48px; }
main { max-width: 900px; margin: 0 auto; padding: 14px 14px calc(150px + env(safe-area-inset-bottom)); }

.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--white);
  border-top: 1px solid var(--beige-dark); padding-bottom: env(safe-area-inset-bottom); }
.tabbar button { flex: 1; background: none; border: 0; padding: 8px 4px 10px; font-size: 12px; color: var(--marron-soft);
  display: flex; flex-direction: column; align-items: center; gap: 2px; position: relative; }
.tabbar button i { font-style: normal; font-size: 20px; }
.tabbar button.active { color: var(--terracotta); font-weight: 600; }
.badge { position: absolute; top: 2px; left: 55%; background: var(--danger); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 6px; }
.fab { position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 7; width: 58px; height: 58px; border-radius: 50%;
  border: 0; background: var(--terracotta); color: #fff; font-size: 34px; line-height: 1; box-shadow: 0 4px 14px rgba(196,98,58,.5); }

/* Composants */
.btn { border: 1px solid var(--beige-dark); background: var(--white); border-radius: 12px; padding: 12px 16px; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.btn.primary:active { background: var(--terracotta-dark); }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn.small { padding: 8px 12px; font-size: 14px; }
label { display: block; font-size: 14px; color: var(--marron-soft); margin: 12px 0 0; }
input, select, textarea { width: 100%; margin-top: 4px; padding: 12px; border: 1px solid var(--beige-dark); border-radius: 10px; background: var(--white); font-size: 16px; }
textarea { min-height: 70px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; margin-bottom: 12px; }
h2 { font-size: 17px; margin: 18px 0 8px; }

.search { position: sticky; top: 54px; z-index: 4; background: var(--beige); padding-bottom: 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 20px; border: 1px solid var(--beige-dark); background: var(--white); font-size: 14px; }
.chip.active { background: var(--marron); color: var(--beige); border-color: var(--marron); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.item { display: flex; gap: 12px; background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; cursor: pointer; }
.thumb { width: 78px; height: 78px; border-radius: 10px; background: var(--beige-dark) center/cover; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 30px; color: var(--marron-soft); }
.item .info { flex: 1; min-width: 0; }
.item .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .sub { font-size: 14px; color: var(--marron-soft); }
.pill { display: inline-block; border-radius: 10px; font-size: 12px; padding: 2px 9px; font-weight: 600; color: #fff; background: var(--ok); }
.pill.low { background: var(--warn); }
.pill.out { background: var(--danger); }

.photo-big { width: 100%; aspect-ratio: 4/3; background: var(--beige-dark) center/cover; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center; font-size: 56px; color: var(--marron-soft); }
.variant { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--beige); }
.variant:last-child { border-bottom: 0; }
.variant .label { flex: 1; font-weight: 600; }
.variant .label small { display: block; font-weight: 400; color: var(--marron-soft); }
.stepper { display: flex; align-items: center; gap: 4px; }
.stepper button { width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--beige-dark); background: var(--beige); font-size: 22px; color: var(--marron); }
.stepper button.plus { background: var(--terracotta); border-color: var(--terracotta); color: #fff; }
.stepper .q { min-width: 34px; text-align: center; font-size: 19px; font-weight: 700; }
.q.low { color: var(--warn); } .q.out { color: var(--danger); }

.sizes { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; margin-top: 8px; }
.size { border: 1px solid var(--beige-dark); border-radius: 10px; background: var(--white); padding: 8px 4px; text-align: center; }
.size.on { border-color: var(--terracotta); background: #FBEAE1; }
.size b { display: block; }
.size .stepper { justify-content: center; margin-top: 4px; }
.size .stepper button { width: 30px; height: 30px; font-size: 17px; }
.size .stepper .q { min-width: 22px; font-size: 15px; }

.photo-pick { display: block; text-align: center; border: 2px dashed var(--terracotta); border-radius: var(--radius); padding: 22px; color: var(--terracotta); font-weight: 600; cursor: pointer; background: var(--white); }
.photo-pick img { max-width: 100%; max-height: 220px; border-radius: 10px; display: block; margin: 0 auto 8px; }
.photo-pick input { display: none; }

.empty { text-align: center; color: var(--marron-soft); padding: 40px 10px; }
.order-group h3 { margin: 0 0 6px; }
.order-line { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--beige); }

.toast { position: fixed; left: 50%; bottom: calc(150px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--marron); color: var(--beige); padding: 10px 18px; border-radius: 20px; opacity: 0; pointer-events: none; transition: .25s; z-index: 20; font-size: 15px; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }
.chip.small{padding:5px 11px;font-size:13px}

.pill.todo { background: var(--marron-soft); }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; border-left: 5px solid var(--terracotta); }
.banner > div { flex: 1; }
.bar { height: 7px; background: var(--beige-dark); border-radius: 4px; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--terracotta); }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.stepper button.rm { margin-left: 6px; background: none; border: 0; color: var(--marron-soft); font-size: 26px; }
.photo-big.compact { aspect-ratio: auto; height: 30vh; min-height: 170px; background-size: contain; background-repeat: no-repeat; }
