/* ── Base ──────────────────────────────────────────────────────────────────
   Кольори — у theme.css (підключається раніше). Тут лише розмітка й компоненти. */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--tg-bg); color: var(--tg-text); font-size: 15px;
  touch-action: pan-x pan-y; -webkit-text-size-adjust: 100%;
  -webkit-user-select: none; user-select: none; overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; height: 100dvh; overflow: hidden; }
/* Нічого всередині екрана не має бути ширшим за сам екран — інакше макет «їде»
   вбік і краї кнопок зрізаються. Свій горизонтальний скрол мають лише
   схема залу, стрічка дат і сітка розкладу — вони виключені нижче. */
#app > *:not(.floor-wrap):not(.date-strip) { max-width: 100%; }

/* ── Floor ───────────────────────────────────────────────────────────────── */
.floor-wrap { flex: 0 0 auto; max-height: 50vh; overflow: auto; padding: 10px; }
.floor-canvas { position: relative; width: 100%; background: radial-gradient(circle, var(--dots) 1px, transparent 1px); background-size: 22px 22px; border-radius: var(--radius); border: 1px solid var(--line); will-change: transform, opacity; }
.table-cell { position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 7px; font-size: 11px; font-weight: 700; color: #fff; cursor: pointer; transition: background .25s ease, transform .1s, box-shadow .12s; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.table-cell.service { background: var(--service); cursor: default; font-size: 10px; font-weight: 600; opacity: .85; }
.table-cell.bookable.free { background: #3498db; }    /* вільний (синій) */
.table-cell.bookable.busy { background: var(--wait); }   /* є бронь, чекає гостя */
.table-cell.bookable.confirmed { box-shadow: inset 0 0 0 2px rgba(46,204,113,.85); }
.table-cell.bookable.late { background: var(--late); }   /* запізнюється (червоний) */
.table-cell.bookable.seated { background: var(--free); } /* гість за столом (зелений) */
.table-cell.bookable:active { transform: scale(.94); }
.table-cell.selected { box-shadow: 0 0 0 3px var(--tg-bg), 0 0 0 6px #fff; z-index: 6; }
.table-cell.circle { border-radius: 50%; }
.table-cell.oval { border-radius: 50% / 40%; }
.table-badge { display: block; font-size: 9px; font-weight: 500; opacity: .9; }

/* ── Date strip ──────────────────────────────────────────────────────────── */
.date-strip { display: flex; gap: 7px; padding: 8px 10px; overflow-x: auto; scrollbar-width: none; background: var(--tg-secondary-bg); border-top: 1px solid var(--line-soft); flex-shrink: 0; }
.date-strip::-webkit-scrollbar { display: none; }
.date-chip { position: relative; flex: 0 0 auto; min-width: 56px; padding: 6px 6px 5px; border-radius: 10px; background: var(--ovl-1); text-align: center; cursor: pointer; transition: background .15s; }
.date-chip-wd { font-size: 11px; color: var(--label); }
.date-chip-day { font-size: 17px; font-weight: 700; line-height: 1.1; }
.date-chip-day.rel { font-size: 12px; line-height: 1.15; }
.date-chip-mon { font-size: 10px; color: var(--label); }
.date-chip-occ { font-size: 10px; font-weight: 700; color: var(--free); margin-top: 1px; min-height: 12px; }
.date-chip.active { background: var(--tg-btn); }
.date-chip.active .date-chip-wd, .date-chip.active .date-chip-mon { color: rgba(255,255,255,.85); }
.date-chip.active .date-chip-occ { color: #fff; }
.date-chip.today:not(.active) { box-shadow: inset 0 0 0 1.5px var(--tg-btn); }

/* ── Admin bar (тонка кнопка налаштувань) ────────────────────────────────── */
/* wrap обов'язковий: 6 кнопок + версія не влазять у 375px, і панель розпирала весь
   екран — через це праві краї рядків списку зрізало. Панель бачить лише власник. */
.admin-bar { display: flex; align-items: center; justify-content: space-between; gap: 4px 10px; flex-wrap: wrap; padding: 5px 12px; background: var(--tg-secondary-bg); border-bottom: 1px solid var(--line-soft); flex-shrink: 0; }
.admin-bar-btn { background: none; border: none; color: var(--tg-link); font-size: 13px; font-weight: 600; cursor: pointer; padding: 2px 0; }
.app-ver { font-size: 11px; color: var(--label); }

/* ── Hall tabs (вміщуються в ширину, без скролу) ─────────────────────────── */
.hall-tabs { display: flex; gap: 4px; padding: 7px 8px; background: var(--tg-secondary-bg); border-top: 1px solid var(--line-soft); flex-shrink: 0; }
.tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 6px 3px; border-radius: 8px; font-size: 12px; font-weight: 600; color: var(--label); background: var(--ovl-1); white-space: nowrap; cursor: pointer; transition: background .15s, color .15s; overflow: hidden; }
.tab span { overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.tab.active { color: var(--tg-btn-text); background: var(--tg-btn); }
.tab-cnt { font-size: 10px; font-weight: 700; opacity: .9; }
.tab-cnt:empty { display: none; }
.tab-all { color: var(--tg-link); }
.tab-all.active { background: var(--tg-link); color: #fff; }

/* ── Day list / rows ─────────────────────────────────────────────────────── */
.day-list { flex: 1 1 auto; overflow-y: auto; padding: 8px 10px 14px; }
.day-row { display: flex; align-items: center; gap: 10px; padding: 9px 10px; background: var(--tg-secondary-bg); border-radius: 9px; margin-bottom: 7px; cursor: pointer; transition: background .12s; }
.day-row:active { background: var(--ovl-2); }
.day-row.late { box-shadow: inset 0 0 0 1.5px var(--late); }
.day-row.seated { box-shadow: inset 0 0 0 1.5px #2ecc71; }
.res-item.late { box-shadow: 0 0 0 1.5px var(--late); }
.res-item.seated { box-shadow: 0 0 0 1.5px #2ecc71; }
.day-row-table { flex-shrink: 0; min-width: 44px; height: 38px; border-radius: 8px; background: var(--busy); color: #fff; font-weight: 700; font-size: 13px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.day-row-table small { font-size: 9px; font-weight: 500; opacity: .85; }
/* довге ім'я гостя не повинно виштовхувати кнопки за правий край */
.day-row-main { min-width: 0; overflow: hidden; }
.day-row-main { flex: 1; min-width: 0; }
.day-row-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-row-sub { font-size: 12px; color: var(--label); }
.call-btn { flex-shrink: 0; background: var(--free); color: #fff; width: 40px; height: 40px; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; text-decoration: none; }
.call-btn:active { opacity: .8; }
.conf-btn { flex-shrink: 0; background: #e84393; color: #fff; width: 40px; height: 40px; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 700; cursor: pointer; }
.conf-btn:active { opacity: .8; }
.conf-ok-btn { flex-shrink: 0; background: #3498db; color: #fff; width: 40px; height: 40px; border: none; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; }
.conf-ok-btn:active { opacity: .8; }
.restore-btn { flex-shrink: 0; background: var(--tg-btn); color: var(--tg-btn-text); border: none; border-radius: 9px; padding: 9px 14px; font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.restore-btn:active { opacity: .8; }
.hist-tables { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.hist-table { min-width: 46px; padding: 11px 8px; border-radius: 8px; border: none; background: var(--tg-secondary-bg); color: var(--tg-text); font-weight: 600; font-size: 13px; cursor: pointer; }
.hist-table:active { background: var(--tg-btn); color: var(--tg-btn-text); }
.hist-table:disabled { opacity: .35; }

/* ── All reservations ────────────────────────────────────────────────────── */
#allResWrap { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.status-subtabs { display: flex; gap: 5px; padding: 9px 10px; background: var(--tg-secondary-bg); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.status-subtabs::-webkit-scrollbar { display: none; }
.subtab { padding: 6px 12px; border-radius: 16px; font-size: 13px; font-weight: 600; color: var(--label); background: var(--ovl-1); white-space: nowrap; cursor: pointer; }
.subtab.active { background: var(--tg-btn); color: var(--tg-btn-text); }
.all-res-list { flex: 1; overflow-y: auto; padding: 10px; }

/* ── Reservation cards ───────────────────────────────────────────────────── */
.res-item { background: var(--tg-secondary-bg); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; transition: box-shadow .2s, background .2s; }
.res-item.flash { box-shadow: 0 0 0 2px var(--tg-btn); background: rgba(80,168,235,.12); }
.res-item-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 4px; }
.res-name { font-weight: 600; font-size: 15px; }
.res-time { color: var(--label); font-size: 13px; white-space: nowrap; }
.res-meta { font-size: 13px; color: var(--label); margin-top: 2px; }
.res-by { font-size: 11px; color: var(--label); margin-top: 3px; opacity: .85; }
/* Кнопки картки — переносяться на рядки, всі вміщуються без скролу */
.res-actions { display: flex; gap: 7px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.res-actions .btn { flex: 0 0 auto; }
.res-actions .call-btn, .res-actions .conf-btn { flex-shrink: 0; width: 36px; height: 34px; border-radius: 8px; }

/* ── Банкет: одна бронь на кілька столів ─────────────────────────────────────
   Тап-таргети великі (телефон, зміна на ногах), підписи без дрібного тексту. */
.pick-bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-top, 0px)); background: #8e44ad; color: #fff;
  font-size: 13px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.3); }
.pick-bar-txt { flex: 1; line-height: 1.3; }
.pick-bar-x { border: none; background: rgba(255,255,255,.22); color: #fff; border-radius: 9px;
  padding: 9px 14px; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 38px; }
/* Обрані столи на схемі: фіолетова обводка + пульсація, щоб не сплутати зі «зайнято» */
.table-cell.picked { box-shadow: 0 0 0 3px var(--tg-bg), 0 0 0 6px #8e44ad; z-index: 7; }
body.picking .table-cell.bookable { cursor: pointer; }
body.picking .table-cell.service { opacity: .35; }
.pick-hint { font-size: 13px; color: var(--label); line-height: 1.4; margin-bottom: 10px; }
.pick-sum { font-size: 14px; font-weight: 700; margin-top: 8px; }
.sheet-note { font-size: 13px; color: var(--label); line-height: 1.45; background: var(--ovl-2);
  border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
/* Чипи столів: у шторці вибору, у формі й у картці броні */
.tchips { display: flex; flex-wrap: wrap; gap: 8px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; background: var(--ovl-2); color: var(--tg-text);
  border-radius: 10px; padding: 8px 10px; font-size: 15px; font-weight: 700; min-height: 38px; }
.tchip-x { border: none; background: rgba(231,76,60,.2); color: #e74c3c; border-radius: 8px;
  width: 26px; height: 26px; font-size: 13px; font-weight: 700; cursor: pointer; line-height: 1; }
.banquet-tag { display: inline-block; background: rgba(142,68,173,.22); color: #b07cd6;
  border-radius: 9px; padding: 2px 7px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.res-tables { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.form-tables { margin-bottom: 10px; }

.btn { border: none; border-radius: 9px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn:active { opacity: .8; }
.btn-primary { background: var(--tg-btn); color: var(--tg-btn-text); }
.btn-ghost { background: var(--ovl-2); color: var(--tg-text); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-warn { background: #e67e22; color: #fff; }
.btn-info { background: #3498db; color: #fff; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

.status-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 10px; margin-left: 6px; }
.status-active { background: var(--st-active-bg); color: var(--st-active-fg); }
.status-seated { background: var(--st-seated-bg); color: var(--st-seated-fg); }
.status-no_show { background: var(--st-noshow-bg); color: var(--st-noshow-fg); }
.status-completed { background: var(--st-done-bg); color: var(--st-done-fg); }
.status-cancelled { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 12px; color: var(--label); margin-bottom: 4px; font-weight: 600; }
.form-input, .form-textarea { width: 100%; border: 1.5px solid var(--field-border); border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--field-bg); color: var(--tg-text); outline: none; transition: border-color .15s, background .15s; -webkit-user-select: text; user-select: text; }
.form-input::placeholder, .form-textarea::placeholder { color: var(--label); opacity: .7; }
.form-input:focus, .form-textarea:focus { border-color: var(--tg-btn); background: var(--ovl-2); }
.form-textarea { resize: none; min-height: 44px; }
.suggest { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.suggest-item { padding: 9px 12px; background: var(--tg-secondary-bg); border: 1px solid var(--field-border); border-radius: 8px; cursor: pointer; }
.suggest-item:active { background: var(--tg-btn); color: var(--tg-btn-text); }
.suggest-item b { display: block; font-size: 15px; font-weight: 600; }
.suggest-item small { display: block; font-size: 11px; color: var(--label); margin-top: 1px; }
.suggest-item:active small { color: rgba(255,255,255,.85); }
/* Залочене поле телефону — коли бронь привʼязана до клієнта Poster */
.form-input.locked { opacity: .65; cursor: not-allowed; background: var(--tg-secondary-bg); }
/* Чіп привʼязки до реального клієнта */
.bound-chip { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 8px 10px; font-size: 13px; background: rgba(48,209,88,.14); border: 1px solid rgba(48,209,88,.45); border-radius: 8px; color: var(--tg-text); }
.bound-chip b { font-weight: 600; }
.bound-x { margin-left: auto; flex: none; width: 24px; height: 24px; border: none; border-radius: 6px; background: var(--ovl-3); color: var(--tg-text); font-size: 13px; cursor: pointer; }
.bound-x:active { background: var(--ovl-3); }
.form-row { display: flex; gap: 10px; align-items: flex-end; }
.tg-time { flex: 1.3; } .tg-guests { flex: 1; }

.wheel-picker { position: relative; display: flex; gap: 4px; height: 96px; border: 1.5px solid var(--field-border); border-radius: 10px; background: var(--field-bg); overflow: hidden; }
.wheel-picker::before { content: ""; position: absolute; left: 0; right: 0; top: 32px; height: 32px; background: rgba(80,168,235,.16); border-top: 1.5px solid rgba(80,168,235,.5); border-bottom: 1.5px solid rgba(80,168,235,.5); pointer-events: none; }
.wheel-sep { align-self: center; font-size: 18px; font-weight: 700; }
.wheel { flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; text-align: center; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.wheel::-webkit-scrollbar { display: none; }
.wheel-item { height: 32px; line-height: 32px; scroll-snap-align: center; font-size: 18px; font-weight: 600; color: var(--label); }
.wheel-item.sel { color: var(--tg-text); }
.wheel-pad { height: 32px; }
.stepper { display: flex; align-items: center; justify-content: space-between; height: 96px; border: 1.5px solid var(--field-border); border-radius: 10px; background: var(--field-bg); overflow: hidden; }
.stepper-btn { width: 44px; height: 100%; border: none; background: var(--ovl-1); color: var(--tg-text); font-size: 24px; cursor: pointer; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.stepper-btn:active { background: var(--tg-btn); color: var(--tg-btn-text); }
.stepper-value { flex: 1; text-align: center; font-size: 24px; font-weight: 700; }

/* ── Колесо дати народження (день / місяць / рік) ─────────────────────────── */
.dwheel { position: relative; display: flex; gap: 6px; height: 120px; border: 1.5px solid var(--field-border); border-radius: 11px; background: var(--field-bg); overflow: hidden; }
.dwheel::before { content: ""; position: absolute; left: 0; right: 0; top: 42px; height: 36px; background: rgba(80,168,235,.16); border-top: 1.5px solid rgba(80,168,235,.5); border-bottom: 1.5px solid rgba(80,168,235,.5); pointer-events: none; }
.dcol { flex: 1; overflow-y: scroll; scroll-snap-type: y mandatory; text-align: center; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.dcol::-webkit-scrollbar { display: none; }
.dit { height: 36px; line-height: 36px; scroll-snap-align: center; font-size: 17px; color: var(--label); }
.dit.sel { color: var(--tg-text); font-weight: 700; }
.dpad { height: 42px; }

/* ── Cancel reason ───────────────────────────────────────────────────────── */
.reason-list { display: flex; flex-direction: column; gap: 10px; }
.reason-btn { padding: 14px; border-radius: 10px; border: 1.5px solid var(--field-border); background: var(--field-bg); color: var(--tg-text); font-size: 15px; font-weight: 600; cursor: pointer; text-align: left; }
.reason-btn:active { background: var(--tg-btn); color: var(--tg-btn-text); }

/* ── History ─────────────────────────────────────────────────────────────── */
.history-list { font-size: 13px; }
.history-item { padding: 8px 0; border-bottom: 1px solid var(--line); color: var(--label); }
.history-item:last-child { border-bottom: none; }
.history-action { font-weight: 600; color: var(--tg-text); }
.empty-state { text-align: center; padding: 22px 16px; color: var(--label); font-size: 15px; }

.spinner { display: flex; justify-content: center; padding: 24px; }
.spinner::after { content: ""; width: 26px; height: 26px; border: 3px solid var(--ovl-3); border-top-color: var(--tg-btn); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Bottom Sheet ────────────────────────────────────────────────────────── */
.bottom-sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; background: var(--tg-bg); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 40px rgba(0,0,0,.7); border-top: 3px solid var(--tg-btn); max-height: 80dvh; display: flex; flex-direction: column; transform: translateY(101%); transition: transform .25s ease; }
.bottom-sheet.open { transform: translateY(0); }
.sheet-header { padding: 14px 16px; background: var(--tg-secondary-bg); border-radius: 15px 15px 0 0; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 17px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; }
.sheet-close { background: var(--ovl-2); border: none; border-radius: 50%; width: 32px; height: 32px; font-size: 18px; cursor: pointer; color: var(--tg-text); }
.sheet-body { overflow-y: auto; padding: 12px 16px 18px; flex: 1; scroll-behavior: smooth; }
/* Запас висоти у формі: щоб активне поле можна було підняти під верх шторки (місце під підказки/клавіатуру) */
.form-kb-pad { height: 55vh; }

.toast { position: fixed; bottom: 76%; left: 50%; transform: translateX(-50%) translateY(20px); background: rgba(0,0,0,.82); color: #fff; padding: 9px 20px; border-radius: 22px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 200; white-space: nowrap; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Постійний екран помилки — лишається доки не закриють (щоб встигнути заскринити) */
#errOverlay { display: none; position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,.78); align-items: center; justify-content: center; padding: 18px; }
#errOverlay .err-card { width: 100%; max-width: 480px; background: var(--tg-bg, #1c1c1e); border: 1px solid rgba(255,90,90,.5); border-radius: 14px; padding: 16px; box-shadow: 0 10px 40px rgba(0,0,0,.5); }
#errOverlay .err-head { font-size: 17px; font-weight: 700; color: #ff8a8a; margin-bottom: 4px; }
#errOverlay .err-sub { font-size: 13px; color: var(--tg-hint, #9b9b9f); margin-bottom: 12px; }
#errOverlay .err-body { font: 12px/1.5 ui-monospace, Menlo, Consolas, monospace; color: var(--tg-text, #fff); background: var(--ovl-1); border-radius: 8px; padding: 10px 12px; margin: 0 0 12px; white-space: pre-wrap; word-break: break-word; max-height: 50vh; overflow: auto; -webkit-user-select: text; user-select: text; }
#errOverlay .err-actions { display: flex; gap: 10px; }
#errOverlay .err-actions .btn { flex: 1; }

/* ── Fullscreen (settings) ───────────────────────────────────────────────── */
.fullscreen { position: fixed; inset: 0; z-index: 80; background: var(--tg-bg); display: flex; flex-direction: column; }

.settings-header { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--tg-secondary-bg); border-bottom: 1px solid var(--line-soft); font-weight: 700; font-size: 16px; flex-shrink: 0; }
.settings-header .sheet-close { font-size: 22px; }
.settings-body { flex: 1; overflow-y: auto; padding: 12px; }
.staff-card { background: var(--tg-secondary-bg); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.staff-top { display: flex; justify-content: space-between; align-items: center; }
.staff-name { font-weight: 600; font-size: 15px; }
.staff-sub { font-size: 12px; color: var(--label); margin-top: 2px; }
.role-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 10px; }
.role-admin { background: var(--role-admin-bg); color: var(--role-admin-fg); }
.role-viewer { background: var(--st-cancel-bg); color: var(--st-cancel-fg); }
.staff-inactive { opacity: .5; }

/* ── Клієнти (база Poster) ───────────────────────────────────────────────── */
.client-card { background: var(--tg-secondary-bg); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.client-main { flex: 1; min-width: 0; }
.client-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.client-sub { font-size: 12px; color: var(--label); margin-top: 2px; }
.client-actions { display: flex; gap: 6px; flex-shrink: 0; }
.cl-ic { width: 38px; height: 38px; border: none; border-radius: 9px; background: var(--ovl-2); color: var(--tg-text); font-size: 17px; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.cl-ic:active { background: var(--tg-btn); }

/* Модальне вікно (редагування клієнта) — поверх екрана клієнтів */
.modal { position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55); display: flex; align-items: flex-start; justify-content: center; padding: 20px; }
.modal-box { background: var(--tg-bg); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: 100%; max-width: 380px; margin-top: 8vh; box-shadow: 0 12px 40px rgba(0,0,0,.55); }
.modal-title { font-weight: 700; font-size: 16px; margin-bottom: 12px; }

/* ── Огляд: міні-схеми залів (2×2, без тапів) ────────────────────────────── */
/* Обзор заповнює фіксовану висоту floor-canvas (= висоті схеми одного залу),
   щоб при перемиканні зал↔«Всі брони» нижні елементи не зміщувались. */
.overview-grid { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 8px; height: 100%; }
.mini-hall { background: var(--tg-secondary-bg); border-radius: 10px; padding: 6px; display: flex; flex-direction: column; min-height: 0; }
.mini-hall.mini-empty { background: transparent; }
.mini-hall-title { font-size: 11px; font-weight: 700; color: var(--label); margin-bottom: 4px; text-align: center; flex: 0 0 auto; }
.mini-canvas { position: relative; width: 100%; flex: 1 1 auto; min-height: 0; background: radial-gradient(circle, var(--dots) 1px, transparent 1px); background-size: 9px 9px; border-radius: 6px; overflow: hidden; }
.mini-cell { position: absolute; border-radius: 2px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.mini-cell span { font-size: 6px; line-height: 1; font-weight: 700; color: #fff; }
.mini-cell.service { background: var(--service); opacity: .45; }
.mini-cell.free { background: #3498db; }
.mini-cell.busy { background: var(--wait); }
.mini-cell.late { background: var(--late); }
.mini-cell.seated { background: var(--free); }
.mini-cell.histbooked { background: var(--wait); }   /* історія дня: стіл був заброньований */
.mini-cell.circle { border-radius: 50%; }
.mini-cell.oval { border-radius: 50% / 40%; }

/* ── Інфо-документація (інструкція) ──────────────────────────────────────── */
.info-doc { font-size: 14px; }
.info-card { background: var(--tg-secondary-bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.info-card b { font-size: 15px; }
.info-card p { margin-top: 5px; color: var(--label); line-height: 1.55; }
.info-card .dot { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }

@media (orientation: landscape) {
  .floor-wrap { max-height: none; flex: 1 1 auto; }
  .day-list { display: none; }
}

/* ── Список / Розклад ─────────────────────────────────────────────────────── */
.view-switch { display: flex; gap: 4px; padding: 6px 8px 0; flex-shrink: 0; }
.view-btn { flex: 1 1 0; padding: 6px 4px; border: none; border-radius: 8px; font-size: 12px; font-weight: 600;
            color: var(--label); background: var(--ovl-1); cursor: pointer; font-family: inherit; }
.view-btn.active { color: var(--tg-btn-text); background: var(--tg-btn); }

/* Розклад по годинах: столи рядками, години колонками.
   Прокрутка ОБОХ осей живе в одному контейнері (.sch-scroll). Якщо вертикаль
   тримає .schedule-wrap, а горизонталь .sch-scroll, то sticky-шапка годин
   чіпляється до .sch-scroll, який вертикально не гортається, — і при гортанні
   вниз шапка їде вгору разом зі змістом. Тому wrap лише обмежує висоту. */
.schedule-wrap { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column;
                 overflow: hidden; padding: 8px 0 14px; }
.sch-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.sch-inner { position: relative; }
.sch-head { display: flex; position: sticky; top: 0; z-index: 3; background: var(--tg-bg); }
.sch-hours { display: flex; }
.sch-h { flex: 0 0 auto; font-size: 11px; line-height: 14px; color: var(--label); padding: 4px 0 5px 3px;
         border-left: 1px solid var(--line); }
.sch-row { display: flex; align-items: stretch; height: 34px; }
.sch-tbl { position: sticky; left: 0; z-index: 1; flex: 0 0 46px; display: flex; align-items: center; justify-content: center;
           font-size: 12px; font-weight: 700; color: var(--label); background: var(--tg-bg);
           border-right: 1px solid var(--line); cursor: pointer; }
/* Кут «столи × години»: лежить у шапці (z-index 3), тому при обох гортаннях
   перекриває і рядки, і підписи годин — дірки на перетині не буде */
.sch-corner { height: auto; z-index: 2; }
.sch-lane { position: relative; flex: 0 0 auto;
            background-image: linear-gradient(to right, var(--line) 1px, transparent 1px);
            background-size: 62px 100%; }
.sch-bar { position: absolute; top: 4px; bottom: 4px; border-radius: 5px; padding: 0 5px; cursor: pointer;
           font-size: 11px; line-height: 26px; font-weight: 600; white-space: nowrap; overflow: hidden;
           text-overflow: ellipsis; }
.sch-bar.wait   { background: var(--wait);  color: #4a2f02; }
.sch-bar.seated { background: var(--free);  color: #08351d; }
.sch-bar.late   { background: var(--late);  color: #fff; }
.sch-bar.clash  { background: var(--busy);  color: #fff; box-shadow: inset 0 0 0 1.5px #fff; }
/* Починається під шапкою годин (її висота 23px) і йде під нею за z-index */
.sch-now { position: absolute; top: 23px; bottom: 0; width: 2px; background: var(--late); z-index: 1; pointer-events: none; }

/* Тривалість броні у формі */
.dur-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.dur-chip { padding: 7px 11px; border: none; border-radius: 8px; font-size: 13px; font-weight: 600;
            color: var(--label); background: var(--field-bg); cursor: pointer; font-family: inherit; }
.dur-chip.sel { color: var(--tg-btn-text); background: var(--tg-btn); }

/* підписи дій біля галочок підтвердження */
.conf-wrap { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.conf-cap { font-size: 9px; line-height: 1.15; color: var(--label); text-align: center; white-space: nowrap; }

/* ── Борд гостей (лише власник): KPI + таблиці ────────────────────────────── */
.gboard .gb-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.gboard .gb-cards { gap: 9px; }
.gboard .gb-kpi { background: var(--tg-secondary-bg); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; }
.gboard .gb-kpi span { display: block; color: var(--label); font-size: 11.5px; font-weight: 600; letter-spacing: .01em; }
.gboard .gb-kpi b { display: block; font-size: 24px; font-weight: 700; line-height: 1.1; margin-top: 4px; color: var(--tg-text); }
.gboard .gb-h { font-size: 12px; font-weight: 700; color: var(--label); text-transform: uppercase; letter-spacing: .09em; margin: 22px 0 8px; }
.gboard .gb-h3 { font-size: 14.5px; font-weight: 700; margin: 12px 0 5px; }
.gboard .gb-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.gboard .gb-table { width: 100%; border-collapse: collapse; background: var(--tg-secondary-bg); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gboard .gb-table th, .gboard .gb-table td { padding: 10px 11px; text-align: left; font-size: 13px; border-bottom: 1px solid var(--line); }
.gboard .gb-table th { color: var(--label); font-weight: 700; font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; background: var(--ovl-1); }
.gboard .gb-table td { color: var(--tg-text); }
.gboard .gb-table tr:last-child td { border-bottom: none; }
.gboard .gb-table tr.clk:active td { background: var(--ovl-1); }
.gboard .gb-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.gboard .gb-mut { color: var(--label); }
.gboard .gb-tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; }
.gboard .gb-tg, .gboard .gb-bot { background: var(--ok-bg); color: var(--ok-fg); }
.gboard .gb-an, .gboard .gb-cap { background: var(--ovl-2); color: var(--label); }
.gboard .gb-live { background: var(--acc-bg); color: var(--acc-fg); }

/* Клікабельний рядок гостя: палець має куди влучити (≥44px) + видимий відгук */
.gboard tr.gb-clk { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.gboard tr.gb-clk td { padding-top: 14px; padding-bottom: 14px; }
.gboard tr.gb-clk td:first-child { position: relative; }
.gboard tr.gb-clk:active td { background: var(--ovl-2); }
.gboard tr.gb-clk td:last-child::after { content: "›"; color: var(--label); margin-left: 6px; font-weight: 700; }

/* ── Картка гостя (поверх борда) ──────────────────────────────────────────── */
.gc-ovl { position: fixed; inset: 0; z-index: 95; background: rgba(0,0,0,.55); display: flex; align-items: flex-end;
          opacity: 0; transition: opacity .2s ease; }
.gc-ovl.on { opacity: 1; }
.gc-card { width: 100%; max-height: 92dvh; background: var(--tg-bg); border-radius: 18px 18px 0 0; overflow: hidden;
           display: flex; flex-direction: column; box-shadow: 0 -10px 40px rgba(0,0,0,.7); border-top: 3px solid var(--tg-btn);
           transform: translateY(100%); transition: transform .25s ease; }
.gc-ovl.on .gc-card { transform: translateY(0); }
.gc-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px 14px 26px; }
.gc-top { display: flex; align-items: center; gap: 12px; }
.gc-ava { width: 62px; height: 62px; flex-shrink: 0; border-radius: 50%; background: var(--tg-secondary-bg);
          display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; overflow: hidden; }
.gc-ava img { width: 100%; height: 100%; object-fit: cover; }
/* є фото → аватарка клікабельна: обідок і натиск підказують, що можна відкрити */
.gc-ava.gc-ava-clk { cursor: pointer; box-shadow: 0 0 0 2px var(--tg-btn); }
.gc-ava.gc-ava-clk:active { transform: scale(.94); }
.gc-ava .gc-ava-n { position: absolute; right: -2px; bottom: -2px; min-width: 17px; height: 17px; padding: 0 4px;
                    border-radius: 9px; background: var(--tg-btn); color: #fff; font-size: 10.5px; font-weight: 700;
                    display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 2px var(--tg-bg); }
.gc-ava { position: relative; overflow: visible; transition: transform .12s ease; }
.gc-ava img { border-radius: 50%; }
.gc-id { min-width: 0; }
.gc-name { font-size: 19px; font-weight: 700; }
.gc-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.gc-tel { display: block; background: var(--tg-secondary-bg); border-radius: var(--radius); padding: 13px 14px;
          font-size: 16px; font-weight: 600; color: var(--tg-text); text-decoration: none; }
.gc-tel:active { background: var(--ovl-2); }
.gc-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gc-dev { font-size: 11.5px; word-break: break-all; margin-bottom: 4px; }

/* ── Переглядач фото гостя (на весь екран, поверх картки) ─────────────────── */
/* touch-action: none — інакше вертикальний свайп ловить сам Telegram і згортає застосунок */
.pv-ovl { position: fixed; inset: 0; z-index: 120; background: rgba(0,0,0,.94); display: flex;
          align-items: center; justify-content: center; opacity: 0; transition: opacity .18s ease;
          touch-action: none; overscroll-behavior: contain; }
.pv-ovl.on { opacity: 1; }
.pv-stage { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
            padding: env(safe-area-inset-top, 0) 0 0; }
.pv-img { max-width: 100%; max-height: 88dvh; object-fit: contain; display: block;
          transition: transform .18s ease, opacity .18s ease; pointer-events: none; user-select: none; }
.pv-close { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; z-index: 2;
            width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--ovl-3);
            color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.pv-close:active { background: rgba(255,255,255,.28); }
.pv-count { position: absolute; top: calc(20px + env(safe-area-inset-top, 0px)); left: 16px; z-index: 2;
            color: rgba(255,255,255,.75); font-size: 14px; font-weight: 600; }
.pv-dots { position: absolute; bottom: calc(18px + env(safe-area-inset-bottom, 0px)); left: 0; right: 0; z-index: 2;
           display: flex; justify-content: center; gap: 7px; }
.pv-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,.3); }
.pv-dot.on { background: #fff; }
/* поки відкритий переглядач — сторінка під ним не прокручується */
body.pv-lock { overflow: hidden; }
