/* Design tokens + shared components — mobile-first, WCAG AA, 44px+ targets, 200% zoom safe.
   Tenant theme overrides --c-primary / --c-accent / --c-bg / fonts at runtime (shared/theme.js).
   Accent is DECORATIVE ONLY (borders, rules, highlights) — never body text on light surfaces,
   so a low-contrast brand accent (e.g. gold) can never break AA. */

:root {
  --font-stack: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-heading: var(--font-stack);
  --font-body: var(--font-stack);

  --c-primary: #2F3B44;        /* actions, headings — themed per shop */
  --c-accent: #2F3B44;         /* decorative highlight — themed per shop */
  --c-bg: #F7F6F3;             /* page canvas — themed per shop */
  --c-on-primary: #FFFFFF;
  --c-surface: #FFFFFF;
  --c-ink: #1C1F22;            /* 15.5:1 on white */
  --c-muted: #55606B;          /* 6.4:1 on white — AA for small text */
  --c-line: #DCDAD4;
  --c-danger: #B3261E;         /* 6.5:1 on white */
  --c-ok: #1E6B3C;
  --c-warn-bg: #FFF4E0;
  --c-danger-bg: #FBEDEC;
  --c-ok-bg: #E9F4EC;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 24, .06), 0 6px 24px rgba(20, 22, 24, .07);
  --tap: 48px;                 /* min target (44px WCAG + margin for older thumbs) */
  --pad: 1rem;
}

* { box-sizing: border-box; }
html { font-size: 100%; }      /* respect user/browser text size — 200% zoom must reflow */
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;        /* 17px base — clientele skews older */
  line-height: 1.5;
  color: var(--c-ink);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { font-family: var(--font-heading); color: var(--c-ink); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.65rem; font-weight: 650; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
a { color: var(--c-primary); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--c-primary); outline-offset: 2px; border-radius: 4px; }
[tabindex="-1"]:focus { outline: none; }

.muted { color: var(--c-muted); }
.small { font-size: .9375rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ── Layout ── */
.wrap { max-width: 32rem; margin: 0 auto; padding: 0 var(--pad) 4rem; }
.card {
  background: var(--c-surface); border: 1px solid var(--c-line);
  border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow);
}
.stack > * + * { margin-top: .75rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spread { display: flex; justify-content: space-between; align-items: baseline; gap: .6rem; flex-wrap: wrap; }
hr.rule { border: 0; border-top: 1px solid var(--c-line); margin: 1rem 0; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .6rem 1.15rem; width: auto;
  border-radius: var(--radius-sm); border: 1.5px solid transparent;
  font: inherit; font-weight: 600; font-size: 1.0625rem; line-height: 1.2;
  cursor: pointer; text-decoration: none; text-align: center;
  touch-action: manipulation;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn-primary:not(:disabled):active { filter: brightness(1.12); }
.btn-ghost { background: var(--c-surface); color: var(--c-primary); border-color: var(--c-primary); }
.btn-quiet { background: transparent; color: var(--c-primary); border-color: var(--c-line); }
.btn-danger { background: var(--c-surface); color: var(--c-danger); border-color: var(--c-danger); }
.btn-block { display: flex; width: 100%; }
.btn-link {
  background: none; border: 0; color: var(--c-primary); text-decoration: underline;
  text-underline-offset: 3px; font: inherit; cursor: pointer; padding: .5rem .25rem;
  min-height: var(--tap); display: inline-flex; align-items: center;
}

/* ── Choice list (radio-like big rows) ── */
.choice {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  min-height: 56px; padding: .7rem .9rem; text-align: left;
  background: var(--c-surface); border: 1.5px solid var(--c-line);
  border-radius: var(--radius-sm); font: inherit; color: var(--c-ink); cursor: pointer;
}
.choice[aria-pressed="true"], .choice[aria-checked="true"] {
  border-color: var(--c-primary); box-shadow: inset 0 0 0 1px var(--c-primary);
  background: color-mix(in srgb, var(--c-primary) 5%, var(--c-surface));
}
.choice .choice-main { flex: 1 1 auto; min-width: 0; }
.choice .choice-title { display: block; font-weight: 600; }
.choice .choice-sub { display: block; color: var(--c-muted); font-size: .9375rem; }
.choice .choice-side { flex: 0 0 auto; font-weight: 600; white-space: nowrap; }
.choice .tick { flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border-radius: 50%;
  border: 2px solid var(--c-line); display: inline-flex; align-items: center; justify-content: center;
  font-size: .95rem; color: var(--c-on-primary); }
.choice[aria-pressed="true"] .tick, .choice[aria-checked="true"] .tick {
  background: var(--c-primary); border-color: var(--c-primary); }

/* ── Slot grid (time buttons) ── */
.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.4rem, 1fr)); gap: .55rem; }
.slot {
  min-height: var(--tap); border: 1.5px solid var(--c-line); border-radius: var(--radius-sm);
  background: var(--c-surface); font: inherit; font-weight: 600; color: var(--c-ink); cursor: pointer;
  padding: .45rem .3rem; display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.slot .slot-sub { font-weight: 400; font-size: .8125rem; color: var(--c-muted); }
.slot[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }
.slot[aria-pressed="true"] .slot-sub { color: var(--c-on-primary); opacity: .85; }

/* ── Date strip ── */
.date-strip {
  display: flex; gap: .5rem; overflow-x: auto; padding: .25rem 2px .6rem;
  scrollbar-width: thin; -webkit-overflow-scrolling: touch;
}
.date-chip {
  flex: 0 0 auto; min-width: 4.2rem; min-height: 4.4rem; padding: .5rem .4rem;
  border: 1.5px solid var(--c-line); border-radius: var(--radius-sm); background: var(--c-surface);
  font: inherit; color: var(--c-ink); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: .1rem;
}
.date-chip .dc-dow { font-size: .8125rem; color: var(--c-muted); }
.date-chip .dc-day { font-size: 1.25rem; font-weight: 650; }
.date-chip .dc-mon { font-size: .8125rem; color: var(--c-muted); }
.date-chip[aria-pressed="true"] { background: var(--c-primary); border-color: var(--c-primary); }
.date-chip[aria-pressed="true"] .dc-day { color: var(--c-on-primary); }
.date-chip[aria-pressed="true"] .dc-dow, .date-chip[aria-pressed="true"] .dc-mon {
  color: var(--c-on-primary); opacity: .85; }

/* ── Forms ── */
.field { display: block; margin-bottom: .9rem; }
.field > span { display: block; font-weight: 600; margin-bottom: .3rem; }
.field .hint { font-weight: 400; color: var(--c-muted); font-size: .9375rem; }
input[type="text"], input[type="tel"], input[type="email"], input[type="number"],
input[type="time"], input[type="date"], select, textarea {
  width: 100%; min-height: var(--tap); padding: .55rem .75rem;
  font: inherit; font-size: 1.0625rem;   /* ≥16px — no iOS zoom-on-focus */
  color: var(--c-ink); background: var(--c-surface);
  border: 1.5px solid #9AA1A9; border-radius: var(--radius-sm);
}
textarea { min-height: 6rem; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--c-primary); outline: 2px solid var(--c-primary); outline-offset: 0; }

.seg { display: flex; border: 1.5px solid var(--c-primary); border-radius: var(--radius-sm); overflow: hidden; }
.seg > button {
  flex: 1; min-height: var(--tap); border: 0; background: var(--c-surface); color: var(--c-primary);
  font: inherit; font-weight: 600; cursor: pointer; border-left: 1px solid var(--c-primary);
}
.seg > button:first-child { border-left: 0; }
.seg > button[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); }

/* ── Banners / badges / chips ── */
.banner { border-radius: var(--radius-sm); padding: .7rem .9rem; border: 1px solid var(--c-line); background: var(--c-surface); }
.banner-warn { background: var(--c-warn-bg); border-color: #E0C48C; }
.banner-danger { background: var(--c-danger-bg); border-color: #E3B6B3; }
.banner-ok { background: var(--c-ok-bg); border-color: #BCD9C6; }
.badge {
  display: inline-flex; align-items: center; min-height: 1.5rem; padding: .1rem .55rem;
  border-radius: 999px; font-size: .8125rem; font-weight: 700; letter-spacing: .02em;
  background: var(--c-line); color: var(--c-ink);
}
.badge-danger { background: var(--c-danger); color: #fff; }
.badge-ok { background: var(--c-ok); color: #fff; }
.chip-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.chip {
  min-height: 2.5rem; padding: .3rem .85rem; border-radius: 999px; font: inherit; font-size: .9375rem;
  border: 1.5px solid var(--c-line); background: var(--c-surface); color: var(--c-ink); cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--c-primary); color: var(--c-on-primary); border-color: var(--c-primary); }

/* ── Bottom sheet (dashboard actions) ── */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(18, 20, 22, .5); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--c-surface); width: 100%; max-width: 34rem;
  border-radius: var(--radius) var(--radius) 0 0; padding: 1.1rem 1.1rem calc(1.1rem + env(safe-area-inset-bottom));
  max-height: 88vh; overflow-y: auto;
}
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 1rem; }
  .sheet { border-radius: var(--radius); }
}

/* ── Misc ── */
.spinner {
  display: inline-block; width: 1.15rem; height: 1.15rem; vertical-align: -0.2rem;
  border: 2.5px solid currentColor; border-right-color: transparent; border-radius: 50%;
  animation: pb-spin .7s linear infinite;
}
@keyframes pb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.6s; }
  * { scroll-behavior: auto !important; }
}
.accent-rule { border: 0; border-top: 3px solid var(--c-accent); width: 3rem; margin: .35rem 0 1rem; }
