:root {
  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --ink: #14213D;
  --muted: #5B6785;
  --line: #DCE2EE;
  --brand: #2448D8;
  --brand-strong: #1B37A8;
  --brand-soft: #E8EDFF;
  --on-brand: #FFFFFF;
  --hivis: #FFC233;
  --hivis-soft: #FFF4D6;
  --hivis-ink: #7A5200;
  --danger: #C2362F;
  --good: #1E9E6A;
  --good-soft: #E2F5EC;
  --good-ink: #12704A;
  --focus: #14213D;
  --radius-lg: 16px;
  --radius: 10px;
  --radius-sm: 6px;
  --font: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0E1424;
  --surface: #161E33;
  --ink: #E7ECF7;
  --muted: #9AA6C2;
  --line: #27314A;
  --brand: #7C9BFF;
  --brand-strong: #A3B8FF;
  --brand-soft: #1D2850;
  --on-brand: #0B1020;
  --hivis-soft: #3A2F12;
  --hivis-ink: #FFD98A;
  --danger: #FF8A80;
  --good: #4CC995;
  --good-soft: #15352A;
  --good-ink: #7FE0B6;
  --focus: #FFD98A;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 19px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
p { margin: 0; }

/* ---------- App frame ---------- */
.app { min-height: 100%; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar .biz { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.mark { width: 30px; height: 30px; flex: none; }
.main { flex: 1; padding: 20px 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom)); max-width: 760px; width: 100%; margin: 0 auto; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: 12.5px; position: relative;
}
.nav a svg { width: 24px; height: 24px; }
.nav a[aria-current="page"] { color: var(--brand); font-weight: 700; }
.nav .count {
  position: absolute; top: 6px; left: calc(50% + 6px);
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--hivis); color: #3D2B00; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}

@media (min-width: 900px) {
  .app { flex-direction: row; }
  .nav {
    position: sticky; top: 0; height: 100vh; width: 220px; flex: none;
    display: flex; flex-direction: column; gap: 4px; padding: 20px 12px;
    border-top: 0; border-right: 1px solid var(--line);
  }
  .nav .brandrow { display: flex; align-items: center; gap: 10px; padding: 0 10px 20px; font-weight: 700; }
  .nav a { flex-direction: row; justify-content: flex-start; gap: 12px; font-size: 16px; padding: 10px 12px; border-radius: var(--radius); }
  .nav a[aria-current="page"] { background: var(--brand-soft); }
  .nav a:hover { background: var(--brand-soft); }
  .nav .count { position: static; margin-left: auto; }
  .topbar { display: none; }
  .content { flex: 1; min-width: 0; }
  .main { padding: 32px 32px 48px; max-width: 880px; }
  .main.wide { max-width: none; }
}
@media (max-width: 899px) { .nav .brandrow { display: none; } }

.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section { margin-top: 32px; }
.section > h2 { margin-bottom: 12px; }

/* ---------- Buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 16px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-strong); }
.btn.quiet { border-color: transparent; background: transparent; color: var(--brand); padding: 0 10px; }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.block { width: 100%; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }

label.field { display: block; margin-bottom: 16px; }
label.field > span { display: block; font-weight: 700; font-size: 15px; margin-bottom: 6px; }
label.field > small { display: block; color: var(--muted); font-size: 14px; margin-top: 4px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=datetime-local], textarea, select {
  width: 100%; min-height: 46px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
textarea { min-height: 140px; resize: vertical; line-height: 1.45; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }

.toggle { display: flex; align-items: flex-start; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--line); cursor: pointer; }
.toggle:last-child { border-bottom: 0; }
.toggle input[type=checkbox] { appearance: none; flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; cursor: pointer; margin-top: 2px; transition: background .15s; }
.toggle input[type=checkbox]::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input[type=checkbox]:checked { background: var(--brand); }
.toggle input[type=checkbox]:checked::after { transform: translateX(18px); }
.toggle b { display: block; }
.toggle .muted { font-size: 15px; }

/* ---------- Panels & lists ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.panel + .panel { margin-top: 16px; }
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.row {
  display: flex; gap: 14px; align-items: flex-start; padding: 14px 16px;
  border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; background: none;
  width: 100%; text-align: left; border-left: 0; border-right: 0; border-top: 0; cursor: pointer;
}
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--brand-soft); }
.row .body { flex: 1; min-width: 0; }
.row .title { font-weight: 700; display: flex; gap: 8px; align-items: baseline; }
.row .title .when { margin-left: auto; font-weight: 400; color: var(--muted); font-size: 14px; white-space: nowrap; }
.row .preview { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; }
.row .amount { font-weight: 700; white-space: nowrap; }
.avatar { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-strong); display: grid; place-items: center; font-weight: 700; }

/* The signature element: a hi-vis tag for anything that needs the owner */
.needs {
  position: relative; background: var(--hivis-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--hivis) 60%, transparent);
  border-radius: var(--radius-lg); padding: 16px 16px 16px 22px; margin-bottom: 10px;
  display: flex; gap: 12px; align-items: center; text-decoration: none;
}
.needs::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: var(--hivis);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.needs .body { flex: 1; min-width: 0; }
.needs .why { color: var(--hivis-ink); font-size: 15px; }
.needs .go { flex: none; }

.chip { display: inline-block; font-size: 13px; font-weight: 700; padding: 2px 9px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-strong); white-space: nowrap; }
.chip.hivis { background: var(--hivis); color: #3D2B00; }
.chip.grey { background: var(--line); color: var(--ink); }
.chip.red { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }

.empty { padding: 28px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--ink); margin-bottom: 4px; }

/* ---------- Today report sentence ---------- */
.ledger { font-size: 24px; line-height: 1.35; font-weight: 400; max-width: 30ch; letter-spacing: -0.01em; }
.ledger strong { font-weight: 700; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--hivis) 45%, transparent) 62%); padding: 0 2px; }
@media (min-width: 900px) { .ledger { font-size: 30px; } }
.ledger-meta { margin-top: 10px; color: var(--muted); font-size: 15px; }

.banner { display: flex; gap: 12px; align-items: flex-start; background: var(--brand-soft); border-radius: var(--radius-lg); padding: 14px 16px; margin-bottom: 24px; font-size: 15px; }
.banner b { display: block; font-size: 16px; }

/* ---------- Chat ---------- */
.split { display: block; }
@media (min-width: 1100px) {
  /* Two panes that scroll on their own, like a mail app */
  .split { display: grid; grid-template-columns: 360px 1fr; gap: 20px; height: calc(100vh - 64px); }
  .split > .listpane { overflow-y: auto; min-height: 0; padding-right: 4px; }
  .split > .threadpane { display: flex; flex-direction: column; min-height: 0; padding-bottom: 8px; }
  .threadpane > div { display: flex; flex-direction: column; min-height: 0; flex: 1; }
  .threadpane .thread { flex: 1; overflow-y: auto; min-height: 0; padding-right: 4px; }
  .threadpane .composer { position: static; padding-bottom: 0; background: none; }
  .split .pagehead { position: sticky; top: 0; background: var(--bg); z-index: 1; padding-bottom: 12px; margin-bottom: 8px; }
}
.thread { display: flex; flex-direction: column; gap: 8px; padding: 16px 0; }
.bubble { max-width: 82%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 16px; }
.bubble .who { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 2px; opacity: .8; }
.bubble.in { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.bubble.ai { align-self: flex-end; background: var(--brand-soft); border-bottom-right-radius: 4px; }
.bubble.owner { align-self: flex-end; background: var(--brand); color: var(--on-brand); border-bottom-right-radius: 4px; }
.bubble time { display: block; font-size: 12px; opacity: .7; margin-top: 4px; }
.note { align-self: center; font-size: 14px; color: var(--muted); padding: 2px 10px; background: var(--line); border-radius: 999px; }
.threadhead { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.threadhead .who { flex: 1; min-width: 180px; }
.composer {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom)); background: var(--bg);
  padding: 10px 0; display: flex; gap: 10px; align-items: flex-end;
}
@media (min-width: 900px) { .composer { bottom: 0; } }
.composer textarea { min-height: 46px; height: 46px; max-height: 160px; }
.ai-state { display: flex; gap: 10px; align-items: center; padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); font-size: 15px; margin-top: 12px; }
.ai-state .grow { flex: 1; }
.leadfacts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* ---------- Quote editor ---------- */
.items { width: 100%; border-collapse: collapse; }
.items th { text-align: left; font-size: 14px; color: var(--muted); font-weight: 700; padding: 0 6px 6px 0; }
.items td { padding: 4px 6px 4px 0; vertical-align: top; }
.items td.qty { width: 74px; }
.items td.price { width: 120px; }
.items td.rm { width: 44px; }
.items input { min-height: 42px; }
.total { display: flex; justify-content: space-between; align-items: baseline; font-size: 22px; font-weight: 700; padding: 16px 0 4px; border-top: 1px solid var(--line); margin-top: 12px; }
@media (max-width: 560px) {
  .items thead { display: none; }
  .items tr { display: grid; grid-template-columns: 84px 1fr 44px; gap: 6px; margin-bottom: 14px; }
  .items td { padding: 0; width: auto !important; }
  .items td.desc { grid-column: 1 / -1; }
}

/* ---------- Bookings ---------- */
.day { margin-bottom: 20px; }
.day h3 { margin-bottom: 8px; color: var(--muted); font-size: 15px; }
.time { font-weight: 700; width: 92px; flex: none; white-space: nowrap; }

/* ---------- Setup ---------- */
.hours { display: grid; gap: 8px; }
.hours .h { display: grid; grid-template-columns: 70px 1fr 1fr; gap: 8px; align-items: center; }
.hours .h label { display: flex; gap: 6px; align-items: center; font-weight: 700; }
.hours input[type=time]:disabled { opacity: .4; }
pre.code { background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-all; margin: 8px 0; }
.grid2 { display: grid; gap: 0 16px; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }

/* ---------- Sign in ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth .panel { width: 100%; max-width: 420px; padding: 28px; }
.auth .lockup { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.auth .lockup .mark { width: 40px; height: 40px; }
.auth .lockup span { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.auth p.lead { color: var(--muted); margin-bottom: 24px; }
.error { color: var(--danger); font-weight: 700; margin-bottom: 12px; font-size: 15px; }

/* ---------- Toast & sheet ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom));
  background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: var(--radius); font-weight: 700; z-index: 50;
  max-width: calc(100% - 32px);
}
@media (min-width: 900px) { .toast { bottom: 24px; } }

dialog.sheet { border: 0; padding: 0; border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); width: min(640px, calc(100% - 24px)); max-height: calc(100% - 48px); }
dialog.sheet::backdrop { background: rgba(10, 20, 15, .45); }
dialog.sheet .sheetbody { padding: 24px; }
dialog.sheet .sheethead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; }
@media (max-width: 560px) {
  dialog.sheet { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 92%; }
  dialog.sheet .sheetbody { padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
dialog.sheet h2:focus { outline: none; }
@media (min-width: 1100px) {
  .threadpane .thread { border-top: 1px solid var(--line); margin-top: 12px; }
  .threadpane .leadfacts { margin-bottom: 2px; }
}
.hours { max-width: 520px; }
.hours input[type=checkbox] { accent-color: var(--brand); width: 18px; height: 18px; }

/* ---------- Message options (tap a message to delete it) ---------- */
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.left { align-self: flex-start; align-items: flex-start; }
.msg.right { align-self: flex-end; align-items: flex-end; }
.msg.center { align-self: center; align-items: center; max-width: 100%; }
.msg > .bubble { max-width: 100%; align-self: auto; cursor: pointer; }
.msg > .note { cursor: pointer; }
.msg > .bubble:hover { filter: brightness(0.97); }
.msg .actions { display: none; margin-top: 2px; }
.msg.picked .actions { display: flex; }
.msg.picked > .bubble, .msg.picked > .note { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn.small { min-height: 36px; font-size: 14px; }

/* ---------- Demo: text as the customer, inside a chat ---------- */
.demo-customer { margin-top: 12px; padding: 12px 14px; border: 2px dashed color-mix(in srgb, var(--hivis) 70%, transparent); background: var(--hivis-soft); border-radius: var(--radius); }
.demo-customer label { display: block; font-size: 15px; margin-bottom: 8px; }
.demo-customer .row-in { display: flex; gap: 10px; }
.demo-customer input { flex: 1; min-width: 0; }

/* ---------- Enquiries ---------- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.tab .n { font-weight: 400; color: var(--muted); font-size: 14px; }
.tab.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.tab.on .n { color: var(--bg); opacity: .75; }
.tab.alert:not(.on) .n { background: var(--hivis); color: #3D2B00; font-weight: 700; padding: 0 7px; border-radius: 999px; }

.enqs { display: grid; gap: 10px; }
.enq {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px 16px;
}
.enq:hover { border-color: var(--muted); }
.enq.active { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.enq.needy { background: var(--hivis-soft); border-color: color-mix(in srgb, var(--hivis) 60%, transparent); padding-left: 22px; }
.enq.needy::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px;
  background: var(--hivis);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
}
.enq-top { display: flex; align-items: baseline; gap: 8px; }
.enq-name { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.enq-top .when { margin-left: auto; color: var(--muted); font-size: 14px; white-space: nowrap; }
.enq-summary { margin: 4px 0 10px; font-size: 16px; line-height: 1.4; }
.enq-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.enq-detail { font-weight: 700; }
.enq.needy .enq-detail { font-weight: 400; color: var(--hivis-ink); }
.enq-where { color: var(--muted); margin-left: auto; }

.chip.outline { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.chip.solid { background: var(--good); color: #fff; }
.chip.good { background: var(--good-soft); color: var(--good-ink); }
.chip.muted { background: transparent; color: var(--muted); border: 1px dashed var(--line); }

.thread-summary { display: flex; gap: 10px; align-items: baseline; margin-top: 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.thread-summary p { font-size: 16px; font-weight: 700; line-height: 1.4; }
.threadpane .thread-summary { background: var(--brand-soft); }

@media (min-width: 1100px) {
  .split .tabs { flex-wrap: wrap; overflow: visible; }
}
.chip.urgent { background: #FFE6D5; color: #A93F06; }
:root[data-theme="dark"] .chip.urgent { background: #3D2414; color: #FFB685; }

/* ---------- Your Replivo number ---------- */
.number-panel { margin-bottom: 16px; border: 2px solid var(--brand); }
.number-panel.pending { border: 1px dashed var(--line); }
.big-number { font-size: 34px; font-weight: 700; letter-spacing: 0.02em; margin: 6px 0 8px; color: var(--brand); }
.number-panel.pending .big-number { font-size: 24px; color: var(--muted); }
.fwd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.fwd b { display: block; font-size: 16px; }
.fwd code { font-size: 17px; font-weight: 700; background: var(--brand-soft); color: var(--brand-strong); padding: 6px 10px; border-radius: 8px; letter-spacing: 0.03em; user-select: all; }

/* Business facts and price list grow with what you type */
textarea.grow { resize: none; overflow: hidden; line-height: 1.5; }
textarea.grow.facts { min-height: 260px; }
textarea.grow.prices { min-height: 340px; }
