/* BST Admin: mobile-first. Base styles are for phones; 600px and 900px add room for tablets and desktops. */

:root {
  --navy: #0b1220;
  --navy-2: #16213a;
  --bg: #f3f5f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --line: #d9dee7;
  --input-line: #9aa3b2;
  --blue: #1560d4;
  --blue-hover: #0f4fb3;
  --blue-soft: #e7effc;
  --danger: #b42318;
  --danger-soft: #fef0ef;
  --ok: #05603a;
  --ok-soft: #ecfdf3;
  --warn: #8a4b00;
  --warn-soft: #fff7e6;
  --radius: 12px;
  --tap: 48px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; font: 400 1rem/1.55 var(--font); color: var(--text); background: var(--bg); }
img, svg { max-width: 100%; }
h1, h2 { line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.5rem, 1.25rem + 1vw, 1.875rem); font-weight: 800; }
h2 { font-size: 1.125rem; font-weight: 750; }
p { margin: 0 0 1rem; }
a { color: var(--blue); }
code { font-family: var(--mono); font-size: .95em; overflow-wrap: anywhere; }
/* 16px minimum stops iOS Safari from zooming into fields. */
input, button, select, textarea { font: inherit; font-size: max(16px, 1rem); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.skip-link { position: absolute; left: -999px; top: 0; z-index: 100; background: #fff; padding: .75rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }

/* ---------- Forms & buttons ---------- */

.form { display: grid; gap: 1rem; margin: 1rem 0; }
.field { display: grid; gap: .375rem; font-weight: 650; }
.field input {
  width: 100%; min-height: var(--tap); padding: .625rem .75rem;
  color: var(--text); background: #fff; font-weight: 400;
  border: 1px solid var(--input-line); border-radius: 10px;
}
.field input:focus-visible { outline: 3px solid var(--blue-soft); border-color: var(--blue); }
.code-input { text-align: center; letter-spacing: .35em; font-variant-numeric: tabular-nums; font-size: 1.375rem !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: var(--tap); padding: .625rem 1.125rem;
  border: 1px solid transparent; border-radius: 10px;
  font-weight: 700; line-height: 1.2; text-align: center; text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); }
.btn-secondary { background: #fff; color: var(--text); border-color: var(--line); }
.btn-secondary:hover { border-color: var(--blue); }
.btn-on-dark { background: transparent; color: #fff; border-color: rgba(255, 255, 255, .45); }
.btn-on-dark:hover { border-color: #fff; }
.btn-link { background: none; border: 0; padding: .5rem; min-height: var(--tap); color: var(--blue); text-decoration: underline; cursor: pointer; }
.btn-sm { min-height: 40px; padding: .375rem .875rem; font-size: .9375rem; }
.btn-block { width: 100%; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; margin: 0 0 1rem; }
.row .btn { flex: 1 1 10rem; }

.hint { color: var(--muted); font-size: .9375rem; }
.center { text-align: center; }
.lead { font-size: 1.125rem; }

.alert { padding: .75rem 1rem; border-radius: 10px; border: 1px solid; margin: 0 0 1rem; }
.alert-error { color: var(--danger); background: var(--danger-soft); border-color: #f9c9c4; }
.alert-ok { color: var(--ok); background: var(--ok-soft); border-color: #abefc6; }
.alert-warn { color: var(--warn); background: var(--warn-soft); border-color: #fedf89; }

/* ---------- Sign-in pages ---------- */

body.auth {
  min-height: 100vh; min-height: 100dvh;
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  background: radial-gradient(120% 60% at 50% 0%, var(--navy-2), var(--navy) 70%);
}
.auth-card {
  width: 100%; max-width: 30rem; margin-top: .5rem;
  padding: 1.5rem 1.25rem 1.75rem;
  background: var(--surface); border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .35);
}
.auth-card h1 { text-align: center; }
.auth-logo { display: block; width: 112px; height: auto; margin: 0 auto .75rem; }

.steps { padding-left: 1.25rem; margin: 0 0 1.25rem; }
.steps li { margin-bottom: 1.25rem; }
.steps li .btn, .steps li .secret { margin-top: .625rem; }
.qr { display: flex; justify-content: center; margin-top: .625rem; }
.qr svg { width: 184px; height: 184px; border: 1px solid var(--line); border-radius: 8px; }
.secret { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.secret code { padding: .5rem .625rem; background: var(--bg); border-radius: 8px; letter-spacing: .05em; }

.codes { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: .5rem 2rem; padding: 1rem 1rem 1rem 2.5rem; margin: 0 0 1rem; background: var(--bg); border-radius: 10px; }
.codes code { font-size: 1.0625rem; }

.help { margin: 1rem 0 .5rem; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 10px; }
.help summary { cursor: pointer; font-weight: 650; min-height: 32px; }
.help[open] summary { margin-bottom: .5rem; }

/* ---------- Signed-in layout ---------- */

body.app { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: max(.5rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
  background: var(--navy); color: #fff;
}
.topbar form { margin: 0; }
.brand { display: flex; align-items: center; gap: .625rem; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.0625rem; }

/* Phones: bottom tab bar within thumb reach. */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  background: var(--surface); border-top: 1px solid var(--line);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-height: 60px; padding: .25rem;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 650;
}
.nav-item[aria-current="page"] { color: var(--blue); }
.nav-item.is-disabled { opacity: .45; }
.nav-item small { display: none; }
.icon { width: 24px; height: 24px; flex: none; }

.main { width: 100%; max-width: 60rem; margin: 0 auto; padding: 1.25rem max(1rem, env(safe-area-inset-right)) 2rem max(1rem, env(safe-area-inset-left)); }
.page-title { margin-bottom: 1rem; }

.cards { display: grid; gap: 1rem; }
.card, .section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; }
.card.is-muted { background: #f8f9fb; color: var(--muted); }
.section { margin-bottom: 1rem; }
.section .form { max-width: 28rem; }

.facts { list-style: none; padding: 0; margin: 0 0 1rem; display: grid; gap: .5rem; }
.facts li, .facts div { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line); padding-bottom: .5rem; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 650; text-align: right; overflow-wrap: anywhere; }

.device-list { list-style: none; padding: 0; margin: 0 0 1rem; }
.device-list li { display: grid; gap: .125rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.device-list li:last-child { border-bottom: 0; }
.badge { justify-self: start; display: inline-block; padding: .125rem .5rem; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: .75rem; font-weight: 700; }

/* ---------- Content editors ---------- */

.back { margin: -.25rem 0 1rem; }
.back a { font-weight: 650; text-decoration: none; }
.hub .hub-card { color: var(--text); text-decoration: none; transition: border-color .15s, box-shadow .15s; }
.hub .hub-card:hover { border-color: var(--blue); box-shadow: 0 4px 16px rgba(17, 24, 39, .08); }
.hub .hub-card p { margin: 0; color: var(--muted); }
.hub-card-alert { border-left: 4px solid #f59e0b; }
.publish-panel { display: grid; gap: .75rem; margin-bottom: 1rem; border-left: 4px solid var(--ok); }
.publish-panel.has-changes { border-left-color: #f59e0b; background: #fffbeb; }
.publish-panel h2 { margin-bottom: .25rem; }
.publish-panel p { margin: 0; }
.publish-panel .row { margin: 0; }

.list { list-style: none; margin: 0 0 1rem; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.list-row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1rem; border-top: 1px solid var(--line); }
.list-row:first-child { border-top: 0; }
.list-main { display: grid; gap: .125rem; min-width: 0; }
.list-title { font-weight: 700; text-decoration: none; overflow-wrap: anywhere; }
.list-main .pill { justify-self: start; }
.pill { display: inline-block; padding: .0625rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 700; }
.pill-on { background: var(--ok-soft); color: var(--ok); }
.pill-off { background: #f2f4f7; color: var(--muted); }
.move { display: flex; gap: .375rem; flex: none; }
.move form { margin: 0; }
.btn-icon { min-width: 44px; min-height: 44px; padding: 0; font-size: 1.125rem; }
.btn:disabled { opacity: .35; cursor: not-allowed; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger .icon { width: 20px; height: 20px; }
.btn-icon-danger { color: var(--danger); }
.btn-icon-danger:hover { border-color: var(--danger); background: var(--danger-soft); color: var(--danger); }
.btn-icon .icon { width: 20px; height: 20px; }
.row-actions { display: flex; align-items: center; gap: .375rem; flex: none; }
.confirm-card { display: grid; gap: .75rem; max-width: 34rem; }
.confirm-card p { margin: 0; }
.confirm-message { font-size: 1.125rem; font-weight: 700; }
.confirm-card .row { margin: 0; }
.btn-danger:hover { background: #912018; }

.editor .section { display: grid; gap: 1.125rem; }
.editor .section h2 { font-size: 1.0625rem; margin: 0; }
.field .hint, fieldset.field .hint { font-weight: 400; margin: 0; }
.check { display: flex; align-items: flex-start; gap: .625rem; min-height: 44px; padding: .375rem 0; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; margin-top: .125rem; flex: none; accent-color: var(--blue); }
.check .hint { display: block; font-weight: 400; }
.field textarea { width: 100%; padding: .625rem .75rem; border: 1px solid var(--input-line); border-radius: 10px; font: inherit; line-height: 1.5; resize: vertical; }
.field textarea:focus-visible, .field select:focus-visible { outline: 3px solid var(--blue-soft); border-color: var(--blue); }
.field input[aria-invalid="true"], .field textarea[aria-invalid="true"] { border-color: var(--danger); }
.field-error { color: var(--danger); font-weight: 600; font-size: .9375rem; }
.field-compact input { min-height: 40px; }
fieldset.field { border: 0; padding: 0; margin: 0; min-width: 0; }
fieldset.field legend { font-weight: 650; margin-bottom: .375rem; padding: 0; }
.origin-bar { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.origin-bar h2 { margin: 0; }
.origin-section { display: grid; gap: .875rem; }
.origin-section > p, .origin-section > .list { margin: 0; }
.check-list { display: grid; gap: 0; }
@media (min-width: 600px) { .check-list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 1.5rem; } }
.pair { display: grid; gap: .75rem; padding: .75rem 0; border-top: 1px dashed var(--line); }
.pair:first-of-type { border-top: 0; }

.md-toolbar { display: flex; flex-wrap: wrap; gap: .375rem; }
.md-toolbar .btn { min-width: 44px; }

/* Sticky save bar: above the bottom tabs on phones, at the bottom of the screen on desktop. */
.save-bar {
  position: sticky; bottom: calc(60px + env(safe-area-inset-bottom)); z-index: 10;
  display: flex; flex-wrap: wrap; align-items: center; gap: .5rem;
  margin: 1rem -1rem 0; padding: .75rem 1rem;
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--line); box-shadow: 0 -6px 16px rgba(17, 24, 39, .06);
}
.save-bar .btn-primary { flex: 1 1 12rem; }
/* A save bar inside a card would break out of it (its negative margins assume it sits on the page). */
.card .save-bar, .section .save-bar { position: static; margin: 1rem 0 0; padding: 0; background: none; border: 0; box-shadow: none; }
.publish-form { display: grid; gap: .875rem; }
.publish-form p, .publish-form .row { margin: 0; }
.publish-form .btn-primary { flex: 0 1 18rem; }

.photo-picker .picker-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
.pick { position: relative; display: grid; gap: .25rem; padding: .375rem; border: 2px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; }
.pick:has(input:checked) { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.pick input { position: absolute; top: .5rem; left: .5rem; width: 20px; height: 20px; accent-color: var(--blue); }
.pick img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.pick-alt { font-size: .8125rem; color: var(--muted); line-height: 1.3; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pick-none { place-items: center; min-height: 6rem; color: var(--muted); font-weight: 650; }
.gallery-pick { display: grid; gap: .75rem; }
.gallery-pick-item { display: grid; gap: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.gallery-pick-item .check img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; flex: none; }
.gallery-pick-item .check span { font-weight: 500; font-size: .9375rem; }

.photo-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; }
.photo-tile { display: grid; gap: .25rem; padding: .5rem; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--text); text-decoration: none; }
.photo-tile:hover { border-color: var(--blue); }
.photo-tile img { width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; }
.photo-alt { font-weight: 650; font-size: .9375rem; line-height: 1.3; }
.photo-large { width: 100%; max-width: 40rem; height: auto; border-radius: var(--radius); margin-bottom: .5rem; }
.upload-preview { max-width: 16rem; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); }
.upload-progress { width: 100%; height: 10px; }

.danger-zone { margin-top: 1.5rem; padding: .75rem 1rem; border: 1px solid #f9c9c4; border-radius: 10px; background: var(--danger-soft); }
.danger-zone summary { cursor: pointer; font-weight: 700; color: var(--danger); min-height: 32px; }

/* ---------- Bookings ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: .375rem; margin: 0 0 1rem; }
.tab { display: inline-flex; align-items: center; gap: .375rem; min-height: 40px; padding: 0 .875rem; border: 1px solid var(--line); border-radius: 999px; background: #fff; color: var(--text); text-decoration: none; font-weight: 650; }
.tab[aria-current="page"] { background: var(--navy); border-color: var(--navy); color: #fff; }
.tab .count { display: inline-grid; place-items: center; min-width: 1.4rem; height: 1.4rem; padding: 0 .3rem; border-radius: 999px; background: var(--blue-soft); color: var(--blue); font-size: .75rem; font-weight: 800; }
.booking-list { display: grid; gap: 1rem; margin-bottom: 1rem; }
.booking { display: grid; gap: .75rem; }
.booking.is-new { border-left: 4px solid var(--blue); }
.booking-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; }
.booking-head h2 { margin: 0; font-size: 1.125rem; }
.booking-head h2 a { text-decoration: none; }
.booking-head p { margin: 0; }
.booking-route { margin: 0; font-size: 1.0625rem; }
.booking-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem 1rem; margin: 0; }
.booking-facts div { display: grid; }
.booking-facts dt { color: var(--muted); font-size: .875rem; }
.booking-facts dd { margin: 0; font-weight: 650; overflow-wrap: anywhere; }
.booking-notes { margin: 0; padding: .625rem .875rem; border-left: 3px solid var(--line); background: var(--bg); border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.contact-actions, .booking-actions { margin: 0; }
.contact-actions .btn { overflow-wrap: anywhere; text-align: left; }
.booking-actions form { margin: 0; }
.booking .alert, .booking .hint { margin: 0; }
.pill-new { background: var(--blue-soft); color: var(--blue); }
.card.has-new { border-left: 4px solid var(--blue); }
@media (min-width: 600px) { .booking-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.draft-banner { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1rem; padding: .75rem 1rem; margin: 0 0 1rem; border: 1px solid #fedf89; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.draft-banner .row { margin: 0; }

/* ---------- Tablets ---------- */

@media (min-width: 600px) {
  .photo-picker .picker-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .gallery-pick-item { grid-template-columns: 1fr 14rem; align-items: center; }
  .publish-panel { grid-template-columns: 1fr auto; align-items: center; }
  .auth-card { margin-top: 6vh; padding: 2rem 2.25rem 2.25rem; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding-top: 1.75rem; }
}

/* ---------- Tablet landscape & desktop: sidebar ---------- */

@media (min-width: 900px) {
  body.app {
    padding-bottom: 0;
    display: grid; grid-template-columns: 15rem minmax(0, 1fr); grid-template-rows: auto 1fr;
    min-height: 100vh; min-height: 100dvh;
  }
  .topbar { grid-column: 1 / -1; }
  .nav {
    position: sticky; top: 56px; bottom: auto; align-self: start;
    display: flex; flex-direction: column; gap: .25rem;
    height: calc(100dvh - 56px); padding: 1rem .75rem;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav-item { flex-direction: row; justify-content: flex-start; gap: .75rem; min-height: 44px; padding: 0 .75rem; border-radius: 10px; font-size: .9375rem; }
  .nav-item[aria-current="page"] { background: var(--blue-soft); }
  .nav-item:not(.is-disabled):hover { background: var(--bg); }
  .nav-item small { display: inline; margin-left: auto; font-size: .6875rem; text-transform: uppercase; letter-spacing: .04em; }
  .main { margin: 0; padding: 2rem 2.5rem; }
  .save-bar { bottom: 0; margin: 1rem -2.5rem 0; padding: .75rem 2.5rem; }
  .photo-picker .picker-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .photo-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

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

/* Printing the recovery codes: only the codes. */
@media print {
  body * { visibility: hidden; }
  #recovery-codes, #recovery-codes * { visibility: visible; }
  #recovery-codes { position: absolute; inset: 0 auto auto 0; background: none; }
}
