/* App shell: sidebar (desktop), top bar, bottom tabs (phone), layers. */

.app { min-height: 100%; }

/* ---------- Phone first ---------- */
.sidebar { display: none; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--top-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 8px 0 var(--gutter);
  display: flex; align-items: center; gap: 4px;
  background: rgba(22, 23, 28, .94);
  backdrop-filter: saturate(1.2) blur(10px);
  -webkit-backdrop-filter: saturate(1.2) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar .wordmark { width: 86px; margin-right: 6px; flex: none; }
.topbar .spacer { flex: 1; }

.main {
  min-height: calc(100vh - var(--top-h) - var(--tab-h));
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 24px);
}
.main:focus { outline: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(22, 23, 28, .97);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: var(--tap); text-decoration: none; color: var(--text-3);
  font-size: 12px; letter-spacing: .02em; position: relative;
}
.tabbar a svg { width: 23px; height: 23px; }
.tabbar a[aria-current="page"] { color: var(--text); }
.tabbar a[aria-current="page"]::before {
  content: ""; position: absolute; top: -1px; left: 28%; right: 28%; height: 2px; background: var(--coral);
}
.tabbar a[aria-current="page"] svg { color: var(--coral); }

/* Location chip in phone header */
.loc-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px 0 12px;
  border: 1px solid var(--line-2); border-radius: 999px; font-weight: 700; font-size: 15px;
  min-width: var(--tap); white-space: nowrap;
}
.loc-chip svg { width: 16px; height: 16px; color: var(--text-2); }
.loc-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--coral); }

.icon-btn {
  width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border-radius: 50%;
  color: var(--text); position: relative; flex: none;
}
.icon-btn:hover { background: var(--surface); }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn .badge {
  position: absolute; top: 8px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px;
  background: var(--coral); color: var(--coral-ink); font-size: 10.5px; font-weight: 700; line-height: 16px; text-align: center;
}

.demo-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 9px;
  border: 1px dashed rgba(236,236,236,.35); border-radius: 999px; color: var(--text-2);
  font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; white-space: nowrap;
}
.demo-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--amber); }
.demo-pill:hover { color: var(--text); border-color: var(--text-2); }
/* Visible hit area ≥44px while staying visually small */
.demo-pill { position: relative; }
.demo-pill::after { content: ""; position: absolute; inset: -9px -4px; }

/* Staff mode tints the chrome */
.app[data-role="staff"] .topbar { background: rgba(28, 29, 36, .96); }
.role-tag {
  font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase;
  padding: 3px 7px; border-radius: 3px; background: var(--text); color: var(--bg);
}

/* ---------- Desktop ---------- */
@media (min-width: 1024px) {
  .app {
    display: grid;
    grid-template-columns: var(--side-w) minmax(0, 1fr);
    grid-template-rows: auto 1fr;
    grid-template-areas: "side top" "side main";
  }
  .sidebar {
    grid-area: side; display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    border-right: 1px solid var(--line); padding: 26px 18px 18px;
    background: var(--bg);
  }
  /* The desktop top bar lines up with the page column below it. Percentages
     resolve against the main column, so the edges match the centred .page. */
  .topbar {
    --tb-max: var(--page-max);
    grid-area: top; height: 64px; background: rgba(22,23,28,.92);
    padding-left: max(var(--gutter), calc((100% - var(--tb-max)) / 2 + var(--gutter)));
    /* -10px: the icon glyph (not its 44px hit box) lines up with the content edge */
    padding-right: max(calc(var(--gutter) - 10px), calc((100% - var(--tb-max)) / 2 + var(--gutter) - 10px));
  }
  .topbar .hide-desk-logo { display: none; }
  .app:has(#main > .page.narrow, #main[data-view="restaurant"]) .topbar { --tb-max: var(--page-narrow); }
  /* Full-canvas workspaces keep their edge-to-edge chrome. */
  .app:has(#main[data-view="gym"], #main[data-view="history"]) .topbar { --tb-max: 100000px; }
  .topbar .wordmark, .topbar .loc-chip { display: none; }
  .main { grid-area: main; padding-bottom: 64px; min-height: calc(100vh - 64px); }
  .tabbar { display: none; }
}

.sidebar .wordmark { width: 150px; margin: 0 0 30px 4px; }
.side-label { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--text-3); font-weight: 700; margin: 0 6px 8px; }
.side-nav { display: grid; gap: 2px; margin-bottom: 22px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 10px; border-radius: var(--r-m);
  text-decoration: none; color: var(--text-2); font-size: 16px;
}
.side-nav a svg { width: 21px; height: 21px; }
.side-nav a:hover { background: var(--surface); color: var(--text); }
.side-nav a[aria-current="page"] { color: var(--text); background: var(--surface); }
.side-nav a[aria-current="page"] svg { color: var(--coral); }
.side-nav a .hint { margin-left: auto; font-size: 12px; color: var(--text-3); }

.seg-loc { display: grid; grid-template-columns: 1fr 1fr; gap: 0; border: 1px solid var(--line-2); border-radius: var(--r-m); padding: 3px; margin-bottom: 26px; }
.seg-loc button { height: 38px; border-radius: 4px; font-weight: 700; color: var(--text-2); font-size: 15px; text-align: center; }
.seg-loc button[aria-pressed="true"] { background: var(--text); color: var(--bg); }

.side-pass {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; align-items: center;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r-m); text-decoration: none; margin-bottom: 14px;
}
.side-pass:hover { border-color: var(--line-2); }
.side-pass svg { width: 22px; height: 22px; color: var(--coral); grid-row: span 2; }
.side-pass b { font-family: var(--font-display); font-size: 19px; }
.side-pass span { font-size: 13px; color: var(--text-2); }

.side-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 18px; border-top: 1px solid var(--line); }
.side-foot .row { display: flex; gap: 8px; align-items: center; }
.side-btn {
  display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: var(--r-m);
  color: var(--text-2); font-size: 14.5px; text-decoration: none;
}
.side-btn:hover { background: var(--surface); color: var(--text); }
.side-btn svg { width: 19px; height: 19px; }

/* Page title in top bar on desktop */
.top-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; display: none; }
@media (min-width: 1024px) { .top-title { display: block; } }

/* ---------- Layers: sheets, dialogs, toasts ---------- */
#layer { position: relative; z-index: 60; }
.scrim {
  position: fixed; inset: 0; background: rgba(8, 8, 10, .62); z-index: 60;
  animation: fade .18s var(--ease);
}
.dialog {
  position: fixed; z-index: 61; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 24px)); max-height: min(86vh, 860px); overflow: auto;
  background: var(--bg-raise); border: 1px solid var(--line-2); border-radius: var(--r-l);
  box-shadow: var(--shadow); animation: pop .22s var(--ease);
}
.dialog.wide { width: min(820px, calc(100vw - 24px)); }
.dialog-head {
  position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px;
  padding: 14px 10px 12px 22px; background: var(--bg-raise); border-bottom: 1px solid var(--line);
}
.dialog-head h2 { font-size: 23px; flex: 1; }
.dialog-body { padding: 20px 22px 24px; }
.dialog-foot {
  position: sticky; bottom: 0; display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
  padding: 14px 22px; background: var(--bg-raise); border-top: 1px solid var(--line);
}

@media (max-width: 719px) {
  .dialog {
    left: 0; right: 0; top: auto; bottom: 0; transform: none; width: 100%;
    max-height: 92vh; border-radius: 16px 16px 0 0; border-bottom: 0;
    animation: rise .26s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .dialog.wide { width: 100%; }
  .dialog-head::before {
    content: ""; position: absolute; left: 50%; top: 6px; width: 36px; height: 4px; margin-left: -18px;
    border-radius: 2px; background: var(--line-2);
  }
  .dialog-head { padding-top: 18px; }
  .dialog-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .dialog-foot .btn { flex: 1; }
}

.toasts {
  position: fixed; z-index: 80; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  display: grid; gap: 8px; width: min(460px, calc(100vw - 24px)); pointer-events: none;
}
@media (min-width: 1024px) { .toasts { bottom: 28px; left: calc(50% + var(--side-w) / 2); } }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  padding: 10px 10px 10px 16px; border-radius: var(--r-m);
  background: var(--text); color: var(--bg); box-shadow: var(--shadow); font-size: 15px;
  animation: rise .24s var(--ease);
}
.toast span { flex: 1; }
.toast button { font-weight: 700; padding: 0 12px; min-height: 36px; border-radius: 4px; color: #9A3E3B; }
.toast button:hover { background: rgba(0,0,0,.06); }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -48%) scale(.98); } }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } }
