:root {
  --bg: #f7f3ef; --card: #fff; --ink: #221b18; --muted: #6f625c; --line: #e3dad3;
  --accent: #8a1c1c; --accent-ink: #fff; --warn-bg: #fff4d6; --ok-bg: #e4f3e6; --err-bg: #fde4e1; --low: #b3261e;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font-size: 17px; }
body { margin: 0; background: var(--bg); color: var(--ink); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; line-height: 1.45; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: .4rem 0 1rem; text-wrap: balance; }
h2 { font-size: 1.15rem; margin: 1.6rem 0 .6rem; }
main { max-width: 1200px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); font-weight: 400; }
.low { color: var(--low); font-weight: 600; }
.nowrap { white-space: nowrap; }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; padding: 8px 16px; background: var(--accent); color: var(--accent-ink); }
.top a, .top .link { color: inherit; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.15rem; }
.top nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.top nav a { padding: 10px 12px; border-radius: 8px; }
.top nav a:hover, .top nav a:focus-visible { background: rgba(255,255,255,.18); }
@media (max-width: 720px) { .top nav { order: 3; flex-basis: 100%; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; } .who { margin-left: auto; } }
.who { display: flex; align-items: center; gap: 12px; margin: 0; }
.link { background: none; border: 0; font: inherit; cursor: pointer; text-decoration: underline; padding: 10px 0; }

.msg { padding: 12px 14px; border-radius: 10px; background: var(--ok-bg); margin: 0 0 12px; }
.msg.error { background: var(--err-bg); } .msg.warning { background: var(--warn-bg); }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 48px; padding: 8px 18px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn:focus-visible, .product:focus-visible, .chip:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #e0a23c; outline-offset: 2px; }
.btn.primary, .btn.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--low); }
.btn.big { min-height: 56px; }
.btn.huge { min-height: 76px; font-size: 1.15rem; }
.btn.small { min-height: 40px; padding: 4px 12px; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.stats { margin-bottom: 14px; }
.stats div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.stats span, .stats small { display: block; color: var(--muted); font-size: .85rem; }
.stats strong { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.badge { background: var(--low); color: #fff; border-radius: 99px; padding: 1px 9px; font-size: .85rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.narrow { max-width: 520px; margin: 12px auto; }
.card > .btn, .narrow > .btn, .cart form > .btn { width: 100%; margin-top: 10px; }
label { display: block; margin-bottom: 14px; font-weight: 600; }
label small { display: block; font-weight: 400; color: var(--muted); margin-top: 4px; }
label small.err { color: var(--low); font-weight: 600; }
label.check { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
label.check input { order: -1; width: 26px; height: 26px; }
label.check small { flex-basis: 100%; }
input:not([type=checkbox]):not([type=hidden]), select, textarea { display: block; width: 100%; min-height: 50px; margin-top: 5px; padding: 8px 12px;
  font: inherit; border: 1px solid #b9aca3; border-radius: 10px; background: #fff; color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; margin-bottom: 14px; }
.filters label { margin: 0; font-size: .9rem; }
.filters input, .filters select { min-width: 150px; }
.exports { display: flex; gap: 8px; margin-left: auto; }

.scroll { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .95rem; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totals td { font-weight: 700; border-top: 2px solid var(--ink); }
.rowact { white-space: nowrap; text-align: right; }
.rowact form { display: inline; }
.details { font-size: .85rem; word-break: break-word; min-width: 260px; }
.pager { display: flex; align-items: center; gap: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.chip { min-height: 46px; padding: 8px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; }
.chip.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.product { display: flex; flex-direction: column; gap: 4px; min-height: 96px; padding: 12px; text-align: left; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink); font: inherit; cursor: pointer; text-decoration: none; }
.product:hover { border-color: var(--accent); }
.product strong { font-size: 1.02rem; line-height: 1.2; }
.product span { color: var(--muted); font-size: .9rem; }
.product small { margin-top: auto; color: var(--muted); font-size: .78rem; }
.product small.low { color: var(--low); }

.pos { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
@media (min-width: 900px) { .pos { grid-template-columns: 1fr 360px; } .cart { position: sticky; top: 12px; } }
.cart h2 { margin-top: 0; }
#cart { list-style: none; margin: 0; padding: 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; width: 100%; min-height: 56px; padding: 8px 4px; border: 0; border-bottom: 1px solid var(--line);
  background: none; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.line strong { grid-row: 1 / span 2; grid-column: 2; align-self: center; font-variant-numeric: tabular-nums; }
.line .muted { font-size: .85rem; }
.total { display: flex; justify-content: space-between; align-items: baseline; margin: 14px 0; }
.total strong { font-size: 1.7rem; font-variant-numeric: tabular-nums; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.pay .btn { min-height: 60px; }

dialog { border: 0; border-radius: 16px; padding: 18px; width: min(380px, 94vw); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin: 0; }
dialog p { margin: 2px 0; }
.display { font-size: 2.2rem; font-weight: 700; text-align: right; padding: 8px 12px; margin: 10px 0 2px; border: 1px solid var(--line); border-radius: 10px; font-variant-numeric: tabular-nums; }
.line-total { text-align: right; min-height: 1.5em; font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
.keypad .btn { min-height: 62px; font-size: 1.4rem; }
.row { display: flex; gap: 8px; } .row .btn { flex: 1; min-height: 58px; }
