@import url('https://fonts.googleapis.com/css2?family=Bebas+Neue&family=Inter:wght@400;500;600;700&family=Space+Mono:wght@400;700&display=swap');

:root {
  --ink: #15171B;
  --panel: #1E2126;
  --panel-raised: #262A31;
  --line: #34383F;
  --brass: #C9A24B;
  --brass-dim: #8C7434;
  --brick: #A6473F;
  --steel: #4E7186;
  --paper: #EFEAE0;
  --paper-dim: #A6A197;
  --good: #6E9B6A;

  --display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'Space Mono', monospace;

  --radius: 3px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; overflow-x: hidden; }

body {
  margin: 0;
  /* Backdrop: a real photo of barber essentials (straight razor, shaving
     brush, clippers) dimmed with a dark scrim so foreground text stays
     legible. Both layers share the same fixed/cover treatment so the
     scrim never drifts out of alignment with the photo underneath. */
  background-color: var(--ink);
  background-image:
    linear-gradient(rgba(21,23,27,0.82), rgba(21,23,27,0.82)),
    url("/img/bg-barber-essentials.jpg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  background-attachment: fixed;
  color: var(--paper);
  font-family: var(--body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

h1, h2, h3, h4 {
  font-family: var(--display);
  letter-spacing: 0.02em;
  margin: 0 0 .4em;
  font-weight: 400;
}

h1 { font-size: clamp(2.6rem, 6vw, 4.6rem); line-height: 0.95; }
h2 { font-size: clamp(1.8rem, 3.4vw, 2.6rem); }
h3 { font-size: 1.4rem; }

p { margin: 0 0 1em; color: var(--paper-dim); }

.eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--brass);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 1px;
  background: var(--brass);
  display: inline-block;
}

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- top bar ---------- */
.topbar {
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(21,23,27,0.92);
  backdrop-filter: blur(6px);
  z-index: 50;
}
.topbar-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-size: 1.35rem;
  letter-spacing: 0.02em;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}
.brand .mark {
  width: 30px; height: 30px;
  border: 1.5px solid var(--brass);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0;
  color: var(--brass);
  flex-shrink: 0;
}
.nav-links { display: flex; gap: 20px; font-size: 0.88rem; flex-wrap: wrap; align-items: center; }
.nav-links a { text-decoration: none; color: var(--paper-dim); transition: color .15s; }
.nav-links a:hover, .nav-links a.active { color: var(--brass); }
.nav-links #auth-status { color: var(--paper-dim); font-family: var(--mono); font-size: 0.78rem; }
.nav-links #auth-status a { color: var(--brass); margin-left: 6px; }
.nav-links .nav-user { color: var(--brass); font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.02em; }

/* ---------- hero ---------- */
.hero {
  padding: 90px 0 60px;
  border-bottom: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 40px;
  align-items: end;
}
.hero-copy p { max-width: 44ch; font-size: 1.05rem; }
.hero-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

.hero-stats {
  display: grid;
  gap: 14px;
  border-left: 1px solid var(--line);
  padding-left: 28px;
}
.hero-stat { display: flex; align-items: baseline; gap: 12px; }
.hero-stat .num {
  font-family: var(--mono);
  font-size: 1.6rem;
  color: var(--brass);
}
.hero-stat .label { color: var(--paper-dim); font-size: 0.85rem; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  font-family: var(--body);
  font-weight: 600;
  font-size: 0.92rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, background .15s, border-color .15s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--brass); color: #1a1a1a; }
.btn-primary:hover { background: #dcb45c; }
.btn-outline { background: transparent; color: var(--paper); border-color: var(--line); }
.btn-outline:hover { border-color: var(--brass); color: var(--brass); }
.btn-danger { background: transparent; color: var(--brick); border-color: var(--brick); }
.btn-danger:hover { background: var(--brick); color: var(--paper); }

.btn-lg {
  padding: 22px 36px;
  font-size: 1.15rem;
  font-weight: 700;
  border-radius: calc(var(--radius) + 2px);
  gap: 12px;
}
.btn-walkin {
  position: relative;
  background: var(--brick);
  color: var(--paper);
  border-color: var(--brick);
  box-shadow: 0 0 0 4px rgba(166,71,63,0.18);
}
.btn-walkin:hover { background: #c05a50; box-shadow: 0 0 0 6px rgba(166,71,63,0.25); }
/* A slow "ping" ring draws the eye to the walk-in CTA without touching the
   button's own box-shadow (which the hover state above already animates). */
.btn-walkin::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(166,71,63,0.55);
  animation: walkin-pulse 2.4s cubic-bezier(0,0,0.2,1) infinite;
  pointer-events: none;
}
.walkin-icon {
  display: inline-block;
  animation: walkin-step 1.4s ease-in-out infinite;
}
@keyframes walkin-pulse {
  0% { box-shadow: 0 0 0 0 rgba(166,71,63,0.55); }
  70%, 100% { box-shadow: 0 0 0 16px rgba(166,71,63,0); }
}
@keyframes walkin-step {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-2px) rotate(-10deg); }
  50% { transform: translateY(0) rotate(0deg); }
  75% { transform: translateY(-1px) rotate(8deg); }
}
@media (prefers-reduced-motion: reduce) {
  .btn-walkin::after { animation: none; display: none; }
  .walkin-icon { animation: none; }
}
.btn-block { width: 100%; justify-content: center; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

/* ---------- booth tag (signature element) ---------- */
.booth-tag {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--ink);
  background: var(--brass);
  padding: 3px 8px;
  border-radius: 2px;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
}
.booth-tag::before { content: '⌘'; opacity: 0; width: 0; } /* placeholder, unused rivet hook */
.booth-tag.ghost {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--paper-dim);
}

/* ---------- section ---------- */
.section { padding: 64px 0; }
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 32px;
  gap: 20px;
  flex-wrap: wrap;
}

/* ---------- haircut styles carousel ---------- */
.styles-section { border-top: 1px solid var(--line); }
.carousel { position: relative; }
/* wraps just the track + arrows, so the arrows center on the cards and aren't
   thrown off by the pagination dots that sit below in .carousel */
.carousel-viewport { position: relative; }
.carousel-track {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  /* symmetric vertical padding: room for a hovered card's scale + ring, which
     the track would otherwise clip (overflow-x:auto forces overflow-y to clip) */
  padding: 16px 4px;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.style-card {
  flex: 0 0 150px;
  scroll-snap-align: start;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 10px 14px;
  text-align: center;
  transition: transform .25s cubic-bezier(.34,1.3,.6,1), border-color .2s ease,
    box-shadow .2s ease, background-color .2s ease;
}
.style-card:hover,
.style-card:focus-visible {
  transform: scale(1.07);
  border-color: var(--brass);
  background-color: var(--panel-raised);
  /* the outer glow is mostly clipped by the scroll container, so the brass
     ring is drawn inset (painted inside the card) to stay visible */
  box-shadow: inset 0 0 0 2px var(--brass), 0 8px 20px rgba(0,0,0,0.35);
  z-index: 1;
}
.style-card-photo:hover,
.style-card-photo:focus-visible {
  filter: brightness(1.1) saturate(1.05);
  box-shadow: inset 0 0 0 2px var(--brass);
}
.style-card svg {
  width: 76px;
  height: 76px;
  transition: transform .25s cubic-bezier(.34,1.3,.6,1);
}
.style-card:hover svg { transform: scale(1.1) rotate(-3deg); }
.style-card .style-name { transition: color .2s ease; }
.style-card:hover .style-name { color: var(--brass); }
.style-name {
  font-family: var(--mono);
  font-size: 0.74rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
  color: var(--paper);
}

/* Real haircut photos pulled from barbers' own galleries — see renderStyleCarousel() */
.style-card-photo {
  position: relative;
  aspect-ratio: 3/4;
  background-size: cover;
  background-position: center;
  background-color: var(--panel-raised);
  padding: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}
.style-card-photo .style-name {
  position: relative;
  width: 100%;
  margin: 0;
  padding: 10px 8px;
  box-sizing: border-box;
  background: linear-gradient(to top, rgba(10,11,13,0.85), transparent);
  color: #fff;
  text-align: left;
}
.carousel-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--panel-raised);
  border: 1px solid var(--line);
  color: var(--paper);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  z-index: 2;
  transition: opacity .25s ease, transform .18s ease, border-color .15s, color .15s;
}
.carousel-arrow:hover { border-color: var(--brass); color: var(--brass); }
.carousel-arrow.left { left: -8px; }
.carousel-arrow.right { right: -8px; }
.carousel-arrow.left:hover { transform: translateY(-50%) translateX(-2px) scale(1.08); }
.carousel-arrow.right:hover { transform: translateY(-50%) translateX(2px) scale(1.08); }
/* dim (don't remove) the arrow once you can't scroll further that way */
.carousel-arrow:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
/* when every card already fits, there's nothing to page through — drop the
   arrows entirely and center the row instead of leaving it left-aligned */
.carousel.no-scroll .carousel-arrow { display: none; }
.carousel.no-scroll .carousel-track { justify-content: center; }

.carousel-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
}
.carousel-dots:empty { display: none; }
.carousel-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 999px;
  background: var(--line);
  cursor: pointer;
  transition: width .38s cubic-bezier(.34,1.4,.64,1), background-color .25s ease;
}
.carousel-dot:hover { background: var(--brass-dim); }
.carousel-dot.active {
  width: 24px;
  background: var(--brass);
}
.carousel-dot:focus-visible { outline: 2px solid var(--brass); outline-offset: 3px; }

@media (max-width: 640px) {
  .carousel-arrow { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .style-card, .style-card svg, .carousel-arrow, .carousel-dot { transition: none; }
  .style-card:hover { transform: none; }
  .style-card:hover svg { transform: none; }
  .carousel-arrow.left:hover, .carousel-arrow.right:hover { transform: translateY(-50%); }
  /* Keep the coverflow's spatial arrangement (still useful at a glance) but
     drop the animated swing between positions. */
  .barber-card { transition: none; }
}

/* ---------- barber directory ---------- */
/* Base card look, shared by the public 3D carousel (below) AND the plain
   multi-column grid the admin dashboard renders (#admin-barber-grid reuses
   these same .barber-grid/.barber-card classes — see renderAdminBarberGrid
   in management.js) — so nothing carousel-specific (position, width,
   transform) belongs at this unscoped level. */
.barber-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 20px;
}
.barber-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 8px;
  transition: border-color .15s, transform .15s;
}
.barber-card:hover { border-color: var(--brass-dim); transform: translateY(-2px); }

/* ---------- 3D coverflow (public booking page only — .carousel-3d wraps
   #barber-grid there; the admin grid above is never inside it) ---------- */
/* perspective + overflow:hidden together on the same element clips cards that
   swing past the viewport edge without breaking the 3D depth effect. */
.carousel-3d-viewport {
  position: relative;
  overflow: hidden;
  perspective: 1400px;
  padding: 24px 0 36px;
}
.carousel-3d .barber-grid {
  display: block;
  position: relative;
  transform-style: preserve-3d;
  /* height is kept in sync with the active card's real height by JS
     (setupBarberCarousel/positionBarberCards) since children are absolute. */
}
.carousel-3d .barber-card {
  position: absolute;
  top: 0;
  left: 50%;
  width: 220px;
  cursor: pointer;
  transition: transform .5s cubic-bezier(.22,.9,.34,1), opacity .5s ease, border-color .15s;
}
/* Only the centered card is directly bookable — tapping any other card brings
   it to center first (see the click-intercept in setupBarberCarousel). */
.carousel-3d .barber-card.is-active { cursor: default; }
.carousel-3d .barber-card:not(.is-active) .select-barber,
.carousel-3d .barber-card:not(.is-active) .view-profile-trigger { pointer-events: none; }
.barber-card:hover .barber-photo {
  box-shadow: 0 0 0 4px var(--brass), 0 0 0 10px rgba(201,162,92,0.16), 0 14px 30px rgba(0,0,0,0.45);
}
/* Oval portrait avatar — taller than wide, flatters a head-and-shoulders photo */
.barber-photo {
  width: 152px;
  height: 186px;
  border-radius: 50%;
  background: var(--panel-raised) center/cover no-repeat;
  position: relative;
  cursor: pointer;
  border: 3px solid var(--brass-dim);
  box-shadow: 0 0 0 4px var(--brass-dim), 0 0 0 9px rgba(201,162,92,0.10), 0 10px 24px rgba(0,0,0,0.38);
  transition: box-shadow .18s ease;
}
.barber-photo .booth-tag {
  position: absolute;
  left: 50%;
  bottom: -10px;
  transform: translateX(-50%);
  white-space: nowrap;
}
.barber-photo .no-photo {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 38%, var(--panel-raised), var(--ink));
  font-family: var(--display);
  font-size: 3.4rem;
  color: var(--brass-dim);
}
.barber-body { padding: 16px 18px 18px; display: flex; flex-direction: column; align-items: center; text-align: center; gap: 5px; flex: 1; width: 100%; }
.barber-body h3 { margin: 0; }
.barber-specialty { color: var(--brass); font-size: 0.8rem; font-family: var(--mono); text-transform: uppercase; letter-spacing: 0.06em; }
.barber-bio { font-size: 0.88rem; flex: 1; }

.mini-gallery {
  display: grid;
  /* Shrinks each thumbnail to fit more per row as the gallery grows (up to
     MAX_GALLERY_PHOTOS = 12), rather than just stacking more rows at a fixed
     4-per-row size. */
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 6px;
  margin: 4px 0 12px;
}
.mini-gallery-item {
  aspect-ratio: 1;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  background-color: var(--ink);
  border: 1px solid var(--line);
}

.pay-qr-link {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--brass);
  font-size: 0.78rem;
  font-family: var(--mono);
  margin-bottom: 10px;
}
.pay-qr-link img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  background: #fff;
  border-radius: 4px;
  padding: 2px;
  border: 1px solid var(--line);
}
.pay-qr-link:hover { text-decoration: underline; }

.social-links {
  display: flex;
  gap: 14px;
  margin: 2px 0 4px;
}
.social-links a {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--brass);
  font-size: 0.78rem;
  font-family: var(--mono);
  text-decoration: none;
}
.social-links a svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.social-links a:hover { text-decoration: underline; }

.label-with-icon {
  display: flex;
  align-items: center;
  gap: 6px;
}
.label-with-icon svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--brass);
}

.barber-days {
  display: flex; gap: 4px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 0.68rem;
  margin: 4px 0 10px;
}
.day-chip {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--paper-dim);
}
.day-chip.on { color: var(--good); border-color: var(--good); }

/* ---------- booking panel ---------- */
.booking-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block;
  font-size: 0.78rem;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
  margin-bottom: 6px;
}
.field-error { border-color: #e08b83 !important; box-shadow: 0 0 0 1px #e08b83; }

.password-input-wrap { position: relative; }
.password-input-wrap input { padding-right: 44px; }
.password-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 6px;
  color: var(--paper-dim);
}
.password-toggle-btn:hover { color: var(--paper); }

.form-row input:not([type="checkbox"]):not([type="radio"]), .form-row select, .form-row textarea {
  width: 100%;
  background: var(--ink);
  border: 1px solid var(--line);
  color: var(--paper);
  padding: 11px 12px;
  border-radius: var(--radius);
  font-family: var(--body);
  font-size: 16px; /* keeps iOS Safari from auto-zooming into the field on focus */
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
  outline: none;
  border-color: var(--brass);
}
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Checkboxes: fixed small size, never stretched by the width:100% rule above,
   and don't get the uppercase-mono label treatment. */
input[type="checkbox"], input[type="radio"] {
  width: 1.15rem;
  height: 1.15rem;
  min-height: 0;
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--brass);
}
/* A checkbox + wrapping explanatory text, e.g. the SMS opt-in on sign-up.
   Compound selector so it beats `.form-row label` on specificity. */
.checkbox-row,
.form-row label.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: var(--body);
  font-size: 0.9rem;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.45;
  color: var(--paper-dim);
  margin-bottom: 6px;
}
.checkbox-row span { flex: 1; min-width: 0; }
.checkbox-row input[type="checkbox"] { margin-top: 2px; }

.calendar-widget {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: var(--ink);
  max-width: 340px;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-month-label {
  font-family: var(--display);
  font-size: 1.05rem;
}
.cal-nav {
  background: none;
  border: 1px solid var(--line);
  color: var(--paper);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.cal-nav:hover:not(:disabled) { border-color: var(--brass); color: var(--brass); }
.cal-nav:disabled { opacity: 0.25; cursor: not-allowed; }
.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}
.cal-weekdays {
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--paper-dim);
  margin-bottom: 4px;
}
.cal-cell {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  border: 1px solid transparent;
}
.cal-cell:not(.disabled):not(.empty):hover { border-color: var(--brass); }
.cal-cell.empty { cursor: default; }
.cal-cell.disabled { color: var(--paper-dim); opacity: 0.3; cursor: not-allowed; text-decoration: line-through; }
.cal-cell.today:not(.selected) { border-color: var(--line); font-weight: 700; }
.cal-cell.selected { background: var(--brass); color: #1a1a1a; font-weight: 700; }

/* Marks a day that already has appointments on it in the barber's booking calendars.
   Red instead of brass when any of that day's appointments overlap (double-booked). */
.cal-appt-badge {
  position: absolute;
  bottom: 3px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--brass);
}
.cal-appt-badge.double { background: var(--brick); }
.cal-cell.selected .cal-appt-badge:not(.double) { background: #1a1a1a; }

/* ============ WEEK SCHEDULE GRID (barber portal "Appointments" section) ============
   The one calendar on that page: a Sun–Sat time grid with each booking drawn as a
   positioned block (top/height set inline in JS from its time/duration), rather than
   a separate month calendar plus a text list. */
.week-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.week-nav .cal-month-label { font-family: var(--display); font-size: 1.05rem; flex: 1; }
.week-grid-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  background: var(--ink);
}
.week-grid {
  display: grid;
  grid-template-columns: 40px repeat(7, minmax(76px, 1fr));
  min-width: 572px;
}
.week-grid-corner, .week-day-head {
  position: sticky;
  top: 0;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
  padding: 8px 4px;
  text-align: center;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--paper-dim);
  z-index: 2;
}
.week-day-head { border-left: 1px solid var(--line); }
.week-day-head .wdh-num { display: block; font-family: var(--display); font-size: 1.1rem; color: var(--paper); margin-top: 2px; }
.week-day-head.today { color: var(--brass); }
.week-day-head.today .wdh-num { color: var(--brass); }
.week-time-axis { position: relative; border-right: 1px solid var(--line); }
.week-time-label {
  position: absolute;
  right: 6px;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--paper-dim);
  white-space: nowrap;
}
.week-day-col {
  position: relative;
  border-left: 1px solid var(--line);
  background-image: repeating-linear-gradient(to bottom, transparent, transparent 29px, var(--line) 29px, var(--line) 30px);
}
.week-day-col.today { background-color: rgba(201,162,75,0.05); }
.week-day-head.selected { background: rgba(201,162,75,0.18); color: var(--brass); }
.week-day-col.selected { background-color: rgba(201,162,75,0.1); }
.week-off-hatch {
  position: absolute;
  left: 0;
  right: 0;
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,0.03), rgba(255,255,255,0.03) 4px, transparent 4px, transparent 10px);
}
.week-appt-block {
  position: absolute;
  border-radius: 5px;
  border-left: 3px solid var(--good);
  background: rgba(110,155,106,0.25);
  color: var(--paper);
  padding: 3px 6px;
  font-size: 0.72rem;
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
}
.week-appt-block:hover { filter: brightness(1.2); }
.week-appt-block.pending { border-left-color: #c8a03c; background: rgba(200,160,60,0.25); }
.week-appt-block.completed { border-left-color: #8fb3c7; background: rgba(78,113,134,0.25); }
.week-appt-block.double { border-left-color: var(--brick); background: rgba(166,71,63,0.35); }
.week-appt-block.block-reserved {
  border-left-style: dashed;
  border-left-color: var(--paper-dim);
  background: repeating-linear-gradient(45deg, rgba(166,161,151,0.12), rgba(166,161,151,0.12) 4px, rgba(166,161,151,0.05) 4px, rgba(166,161,151,0.05) 10px);
  color: var(--paper-dim);
}

.block-duration-preset.active { background: var(--brass); color: #1a1a1a; border-color: var(--brass); }
.toggle-btn.active { background: var(--brass); color: #1a1a1a; border-color: var(--brass); }
.week-appt-block .wab-time { display: block; font-weight: 700; }
.week-appt-block .wab-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}
.slot {
  padding: 10px 6px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 0.82rem;
  cursor: pointer;
  background: var(--ink);
  color: var(--paper);
}
.slot:hover { border-color: var(--brass); }
.slot.taken { opacity: 0.3; text-decoration: line-through; cursor: not-allowed; pointer-events: none; }
.slot.past { opacity: 0.32; cursor: not-allowed; pointer-events: none; background: var(--panel); }
.slot.selected { background: var(--brass); color: var(--ink); border-color: var(--brass); font-weight: 700; }

/* Book-a-customer panel in the barber portal (both the inline slot grid and the one
   inside the week popup): taken slots stay clickable here so a barber can
   deliberately double-book (with a confirm prompt in JS). Every other slot grid —
   customer-facing booking, reschedule — keeps the disabled look above. */
#pb-slot-grid .slot.taken, #pb-week-slot-grid .slot.taken { opacity: 0.55; text-decoration: none; cursor: pointer; pointer-events: auto; border-color: var(--brick); }
#pb-slot-grid .slot.taken:hover, #pb-week-slot-grid .slot.taken:hover { border-color: var(--brass); }
#pb-slot-grid .slot.selected.double-booked, #pb-week-slot-grid .slot.selected.double-booked { background: var(--brick); color: var(--paper); border-color: var(--brick); }

.slot-legend {
  display: flex;
  gap: 18px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--paper-dim);
  font-family: var(--mono);
}
.slot-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border: 1px solid var(--line); background: var(--ink); }
.legend-dot.taken { opacity: 0.3; }
.legend-dot.selected { background: var(--brass); border-color: var(--brass); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 13, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-card {
  position: relative;
  max-width: 440px;
  width: 100%;
  margin: 0;
  max-height: 90vh;
  overflow-y: auto;
}
.modal-card-wide { max-width: 560px; }
.modal-card-week { max-width: 640px; }
.modal-card-week .week-nav { padding-right: 36px; }

.modal-subhead {
  margin: 18px 0 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--paper-dim);
}
.modal-list { list-style: none; padding: 0; margin: 0; font-size: 0.9rem; }
.modal-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.modal-list li:last-child { border-bottom: none; }
.modal-list-meta { color: var(--brass); font-family: var(--mono); white-space: nowrap; }

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 10;
  background: none;
  border: none;
  color: var(--paper-dim);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}
.modal-close:hover { color: var(--paper); }

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 16px;
  border: 1px solid;
}
.banner.success { background: rgba(110,155,106,0.1); border-color: var(--good); color: var(--good); }
.banner.error { background: rgba(166,71,63,0.1); border-color: var(--brick); color: #e08b83; }
.banner.info { background: rgba(78,113,134,0.12); border-color: var(--steel); color: #8fb3c7; }

footer {
  border-top: 1px solid var(--line);
  padding: 30px 0;
  color: var(--paper-dim);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- management ---------- */
.admin-shell { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 65px); }
.admin-side {
  border-right: 1px solid var(--line);
  padding: 24px 0;
}
.admin-side button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--paper-dim);
  font-family: var(--body);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 24px;
  cursor: pointer;
  border-left: 2px solid transparent;
}
.admin-side button:hover { color: var(--paper); }
.admin-side button.active { color: var(--brass); border-left-color: var(--brass); background: var(--panel); }
.admin-main { padding: 32px; }

.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.table {
  width: 100%;
  min-width: 560px; /* scrolls sideways on phones instead of crushing columns */
  border-collapse: collapse;
  font-size: 0.9rem;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.table th { color: var(--paper-dim); font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; }
.table tr:hover td { background: var(--panel); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: 20px; }

/* ---------- collapsible section (barber portal) ---------- */
/* The portal is a stack of collapsible cards — keep them close together so the
   whole page fits in a screen or two, especially on a phone. */
#portal-shell .section { padding-bottom: 20px; }
#portal-shell .section:first-child { padding-bottom: 26px; }

.portal-card { padding: 0; overflow: hidden; }
.portal-card > summary {
  list-style: none;
  cursor: pointer;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  user-select: none;
}
.portal-card > summary::-webkit-details-marker { display: none; }
.portal-card > summary:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: -2px;
}
.portal-card > summary > :first-child { min-width: 0; }
.portal-card > summary h2,
.portal-card > summary h3 { margin: 0; }
.portal-card[open] > summary { border-bottom: 1px solid var(--line); }
.portal-card__chev {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--paper-dim);
  transition: transform 0.2s ease;
}
.portal-card[open] > summary .portal-card__chev { transform: rotate(180deg); }
.portal-card__body { padding: 24px; }
@media (prefers-reduced-motion: reduce) {
  .portal-card__chev { transition: none; }
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}
.login-card { width: 100%; max-width: 340px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  color: var(--paper-dim);
  font-family: var(--body);
  font-size: 0.9rem;
  padding: 10px 4px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
}
.auth-tab.active { color: var(--paper); border-bottom-color: var(--brass); font-weight: 600; }

.link-btn {
  display: block;
  width: 100%;
  text-align: center;
  background: none;
  border: none;
  color: var(--brass);
  font-family: var(--body);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 6px;
}
.link-btn:hover { text-decoration: underline; }

.pill {
  font-family: var(--mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: uppercase;
}
.pill.confirmed { background: rgba(110,155,106,0.15); color: var(--good); }
.pill.cancelled { background: rgba(166,71,63,0.15); color: #e08b83; }
.pill.completed { background: rgba(78,113,134,0.15); color: #8fb3c7; }
.pill.pending { background: rgba(200,160,60,0.15); color: #c8a03c; }

.avail-row { display: grid; grid-template-columns: 100px 1fr 130px 130px; gap: 10px; align-items: center; margin-bottom: 8px; }
.avail-row label { font-size: 0.85rem; color: var(--paper); text-transform: capitalize; }
.avail-row select { cursor: pointer; }
.avail-row select[disabled] { opacity: 0.4; cursor: not-allowed; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-top: 4px;
}
.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line);
  background-size: cover;
  background-position: center;
  background-color: var(--ink);
}
.gallery-item .gallery-caption {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.75));
  color: var(--paper);
  font-size: 0.72rem;
  padding: 14px 8px 6px;
  text-align: center;
}
.gallery-item .gallery-remove {
  position: absolute;
  top: 5px; right: 5px;
  width: 22px; height: 22px;
  border-radius: 50%;
  border: none;
  background: rgba(10,11,13,0.75);
  color: var(--paper);
  cursor: pointer;
  font-size: 0.8rem;
  line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.gallery-item .gallery-remove:hover { background: var(--brick); }

.service-row { display: grid; grid-template-columns: 1fr 90px 90px 34px; gap: 10px; align-items: center; margin-bottom: 8px; }
.service-row input[type="text"], .service-row input[type="number"] { margin: 0; }
.service-row select.service-duration { margin: 0; padding: 11px 8px; font-size: 0.85rem; }
.service-row .remove-service {
  width: 34px; height: 34px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--brick);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}
.service-row .remove-service:hover { border-color: var(--brick); }
.service-price-wrap { position: relative; }
.service-price-wrap::before {
  content: '$';
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--paper-dim); font-family: var(--mono); pointer-events: none;
}
.service-price-wrap input { padding-left: 20px; }

.photo-preview {
  width: 90px; height: 90px;
  border-radius: var(--radius);
  background: var(--panel-raised) center/cover no-repeat;
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; gap: 12px; flex-wrap: wrap; }

.walkin-box {
  border: 1px dashed var(--brick);
  background: rgba(166,71,63,0.06);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

@media (max-width: 860px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-stats { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 20px; }
  .form-grid-2 { grid-template-columns: 1fr; }

  /* Stack the dashboard: the side nav becomes a compact scrollable tab strip
     that sits at its natural height (auto), not a stretched grid column. */
  .admin-shell {
    display: block;
    min-height: 0;
  }
  .admin-side {
    display: flex;
    gap: 2px;
    overflow-x: auto;
    scrollbar-width: none;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 6px 8px;
    position: sticky;
    top: 0;
    background: rgba(21,23,27,0.95);
    backdrop-filter: blur(6px);
    z-index: 40;
  }
  .admin-side::-webkit-scrollbar { display: none; }
  .admin-side button {
    display: block;
    width: auto;
    flex: 0 0 auto;
    white-space: nowrap;
    padding: 10px 14px;
    border-left: none;
    border-bottom: 2px solid transparent;
  }
  .admin-side button.active {
    border-left: none;
    border-bottom-color: var(--brass);
    background: transparent;
  }
}

/* ---------- tablet PORTRAIT only: make the walk-in CTA the standout action ----------
   Landscape tablets get the normal desktop layout; this only fires when a tablet
   is held upright (portrait), where screen space is tighter. Range covers the
   iPad Mini (744px) up through the 12.9" Pro (1024px). */
@media (min-width: 700px) and (max-width: 1024px) and (orientation: portrait) {
  /* drop it onto its own full-width row below "Choose a barber" */
  .hero-actions .btn-walkin {
    flex: 1 1 100%;
    justify-content: center;
    font-size: 1.25rem;
    box-shadow: 0 0 0 6px rgba(166,71,63,0.30);
  }
  .hero-actions .btn-walkin:hover {
    box-shadow: 0 0 0 9px rgba(166,71,63,0.34);
  }
}

/* ---------- phones ---------- */
@media (max-width: 560px) {
  .wrap { padding: 0 16px; }
  .hero { padding: 56px 0 40px; }
  .section { padding: 44px 0; }
  .hero-actions .btn { flex: 1 1 auto; text-align: center; justify-content: center; }
  .booking-panel { padding: 20px; }
  .admin-main { padding: 20px 14px; }
  .card { padding: 18px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; justify-content: center; }
  .section-head { flex-direction: column; align-items: flex-start; }
  .walkin-box { padding: 18px 14px; }

  /* Tables become stacked cards on phones — one labelled line per field —
     instead of a 6-column grid you have to scroll sideways to read. The
     JS that builds each row adds data-label to every <td>. */
  .table-wrap { overflow-x: visible; }
  .table { min-width: 0; }
  .table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table tr {
    display: block;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 6px 14px;
    margin-bottom: 10px;
  }
  .table td {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 16px;
    padding: 7px 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
    overflow-wrap: anywhere;
  }
  .table tr td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    color: var(--paper-dim);
    font-family: var(--mono);
    font-size: 0.66rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    flex-shrink: 0;
  }
  .table td[data-label=""]::before,
  .table td:not([data-label])::before { content: none; }
  .table td[data-label=""] { justify-content: flex-end; gap: 8px; padding-top: 12px; }
  .table td[colspan] { justify-content: center; text-align: center; color: var(--paper-dim); }
  .table tr:hover td { background: none; }

  /* iOS Safari renders a fixed background sized to the whole (very tall) page,
     which looks blurry/oversized and makes scrolling janky. Pin it to the
     viewport instead on phones. */
  body { background-attachment: scroll; }

  /* portal: tighter collapsible cards, less air between them */
  #portal-shell .section { padding-bottom: 12px; }
  #portal-shell .section:first-child { padding-bottom: 18px; }
  .portal-card > summary { padding: 15px 18px; }
  .portal-card__body { padding: 18px; }

  /* day/checkbox on its own row, then the two time pickers side by side —
     two lines per day instead of the four squeezed columns (or three when
     fully stacked), so the whole week fits without endless scrolling. */
  .avail-row {
    grid-template-columns: 1fr 1fr;
    column-gap: 8px;
    row-gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .avail-row label { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; }
  .avail-row > span { display: none; }
  .avail-row select { width: 100%; }

  .service-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "name remove" "price remove" "duration remove";
    row-gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
  }
  .service-row input[type="text"] { grid-area: name; }
  .service-price-wrap { grid-area: price; }
  .service-row select.service-duration { grid-area: duration; width: 100%; }
  .service-row .remove-service { grid-area: remove; align-self: center; }

  .carousel-3d .barber-card { width: 180px; }
  .barber-photo { width: 118px; height: 144px; }
  .barber-body { padding: 14px 10px 14px; }
  .form-grid-2 { gap: 12px; }
}

@media (max-width: 380px) {
  .carousel-3d .barber-card { width: 160px; }
}

/* ---------- touch targets ---------- */
@media (pointer: coarse) {
  .btn, .slot, .day-chip, .admin-side button,
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    min-height: 40px;
  }
  .slot { min-height: 44px; display: flex; align-items: center; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
