/* ── 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;
  --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: var(--free); }
.table-cell.bookable.busy { background: var(--busy); }
.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: 54px; padding: 6px 6px 9px; 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.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.today:not(.active) { box-shadow: inset 0 0 0 1.5px var(--tg-btn); }
.date-chip.has-booking::after { content: ""; position: absolute; left: 50%; bottom: 3px; transform: translateX(-50%); width: 5px; height: 5px; border-radius: 50%; background: var(--free); }
.date-chip.active.has-booking::after { background: #fff; }

/* ── Hall tabs (під датою) ───────────────────────────────────────────────── */
.hall-tabs { display: flex; gap: 5px; padding: 7px 10px; background: var(--tg-secondary-bg); border-top: 1px solid rgba(255,255,255,.07); overflow-x: auto; scrollbar-width: none; flex-shrink: 0; }
.hall-tabs::-webkit-scrollbar { display: none; }
.tab { padding: 7px 13px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--tg-hint); background: rgba(255,255,255,.05); white-space: nowrap; cursor: pointer; transition: background .15s, color .15s; }
.tab.active { color: var(--tg-btn-text); background: var(--tg-btn); }
.tab-all { color: var(--tg-link); margin-left: auto; }
.tab-all.active { background: var(--tg-link); color: #fff; }

/* ── Day list ────────────────────────────────────────────────────────────── */
.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-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; }
.call-btn:active { opacity: .8; }

/* ── 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-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.res-actions::-webkit-scrollbar { display: none; }
.res-actions .btn, .res-actions .call-btn { flex-shrink: 0; }
.res-actions .call-btn { width: 36px; height: 34px; border-radius: 8px; font-size: 16px; }

.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-success { background: var(--free); color: #fff; }
.btn-sm { padding: 7px 11px; 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; }
.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; }

/* ── 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: 50; background: var(--tg-bg); border-radius: 16px 16px 0 0; box-shadow: 0 -6px 24px rgba(0,0,0,.5); border-top: 1px solid rgba(255,255,255,.12); max-height: 80dvh; display: flex; flex-direction: column; transform: translateY(101%); transition: transform .25s ease; }
.bottom-sheet.open { transform: translateY(0); }
.sheet-handle { width: 40px; height: 4px; background: var(--tg-hint); opacity: .4; border-radius: 2px; margin: 8px auto 0; flex-shrink: 0; }
.sheet-header { padding: 8px 16px 6px; font-weight: 700; font-size: 16px; 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: 30px; height: 30px; font-size: 16px; cursor: pointer; color: var(--tg-text); }
.sheet-body { overflow-y: auto; padding: 0 16px 18px; flex: 1; }

.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); }

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