@import url('/assets/brand.css');

/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg: var(--brand-background);
  --text: var(--brand-text);
  --heading: var(--brand-heading);
  --primary: var(--brand-primary);
  --on-primary: var(--brand-button-text);
  --btn-bg: var(--brand-button-background);
  --header-bg: var(--brand-header-background);
  --header-text: var(--brand-header-text);
  --ink-tile: var(--brand-text);
  --on-ink: #ffffff;
  --surface: #ffffff;
  --surface-2: #eef3f7;
  --muted: #4a6378;
  --line: #d5dee6;
  --field: #6b8096;
  --tint: #e3f4f2;
  --ok: #1d6b3a; --ok-bg: #e2f4e8;
  --warn: #7a4b00; --warn-bg: #fff1d1;
  --bad: #a3242b; --bad-bg: #fde8e8;
  --focus: var(--brand-text);
  --font: var(--brand-font-body);
  --font-head: var(--brand-font-heading);
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px; --s8: 72px;
  --t-xs: .8125rem; --t-sm: .9375rem; --t-md: 1rem; --t-lg: 1.25rem; --t-xl: 1.625rem; --t-2xl: 2.25rem; --t-hero: clamp(2.5rem, 6vw, 3.75rem);
  --r: 12px; --r-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 59, 95, .06), 0 8px 24px rgba(15, 59, 95, .08);
  color-scheme: light;
}
[data-theme='dark'] {
  --bg: #0b1d2e;
  --text: #e8f0f6;
  --heading: #ffffff;
  --header-bg: #0b1d2e;
  --header-text: #e8f0f6;
  --ink-tile: #163a5a;
  --surface: #12283d;
  --surface-2: #183049;
  --muted: #a9bccb;
  --line: #24405a;
  --field: #7d98b0;
  --tint: #123b3a;
  --ok: #8be0a8; --ok-bg: #12321f;
  --warn: #ffd27a; --warn-bg: #3a2a08;
  --bad: #ffa3a8; --bad-bg: #3a1518;
  --focus: var(--brand-primary);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: var(--t-md); line-height: 1.55; min-height: 100vh; overflow-x: hidden; }
h1, h2, h3, h4 { font-family: var(--font-head); color: var(--heading); line-height: 1.15; margin: 0 0 var(--s3); letter-spacing: -.01em; }
h1 { font-size: var(--t-2xl); font-weight: 800; }
h2 { font-size: var(--t-xl); font-weight: 800; }
h3 { font-size: var(--t-lg); font-weight: 700; }
p { margin: 0 0 var(--s3); }
a { color: var(--text); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); color: var(--text); padding: var(--s2) var(--s3); z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.small { font-size: var(--t-sm); }
.money, .price { white-space: nowrap; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.icon { width: 20px; height: 20px; flex: none; vertical-align: -4px; }
.icon-lg { width: 28px; height: 28px; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 var(--s4); }
.stack > * + * { margin-top: var(--s4); }
.row { display: flex; gap: var(--s3); align-items: center; flex-wrap: wrap; }
.row-between { display: flex; gap: var(--s3); align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-end { display: flex; gap: var(--s3); justify-content: flex-end; flex-wrap: wrap; margin-top: var(--s4); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); min-height: 44px; padding: 10px 18px; border-radius: var(--r-sm); border: 1.5px solid var(--field); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; text-decoration: none; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
.btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:disabled, .btn[aria-busy='true'] { opacity: .65; cursor: progress; transform: none; box-shadow: none; }
.btn-primary { background: var(--btn-bg); border-color: var(--btn-bg); color: var(--on-primary); }
.btn-danger { background: var(--bad-bg); border-color: var(--bad); color: var(--bad); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { min-height: 44px; padding: 6px 12px; font-size: var(--t-sm); }
.btn-lg { min-height: 52px; padding: 14px 26px; font-size: var(--t-lg); }
.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: var(--r-sm); border: 1.5px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; }
.icon-btn:hover { border-color: var(--field); }

/* ── Badges ─────────────────────────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: var(--t-xs); font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--text); }
.badge-ok { background: var(--ok-bg); color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad { background: var(--bad-bg); color: var(--bad); }
.badge-tint { background: var(--tint); color: var(--text); }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: var(--s1); margin-bottom: var(--s4); }
.field label, .label { font-weight: 700; }
.hint { font-size: var(--t-sm); color: var(--muted); }
.input, select.input, textarea.input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1.5px solid var(--field); border-radius: var(--r-sm); background: var(--surface); color: var(--text); font: inherit; }
textarea.input { min-height: 110px; resize: vertical; }
.input[aria-invalid='true'] { border-color: var(--bad); }
.field-error { color: var(--bad); font-size: var(--t-sm); font-weight: 700; min-height: 0; }
.error-summary { border: 2px solid var(--bad); background: var(--bad-bg); color: var(--bad); padding: var(--s3) var(--s4); border-radius: var(--r-sm); margin-bottom: var(--s4); }
.error-summary a { color: var(--bad); }
.choice { display: flex; gap: var(--s2); flex-wrap: wrap; }
.choice label { display: inline-flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 8px 14px; border: 1.5px solid var(--field); border-radius: var(--r-sm); background: var(--surface); cursor: pointer; font-weight: 600; }
.choice input { width: 18px; height: 18px; accent-color: var(--brand-text); }
.choice label:has(input:checked) { background: var(--tint); border-color: var(--text); }
.check-row { display: flex; gap: var(--s2); align-items: center; min-height: 44px; }
.check-row input { width: 20px; height: 20px; accent-color: var(--brand-text); }

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); box-shadow: var(--shadow); min-width: 0; }
.card-flat { box-shadow: none; }
.card h3 { margin-bottom: var(--s2); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: var(--s3); }

/* ── States ─────────────────────────────────────────────────────────────── */
.skeleton { display: grid; gap: var(--s3); }
.sk-row { height: 56px; border-radius: var(--r-sm); background: linear-gradient(90deg, var(--surface-2), var(--surface), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite linear; }
@keyframes sk { to { background-position: -200% 0; } }
.empty, .error-state { text-align: center; padding: var(--s6) var(--s4); border: 1.5px dashed var(--line); border-radius: var(--r); background: var(--surface); }
.error-state { border-color: var(--bad); color: var(--text); }
.error-state .icon { color: var(--bad); width: 28px; height: 28px; }

/* ── Toasts & dialogs ───────────────────────────────────────────────────── */
.toasts { position: fixed; bottom: var(--s4); left: 50%; transform: translateX(-50%); display: grid; gap: var(--s2); z-index: 200; width: min(92vw, 420px); }
.toast { padding: var(--s3) var(--s4); border-radius: var(--r-sm); background: var(--brand-text); color: #ffffff; box-shadow: var(--shadow); font-weight: 600; transition: opacity .3s; }
.toast-bad { background: #8a1c22; }
.toast.out { opacity: 0; }
.dialog { border: none; border-radius: var(--r); padding: 0; width: min(94vw, 520px); background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(8, 24, 40, .55); }
.dialog-body { padding: var(--s5); }
.dialog-body h2 { font-size: var(--t-lg); }

/* ── Customer shell ─────────────────────────────────────────────────────── */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--header-bg); color: var(--header-text); border-bottom: 1px solid var(--line); }
.topbar-in { display: flex; align-items: center; gap: var(--s3); min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: var(--s2); text-decoration: none; color: var(--header-text); font-weight: 800; flex: none; }
.brand img { height: 36px; width: auto; display: block; }
.nav { display: flex; gap: var(--s1); margin-left: auto; align-items: center; }
.nav a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 8px 12px; border-radius: var(--r-sm); color: var(--header-text); text-decoration: none; font-weight: 700; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current='page'] { background: var(--tint); }
.nav-cta { margin-left: var(--s2); }
.burger { display: none; margin-left: auto; }
main { min-height: 60vh; }
.page { padding: var(--s6) 0 var(--s8); }
.page-head { margin-bottom: var(--s5); }
.page-head p { color: var(--muted); max-width: 60ch; }

/* Home: hero collage */
.hero { padding: var(--s7) 0 var(--s6); }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: var(--s6); align-items: center; }
.hero h1 { font-size: var(--t-hero); line-height: 1.04; letter-spacing: -.02em; margin-bottom: var(--s4); }
.hero .lede { font-size: var(--t-lg); color: var(--muted); max-width: 46ch; margin-bottom: var(--s5); }
.mosaic { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(150px, auto) minmax(150px, auto); gap: var(--s3); }
.tile { border-radius: var(--r); padding: var(--s5); display: flex; flex-direction: column; justify-content: flex-end; gap: var(--s1); min-width: 0; }
.tile:first-child { grid-row: span 2; }
.tile-primary { background: var(--primary); color: var(--on-primary); }
.tile-ink { background: var(--ink-tile); color: var(--on-ink); }
.tile-soft { background: var(--surface); color: var(--text); border: 1px solid var(--line); }
.tile-big { font-family: var(--font-head); font-size: clamp(2.25rem, 5vw, 3.25rem); font-weight: 800; line-height: 1; }
.tile-mid { font-family: var(--font-head); font-size: var(--t-xl); font-weight: 800; line-height: 1.1; }
.tile p { margin: 0; font-weight: 600; }
.trust-row { display: flex; gap: var(--s4); flex-wrap: wrap; margin-top: var(--s5); color: var(--muted); font-size: var(--t-sm); font-weight: 600; }
.trust-row span { display: inline-flex; gap: 6px; align-items: center; }
.steps { padding: var(--s6) 0 var(--s7); }
.steps-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s4); }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s5); display: flex; flex-direction: column; gap: var(--s2); }
.step-num { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--primary); color: var(--on-primary); font-family: var(--font-head); font-weight: 800; font-size: var(--t-lg); }
.footer { border-top: 1px solid var(--line); background: var(--surface); padding: var(--s6) 0; font-size: var(--t-sm); }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: var(--s5); }
.footer h2 { font-size: var(--t-md); margin-bottom: var(--s2); }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }

/* Booking */
.date-strip { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: var(--s2); scroll-snap-type: x mandatory; }
.date-chip { flex: none; scroll-snap-align: start; display: grid; justify-items: center; min-width: 64px; min-height: 72px; padding: 8px; border-radius: var(--r-sm); border: 1.5px solid var(--field); background: var(--surface); color: var(--text); cursor: pointer; font: inherit; }
.date-chip b { font-size: var(--t-lg); }
.date-chip[aria-pressed='true'] { background: var(--brand-text); color: #ffffff; border-color: var(--brand-text); }
[data-theme='dark'] .date-chip[aria-pressed='true'] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: var(--s2); }
.slot { min-height: 48px; border-radius: var(--r-sm); border: 1.5px solid var(--field); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; font-variant-numeric: tabular-nums; }
.slot[aria-pressed='true'] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.summary { display: grid; gap: var(--s2); }
.summary-line { display: flex; justify-content: space-between; gap: var(--s3); }
.book-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); align-items: start; }
.sticky { position: sticky; top: 88px; }

/* Sessions */
.session { display: grid; grid-template-columns: auto 1fr; gap: var(--s4); align-items: start; }
.datebox { display: grid; justify-items: center; min-width: 64px; padding: var(--s2); border-radius: var(--r-sm); background: var(--tint); font-weight: 700; }
.datebox b { font-size: var(--t-xl); font-family: var(--font-head); line-height: 1; }
.session-actions { display: flex; gap: var(--s2); flex-wrap: wrap; margin-top: var(--s3); }

/* Messages */
.thread { display: flex; flex-direction: column; gap: var(--s3); max-height: 60vh; overflow-y: auto; padding: var(--s4); background: var(--surface-2); border-radius: var(--r); }
.bubble { max-width: 80%; padding: var(--s3) var(--s4); border-radius: 16px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.mine { align-self: flex-end; background: var(--tint); }
.bubble small { display: block; color: var(--muted); margin-top: 4px; font-size: var(--t-xs); }
.compose { display: flex; gap: var(--s2); margin-top: var(--s3); align-items: flex-end; }
.compose textarea { min-height: 52px; }

/* Library */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; margin-bottom: var(--s4); }
.chip { min-height: 44px; padding: 8px 16px; border-radius: 999px; border: 1.5px solid var(--field); background: var(--surface); color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.chip[aria-pressed='true'] { background: var(--brand-text); color: #ffffff; border-color: var(--brand-text); }
[data-theme='dark'] .chip[aria-pressed='true'] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.guides { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s4); }
.guide details summary { cursor: pointer; font-weight: 700; min-height: 44px; display: flex; align-items: center; }
.guide .body { white-space: pre-line; }

/* ── Admin shell ────────────────────────────────────────────────────────── */
.admin { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: var(--s4); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--s4); }
.sidebar .brand img { height: 32px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a { display: flex; gap: var(--s3); align-items: center; min-height: 44px; padding: 8px 12px; border-radius: var(--r-sm); text-decoration: none; color: var(--text); font-weight: 700; }
.side-nav a:hover { background: var(--surface-2); }
.side-nav a[aria-current='page'] { background: var(--tint); }
.side-nav .count { margin-left: auto; }
.console-tag { font-size: var(--t-xs); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.admin-top { position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: var(--s3); min-height: 64px; padding: 0 var(--s5); background: var(--header-bg); border-bottom: 1px solid var(--line); }
.admin-top h1 { font-size: var(--t-lg); margin: 0; }
.admin-top .who { margin-left: auto; display: flex; align-items: center; gap: var(--s2); }
.admin-main { padding: var(--s5); min-width: 0; }
.admin-burger { display: none; }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: var(--s4); margin-bottom: var(--s5); }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); }
.kpi .v { font-family: var(--font-head); font-size: var(--t-2xl); font-weight: 800; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; }
.kpi .l { color: var(--muted); font-weight: 700; font-size: var(--t-sm); }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--primary); }
.chart text { fill: var(--muted); font-size: 12px; font-family: var(--font); }
.chart .val { fill: var(--text); font-weight: 700; }
.table-tools { margin-bottom: var(--s3); max-width: 320px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); max-height: 70vh; }
.table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 0; z-index: 1; white-space: nowrap; }
.table th > .th-sort, .table th:not(:has(button)) { padding: 10px 12px; }
.th-sort { background: none; border: 0; font: inherit; font-weight: 800; color: var(--text); cursor: pointer; min-height: 44px; width: 100%; text-align: left; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.pager { display: flex; gap: var(--s3); align-items: center; justify-content: flex-end; margin-top: var(--s3); }
.day-group { margin-bottom: var(--s5); }
.day-group h3 { display: flex; align-items: baseline; gap: var(--s2); }
.diary-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: var(--s3); align-items: center; padding: var(--s3) var(--s4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); margin-bottom: var(--s2); }
.diary-row.cancelled { opacity: .75; }
.split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: var(--s4); align-items: start; }
.inbox a { display: block; padding: var(--s3); border-radius: var(--r-sm); text-decoration: none; border: 1px solid var(--line); background: var(--surface); margin-bottom: var(--s2); }
.inbox a[aria-current='true'] { border-color: var(--text); background: var(--tint); }
.answers { display: grid; gap: 6px; margin: 0; }
.answers div { display: flex; justify-content: space-between; gap: var(--s3); border-bottom: 1px dashed var(--line); padding: 4px 0; }
.answers dt { font-weight: 600; }
.answers dd { margin: 0; font-weight: 700; text-align: right; }
.signin-wrap { min-height: 100vh; display: grid; place-items: center; padding: var(--s4); }
.signin-card { width: min(100%, 440px); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .book-layout, .split { grid-template-columns: minmax(0, 1fr); }
  .sticky { position: static; }
}
@media (max-width: 860px) {
  .burger { display: inline-grid; }
  .nav { display: none; position: absolute; left: 0; right: 0; top: 68px; flex-direction: column; align-items: stretch; background: var(--header-bg); border-bottom: 1px solid var(--line); padding: var(--s3) var(--s4); }
  .nav.open { display: flex; }
  .nav-cta { margin-left: 0; }
  .hero-grid, .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .admin { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(82vw, 280px); z-index: 60; transform: translateX(-105%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .admin-burger { display: inline-grid; }
  .admin-top { padding: 0 var(--s3); }
  .admin-main { padding: var(--s4) var(--s3); }
}
@media (max-width: 640px) {
  .steps-grid, .grid-2, .grid-3, .guides { grid-template-columns: minmax(0, 1fr); }
  .mosaic { grid-template-rows: auto auto; }
  .tile { padding: var(--s4); min-height: 130px; }
  .diary-row { grid-template-columns: minmax(0, 1fr); }
  .card { padding: var(--s4); }
  .admin-top .who .email { display: none; }
  .kpi .v { font-size: var(--t-xl); }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
