* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
::-webkit-scrollbar { display: none; }
input, select, button { font-family: 'Noto Serif Khmer', serif; }
input:focus, select:focus { outline: none; }

@keyframes fadeIn   { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp  { from { transform: translateY(101%); } to { transform: translateY(0); } }
@keyframes screenIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

.stage {
  min-height: 100dvh;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: 0;
  background: transparent;   /* the fixed .starfield shows through */
  font-family: 'Noto Serif Khmer', serif;
}

/* Frameless: pure mobile viewport — no device bezel, shadow or rounded corners.
   Full-bleed on phones; centered mobile-width column on wider screens. */
.phone {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100dvh;
  overflow: hidden;
}

.statusbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 30px 7px;
  position: relative;
  z-index: 5;
}

.content {
  position: absolute;
  top: 0;
  left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  padding-top: max(8px, env(safe-area-inset-top));
  padding-bottom: 98px;
}

.wordmark { cursor: pointer; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }

/* Mid dark-blue gradient card with a soft top sheen + subtle border. */
.card {
  border-radius: 18px;
  background:
    radial-gradient(135% 90% at 86% 0%, rgba(255, 255, 255, 0.09), transparent 55%),
    linear-gradient(160deg, #274a7e 0%, #16315a 48%, #0c1c34 100%);
  border: 1px solid rgba(255, 255, 255, 0.10);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.65);   /* keeps label text legible over any card bg */
}

/* Open-table card — animated diagonal stripes + rotating shimmer.
   From Uiverse.io by SachinKumar666 (adapted; content kept above the layers). */
.card-open {
  position: relative;
  overflow: hidden;
  background-color: #2a2a72;
}
.card-open::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    repeating-linear-gradient(45deg, transparent 0, transparent 35px, rgba(255, 255, 255, 0.15) 35px, rgba(255, 255, 255, 0.15) 70px),
    repeating-linear-gradient(-45deg, transparent 0, transparent 35px, rgba(255, 255, 255, 0.15) 35px, rgba(255, 255, 255, 0.15) 70px),
    linear-gradient(90deg, #009ffd, #2a2a72);
}
.card-open::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 50%, transparent 20%, rgba(0, 0, 0, 0.2) 70%, rgba(0, 0, 0, 0.5) 100%),
    repeating-conic-gradient(from 0deg, rgba(255, 255, 255, 0.15) 0deg 30deg, transparent 30deg 60deg);
  mix-blend-mode: overlay;
  animation: cardRotate 10s linear infinite;
}
.card-open > * { position: relative; z-index: 1; }
@keyframes cardRotate { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .card-open::after { animation: none; } }

/* Reserved-table card — orange/orangered diagonal stripes. From Uiverse.io by catraco. */
.card-reserved {
  background: repeating-linear-gradient(-45deg, orange, orangered 10px, orange 10px, orangered 20px) orange;
  background-blend-mode: screen;
  color: #0f2452;                                  /* dark-blue text for contrast on orange */
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.45);
}
.card-reserved * { color: #0f2452 !important; }    /* override the inline white on the labels */

/* Seated-table card — red gradient (keeps the white label text from .card). */
.card-seated { background: linear-gradient(160deg, #ef4444 0%, #b91c1c 100%); }

/* Floor tab background — from Uiverse.io by kencode7 (white → cyan/purple, faded grid lines).
   A fixed layer behind the floor screen (covers the phone viewport, doesn't scroll). */
.floor-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    linear-gradient(to bottom, #fff 0%, #fff 40%, rgba(255, 255, 255, 0) 100%),
    linear-gradient(to right, #0ed2da, #5f29c7);
}
.floor-bg::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(90deg, #ccc 1px, transparent 1px);
  background-size: 50px 100%;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 70%);
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 1) 0%, rgba(0, 0, 0, 0) 70%);
}

/* Dark inputs/selects + readable placeholders on the cosmic theme. */
input::placeholder, textarea::placeholder { color: rgba(255, 255, 255, 0.42); }
select { color-scheme: dark; }

/* ===== Staff sign-in — blue-gradient card (Uiverse.io by SyedShahzaib7, adapted) ===== */
.login-stage {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  font-family: 'Noto Serif Khmer', system-ui, sans-serif;
}
.wrapper {
  width: 100%;
  max-width: 420px;
  background: linear-gradient(90deg, rgba(2, 0, 36, 1) 9%, rgba(9, 9, 121, 1) 68%, rgba(0, 91, 255, 1) 97%);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  color: #fff;
  border-radius: 16px;
  padding: 34px 34px 30px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 26px 60px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}
.form-login { font-size: 34px; font-weight: 700; text-align: center; margin: 0; letter-spacing: 1px; }
.login-sub { text-align: center; color: rgba(255, 255, 255, 0.72); font-size: 14px; margin: 6px 0 2px; }
.login-err { background: rgba(255, 90, 90, 0.18); color: #ffd7d7; border: 1px solid rgba(255, 120, 120, 0.4); padding: 10px 12px; border-radius: 12px; font-size: 13px; text-align: center; margin: 14px 0 0; }
.wrapper .input-box { position: relative; width: 100%; height: 52px; margin: 22px 0; }
.input-box input {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 2px solid rgba(255, 255, 255, 0.25);
  outline: none;
  border-radius: 40px;
  font-size: 16px;
  color: #fff;
  padding: 0 22px;
  transition: border-color .2s ease, background .2s ease;
}
.input-box input::placeholder { color: rgba(255, 255, 255, 0.7); }
.input-box input:focus { border-color: #fff; background: rgba(255, 255, 255, 0.06); }
.wrapper .btn {
  display: block;
  min-width: 160px;
  height: 46px;
  padding: 0 26px;
  margin: 6px auto 0;
  background: #fff;
  border: none;
  outline: none;
  border-radius: 40px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  font-size: 16px;
  color: #10233f;
  font-weight: 700;
  transition: transform .05s ease, box-shadow .2s ease;
}
.wrapper .btn:hover { box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3); }
.wrapper .btn:active { transform: scale(.98); }
.login-back-row { text-align: center; margin-top: 18px; }
.login-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s ease;
}
.login-back:hover { background: rgba(255, 255, 255, 0.2); }

/* Tables tab — searchable combobox dropdown rows */
.tbl-combo-item { transition: background .12s ease; }
.tbl-combo-item:hover { background: rgba(255, 255, 255, 0.06); }
.tbl-combo-item:last-child { border-bottom: none; }

/* Pull-to-refresh indicator (mobile: drag down at the top to reload) */
#ptr {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50px);
  z-index: 200;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(18, 22, 32, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45);
  color: #cfe3ff;
  opacity: 0;
  pointer-events: none;
}
#ptr svg { width: 22px; height: 22px; transition: transform .12s ease; }
#ptr.spin svg { animation: ptrspin .8s linear infinite; }
@keyframes ptrspin { to { transform: rotate(360deg); } }

/* Scroll-to-top FAB — hidden until the content is scrolled down, then fades in bottom-right.
   Right offset keeps it inside the centered phone column on wider screens. */
#to-top {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  right: max(16px, calc(50vw - 240px + 16px));
  z-index: 45;
  width: 46px; height: 46px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(160deg, #7c5cff 0%, #5f29c7 100%);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 10px 26px rgba(95, 41, 199, 0.45);
  opacity: 0; transform: translateY(14px) scale(0.85); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  -webkit-tap-highlight-color: transparent;
}
#to-top.show { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
#to-top:active { transform: scale(0.92); }
#to-top svg { width: 22px; height: 22px; }

/* Floating pill footer nav — from Uiverse.io by themrsami (adapted to plain CSS).
   Black rounded bar with a white ring; icon buttons get a slate circle on
   hover/active and a tooltip that pops above the bar. */
.pillnav-wrap {
  position: absolute;
  left: 0; right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  display: flex;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
}
.pillnav {
  pointer-events: auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
  gap: 4px;
  padding: 5px 8px;
  background: #000;
  border-radius: 20px;
  box-shadow: 0 0 0 1px #fff, 0 12px 30px rgba(0, 0, 0, 0.5);
}
.pillnav-item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 7px 11px;
  border: none;
  background: none;
  border-radius: 14px;
  cursor: pointer;
  transition: background .3s;
  -webkit-tap-highlight-color: transparent;
}
.pillnav-item:hover, .pillnav-item.active { background: #1e293b; }
.pillnav-label {
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1;
  color: rgba(255, 255, 255, 0.6);
  white-space: nowrap;
}
.pillnav-item.active .pillnav-label { color: #fff; }

/* Late-arrival alert pill on the Today tab (មកយឺត) — gentle pulse to draw the eye */
@keyframes latePulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.late-pill { animation: latePulse 1.5s ease-in-out infinite; }

/* Waiting-queue alert banner on the Today tab — a pulsing purple glow, a shaking bell and a
   sweeping light streak to draw the eye whenever guests are waiting on the list. */
@keyframes queuePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(124, 92, 255, 0.50), 0 10px 24px rgba(95, 41, 199, 0.38); }
  50%      { box-shadow: 0 0 0 10px rgba(124, 92, 255, 0), 0 12px 30px rgba(95, 41, 199, 0.62); }
}
@keyframes queueBell {
  0%, 46%, 100% { transform: rotate(0); }
  8%, 24%       { transform: rotate(-16deg); }
  16%, 32%      { transform: rotate(16deg); }
}
@keyframes queueSweep { from { transform: translateX(-140%); } to { transform: translateX(240%); } }
.queue-alert { position: relative; overflow: hidden; animation: queuePulse 1.9s ease-in-out infinite, screenIn .4s ease; }
.queue-alert .bell { display: inline-block; transform-origin: 50% 12%; animation: queueBell 2.6s ease-in-out infinite; }
.queue-alert::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 38%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  animation: queueSweep 2.8s ease-in-out infinite; pointer-events: none;
}
@media (prefers-reduced-motion: reduce) { .queue-alert, .queue-alert .bell, .queue-alert::after { animation: none; } }

/* ===== Waiting-slip printing (Queue tab → terminal printer) =====
   Hidden on screen; shown ALONE when printing. Centred + fluid so it adapts to
   whatever paper the terminal printer is configured for (58mm / 80mm / A-size). */
#print-slip { display: none; }
#print-slip .slip { text-align: center; color: #000; background: #fff; font-family: 'Noto Serif Khmer', serif; max-width: 76mm; margin: 0 auto; padding: 4mm 2mm; }
#print-slip .slip-brand { font-size: 15px; font-weight: 700; letter-spacing: 1px; }
#print-slip .slip-lbl { font-size: 17px; font-weight: 700; }
#print-slip .slip-num { font-size: 54px; font-weight: 900; line-height: 1.02; margin: 2px 0 6px; }
#print-slip .slip-name { font-size: 20px; font-weight: 700; }
#print-slip .slip-line { font-size: 15px; margin-top: 3px; }
#print-slip .slip-foot { font-size: 12px; margin-top: 4px; }
#print-slip .slip-hr { border-top: 1px dashed #000; margin: 8px 4px; }
@media print {
  #app, .starfield, #ptr, #to-top { display: none !important; }
  #print-slip { display: block !important; }
  html, body { background: #fff !important; height: auto !important; min-height: 0 !important; overflow: visible !important; }
  @page { size: auto; margin: 4mm; }
}

/* Today (ថ្ងៃនេះ) tab background — dark diagonal tiled pattern (Uiverse by HarryHeywood04).
   A fixed layer covering the phone viewport, behind the screen content. */
.today-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  background-color: #111111;
  background-image: linear-gradient(32deg, rgba(8, 8, 8, 0.74) 30px, transparent);
  background-size: 60px 60px;
  background-position: -5px -5px;
}
