/* ─── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg: #f7f5f0;
  --card: #fffefb;
  --ink: #191917;
  --muted: #6e6a60;
  --line: #e6e1d5;
  --primary: #a0824c;
  --primary-dark: #85683c;
  --grad: linear-gradient(150deg, #26261f 0%, #191917 100%);
  --serif: "Fraunces", Georgia, "Times New Roman", serif;
  --success: #4a7c59;
  --success-bg: #edf3ec;
  --warn: #96691c;
  --warn-bg: #f9f3e2;
  --danger: #b3402e;
  --danger-bg: #f9ecea;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(25,25,23,.05), 0 10px 26px -16px rgba(25,25,23,.18);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: var(--ink); }
a { color: var(--primary); text-decoration: none; }

/* ─── Layout shell ───────────────────────────────────────────────────────── */
.shell { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 20px 16px 96px; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(251,250,245,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; height: 58px;
}
.topbar .brand { font-family: var(--serif); font-weight: 600; font-size: 19px; letter-spacing: -.02em; }
.brand .dot { color: var(--primary); }
.topbar .who { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 10px; }

.statuspill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
}
.statuspill.live { background: var(--success-bg); color: var(--success); }
.statuspill.draft { background: var(--warn-bg); color: var(--warn); }
.statuspill.paused { background: var(--danger-bg); color: var(--danger); }
.statuspill .blink { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 2s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* Bottom tab bar (mobile-first) */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabbar button {
  background: none; border: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 10px;
  position: relative;
}
.tabbar button .ico { display: flex; align-items: center; justify-content: center; line-height: 1; }
.tabbar button.active { color: var(--primary); }
.tabbar button .badge {
  position: absolute; top: -2px; right: 2px;
  background: var(--danger); color: #fff; font-size: 10px; font-weight: 800;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; padding: 0 4px;
}

@media (min-width: 900px) {
  .main { max-width: 980px; padding: 28px 32px 60px; }
  .tabbar {
    top: 57px; bottom: auto; left: auto; right: auto;
    position: sticky; border: 0; border-bottom: 1px solid var(--line);
    background: rgba(247,245,240,.94); backdrop-filter: blur(8px);
    justify-content: flex-start; gap: 4px; padding: 14px 0 10px;
    max-width: 980px; margin: -1px auto 0; width: 100%;
  }
  .shell > .tabbar { padding-left: 32px; }
  .tabbar button { flex-direction: row; gap: 8px; font-size: 14px; padding: 8px 14px; }
  .tabbar button.active { background: #f0eadc; }
  .tabbar button .badge { position: static; }
}

/* ─── Cards & typography ─────────────────────────────────────────────────── */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin-bottom: 16px;
}
.card h2 { font-family: var(--serif); font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin-bottom: 4px; }
.card .sub { color: var(--muted); font-size: 14px; margin-bottom: 14px; }
.pagetitle { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 4px; }
.pagesub { color: var(--muted); font-size: 15px; margin-bottom: 18px; }

/* ─── Forms ──────────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 12px; background: #fff; font-size: 16px; outline: none;
  transition: border-color .15s;
}
.input:focus { border-color: var(--primary); }
textarea.input { resize: vertical; min-height: 80px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 520px) { .row2.stack { grid-template-columns: 1fr; } }

.prefix-input { display: flex; align-items: center; border: 1.5px solid var(--line); border-radius: 12px; background: #fff; }
.prefix-input:focus-within { border-color: var(--primary); }
.prefix-input span { padding: 0 0 0 14px; color: var(--muted); font-weight: 600; font-size: 15px; line-height: 1; }
.prefix-input input { border: 0; outline: none; padding: 12px 14px 12px 7px; width: 100%; font-size: 16px; border-radius: 12px; font-variant-numeric: tabular-nums; }
.prefix-input input::-webkit-outer-spin-button, .prefix-input input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.prefix-input input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; font-weight: 700; font-size: 15px;
  padding: 13px 20px; transition: transform .05s, opacity .15s;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--grad); color: #fff; box-shadow: 0 4px 14px -4px rgba(25,25,23,.35); }
.btn-ghost { background: #edeadf; color: var(--ink); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: 10px; }
.btn-big { padding: 16px 24px; font-size: 17px; border-radius: 14px; }

/* Toggle switch */
.switch { position: relative; width: 46px; height: 27px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track {
  position: absolute; inset: 0; background: #d6d0c2; border-radius: 999px;
  transition: background .15s; cursor: pointer;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  background: #fff; border-radius: 50%; transition: left .15s;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .track { background: var(--success); }
.switch input:checked + .track::after { left: 22px; }
.switchrow { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 6px 0; }
.switchrow .lbl { font-size: 14px; font-weight: 600; }
.switchrow .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }

/* ─── Wizard ─────────────────────────────────────────────────────────────── */
.steps { display: flex; gap: 8px; justify-content: center; margin: 18px 0 22px; }
.steps .s {
  width: 34px; height: 6px; border-radius: 3px; background: #e3ddcd; transition: background .3s;
}
.steps .s.done { background: var(--primary); }

.choicegrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 520px) { .choicegrid { grid-template-columns: repeat(2, 1fr); } }
.choice {
  border: 2px solid var(--line); border-radius: 14px; background: #fff;
  padding: 14px 8px; text-align: center; font-weight: 700; font-size: 13px;
}
.choice .emoji { font-size: 26px; display: block; margin-bottom: 6px; }
.choice.selected { border-color: var(--primary); background: #f6f1e4; }

.voicegrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.voice {
  border: 2px solid var(--line); border-radius: 14px; background: #fff;
  padding: 12px 14px; text-align: left;
}
.voice.selected { border-color: var(--primary); background: #f6f1e4; }
.voice b { display: block; font-size: 14px; }
.voice small { color: var(--muted); font-size: 12px; }

.bignumber {
  font-size: 32px; font-weight: 800; letter-spacing: .01em; text-align: center;
  background: var(--grad); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; margin: 10px 0;
}
.centered { text-align: center; }

.building { text-align: center; padding: 40px 10px; }
.building .spinner {
  width: 46px; height: 46px; margin: 0 auto 18px; border-radius: 50%;
  border: 4px solid #e6e1d5; border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.building .msg { font-weight: 700; font-size: 16px; min-height: 24px; }
.building .submsg { color: var(--muted); font-size: 13px; margin-top: 6px; }

/* ─── Lists (calls / messages / bookings) ────────────────────────────────── */
.item {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 14px 16px; margin-bottom: 10px;
}
.item .toprow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.item .who { font-weight: 700; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.item .when { color: var(--muted); font-size: 12px; white-space: nowrap; }
.item .body { color: #3c3a33; font-size: 14px; margin-top: 6px; }
.item .actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.unreaddot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); flex: none; }
.tag { font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; }
.tag.urgent { background: var(--danger-bg); color: var(--danger); }
.tag.booked { background: var(--success-bg); color: var(--success); }
.tag.cancelled { background: #f1f2f6; color: var(--muted); }
details.transcript { margin-top: 8px; }
details.transcript summary { font-size: 13px; font-weight: 700; color: var(--primary); cursor: pointer; }
details.transcript pre {
  white-space: pre-wrap; font: 13px/1.5 inherit; background: #f5f2e9;  border-radius: 10px; padding: 12px; margin-top: 8px; max-height: 320px; overflow: auto;
}
audio { width: 100%; margin-top: 8px; }

/* ─── Stats / home ───────────────────────────────────────────────────────── */
.roi {
  background: var(--grad); color: #fff; border-radius: var(--radius);
  padding: 22px 20px; margin-bottom: 16px; box-shadow: 0 10px 30px -12px rgba(25,25,23,.45);
}
.roi .lbl { font-size: 11.5px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; color: #cdb489; }
.roi .big { font-family: var(--serif); font-size: 40px; font-weight: 600; letter-spacing: -.02em; margin: 2px 0; }
.roi .foot { font-size: 13px; opacity: .85; }
.statgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 16px; }
@media (min-width: 900px) { .statgrid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 16px; }
.stat .n { font-family: var(--serif); font-size: 27px; font-weight: 600; letter-spacing: -.02em; }
.stat .l { font-size: 10.5px; color: var(--muted); font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }

.meter { background: #e9e4d6; border-radius: 999px; height: 8px; overflow: hidden; margin-top: 8px; }
.meter > div { height: 100%; background: var(--primary); border-radius: 999px; }

/* ─── FAQ / staff editors ────────────────────────────────────────────────── */
.qacard { border: 1.5px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; background: #fcfbf6; position: relative; }
.qacard input, .qacard textarea { margin-bottom: 8px; }
.qacard .rm { position: absolute; top: 9px; right: 12px; background: none; border: 0; color: var(--danger); font-size: 12px; font-weight: 700; letter-spacing: .02em; z-index: 1; }
.qacard .row2 { padding-right: 56px; }

/* ─── Tables (admin) ─────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; }
table.admin { width: 100%; border-collapse: collapse; font-size: 13px; }
table.admin th { text-align: left; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.admin td { padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.flag { font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; margin-right: 4px; }
.flag.risk { background: var(--danger-bg); color: var(--danger); }
.flag.over { background: var(--warn-bg); color: var(--warn); }
.flag.fail { background: var(--danger-bg); color: var(--danger); }

/* ─── Auth ───────────────────────────────────────────────────────────────── */
.authwrap { max-width: 420px; margin: 8vh auto 0; padding: 0 16px; }
.authwrap .logo { font-family: var(--serif); text-align: center; font-size: 30px; font-weight: 600; margin-bottom: 6px; }
.authwrap .tag { display: block; text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 14px; background: none; }

/* ─── Toast / banner ─────────────────────────────────────────────────────── */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: #191917; color: #fff; font-size: 14px; font-weight: 600;
  padding: 12px 18px; border-radius: 12px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 100; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--danger); }

.banner {
  border-radius: 12px; padding: 12px 14px; font-size: 14px; font-weight: 600;
  margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px;
}
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.info { background: #f0eadc; color: var(--primary-dark); }

.empty { text-align: center; color: var(--muted); padding: 42px 16px; font-size: 14px; }
.empty .big { margin-bottom: 12px; } .empty .big svg { width: 34px; height: 34px; opacity: .4; }

.copybox {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #f5f2e9; border: 1.5px dashed var(--line); border-radius: 12px;
  padding: 12px 14px; font-weight: 700; margin: 10px 0;
}
.savebar { display: flex; justify-content: flex-end; margin-top: 6px; }

/* ─── "What does this do?" info buttons ──────────────────────────────────── */
.infobtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; border-radius: 50%; border: 0;
  background: #eae4d5; color: var(--primary-dark); font-size: 11px; font-weight: 800;
  margin-left: 6px; vertical-align: middle; cursor: pointer; flex: none;
}
.infobtn:hover { background: var(--primary); color: #fff; }
#infocard {
  position: fixed; left: 50%; bottom: 140px; transform: translateX(-50%) translateY(16px);
  background: #191917; color: #fff; font-size: 14px; line-height: 1.5;
  padding: 14px 18px; border-radius: 14px; opacity: 0; pointer-events: none;
  transition: all .25s; z-index: 110; max-width: min(440px, 92vw);
  box-shadow: 0 16px 44px -8px rgba(0,0,0,.45);
}
#infocard.show { opacity: 1; transform: translateX(-50%) translateY(0); pointer-events: auto; }
#infocard b { color: #d3b98a; }

/* ─── Support chat widget ────────────────────────────────────────────────── */
#help-fab {
  position: fixed; right: 16px; bottom: 84px; z-index: 60;
  width: 54px; height: 54px; border-radius: 50%; border: 0;
  background: var(--grad); color: #fff; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px -6px rgba(25,25,23,.45);
}
@media (min-width: 900px) { #help-fab { bottom: 24px; } }
#help-panel {
  position: fixed; right: 12px; bottom: 148px; z-index: 61;
  width: min(380px, calc(100vw - 24px)); height: min(520px, 70vh);
  background: #fff; border-radius: 18px; box-shadow: 0 20px 60px -10px rgba(16,24,40,.35);
  display: flex; flex-direction: column; overflow: hidden;
}
@media (min-width: 900px) { #help-panel { bottom: 88px; } }
#help-panel .head {
  background: var(--grad); color: #fff; padding: 14px 16px; font-weight: 800;
  display: flex; justify-content: space-between; align-items: center;
}
#help-panel .head button { background: none; border: 0; color: #fff; font-size: 18px; }
#help-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.hmsg { max-width: 85%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.hmsg.user { align-self: flex-end; background: var(--grad); color: #fff; border-bottom-right-radius: 4px; }
.hmsg.bot { align-self: flex-start; background: #f1eee5; border-bottom-left-radius: 4px; }
.hmsg.typing { color: var(--muted); font-style: italic; }
#help-actions { padding: 0 14px 8px; display: flex; gap: 8px; flex-wrap: wrap; }
#help-input { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); }
#help-input input { flex: 1; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 14px; outline: none; }
#help-input button { border: 0; background: var(--grad); color: #fff; border-radius: 10px; padding: 0 16px; font-weight: 700; }

/* ─── Plan picker ────────────────────────────────────────────────────────── */
.planpick { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
@media (min-width: 700px) { .planpick { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); } }
.planopt { border: 2px solid var(--line); border-radius: 14px; padding: 14px; background: #fff; text-align: left; }
.planopt.current { border-color: var(--success); background: var(--success-bg); }
.planopt.best { border-color: var(--primary); }
.planopt h3 { font-size: 15px; }
.planopt .amt { font-size: 24px; font-weight: 800; margin: 2px 0; }
.planopt .inc { font-size: 12px; color: var(--muted); }
.planopt .btn { margin-top: 10px; width: 100%; }
#help-fab svg { width: 25px; height: 25px; }

/* ─── Required fields + setup strength ───────────────────────────────────── */
.reqtag {
  display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--danger); background: var(--danger-bg);
  padding: 2px 8px; border-radius: 999px; margin-left: 7px; vertical-align: 1px;
}
.input.req-missing { border-color: rgba(179,64,46,.5); background: #fdf8f6; }
.input.req-missing:focus { border-color: var(--danger); }
.strength-item { display: flex; align-items: baseline; gap: 9px; padding: 4px 0; font-size: 14px; }
.strength-item .mark { font-weight: 700; width: 15px; flex: none; text-align: center; }
.strength-item.done .mark { color: var(--success); }
.strength-item.todo .mark { color: var(--danger); }
.strength-item.extra.todo .mark { color: var(--muted); }
.strength-item.todo.extra { color: var(--muted); }
.strength-head { font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.infobtn.intapp {
  width: auto; height: auto; border-radius: 999px; padding: 6px 13px;
  font-size: 12.5px; font-weight: 600; letter-spacing: 0;
  background: #f0ece1; color: var(--ink); margin: 0;
}
.infobtn.intapp:hover { background: var(--ink); color: #fff; }
