:root {
  --green: #1f7a3d;
  --green-d: #155c2c;
  --bg: #f5f6f4;
  --card: #ffffff;
  --ink: #16241a;
  --muted: #6b7a6f;
  --line: #e3e7e2;
  --red: #c23b3b;
  --amber: #c98a1a;
  --blue: #2b6cb0;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.4;
}
.hidden { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, button { font-size: 16px; }

/* ---- Вход ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { background: var(--card); border-radius: 16px; padding: 28px 22px; width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 12px; box-shadow: 0 6px 30px rgba(0,0,0,.08); }
.brand { font-size: 26px; font-weight: 800; color: var(--green); text-align: center; }
.brand-sub { text-align: center; color: var(--muted); margin-top: -8px; margin-bottom: 8px; }
.login-card input { padding: 15px 14px; border: 1px solid var(--line); border-radius: 10px; text-align: center; letter-spacing: .3em; font-size: 22px; }
.login-card button { padding: 15px; background: var(--green); color: #fff; border: 0; border-radius: 10px; font-weight: 700; }
.login-error { color: var(--red); font-size: 14px; text-align: center; min-height: 18px; }

/* ---- Каркас ---- */
.app { min-height: 100vh; padding-bottom: 66px; max-width: 640px; margin: 0 auto; }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  background: var(--green); color: #fff; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); }
.topbar-title { font-weight: 800; font-size: 18px; flex: 1; }
.loc-select { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 8px; padding: 6px 8px; max-width: 160px; }
.loc-select option { color: #000; }
.ghost { background: transparent; border: 0; color: #fff; font-size: 18px; opacity: .9; }
.view { padding: 12px; display: flex; flex-direction: column; gap: 12px; }

/* ---- Табы ---- */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); max-width: 640px; margin: 0 auto; }
.tab { flex: 1; background: 0; border: 0; color: var(--muted); font-size: 22px; padding: 8px 0 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; }
.tab span { font-size: 11px; }
.tab.active { color: var(--green); }

/* ---- Общие ---- */
.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.card h3 { margin: 0 0 10px; font-size: 15px; }
.muted { color: var(--muted); }
.loading { color: var(--muted); text-align: center; padding: 30px; }
.empty { color: var(--muted); text-align: center; padding: 24px; }
.row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.row:last-child { border-bottom: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 600; }
.row .sub { color: var(--muted); font-size: 13px; }
.row .num { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.pill { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: #eef3ee; color: var(--green-d); white-space: nowrap; }
.pill.warn { background: #fbf0d8; color: var(--amber); }
.pill.bad { background: #fbe0e0; color: var(--red); }
.pill.ok { background: #e4f2e8; color: var(--green-d); }

/* ---- Строка смены ---- */
.shiftbar { display: flex; gap: 10px; }
.shiftbar .kpi { flex: 1; background: var(--card); border-radius: 12px; padding: 11px 13px; box-shadow: 0 1px 4px rgba(0,0,0,.05); }
.shiftbar .kpi .label { color: var(--muted); font-size: 12px; }
.shiftbar .kpi .value { font-size: 20px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* ---- Касса ---- */
.search { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.prod-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.prod {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; text-align: left;
  display: flex; flex-direction: column; gap: 3px; min-height: 74px;
}
.prod:active { background: #eef3ee; }
.prod .pn { font-weight: 700; font-size: 15px; line-height: 1.15; }
.prod .pp { color: var(--muted); font-size: 13px; }
.prod .pq { font-size: 12px; }
.prod.out { opacity: .5; }

/* ---- Корзина продажи ---- */
.cart { position: sticky; bottom: 66px; z-index: 4; }
.cart .line { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cart .line:last-of-type { border-bottom: 0; }
.cart .line .grow { flex: 1; min-width: 0; }
.cart .line .amt { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.cart .line .x { background: #fbe0e0; color: var(--red); border: 0; border-radius: 8px; width: 34px; height: 34px; font-size: 18px; }
.cart .total { display: flex; justify-content: space-between; align-items: center; margin: 10px 2px; font-size: 20px; font-weight: 800; }
.btn { padding: 15px; background: var(--green); color: #fff; border: 0; border-radius: 12px; font-weight: 800; width: 100%; font-size: 17px; }
.btn:disabled { opacity: .45; }
.btn.sec { background: #eef3ee; color: var(--green-d); }
.btn.small { width: auto; padding: 9px 13px; font-size: 14px; font-weight: 700; }
.btn.danger { background: #fbe0e0; color: var(--red); }

/* ---- Сборка ---- */
.task { background: var(--card); border-radius: 12px; padding: 13px; box-shadow: 0 1px 4px rgba(0,0,0,.05); display: flex; align-items: center; gap: 10px; }
.task:active { background: #eef3ee; }
.task .grow { flex: 1; min-width: 0; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 7px; }
.progress i { display: block; height: 100%; background: var(--green); }
.pline { display: flex; align-items: center; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.pline:last-child { border-bottom: 0; }
.pline .grow { flex: 1; min-width: 0; }
.pline .mark { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 16px; background: #eef3ee; color: var(--muted); flex: none; }
.pline.done .mark { background: var(--green); color: #fff; }
.pline .plan { color: var(--muted); font-size: 13px; }
.pline .go { background: #eef3ee; color: var(--green-d); border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 700; }
.pline.done .go { background: #f2f5f1; color: var(--muted); }

/* ---- Клавиатура (модалка ввода веса) ---- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; display: flex; align-items: flex-end; }
.sheet { background: var(--bg); width: 100%; max-width: 640px; margin: 0 auto; border-radius: 18px 18px 0 0; padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px; }
.sheet .sh-title { font-weight: 800; font-size: 17px; }
.sheet .sh-sub { color: var(--muted); font-size: 13px; margin-top: -8px; }
.disp { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; font-size: 32px; font-weight: 800;
  text-align: right; font-variant-numeric: tabular-nums; }
.disp .u { color: var(--muted); font-size: 18px; font-weight: 600; margin-left: 6px; }
.warn-note { background: #fbf0d8; color: #7a5610; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.warn-note.gross { background: #fbe0e0; color: #7a2020; }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keys button { padding: 16px 0; font-size: 22px; font-weight: 700; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.keys button:active { background: #eef3ee; }
.keys .wide { grid-column: span 1; }
.sheet-actions { display: flex; gap: 8px; }
.sheet-actions .btn { flex: 1; }

.toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); background: #222; color: #fff;
  padding: 11px 16px; border-radius: 10px; font-size: 14px; z-index: 50; max-width: 90%; text-align: center; }
.toast.err { background: var(--red); }
.toast.warn { background: var(--amber); }
