/* ===== Палитра: единственное место, где правятся цвета (согласовано на этапе 0) ===== */
:root {
  color-scheme: dark;
  --brand-mint: #13E5AF;
  --brand-red:  #FE3045;

  --bg:        #120D11;
  --surface:   #1C1419;
  --surface-2: #2A1F26;
  --line:      #3A2D35;
  --text:      #F6EEF1;
  --text-muted:#A8979F;
  --on-color:  #140D10;
  --count-opacity: .45;

  --accent: var(--brand-mint);
  --danger: #FF5A6B;

  --status-ok:      var(--brand-mint);
  --status-pending: #FFB23E;
  --status-offline: #FF5A6B;

  /* категории — цвета физических жетонов */
  --cat-cocktail:  #7F0035;  --cat-cocktail-text:  #FFFFFF;
  --cat-mocktail:  #0093A3;  --cat-mocktail-text:  #140D10;
  --cat-shot:      #4CD000;  --cat-shot-text:      #140D10;
  --cat-shotset:   #155C00;  --cat-shotset-text:   #FFFFFF;
  --cat-wine:      #FEBE5C;  --cat-wine-text:      #140D10;
  --cat-sparkling: #FFF0CC;  --cat-sparkling-text: #140D10;

  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.c-cocktail  { background: var(--cat-cocktail);  color: var(--cat-cocktail-text); }
.c-mocktail  { background: var(--cat-mocktail);  color: var(--cat-mocktail-text); }
.c-shot      { background: var(--cat-shot);      color: var(--cat-shot-text); }
.c-shotset   { background: var(--cat-shotset);   color: var(--cat-shotset-text); }
.c-wine      { background: var(--cat-wine);      color: var(--cat-wine-text); }
.c-sparkling { background: var(--cat-sparkling); color: var(--cat-sparkling-text); }
.c-other     { background: var(--surface-2);     color: var(--text); }

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  background: var(--bg); color: var(--text); height: 100%;
  overscroll-behavior: none; -webkit-text-size-adjust: 100%;
}
body { font: 16px/1.4 var(--font); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }

.screen {
  position: fixed; inset: 0; display: flex; flex-direction: column;
  padding-top: var(--safe-top); padding-bottom: var(--safe-bottom);
  background: var(--bg);
}

/* ===== общие элементы ===== */
.logo-micro { height: 22px; width: auto; display: block; flex: none; }
.btn-primary {
  height: 56px; border: 0; border-radius: 14px; background: var(--accent); color: var(--on-color);
  font-weight: 700; font-size: 18px; width: 100%;
}
.btn-primary:disabled { opacity: .5; }
.btn-ghost {
  min-height: 48px; border-radius: 12px; background: transparent; border: 1px solid var(--line);
  color: var(--text-muted); font-size: 15px; padding: 0 16px;
}
.btn-text { background: none; border: 0; color: var(--text-muted); font-size: 14px; padding: 10px 12px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; color: var(--text-muted); }
.field input {
  height: 54px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 14px; font-size: 18px; outline: none;
}
.field input:focus { border-color: var(--accent); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }
.note { color: var(--text-muted); font-size: 14px; }

/* ===== вход ===== */
.login { justify-content: center; padding-left: 20px; padding-right: 20px; }
.login-box { width: 100%; max-width: 380px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.login-box .logo-micro { height: 34px; margin: 0 auto 8px; }
.login-box h1 { font-size: 20px; font-weight: 650; text-align: center; margin-bottom: 4px; }

/* ===== выбор бара ===== */
.bar-head {
  height: 52px; flex: none; display: flex; align-items: center; gap: 10px; padding: 0 12px;
  border-bottom: 1px solid var(--line); background: var(--surface);
}
.bar-head .who { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tables {
  flex: 1; display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow-y: auto;
}
.table-btn {
  flex: 1; min-height: 96px; max-height: 200px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface-2); font-size: 30px; font-weight: 800; letter-spacing: -.01em;
}
.table-btn:active { border-color: var(--accent); }
.tables-foot { flex: none; display: flex; justify-content: space-between; align-items: center; padding: 8px 12px 12px; }
.btn-admin { background: none; border: 0; color: var(--text-muted); opacity: .55; font-size: 13px; padding: 12px; }

/* ===== экран продаж ===== */
.sales { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.topbar {
  height: 44px; flex: none; display: flex; align-items: center; gap: 8px;
  padding: 0 10px; background: var(--surface); border-bottom: 1px solid var(--line);
  font-size: 14px; white-space: nowrap;
}
.topbar .who { font-weight: 600; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.topbar .who .sep { color: var(--text-muted); font-weight: 400; }
.topbar .total { font-weight: 700; font-variant-numeric: tabular-nums; }
.status {
  font-size: 12px; font-weight: 600; border-radius: 999px; padding: 3px 8px; flex: none;
  display: inline-flex; align-items: center; gap: 5px; border: 0;
}
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.ok { color: var(--status-ok); background: transparent; padding-left: 2px; }
.status.pending { background: var(--status-pending); color: var(--on-color); }
.status.offline { background: var(--status-offline); color: var(--on-color); }

.grid {
  flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; grid-auto-rows: 1fr;
  gap: 8px; padding: 8px; position: relative; touch-action: manipulation;
}
.cat {
  position: relative; border: 0; border-radius: var(--radius); min-height: 0;
  display: flex; flex-direction: column; justify-content: space-between; align-items: stretch;
  padding: 14px 14px 10px; text-align: left; overflow: hidden;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.cat .name { font-size: clamp(19px, 6.2vw, 30px); font-weight: 800; line-height: 1.05; letter-spacing: -.01em; }
.cat .price { font-size: clamp(14px, 4.4vw, 20px); font-weight: 600; opacity: .8; font-variant-numeric: tabular-nums; margin-top: 2px; }
.cat .count {
  align-self: flex-end; opacity: var(--count-opacity); font-weight: 700; line-height: 1;
  font-size: clamp(34px, 12vw, 64px); font-variant-numeric: tabular-nums;
}
.cat::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.95); background: rgba(255,255,255,.18); opacity: 0;
}
.cat.flash::after { animation: flash 220ms ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }
.cat:disabled { filter: grayscale(.6) brightness(.6); }

.ended {
  position: absolute; inset: 8px; border-radius: var(--radius); background: rgba(18,13,17,.88);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center;
  padding: 20px;
}
.ended b { font-size: 24px; }

.undo-zone { height: 64px; flex: none; padding: 0 8px; display: flex; align-items: center; }
.undo {
  width: 100%; height: 52px; border-radius: 14px; background: var(--surface-2);
  border: 1px solid var(--line); display: flex; align-items: center; overflow: hidden; position: relative;
}
.undo .stripe { width: 8px; align-self: stretch; flex: none; }
.undo .txt { flex: 1; padding: 0 12px; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.undo .txt .sep { color: var(--text-muted); font-weight: 400; }
.undo .act {
  height: 100%; padding: 0 18px; display: flex; align-items: center; font-weight: 700; color: var(--accent);
  font-size: 16px; background: none; border: 0; border-left: 1px solid var(--line);
}
.undo .timer { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 100%; transform-origin: left; }
.undo .timer.run { animation: undo-timer 3s linear forwards; }
@keyframes undo-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.footer { height: 52px; flex: none; display: flex; gap: 8px; padding: 0 8px 8px; }
.hold {
  flex: 1; position: relative; overflow: hidden; border-radius: 12px; background: transparent;
  border: 1px solid var(--line); color: var(--text-muted); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.15;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.hold i { font-style: normal; font-size: 10.5px; opacity: .75; }
.hold .fill { position: absolute; inset: 0; background: var(--surface-2); transform: scaleX(0); transform-origin: left; z-index: -1; }
.hold { isolation: isolate; }
.hold.holding .fill { transform: scaleX(1); transition: transform var(--hold-ms, 800ms) linear; }

.toast {
  position: fixed; left: 12px; right: 12px; top: calc(var(--safe-top) + 52px); z-index: 50;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.5);
}

/* ===== закрытие смены ===== */
.close { overflow-y: auto; }
.close-body { width: 100%; max-width: 460px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.close-title { font-size: 18px; font-weight: 700; }
.close-title .sep { color: var(--text-muted); font-weight: 400; }
.summary { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.summary td { padding: 10px 4px; border-bottom: 1px solid var(--line); font-size: 17px; }
.summary td.n, .summary td.sum { text-align: right; white-space: nowrap; }
.summary td.n { width: 60px; color: var(--text-muted); }
.summary .dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: 1px; }
.summary tr.cancels td { color: var(--text-muted); font-size: 15px; }
.summary tr.total td { font-weight: 800; font-size: 20px; border-bottom: 0; }
.summary tr.total td.n { color: var(--text); }
.sending { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.sending b { font-size: 17px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.done-mark { color: var(--status-ok); font-weight: 700; }

/* ===== модальное окно ===== */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.modal-box { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.modal-box h2 { font-size: 18px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.hold { touch-action: none; }

@media (max-width: 360px) {
  .topbar { gap: 6px; padding: 0 8px; font-size: 13px; }
  .topbar .logo-micro { height: 18px; }
  .status { font-size: 11px; padding: 2px 6px; gap: 4px; }
  .status::before { width: 6px; height: 6px; }
}

/* ===== служебное ===== */
.svc-hold { touch-action: none; -webkit-user-drag: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.svc-info { font-size: 14px; color: var(--text-muted); display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.svc-info b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; word-break: break-all; }

/* ===== нажатие на жетон и меню «− число +» ===== */
.cat { transition: transform 90ms ease-out, filter 90ms ease-out; }
.cat.pressed { transform: scale(.97); filter: brightness(1.08); }
.cat { touch-action: none; }

.ed-box { gap: 16px; padding: 0 0 16px; overflow: hidden; }
.ed-box > .row, .ed-box > .ed-current, .ed-box > .ed-note { margin: 0 16px; }
.ed-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 16px; }
.ed-name { font-size: 24px; font-weight: 800; letter-spacing: -.01em; }
.ed-price { font-size: 16px; font-weight: 600; opacity: .8; }
.ed-row { display: grid; grid-template-columns: minmax(60px, 84px) minmax(0, 1fr) minmax(60px, 84px); align-items: center; gap: 10px; padding: 4px 16px; }
.ed-btn {
  height: 84px; border-radius: 18px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 44px; font-weight: 700; line-height: 1; color: var(--text); touch-action: manipulation;
  user-select: none; -webkit-user-select: none;
}
.ed-btn:active { background: var(--line); }
.ed-btn:disabled { opacity: .35; }
.ed-value { min-width: 0; text-align: center; font-size: clamp(40px, 15vw, 64px); font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1; }
.ed-value.plus { color: var(--brand-mint); }
.ed-value.minus { color: var(--status-offline); }
.ed-current { text-align: center; color: var(--text-muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.ed-note { text-align: center; color: var(--status-pending); font-size: 13px; min-height: 0; }
.ed-note:empty { display: none; }
.summary td.n { width: 80px; color: var(--text); font-weight: 700; }
.summary tr.empty td { color: var(--text-muted); }

@media (max-width: 360px) {
  .ed-box .btn-primary, .ed-box .btn-ghost { font-size: 16px; padding: 0 8px; }
  .ed-btn { height: 72px; font-size: 38px; }
  .ed-name { font-size: 21px; }
}
