html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 16px; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; touch-action: manipulation; }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#view:focus { outline: none; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }
.app { height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; padding: 10px 16px 12px; padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); padding-bottom: max(12px, env(safe-area-inset-bottom)); }
.top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.brand { font-family: var(--f-display); font-weight: 700; font-size: 24px; letter-spacing: .04em; text-transform: uppercase; }
.brand small { font-family: var(--f-body); font-weight: 500; font-size: 13px; letter-spacing: 0; text-transform: none; color: var(--muted); margin-left: 8px; }
.spacer { flex: 1; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); font-weight: 500; font-size: 15px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.chip.off .dot, .chip.pend .dot { background: var(--warn); }
.chip.off { border-color: var(--warn); }
.themebtn { min-height: 44px; padding: 0 14px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); font-weight: 500; font-size: 15px; }
.note { font-size: 14px; color: var(--muted); margin: 0; }

#view.pos { min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; }
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.tabwrap { flex: 0 0 auto; display: flex; align-items: stretch; border-radius: 12px; background: var(--panel2); border: 2px solid transparent; min-width: 170px; }
.tabwrap.sel { background: var(--panel); border-color: var(--accent); }
.tab { flex: 1; min-height: 56px; padding: 6px 4px 6px 12px; text-align: left; display: grid; grid-template-columns: 1fr auto; column-gap: 10px; align-items: center; }
.tab .t-no { font-family: var(--f-display); font-weight: 600; font-size: 20px; line-height: 1.1; }
.tab .t-sum { font-weight: 600; font-size: 17px; text-align: right; }
.tab .t-meta { grid-column: 1 / 3; font-size: 13px; color: var(--muted); }
.tag-eb { color: var(--eb); font-weight: 600; }
.tab-x { min-width: 44px; border-radius: 10px; color: var(--muted); font-size: 20px; }
.tab-x.arm { background: var(--bad); color: #fff; font-size: 13px; padding: 0 8px; }
.tab-new { flex: 0 0 auto; min-width: 60px; min-height: 60px; border-radius: 12px; border: 2px dashed var(--line); font-size: 28px; color: var(--muted); }

.main { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 12px; }
.left { min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.cats { display: flex; gap: 8px; overflow-x: auto; flex: 0 0 auto; }
.cat { flex: 0 0 auto; min-height: 48px; padding: 0 18px; border-radius: 24px; background: var(--panel2); font-weight: 600; }
.cat[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.grid { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 112px; gap: 10px; align-content: start; }
.grid.block { display: block; }
.prod { position: relative; text-align: left; padding: 12px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.prod:active { transform: scale(.97); }
.p-name { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; line-height: 1.15; }
.p-price { font-family: var(--f-display); font-weight: 600; font-size: 22px; color: var(--accent); }
.p-cnt { position: absolute; top: 8px; right: 8px; min-width: 28px; height: 28px; padding: 0 8px; border-radius: 14px; background: var(--accent); color: var(--accent-fg); font-weight: 700; display: grid; place-items: center; font-size: 15px; }

.cart { min-height: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.cart-head { padding: 10px 16px 6px; display: flex; align-items: center; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; }
.cart-head h2 { margin: 0; font-family: var(--f-display); font-size: 24px; font-weight: 700; letter-spacing: .02em; }
.cart-head .acts { display: flex; gap: 4px; flex-wrap: wrap; }
.link { color: var(--muted); text-decoration: underline; min-height: 44px; padding: 0 6px; font-size: 14px; }
.link.arm { color: var(--bad); font-weight: 600; }
.link:disabled { opacity: .4; cursor: default; text-decoration: none; }
.lines { flex: 1; min-height: 0; overflow-y: auto; padding: 0 12px; display: flex; flex-direction: column; gap: 6px; }
.empty { margin: auto; text-align: center; color: var(--muted); padding: 20px; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 8px 10px; border-radius: 12px; background: var(--panel2); }
.l-name { font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.l-sum { font-weight: 600; text-align: right; font-size: 17px; }
.l-ctl { grid-column: 1 / 3; display: flex; align-items: center; gap: 8px; }
.qty { display: inline-flex; align-items: center; background: var(--panel); border-radius: 22px; border: 1px solid var(--line); }
.qty button { width: 44px; height: 44px; font-size: 24px; border-radius: 22px; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; font-size: 18px; }
.eb-btn { margin-left: auto; min-height: 44px; padding: 0 14px; border-radius: 22px; border: 2px solid var(--line); font-weight: 600; font-size: 15px; color: var(--muted); }
.eb-btn[aria-pressed="true"] { background: var(--eb-soft); border-color: var(--eb); color: var(--eb); }
.line.is-eb { background: var(--eb-soft); }
.who { margin: 8px 12px 0; padding: 10px 12px; border-radius: 12px; background: var(--eb-soft); border: 1px solid var(--eb); display: flex; align-items: center; gap: 10px; color: var(--eb); font-weight: 600; }
.who select { flex: 1; min-width: 0; min-height: 44px; border-radius: 10px; border: 1px solid var(--eb); background: var(--panel); color: var(--fg); padding: 0 10px; }
.pay { border-top: 1px solid var(--line); padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.sums { display: grid; grid-template-columns: 1fr auto; row-gap: 2px; font-size: 15px; color: var(--muted); }
.sums .r { text-align: right; }
.sums .eb { color: var(--eb); }
.total { display: flex; justify-content: space-between; align-items: baseline; }
.total span:first-child { font-weight: 600; font-size: 16px; }
.big { font-family: var(--f-display); font-weight: 700; font-size: 44px; line-height: 1; }
.given { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.given button { min-height: 52px; border-radius: 12px; background: var(--panel2); border: 2px solid transparent; font-weight: 700; font-size: 18px; white-space: nowrap; padding: 0 2px; }
.given button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.change { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.change .v { font-family: var(--f-display); font-size: 30px; font-weight: 700; }
.change .v.low { color: var(--bad); }
.go { min-height: 64px; border-radius: 14px; background: var(--accent); color: var(--accent-fg); font-family: var(--f-display); font-weight: 700; font-size: 26px; letter-spacing: .04em; text-transform: uppercase; }
.go.eb { background: var(--eb); color: var(--bg); }
.go:disabled { opacity: .35; cursor: not-allowed; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; max-width: 560px; display: flex; flex-direction: column; gap: 12px; }
.card h1, .card h3 { margin: 0; font-family: var(--f-display); font-size: 26px; }
.card p { margin: 0; }
#view.center { overflow-y: auto; display: flex; justify-content: center; align-items: flex-start; padding: 8px 0; }
#view.center .card { width: 100%; }
.f { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); font-weight: 500; }
.f input { min-height: 52px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--fg); padding: 0 12px; font-size: 18px; }
.kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.err { color: var(--bad); font-weight: 600; }
.sumrows { display: grid; grid-template-columns: 1fr auto; row-gap: 6px; font-size: 17px; }
.sumrows .r { text-align: right; font-weight: 600; }
.sumrows .strong { font-weight: 700; font-size: 20px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.btn2 { min-height: 56px; border-radius: 14px; background: var(--panel2); border: 1px solid var(--line); font-weight: 600; font-size: 18px; }

.toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 12px 20px; border-radius: 12px; font-weight: 600; box-shadow: 0 6px 24px rgba(0,0,0,.35); z-index: 5; max-width: calc(100% - 32px); }

@media (max-width: 899px) {
  html, body { height: auto; }
  .app { height: auto; }
  #view.pos { display: block; }
  .tabs { margin-bottom: 10px; }
  .main { grid-template-columns: minmax(0, 1fr); }
  .grid { max-height: 52vh; }
  .cart { min-height: 460px; }
  .big { font-size: 38px; }
}
@media (prefers-reduced-motion: no-preference) { .prod { transition: transform .08s; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media (max-width: 480px) { .given button { font-size: 15px; } }
.row .go { font-size: 20px; padding: 0 8px; white-space: nowrap; }
.joinrow { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.j-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.joinrow .go { width: auto; min-width: 140px; min-height: 56px; flex: none; }
