:root {
  --ground: #F4F5F2;
  --card: #fff;
  --ink: #17201A;
  --ink-2: #3E4A42;
  --muted: #5B665E;
  --line: #E1E5DE;
  --line-2: #EEF0EC;
  --green: #1B472E;
  --green-soft: #E5EEE8;
  --green-done: #EAF2EC;
  --brown: #6E2306;
  --brown-soft: #F3E6E0;
  --amber: #8A4B0A;
  --amber-soft: #FBEBD6;
  --red: #9B1C12;
  --red-soft: #FBE3E0;
  --blue: #1F5FAD;
  --note: #FFF8E6;
  --note-ink: #4A3A10;
  --off: #DADFD7;
}

* { box-sizing: border-box; }
/* locl изключен: Manrope с lang="bg" рисува д/т/л в български курсивни форми, които се четат трудно на бегом */
html, body { margin: 0; background: var(--ground); color: var(--ink); font-family: Manrope, system-ui, sans-serif; font-feature-settings: "locl" 0; -webkit-tap-highlight-color: transparent; }
button, input, select { font-feature-settings: "locl" 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--green); }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.sm { width: 16px; height: 16px; }

.app { max-width: 560px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

/* ---- шапка ---- */
.top { padding: 20px 20px 12px; display: flex; flex-direction: column; gap: 14px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.eyebrow { font-size: 13px; font-weight: 600; color: var(--muted); }
h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.who-btn { min-height: 44px; border-radius: 22px; border: none; background: var(--green); color: #fff; font-weight: 700; font-size: 15px; padding: 4px 16px; display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.who-btn small { font-size: 11px; font-weight: 600; opacity: .8; }
.login-form { display: flex; flex-direction: column; gap: 12px; }
.login-form input { height: 52px; border-radius: 14px; border: 1px solid var(--off); background: #fff; padding: 0 16px; font-size: 17px; }
.person-wrap { display: flex; flex-direction: column; align-items: stretch; }
.person-wrap.off .person { opacity: .45; }
.person-wrap .link-btn { align-self: center; padding: 4px; }
.icon-btn { width: 44px; height: 44px; border: none; background: transparent; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--ink); }
.icon-btn:active { background: var(--line); }

.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; background: #E6E9E3; padding: 4px; border-radius: 14px; }
.seg a { height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--ink-2); text-decoration: none; }
.seg a.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.08); font-weight: 700; color: var(--ink); }
.count { font-size: 12px; color: var(--muted); }
.seg a.on .count { background: var(--blue); color: #fff; border-radius: 10px; padding: 1px 7px; }
.sync-line { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.mailer-warn { font-size: 13px; background: var(--note); color: var(--note-ink); border-radius: 10px; padding: 8px 12px; }

/* ---- списък ---- */
.list { padding: 4px 16px 16px; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--card); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: 0 1px 2px rgba(23,32,26,.06); text-decoration: none; color: inherit; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.num { font-size: 17px; font-weight: 800; }
.ago { font-size: 13px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.who { font-size: 15px; font-weight: 600; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--ink-2); font-weight: 500; }
.meta span { display: inline-flex; align-items: center; gap: 5px; }
.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 10px; white-space: nowrap; }
.chip.online { background: var(--green-soft); color: var(--green); }
.chip.distr { background: var(--brown-soft); color: var(--brown); }
.chip.work { background: var(--amber-soft); color: var(--amber); }
.chip.ready { background: var(--green); color: #fff; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.missing { background: var(--amber-soft); color: var(--amber); }
.chip.warn { background: var(--red-soft); color: var(--red); }
.chip.note { background: var(--note); color: var(--note-ink); }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; font-weight: 600; }

/* ---- поръчка ---- */
.bar { padding: 12px 12px 8px; display: flex; align-items: center; gap: 4px; }
.bar-title { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.bar-title b { font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.box { margin: 0 16px; background: var(--card); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.list > .box { margin: 0; }
.line { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.note { background: var(--note); border-radius: 10px; padding: 10px 12px; font-size: 14px; line-height: 1.4; color: var(--note-ink); white-space: pre-line; }
.note b { font-weight: 800; }
.section-h { padding: 18px 20px 8px; display: flex; justify-content: space-between; align-items: center; }
.section-h span:first-child { font-size: 13px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.section-h .prog { font-size: 14px; font-weight: 700; color: var(--green); }
.stack { padding: 0 16px; display: flex; flex-direction: column; gap: 8px; }

.check-row { width: 100%; min-height: 64px; border: none; display: flex; align-items: center; gap: 14px; padding: 12px 14px; border-radius: 14px; background: var(--card); text-align: left; }
.check-row.done { background: var(--green-done); }
.check-row:disabled { cursor: default; }
.tick { width: 30px; height: 30px; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: #fff; border: 2px solid #9AA39C; }
.done .tick { background: var(--green); border-color: var(--green); }
.tick svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 3; }
.item-main { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.item-name { font-size: 16px; font-weight: 700; }
.item-qty { font-size: 16px; font-weight: 800; white-space: nowrap; }
.item-sub { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--ink-2); flex-wrap: wrap; }
.qty-big { color: var(--red); }
.by { font-size: 12px; font-weight: 700; color: var(--green); }
.swatch { width: 22px; height: 22px; border-radius: 6px; flex: none; border: 1.5px solid rgba(0,0,0,.12); }
.attr { background: var(--ground); border-radius: 8px; padding: 3px 8px; font-weight: 700; color: var(--ink); }
.thumb { width: 56px; height: 56px; flex: none; border-radius: 10px; border: 1px solid var(--line); padding: 0; overflow: hidden; background: #fff; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.choices.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.choice { min-height: 56px; border-radius: 14px; border: 2px solid var(--off); background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; font-weight: 700; font-size: 14px; text-align: center; }
.choice small { font-size: 12px; font-weight: 600; }
.choice.on { background: var(--green); border-color: var(--green); color: #fff; }
.choice:disabled { cursor: default; }

.footer { position: sticky; bottom: calc(76px + env(safe-area-inset-bottom)); padding: 12px 16px; background: linear-gradient(to bottom, rgba(244,245,242,0), var(--ground) 30%); }
.big-btn { width: 100%; height: 56px; border: none; border-radius: 16px; font-size: 17px; font-weight: 800; background: var(--off); color: var(--muted); }
.big-btn.go { background: var(--green); color: #fff; }
.big-btn.soft { background: #DDE9E0; color: var(--green); }
.link-btn { border: none; background: transparent; color: var(--green); font-weight: 700; font-size: 14px; padding: 12px 4px; display: inline-flex; align-items: center; gap: 6px; text-decoration: none; }
.history { padding: 0 20px 24px; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* ---- за куриер ---- */
.group { display: flex; flex-direction: column; gap: 8px; }
.group-h { display: flex; justify-content: space-between; align-items: center; padding: 0 4px; }
.group-h b { font-size: 18px; font-weight: 800; }
.group-list { background: #fff; border-radius: 16px; overflow: hidden; }
.ship-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); align-items: flex-start; width: 100%; border-left: none; border-right: none; border-top: none; background: #fff; text-align: left; }
.ship-row .tick { width: 26px; height: 26px; border-radius: 8px; margin-top: 2px; }
.ship-row.done .tick { background: var(--green); border-color: var(--green); }
.ship-main { flex: 1; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.ship-main .chip { align-self: flex-start; }
.hand-btn { height: 52px; border: none; border-radius: 14px; background: var(--green); color: #fff; font-weight: 800; font-size: 16px; }
.hand-btn:disabled { background: var(--off); color: var(--muted); }

/* ---- пликове ---- */
.legend { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.legend div { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 700; }
.tea-row { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.tea-row b { font-size: 15px; }
.size-pick { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.size-btn { min-width: 48px; height: 44px; border-radius: 12px; border: 2px solid var(--off); background: #fff; font-weight: 800; font-size: 15px; }
.size-btn.on { background: var(--green); border-color: var(--green); color: #fff; }
.color-btn { width: 44px; height: 44px; border-radius: 12px; border: 3px solid #fff; box-shadow: 0 0 0 1px var(--off); }
.color-btn.on { box-shadow: 0 0 0 3px var(--ink); }
.size-btn.auto { font-size: 13px; padding: 0 10px; }
.type-sel { height: 40px; border: 1px solid var(--off); border-radius: 10px; padding: 0 8px; background: #fff; font-size: 14px; align-self: flex-start; }
.ladder { display: flex; flex-wrap: wrap; gap: 6px; }
.rung { font-size: 13px; font-weight: 600; color: var(--ink-2); background: var(--ground); border-radius: 8px; padding: 4px 8px; }
.rung b { color: var(--ink); }
.rung.warn { background: var(--red-soft); color: var(--red); }
.size-badge { min-width: 30px; height: 24px; padding: 0 6px; border-radius: 7px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.size-badge.warn { background: var(--red); }
.part { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; color: var(--ink); }
.add-type { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.add-type input[type=text] { flex: 1; min-width: 140px; height: 44px; border: 1px solid var(--off); border-radius: 12px; padding: 0 12px; }
.add-type input[type=color] { width: 52px; height: 44px; border: 1px solid var(--off); border-radius: 12px; padding: 4px; background: #fff; }
.add-type button { height: 44px; border: none; border-radius: 12px; background: var(--green); color: #fff; font-weight: 700; padding: 0 16px; }
.search { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 14px; background: #fff; border-radius: 14px; border: 1px solid var(--off); }
.search input { flex: 1; border: none; outline: none; font-size: 16px; background: transparent; }

/* ---- вход ---- */
.login { padding: 48px 24px; display: flex; flex-direction: column; gap: 20px; align-items: stretch; }
.login h1 { text-align: center; }
.people { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.person { height: 64px; border-radius: 16px; border: 2px solid var(--off); background: #fff; font-weight: 700; font-size: 17px; }
.person.on { border-color: var(--green); background: var(--green-soft); }
.err { color: var(--red); text-align: center; font-weight: 700; min-height: 20px; }

/* ---- лента долу ---- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; height: calc(76px + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); z-index: 5; }
.tabbar[hidden] { display: none; }
.tabbar a { text-decoration: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; font-weight: 600; }
.tabbar a.on { color: var(--green); font-weight: 700; }

/* ---- голяма снимка ---- */
.lightbox { border: none; padding: 0; border-radius: 20px; max-width: min(92vw, 520px); width: 100%; background: #fff; }
.lightbox::backdrop { background: rgba(10,15,12,.6); }
.lightbox-inner { position: relative; display: flex; flex-direction: column; }
.lightbox img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff; display: block; }
.lightbox-text { padding: 14px 18px 18px; display: flex; flex-direction: column; gap: 8px; }
.lightbox-text b { font-size: 18px; }
.lightbox-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border-radius: 22px; border: none; background: rgba(255,255,255,.9); display: flex; align-items: center; justify-content: center; }

.toast { position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; font-size: 14px; z-index: 20; max-width: 90vw; }
.toast.bad { background: var(--red); }
