:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --border: #e5e7ee;
  --text: #16181d;
  --muted: #6b7280;
  --brand: #2f6df6;
  --brand-dark: #1f52cc;
  --brand-soft: #eaf1ff;
  --success: #128a52;
  --success-soft: #e7f7ef;
  --danger: #c92a2a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 8px 24px rgba(16, 24, 40, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand);
}
.brand-mark {
  border-radius: 6px;
  display: block;
  flex-shrink: 0;
}

h1 { font-size: 24px; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 17px; letter-spacing: -0.01em; margin: 0 0 4px; }
p.sub { color: var(--muted); margin: 0 0 24px; }
p { margin: 0 0 12px; }

.steps {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  font-size: 13px;
  color: var(--muted);
}
.steps .step {
  flex: 1;
  padding: 8px 10px;
  background: #f2f4f8;
  border-radius: 8px;
  text-align: center;
  transition: background .15s, color .15s;
}
.steps .step.active { background: var(--brand); color: #fff; font-weight: 600; }
.steps .step.done { background: var(--brand-soft); color: var(--brand-dark); }

.field { margin-bottom: 16px; }
label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  font: inherit;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
}
textarea { min-height: 88px; resize: vertical; }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

button {
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  border-radius: 10px;
  padding: 11px 18px;
  border: 1px solid transparent;
  background: var(--brand);
  color: #fff;
  transition: background .15s, opacity .15s;
}
button:hover:not(:disabled) { background: var(--brand-dark); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: transparent; color: var(--muted); border-color: var(--border); }
button.ghost:hover { background: #f2f4f8; color: var(--text); }
button.block { width: 100%; }
.btn {
  display: inline-block;
  flex: 1;
  text-align: center;
  font-weight: 600;
  border-radius: 10px;
  padding: 11px 18px;
  background: var(--brand);
  color: #fff;
  text-decoration: none;
}
.btn:hover { background: var(--brand-dark); }

.row { display: flex; gap: 10px; align-items: center; }
.row.between { justify-content: space-between; }
.actions { display: flex; gap: 10px; margin-top: 24px; }
.actions > * { flex: 1; }

.daylist { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.day {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 8px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: border-color .15s, background .15s;
}
.day:hover { border-color: var(--brand); }
.day.selected { border-color: var(--brand); background: var(--brand-soft); }
.day .dow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.day .num { font-size: 20px; font-weight: 600; }
.day .mon { font-size: 12px; color: var(--muted); }

.slotlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px; }
.slot {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 6px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  /* Buttons inherit color:#fff from the base button rule, which is invisible
     on this white background. Reset it explicitly. */
  color: var(--text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.slot:hover { border-color: var(--brand); background: var(--brand-soft); color: var(--text); }
.slot.selected { border-color: var(--brand); background: var(--brand); color: #fff; }

.summary {
  background: #f8f9fc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 14px;
}
.summary b { display: block; margin-top: 2px; }

.banner {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
}
.banner.error { background: #fdecec; color: var(--danger); }
.banner.warn { background: #fff6e5; color: #8a5a00; }
.banner.ok { background: var(--success-soft); color: var(--success); }
.banner[hidden] { display: none; }
/* Long guidance messages should read as guidance, not a wall of red text. */
.banner.guide { background: #f4f6fb; color: var(--muted); border: 1px solid var(--border); }
.banner.guide b { color: var(--text); }

.meet {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--success-soft);
  border: 1px solid #bfe5d2;
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 16px;
}
.meet a { color: var(--success); font-weight: 600; word-break: break-all; }

.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.45);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); font-size: 14px; padding: 20px 0; text-align: center; }

/* Admin table */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tbody tr:hover { background: #fafbfd; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill.confirmed { background: var(--success-soft); color: var(--success); }
.pill.cancelled { background: #f2f4f8; color: var(--muted); }
.pill.calendar_error { background: #fdecec; color: var(--danger); }
.pill.warn { background: #fff6e5; color: #8a5a00; }
.pill.pending { background: #fff6e5; color: #8a5a00; }

.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 24px; }
.stat { border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.stat .n { font-size: 26px; font-weight: 600; letter-spacing: -0.02em; }
.stat .l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

.feedback { background: #fbfcff; border-left: 3px solid var(--brand); padding: 10px 14px; border-radius: 0 8px 8px 0; white-space: pre-wrap; }
.hidden { display: none !important; }
.steps-list { margin: 0; padding-left: 20px; }
.steps-list li { margin-bottom: 18px; }
.steps-list li > a { display: inline-block; margin-top: 4px; color: var(--brand); font-weight: 600; font-size: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

@media (max-width: 560px) {
  .wrap { padding: 20px 14px 48px; }
  .card { padding: 20px; }
  .steps .step { font-size: 11px; padding: 7px 4px; }
}
/* ------------------------------------------- booking page wording panel */
.msg-group {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  margin: 22px 0 10px;
  font-weight: 600;
}
.msg-group:first-child { margin-top: 4px; }

.counter {
  float: right;
  font-size: 12px;
  color: var(--muted);
  font-weight: 400;
  font-variant-numeric: tabular-nums;
}

/* clickable template tokens */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #cfe0ff;
  cursor: pointer;
}
.chip:hover { background: #dbe8ff; }

/* live preview */
.msg-preview { margin: 18px 0 4px; }
.msg-preview-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
  font-weight: 600;
  margin-bottom: 8px;
}
.msg-preview-card {
  background: #f8f9fc;
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 16px;
}
.msg-preview-card b { display: block; font-size: 19px; letter-spacing: -0.01em; margin-bottom: 4px; }
.msg-preview-card span { display: block; color: var(--muted); font-size: 14px; }
.msg-preview-invite {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* unsaved state */
#messagesSaveBar.dirty .actions { }
#messagesSaveBar button:not(:disabled) { box-shadow: 0 0 0 3px var(--brand-soft); }

.msg-more {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.msg-more > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: var(--brand-dark);
}
.msg-more[open] > summary { margin-bottom: 8px; }

/* ------------------------------------------- booking page additions */
.typeswitch { margin-bottom: 18px; font-size: 14px; }
.typeswitch .typelink {
  color: var(--brand-dark);
  font-weight: 600;
  text-decoration: none;
  margin-left: 6px;
}
.typeswitch .typelink:hover { text-decoration: underline; }

/* Timezone overlay switch. Kept small so it reads as a view control, not a
   choice the visitor has to make before they can book. */
button.tztoggle {
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #cfe0ff;
  flex-shrink: 0;
}
button.tztoggle:hover { background: #dbe8ff; }

/* Extra intake questions. A checkbox needs its label inline, unlike the
   stacked fields above. */
label.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 500;
  cursor: pointer;
}
label.checkbox input { width: auto; }

/* Share + QR */
.qrbox {
  display: flex;
  justify-content: center;
  padding: 16px 0 12px;
}
.qrbox svg {
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 100%;
  height: auto;
}
.sharegrid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sharelink {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}
.sharelink:hover { border-color: var(--brand); color: var(--brand-dark); }
.sharelink.copy { background: var(--brand-soft); border-color: #cfe0ff; color: var(--brand-dark); }

/* ------------------------------------------- admin: booking pages */
.grid2, .grid3, .grid4 {
  display: grid;
  gap: 0 16px;
  align-items: start;
}
.grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* Rows are flex so the address and the buttons stay on one line on a
   laptop, and simply wrap on a phone. */
.pagerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagerow:last-child { border-bottom: none; }
.pagerow code {
  background: #f1f3f9;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 12px;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: 999px;
  background: #eef0f5;
  color: var(--muted);
  white-space: nowrap;
}
.badge-live { background: var(--success-soft); color: var(--success); }

/* Day toggles for a page's working days. */
.daytoggles { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.daytoggle {
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  background: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.daytoggle input { width: auto; margin: 0; }
.daytoggle.off { opacity: 0.45; cursor: default; }

/* One intake question being edited. */
.intakerow {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #fafbfe;
}

/* Branding */
.brandpreview {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafbfe;
}
.brandpreview img {
  max-width: 160px;
  max-height: 56px;
  object-fit: contain;
}

/* ------------------------------------------------------------------ *
 * Admin portal: section nav, attendance, per-call notes.              *
 * ------------------------------------------------------------------ */

.admin-page { padding-top: 24px; }

.adminnav {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 4px 0 18px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.adminnav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.adminnav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.adminnav-links a {
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-decoration: none;
}
.adminnav-links a:hover { background: #f2f4f8; color: var(--text); }
.adminnav-links a[aria-current="page"] {
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.adminnav-actions { display: flex; gap: 8px; align-items: center; }
/* The nav's "Change password" is a link that looks like the other buttons. */
a.navbtn { display: inline-block; }
@media (max-width: 720px) {
  .adminnav-actions { width: 100%; justify-content: flex-start; }
}

/* Attendance */
.pill.showed { background: var(--success-soft); color: var(--success); }
.pill.noshow { background: #fdecec; color: var(--danger); }
.pill.unmarked { background: #f2f4f8; color: var(--muted); }

button.ghost.mini { padding: 4px 10px; font-size: 12.5px; }
button.ghost.pressed {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
button.ghost.pressed:hover { background: var(--brand-dark); color: #fff; }

/* Per-call admin notes. Server-side only: never shown to the client. */
.notesbox {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fbfcff;
  min-width: 170px;
}
.notesbox > summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  user-select: none;
}
.notesbox[open] > summary { margin-bottom: 6px; }
.notesbox .dotmark { color: var(--brand); }
.notesbox textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  resize: vertical;
  background: #fff;
}
.notesbox .row { margin-top: 6px; }
