:root {
  --bg: #f6f1ea;
  --card: #ffffff;
  --ink: #2b2118;
  --muted: #8a7a6b;
  --line: #eadfd2;
  --brand: #6b3f24;
  --brand-2: #a8693f;
  --ok: #2f7d4f;
  --ok-bg: #e6f4ea;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --warn-bg: #fff4dc;
  --radius: 20px;
  --shadow: 0 10px 30px rgba(60, 35, 15, .10);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 17px; line-height: 1.4;
  min-height: 100vh; min-height: 100dvh;
}
.wrap { max-width: 460px; margin: 0 auto; padding: 20px 16px 40px; }
.top { display: flex; align-items: center; gap: 12px; margin: 4px 0 20px; }
.logo {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  display: grid; place-items: center; color: #fff; font-size: 22px;
}
.top h1 { font-size: 20px; margin: 0; line-height: 1.2; }
.top .sub { color: var(--muted); font-size: 14px; }
.top .spacer { flex: 1; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 20px; margin-bottom: 16px; }
.panel h2 { margin: 0 0 6px; font-size: 22px; }
.panel p { margin: 0 0 14px; color: var(--muted); }
.hidden { display: none !important; }

label.field { display: block; margin-bottom: 14px; }
label.field span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; }
input.inp {
  width: 100%; font: inherit; font-size: 19px; padding: 15px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: #fffdfa; color: var(--ink); outline: none;
  transition: border-color .15s;
}
input.inp:focus { border-color: var(--brand-2); }
input.inp.big { font-size: 30px; font-weight: 700; text-align: center; letter-spacing: .5px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  font: inherit; font-size: 18px; font-weight: 650; padding: 16px; border-radius: 16px; border: 0;
  background: var(--brand); color: #fff; cursor: pointer; transition: transform .08s, opacity .15s;
  text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn.light { background: #f1e7dc; color: var(--brand); }
.btn.ok { background: var(--ok); }
.btn.danger { background: var(--bad); }
.btn.small { width: auto; font-size: 15px; padding: 9px 14px; border-radius: 12px; }
.btn + .btn { margin-top: 10px; }
.link { background: none; border: 0; color: var(--brand-2); font: inherit; font-size: 15px; padding: 8px; cursor: pointer; text-decoration: underline; }

/* Сообщения: что случилось + что делать */
.msg { border-radius: 14px; padding: 13px 15px; margin-bottom: 14px; font-size: 16px; }
.msg b { display: block; margin-bottom: 2px; }
.msg.bad { background: var(--bad-bg); color: #7a1a14; }
.msg.ok { background: var(--ok-bg); color: #1d5233; }
.msg.warn { background: var(--warn-bg); color: #6b4a00; }

/* Карта гостя */
.loyalty {
  border-radius: 24px; padding: 22px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 120% at 100% 0%, #c08552 0%, #6b3f24 55%, #3d2314 100%);
  box-shadow: 0 16px 40px rgba(60, 35, 15, .28); margin-bottom: 16px;
}
.loyalty .who { font-size: 15px; opacity: .85; }
.loyalty .bal { font-size: 44px; font-weight: 800; margin: 6px 0 2px; line-height: 1.1; }
.loyalty .bal small { font-size: 22px; font-weight: 600; opacity: .9; }
.loyalty .hint { font-size: 14px; opacity: .85; }
.qrbox { background: #fff; border-radius: 18px; padding: 14px; margin-top: 18px; text-align: center; }
.qrbox img, .qrbox svg { width: 100%; max-width: 260px; height: auto; display: block; margin: 0 auto; image-rendering: pixelated; }
.qrbox .code { color: var(--ink); font-family: ui-monospace, Menlo, monospace; font-size: 15px; letter-spacing: 2px; margin-top: 8px; }

/* Список операций */
.hist { list-style: none; margin: 0; padding: 0; }
.hist li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.hist li:last-child { border-bottom: 0; }
.hist .ic { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex: none; font-size: 18px; }
.hist .ic.plus { background: var(--ok-bg); color: var(--ok); }
.hist .ic.minus { background: #f6e6da; color: var(--brand); }
.hist .ic.back { background: #eee; color: #666; }
.hist .t { flex: 1; min-width: 0; }
.hist .t .a { font-weight: 650; }
.hist .t .d { font-size: 13px; color: var(--muted); }
.hist .sum { font-weight: 700; white-space: nowrap; }
.hist .sum.plus { color: var(--ok); }
.hist .strike { text-decoration: line-through; opacity: .55; }
.empty { color: var(--muted); text-align: center; padding: 10px 0; }

/* Переключатель вместо select */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1e7dc; padding: 5px; border-radius: 16px; margin-bottom: 16px; }
.seg button { font: inherit; font-weight: 650; font-size: 16px; padding: 12px 8px; border: 0; border-radius: 12px; background: transparent; color: var(--brand); cursor: pointer; }
.seg button.on { background: #fff; box-shadow: 0 2px 8px rgba(60, 35, 15, .12); }

/* Клавиатура PIN */
.dots { display: flex; justify-content: center; gap: 14px; margin: 10px 0 22px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--brand-2); }
.dots i.on { background: var(--brand-2); }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.pad button { font: inherit; font-size: 26px; font-weight: 600; padding: 16px 0; border: 0; border-radius: 16px; background: #f6efe7; color: var(--ink); cursor: pointer; }
.pad button:active { background: #eadccc; }
.pad button.fn { font-size: 16px; color: var(--muted); background: transparent; }

/* Гость, найденный кассиром */
.guest { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.guest .av { width: 50px; height: 50px; border-radius: 50%; background: #f1e7dc; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 20px; flex: none; }
.guest .nm { font-weight: 700; font-size: 19px; }
.guest .ph { color: var(--muted); font-size: 14px; }
.guest .bl { margin-left: auto; text-align: right; }
.guest .bl b { display: block; font-size: 22px; }
.guest .bl span { font-size: 12px; color: var(--muted); }
.preview { text-align: center; font-size: 17px; margin: -4px 0 14px; color: var(--muted); }
.preview b { color: var(--ok); font-size: 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -4px 0 14px; }
.chips button { font: inherit; font-size: 15px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--brand); cursor: pointer; }
.found { list-style: none; padding: 0; margin: 0; }
.found li { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; cursor: pointer; }
.found li:last-child { border-bottom: 0; }

/* Камера */
.cam { position: fixed; inset: 0; background: #000; z-index: 50; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; }
.cam .frame { position: absolute; left: 50%; top: 45%; width: 70vw; max-width: 320px; aspect-ratio: 1; transform: translate(-50%, -50%); border: 4px solid rgba(255,255,255,.9); border-radius: 24px; box-shadow: 0 0 0 9999px rgba(0,0,0,.45); }
.cam .bar { position: absolute; bottom: 0; left: 0; right: 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); text-align: center; color: #fff; }
.cam .bar p { margin: 0 0 12px; }

/* Окно подтверждения */
.sheet-bg { position: fixed; inset: 0; background: rgba(30, 18, 8, .45); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 460px; border-radius: 24px 24px 0 0; padding: 24px 20px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { margin: 0 0 8px; font-size: 21px; }
.sheet p { margin: 0 0 18px; color: var(--muted); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 13px 20px; border-radius: 14px; z-index: 70; font-size: 16px; max-width: 90vw; box-shadow: var(--shadow); }
.foot { text-align: center; color: var(--muted); font-size: 13px; margin-top: 24px; }
.spin { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--brand-2); animation: sp 0.8s linear infinite; margin: 30px auto; }
@keyframes sp { to { transform: rotate(360deg); } }
