/* VidaPrim Pro — mobile-first client ordering PWA.
   Palette: Cévennes produce market — chard green, limestone wash, schist slate price tags, apricot. */
:root {
  --leaf: #2F6B3A;        /* primary, theme colour */
  --leaf-deep: #22512B;
  --leaf-soft: #DDE8D9;
  --wash: #EEF2EA;        /* background */
  --paper: #FFFFFF;
  --ink: #23302A;         /* body text */
  --ink-soft: #5B6A61;
  --line: #CFDACB;
  --slate: #34403B;       /* price tags (ardoise) */
  --chalk: #F4F6EF;
  --apricot: #F2B33D;
  --apricot-soft: #FCEBC4;
  --beet: #9B2D4A;        /* errors, cancel */
  --beet-soft: #F6E1E7;
  --radius-s: 8px;
  --radius-m: 14px;
  --tabbar-h: 64px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Young Serif", Georgia, "Times New Roman", serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--wash);
  color: var(--ink);
  font: 400 16px/1.5 var(--font-body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--apricot); outline-offset: 2px; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8;
      stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- buttons & fields ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--radius-m);
  border: 2px solid transparent; font-weight: 600; font-size: 1rem; text-decoration: none;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--leaf); color: #fff; }
.btn-primary:active { background: var(--leaf-deep); }
.btn-primary:disabled { opacity: .55; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: transparent; border-color: var(--beet); color: var(--beet); }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.btn-row .btn-block { grid-column: 1 / -1; }

.field { display: block; margin: 16px 0; }
.field > span { display: block; font-weight: 600; font-size: .9375rem; margin-bottom: 6px; }
.field small { display: block; color: var(--ink-soft); margin-top: 4px; font-size: .875rem; }
.field input, .field textarea {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: var(--radius-s);
  border: 1.5px solid var(--line); background: var(--paper); font-size: 1rem;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus { border-color: var(--leaf); outline: none; box-shadow: 0 0 0 3px var(--leaf-soft); }

.check { display: flex; align-items: center; gap: 12px; min-height: 48px; margin: 12px 0 0; font-weight: 500; }
.check input { width: 24px; height: 24px; accent-color: var(--leaf); flex: none; margin: 0; }

.form-error { margin: 12px 0; padding: 10px 14px; border-radius: var(--radius-s);
              background: var(--beet-soft); color: var(--beet); font-weight: 500; }

/* ---------- login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh;
  padding: calc(40px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  max-width: 440px; margin: 0 auto; display: flex; flex-direction: column;
}
.login-top { text-align: center; margin-bottom: 28px; }
.login-logo { border-radius: 18px; }
.login-title { font-family: var(--font-display); font-weight: 400; font-size: 2.25rem; line-height: 1.1;
               margin: 16px 0 6px; color: var(--leaf-deep); }
.login-sub { margin: 0; color: var(--ink-soft); }
.login-card { background: var(--paper); border-radius: 20px; padding: 8px 20px 20px;
              border: 1px solid var(--line); }
.login-help { text-align: center; color: var(--ink-soft); font-size: .875rem; margin: 14px 0 0; }
.install-btn { margin-top: 20px; }
.ios-hint { margin: 20px 0 0; padding: 12px 14px; text-align: center; border-radius: var(--radius-s);
            background: var(--apricot-soft); font-size: .9375rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: var(--leaf); color: #fff;
}
.topbar-id { display: flex; flex-direction: column; min-width: 0; }
.topbar-brand { font-family: var(--font-display); font-size: 1.25rem; line-height: 1.2; }
.topbar-company { font-size: .875rem; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-out { min-height: 44px; padding: 0 12px; border: 1.5px solid rgba(255,255,255,.45);
              border-radius: var(--radius-s); background: transparent; color: #fff; font-size: .875rem; font-weight: 600; flex: none; }

.banner { padding: 12px 16px; font-size: .9375rem; font-weight: 500; }
.banner-demo { background: var(--apricot-soft); border-bottom: 1px solid var(--apricot); }
.banner-edit { background: var(--apricot-soft); border-radius: var(--radius-m); margin-bottom: 12px; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px calc(var(--tabbar-h) + var(--safe-bottom) + 28px); }
.screen-title { font-family: var(--font-display); font-weight: 400; font-size: 1.75rem; line-height: 1.2; margin: 4px 0 16px; }
.section-title { font-family: var(--font-display); font-weight: 400; font-size: 1.375rem; margin: 0 0 10px; }

.empty { text-align: center; padding: 40px 16px; color: var(--ink-soft); }
.empty p { margin: 0 0 16px; font-size: 1.0625rem; }

/* ---------- delivery card ---------- */
.delivery-card {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--paper); border: 1px solid var(--line); border-left: 5px solid var(--leaf);
  border-radius: var(--radius-s); padding: 12px 14px; margin-bottom: 16px;
}
.delivery-card svg { color: var(--leaf); margin-top: 2px; }
.delivery-card strong { display: block; }
.delivery-card span { color: var(--ink-soft); font-size: .9375rem; }
.delivery-card.is-warn { border-left-color: var(--apricot); }
.delivery-card.is-warn svg { color: #B37A10; }

/* ---------- home ---------- */
.home-message {
  background: var(--leaf-soft); border-radius: var(--radius-m); padding: 14px 16px; margin-bottom: 20px;
  white-space: pre-line; font-size: 1.0625rem;
}
.strip-wrap { margin-bottom: 24px; }
.strip {
  display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
  margin: 0 -16px; padding: 2px 16px 8px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.tile {
  flex: 0 0 168px; scroll-snap-align: start; text-align: left;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m);
  padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 150px;
}
.tile-name { font-weight: 600; line-height: 1.3; }
.tile-origin { color: var(--ink-soft); font-size: .875rem; margin-top: -4px; }
.tile .tag { margin-top: auto; align-self: flex-start; }

/* ---------- price tag (ardoise) : the signature element ---------- */
.tag {
  position: relative; display: inline-flex; align-items: baseline; gap: 4px;
  background: var(--slate); color: var(--chalk);
  padding: 5px 10px 5px 20px; border-radius: 4px 10px 10px 4px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.tag::before { /* punched hole of a market price tag */
  content: ""; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--wash);
}
.tag b { font-weight: 700; font-size: 1.0625rem; }
.tag small { font-size: .8125rem; opacity: .85; }
.tag.is-promo { background: var(--apricot); color: var(--ink); }

.flag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.flag-new { background: var(--leaf-soft); color: var(--leaf-deep); }
.flag-promo { background: var(--apricot-soft); color: #7A4F00; }

/* ---------- catalogue ---------- */
.cat-head {
  position: sticky; top: var(--topbar-real, calc(66px + var(--safe-top))); z-index: 10;
  background: var(--wash); margin: -16px -16px 8px; padding: 12px 16px 8px;
}
.search {
  display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 14px;
  background: var(--paper); border: 1.5px solid var(--line); border-radius: var(--radius-m);
}
.search svg { color: var(--ink-soft); width: 20px; height: 20px; }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; min-height: 44px; font-size: 1rem; outline: none; }
.cat-tabs { display: flex; gap: 8px; overflow-x: auto; margin: 10px -16px 0; padding: 0 16px 4px; scrollbar-width: none; }
.cat-tabs::-webkit-scrollbar { display: none; }
.cat-tab {
  flex: none; min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1.5px solid var(--line); background: var(--paper); font-weight: 600; font-size: .9375rem;
}
.cat-tab[aria-selected="true"] { background: var(--leaf); border-color: var(--leaf); color: #fff; }

.cat-list { display: flex; flex-direction: column; gap: 12px; }
.cat-group-title { font-family: var(--font-display); font-weight: 400; font-size: 1.25rem; margin: 12px 0 0; }
.product {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px;
  scroll-margin-top: 160px;
}
.product.is-flash { animation: flash 1.6s ease-out; }
@keyframes flash { 0%, 30% { box-shadow: 0 0 0 4px var(--apricot); } 100% { box-shadow: 0 0 0 0 transparent; } }
.product-head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.product-name { font-weight: 600; font-size: 1.0625rem; line-height: 1.3; margin: 0; }
.product-origin { color: var(--ink-soft); font-size: .875rem; }
.product-flags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }

.buy { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px 12px;
       padding-top: 12px; margin-top: 12px; border-top: 1px dashed var(--line); }
.buy + .buy { margin-top: 8px; padding-top: 8px; }
.buy-label { font-weight: 600; font-size: .9375rem; }
.buy-detail { display: block; font-weight: 400; color: var(--ink-soft); font-size: .875rem; }

.stepper { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: var(--radius-m);
           background: var(--paper); overflow: hidden; }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--leaf-soft); color: var(--leaf-deep);
                  font-size: 1.375rem; font-weight: 700; line-height: 1; }
.stepper button:disabled { opacity: .4; }
.stepper input { width: 56px; height: 44px; border: 0; text-align: center; font-weight: 700; font-size: 1.0625rem;
                 background: transparent; font-variant-numeric: tabular-nums; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.stepper.has-qty { border-color: var(--leaf); }
.stepper.has-qty input { color: var(--leaf-deep); }

/* ---------- cart ---------- */
.cart-lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.cart-line { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 12px 14px; }
.cart-line-top { display: flex; justify-content: space-between; gap: 10px; }
.cart-line-name { font-weight: 600; }
.cart-line-mode { color: var(--ink-soft); font-size: .875rem; }
.cart-line-total { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.cart-line-bottom { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 10px; }
.cart-line-remove { min-height: 44px; padding: 0 10px; border: 0; background: none; color: var(--beet); font-weight: 600; font-size: .9375rem; }
.cart-line.is-missing { border-color: var(--beet); }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; margin: 16px 0 20px;
              padding: 14px 16px; border-radius: var(--radius-m); background: var(--slate); color: var(--chalk); }
.cart-total strong { font-size: 1.375rem; font-variant-numeric: tabular-nums; }

/* ---------- orders ---------- */
.orders-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.order-card {
  width: 100%; text-align: left; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m); padding: 14px;
}
.order-card-title { font-weight: 600; }
.order-card-sub { color: var(--ink-soft); font-size: .875rem; }
.order-card-total { font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.status { justify-self: end; align-self: start; font-size: .8125rem; font-weight: 700; padding: 3px 10px; border-radius: 999px;
          background: var(--leaf-soft); color: var(--leaf-deep); white-space: nowrap; }
.status-draft_pending_validation { background: var(--apricot-soft); color: #7A4F00; }
.status-pending { background: #E3ECF3; color: #284B63; }
.status-cancelled { background: var(--beet-soft); color: var(--beet); }
.status-delivered, .status-invoiced { background: #E7E9E4; color: var(--ink-soft); }

.back { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; padding: 0 8px 0 0;
        border: 0; background: none; color: var(--leaf-deep); font-weight: 600; margin-bottom: 8px; }
.od-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.od-head h1 { margin: 0; }
.od-items { list-style: none; margin: 0 0 4px; padding: 0; background: var(--paper);
            border: 1px solid var(--line); border-radius: var(--radius-m); }
.od-items li { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-top: 1px solid var(--line); }
.od-items li:first-child { border-top: 0; }
.od-items small { display: block; color: var(--ink-soft); font-size: .875rem; }
.od-items .num { font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
.od-note { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-m);
           padding: 12px 14px; white-space: pre-line; margin-top: 12px; }
.od-note b { display: block; font-size: .875rem; color: var(--ink-soft); font-weight: 600; }
.od-locked { color: var(--ink-soft); font-size: .9375rem; text-align: center; margin-top: 16px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + var(--safe-bottom)); padding-bottom: var(--safe-bottom);
  background: var(--paper); border-top: 1px solid var(--line);
}
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
       border: 0; background: none; color: var(--ink-soft); font-size: .75rem; font-weight: 600; min-height: 48px; }
.tab span { position: relative; }
.tab[aria-current="page"] { color: var(--leaf); }
.tab[aria-current="page"] svg { stroke-width: 2.4; }
.badge { position: absolute; top: -30px; right: -18px; min-width: 20px; height: 20px; padding: 0 5px;
         border-radius: 999px; background: var(--apricot); color: var(--ink); font-size: .75rem; line-height: 20px; text-align: center; }

/* ---------- toast & loader ---------- */
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 12px); z-index: 50;
  max-width: 480px; margin: 0 auto; padding: 14px 16px; border-radius: var(--radius-m);
  background: var(--slate); color: var(--chalk); font-weight: 500; text-align: center;
}
.toast.is-error { background: var(--beet); color: #fff; }
.login:not([hidden]) ~ .toast { bottom: calc(16px + var(--safe-bottom)); }
.loader { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(238,242,234,.6); }
.loader span { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--leaf-soft); border-top-color: var(--leaf);
               animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition: none !important; }
}

@media (min-width: 720px) {
  .cat-list { display: grid; grid-template-columns: 1fr 1fr; }
  .cat-group-title { grid-column: 1 / -1; }
}
