/* ── Base ─────────────────────────────────────────────────────────────────── */
:root {
  --tg-bg: var(--tg-theme-bg-color, #17212b);
  --tg-text: var(--tg-theme-text-color, #ffffff);
  --tg-hint: var(--tg-theme-hint-color, #9aa6b2);
  --tg-link: var(--tg-theme-link-color, #5ea9dd);
  --tg-btn: var(--tg-theme-button-color, #50a8eb);
  --tg-btn-text: var(--tg-theme-button-text-color, #ffffff);
  --tg-secondary-bg: var(--tg-theme-secondary-bg-color, #232e3c);
  --field-bg: rgba(255,255,255,.07);
  --field-border: rgba(255,255,255,.22);
  --free: #2ecc71;
  --busy: #e74c3c;
  --wait: #f5b041;   /* є бронь, чекає гостя (жовто-помаранчевий) */
  --late: #e74c3c;   /* гість запізнюється (червоний) */
  --service: #7f8c9a;
  --radius: 10px;
}
*, *::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; }

/* ── Floor ───────────────────────────────────────────────────────────────── */
.floor-wrap { flex: 0 0 auto; max-height: 50vh; overflow: auto; padding: 10px; }
.floor-canvas { position: relative; width: 100%; background: radial-gradient(circle, rgba(255,255,255,.10) 1px, transparent 1px); background-size: 22px 22px; border-radius: var(--radius); border: 1px solid rgba(255,255,255,.06); 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.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 rgba(255,255,255,.07); 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: rgba(255,255,255,.06); text-align: center; cursor: pointer; transition: background .15s; }
.date-chip-wd { font-size: 11px; color: var(--tg-hint); }
.date-chip-day { font-size: 17px; font-weight: 700; line-height: 1.1; }
.date-chip-mon { font-size: 10px; color: var(--tg-hint); }
.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 (тонка кнопка налаштувань) ────────────────────────────────── */
.admin-bar { display: flex; align-items: center; justify-content: space-between; padding: 5px 12px; background: var(--tg-secondary-bg); border-bottom: 1px solid rgba(255,255,255,.06); 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(--tg-hint); }

/* ── Hall tabs (вміщуються в ширину, без скролу) ─────────────────────────── */
.hall-tabs { display: flex; gap: 4px; padding: 7px 8px; background: var(--tg-secondary-bg); border-top: 1px solid rgba(255,255,255,.07); 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(--tg-hint); background: rgba(255,255,255,.05); 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: rgba(255,255,255,.10); }
.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 { 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(--tg-hint); }
.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(--tg-hint); background: rgba(255,255,255,.07); 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(--tg-hint); font-size: 13px; white-space: nowrap; }
.res-meta { font-size: 13px; color: var(--tg-hint); margin-top: 2px; }
.res-by { font-size: 11px; color: var(--tg-hint); 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; }

.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: rgba(255,255,255,.10); 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: #1e3a2a; color: #6ee7a0; }
.status-seated { background: #3a341e; color: #e7cf6e; }
.status-no_show { background: #3a1e1e; color: #e79a9a; }
.status-completed { background: #1e303a; color: #6ec3e7; }
.status-cancelled { background: #2c2c2c; color: #b0b0b0; }

/* ── Form ────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 10px; }
.form-label { display: block; font-size: 12px; color: var(--tg-hint); 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(--tg-hint); opacity: .7; }
.form-input:focus, .form-textarea:focus { border-color: var(--tg-btn); background: rgba(255,255,255,.10); }
.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(--tg-hint); margin-top: 1px; }
.suggest-item:active small { color: rgba(255,255,255,.85); }
.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(--tg-hint); }
.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: rgba(255,255,255,.06); 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(--tg-hint); }
.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 rgba(255,255,255,.08); color: var(--tg-hint); }
.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(--tg-hint); font-size: 15px; }

.spinner { display: flex; justify-content: center; padding: 24px; }
.spinner::after { content: ""; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.15); 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 rgba(255,255,255,.10); font-weight: 700; font-size: 17px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; }
.sheet-close { background: rgba(255,255,255,.10); 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); }

/* ── 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 rgba(255,255,255,.06); 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(--tg-hint); margin-top: 2px; }
.role-pill { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 10px; }
.role-admin { background: #3a2a1e; color: #e7b06e; }
.role-viewer { background: #2c2c2c; color: #b0b0b0; }
.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(--tg-hint); margin-top: 2px; }
.client-actions { display: flex; gap: 6px; flex-shrink: 0; }
.cl-ic { width: 38px; height: 38px; border: none; border-radius: 9px; background: rgba(255,255,255,.08); 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 rgba(255,255,255,.12); 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(--tg-hint); 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, rgba(255,255,255,.08) 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(--tg-hint); 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; }
}
