/* ZvrShop - mobile-first, one column, large touch targets. */

:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --text: #1d2321;
  --muted: #6b7470;
  --line: #e2ded6;
  --accent: #1f6f5c;
  --accent-text: #ffffff;
  --accent-soft: #dcebe5;
  --danger: #b3261e;
  --checked: #9aa29e;
  --radius: 12px;
  --tabs-h: 60px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2321;
    --text: #e8ece9;
    --muted: #94a09a;
    --line: #2d3532;
    --accent: #4fb596;
    --accent-text: #0d1a15;
    --accent-soft: #23362f;
    --danger: #f2867e;
    --checked: #66706b;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + var(--safe-b) + 88px);
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* top bar */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 20px; margin: 0; letter-spacing: .2px; }
.topbar .user { margin-left: auto; color: var(--muted); font-size: 13px; text-decoration: none; }
.sync-state {
  font-size: 12px; padding: 2px 8px; border-radius: 99px;
  background: #fbe3c4; color: #6b4300;
}

main { max-width: 640px; margin: 0 auto; padding: 12px 12px 0; }

/* buttons and inputs */
.btn {
  appearance: none; border: 1px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 10px; padding: 0 16px; min-height: 44px; font: inherit; font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.btn.big { width: 100%; min-height: 54px; font-size: 18px; border-radius: var(--radius); }
.btn.round { width: 44px; padding: 0; font-size: 22px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0 4px; }

input[type=text], input[type=search], input[type=date], input[type=password], input:not([type]) {
  width: 100%; min-height: 46px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: inherit;
}
input:focus-visible, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 12px 0 0; }
label input { margin-top: 4px; color: var(--text); font-size: 17px; }

/* add form */
.add-form { display: grid; grid-template-columns: 1fr 72px auto; gap: 8px; margin-bottom: 8px; }
.add-form input { min-height: 50px; }
.add-form .btn { min-height: 50px; }

/* list */
.group { margin-top: 14px; }
.group h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted); margin: 0 4px 6px; font-weight: 700;
}
.items { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.item { display: flex; align-items: stretch; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; }
.item .check {
  flex: 1; display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: 8px 12px 8px 14px;
  background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.item .box {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  border: 2px solid var(--muted); display: grid; place-items: center;
}
.item .box svg { width: 20px; height: 20px; stroke: var(--accent-text); stroke-width: 3; fill: none; visibility: hidden; }
.item .label { display: flex; flex-direction: column; min-width: 0; }
.item .name { font-size: 18px; font-weight: 500; overflow-wrap: anywhere; }
.item .note { font-size: 14px; color: var(--muted); }
.item .qty {
  flex: none; min-width: 72px; padding: 0 14px;
  background: none; border: 0; border-left: 1px solid var(--line);
  color: var(--text); font: inherit; font-weight: 600; cursor: pointer;
}
.item.checked .box { background: var(--accent); border-color: var(--accent); }
.item.checked .box svg { visibility: visible; }
.item.checked .name { text-decoration: line-through; color: var(--checked); }
.item.checked .qty { color: var(--checked); }
.item.pending .box { border-style: dashed; }

.cart h2 { color: var(--accent); }

.finish-bar {
  position: fixed; left: 0; right: 0; z-index: 4;
  bottom: calc(var(--tabs-h) + var(--safe-b));
  padding: 10px 12px; background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.finish-bar .btn { max-width: 616px; margin: 0 auto; display: block; }

.empty { text-align: center; padding: 48px 16px; }
.empty p { margin: 4px 0; }

/* catalog */
.catalog-tools { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.prod { display: flex; align-items: center; border-top: 1px solid var(--line); }
.prod:first-child { border-top: 0; }
.prod .open {
  flex: 1; min-height: 58px; padding: 8px 14px; text-align: left;
  background: none; border: 0; color: inherit; font: inherit; cursor: pointer; min-width: 0;
}
.prod .name { font-weight: 500; }
.prod .meta { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.prod .add {
  flex: none; width: 56px; align-self: stretch;
  background: none; border: 0; border-left: 1px solid var(--line);
  color: var(--accent); font-size: 26px; cursor: pointer;
}
.prod .add.on { font-size: 15px; font-weight: 700; }

/* bottom tabs */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  height: calc(var(--tabs-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  display: flex; background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12px; font-weight: 600; position: relative;
}
.tab svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tab.active { color: var(--accent); }
.tab .count {
  position: absolute; top: 6px; left: calc(50% + 8px);
  background: var(--accent); color: var(--accent-text); border-radius: 99px;
  font-size: 11px; padding: 1px 6px; min-width: 18px; text-align: center;
}

/* dialogs */
dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  border: 0; border-radius: 16px; padding: 18px 18px 14px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin: 0 0 6px; font-size: 20px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; margin-top: 18px; align-items: center; }
.actions .spacer { flex: 1; }
.row { display: grid; grid-template-columns: 1fr 1fr 96px; gap: 8px; }
.qty-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.qty-row input { width: 100px; text-align: center; margin: 0; }
.history { margin-top: 14px; font-size: 14px; }
.history h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); margin: 0 0 4px; }
.history ul { list-style: none; margin: 0; padding: 0; max-height: 160px; overflow: auto; }
.history li { display: flex; justify-content: space-between; padding: 4px 0; border-top: 1px solid var(--line); }

/* toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(var(--tabs-h) + var(--safe-b) + 84px);
  max-width: calc(100vw - 24px); padding: 12px 16px; border-radius: 12px;
  background: #222826; color: #fff; box-shadow: 0 6px 24px rgb(0 0 0 / .25);
  display: flex; gap: 10px; align-items: center; font-size: 15px;
}
.toast.error { background: var(--danger); }

/* login */
.login-page { padding: 0; display: grid; place-items: center; min-height: 100dvh; }
.login-box { width: min(380px, calc(100vw - 32px)); text-align: center; }
.login-box form { text-align: left; }
.login-box .btn { margin-top: 18px; }
.login-box pre, .login-box code { background: var(--surface); padding: 8px; border-radius: 8px; display: block; overflow-x: auto; text-align: left; }
.error { color: var(--danger); font-weight: 600; }

@media (min-width: 700px) {
  body { padding-bottom: calc(var(--tabs-h) + 96px); }
}
