/* ReplyFlow components. Load tokens.css first. Mobile layout kicks in at 900px. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--color-ink);
  background: var(--color-paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "cv11" 1;
}
h1, h2, h3, h4 { margin: 0; color: var(--color-ink); letter-spacing: -.01em; line-height: var(--leading-tight); }
p { margin: 0; }
a { color: var(--color-brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
img, svg { display: block; }
button { font: inherit; }
code { font-family: var(--font-mono); font-size: .92em; background: var(--color-grey-50); border-radius: 4px; padding: 1px 5px; }
hr { border: 0; border-top: 1px solid var(--color-line); margin: var(--space-6) 0; }
::selection { background: var(--color-brand-50); }

:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: var(--space-3); top: -60px; z-index: 100; background: var(--color-ink); color: #fff; padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); }
.skip-link:focus { top: var(--space-3); }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 24px; height: 24px; }

.serif { font-family: var(--font-serif); font-weight: var(--weight-medium); letter-spacing: -.02em; }
.muted { color: var(--color-muted); }
.small { font-size: var(--text-sm); }
.xsmall { font-size: var(--text-xs); }
.strong { font-weight: var(--weight-semibold); }
.nowrap { white-space: nowrap; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--space-2); }
.row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--color-surface); border-right: 1px solid var(--color-line); }
.side-in { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.side-biz { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-5) var(--space-5) 18px; border-bottom: 1px solid var(--color-line); min-width: 0; }
.biz-mark { width: 36px; height: 36px; border-radius: 9px; background: var(--color-ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: var(--weight-semibold); font-size: 13px; flex-shrink: 0; }
.biz-name { font-weight: var(--weight-semibold); font-size: 14.5px; line-height: 1.3; }
.biz-sub { font-size: var(--text-xs); color: var(--color-muted); }
.side-nav { padding: var(--space-3); display: flex; flex-direction: column; gap: 2px; flex: 1; overflow-y: auto; }
.side-nav a {
  display: flex; align-items: center; gap: var(--space-3); min-height: 42px; padding: 0 var(--space-3);
  border-radius: 8px; color: var(--color-ink-2); font-weight: var(--weight-medium); font-size: 14.5px;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.side-nav a:hover { background: var(--color-hover); color: var(--color-ink); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--color-paper); color: var(--color-ink); box-shadow: inset 0 0 0 1px var(--color-line); }
.side-nav a .icon { color: var(--color-muted); }
.side-nav a[aria-current="page"] .icon { color: var(--color-brand); }
.side-nav .nav-label { font-size: 11.5px; font-weight: var(--weight-semibold); letter-spacing: .06em; text-transform: uppercase; color: var(--color-muted); padding: var(--space-4) var(--space-3) var(--space-1); }
.count {
  margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--radius-full);
  background: var(--color-amber-50); color: var(--color-amber-700); font-size: 12px; font-weight: var(--weight-semibold);
  display: inline-flex; align-items: center; justify-content: center;
}
.receptionist { margin: var(--space-3); padding: 14px; border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-paper); }
.receptionist-row { display: flex; align-items: center; gap: 10px; }
.receptionist-title { font-weight: var(--weight-semibold); font-size: 14px; flex: 1; }
.receptionist p { font-size: var(--text-xs); color: var(--color-muted); margin-top: 6px; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-live); box-shadow: 0 0 0 3px #D5EBDF; flex-shrink: 0; }
.live-dot.off { background: #98A2B3; box-shadow: 0 0 0 3px #E4E7EC; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 14px var(--space-5); border-top: 1px solid var(--color-line); font-size: var(--text-sm); }
.side-user .avatar { width: 30px; height: 30px; font-size: 12px; }
.side-user form { margin-left: auto; }
.link-button { background: none; border: 0; padding: 0; color: var(--color-muted); cursor: pointer; font-size: inherit; min-height: 32px; }
.link-button:hover { color: var(--color-ink); text-decoration: underline; }

.main { min-width: 0; }
.page { padding: var(--space-8) var(--space-10) var(--space-16); max-width: var(--content-max); }
.page-narrow { max-width: 880px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--space-6); margin-bottom: 28px; flex-wrap: wrap; }
.page-head > div:first-child { min-width: 0; max-width: 100%; }
.page-title { overflow-wrap: anywhere; }
.page-title { font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: var(--text-3xl); line-height: 1.1; letter-spacing: -.02em; }
.page-sub { color: var(--color-muted); margin-top: 6px; font-size: 15.5px; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--color-muted); font-size: var(--text-sm); font-weight: var(--weight-medium); margin-bottom: var(--space-3); min-height: 32px; }
.back-link:hover { color: var(--color-ink); }

.topbar, .tabbar { display: none; }

.banner {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap;
  padding: 10px var(--space-6); background: var(--color-amber-50); color: var(--color-amber-700);
  border-bottom: 1px solid #EFD9A8; font-weight: var(--weight-medium); font-size: 14px;
}

.banner-info { background: var(--color-blue-50); color: var(--color-blue-700); border-bottom-color: #CBD8F2; }

/* ---------- Cards ---------- */
.card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: var(--space-6); }
.grid-2 > .card, .grid-3 > .card, .tiles > .card { margin-top: 0; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 18px var(--space-5) 14px; flex-wrap: wrap; }
.card-h h2, .card-title { font-size: var(--text-md); font-weight: var(--weight-semibold); display: flex; align-items: center; gap: var(--space-2); }
.card-h a { font-size: 14px; font-weight: var(--weight-medium); }
.card-b { padding: var(--space-5); }
.card-h + .card-b { padding-top: 0; }
.card-f { padding: 14px var(--space-5); border-top: 1px solid var(--color-line); display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; }
.card-sub { color: var(--color-muted); font-size: 14px; margin-top: 2px; }
.section-title { font-size: var(--text-md); font-weight: var(--weight-semibold); margin-bottom: var(--space-3); }
.layout-main-side { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: var(--space-6); align-items: start; }
.layout-side-main { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr); gap: var(--space-6); align-items: start; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--tap); padding: 0 18px; border-radius: var(--radius-md); border: 1px solid transparent;
  font-weight: var(--weight-semibold); font-size: 15px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  text-decoration: none; background: var(--color-surface); color: var(--color-ink);
  transition: background var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease);
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--color-brand); color: #fff; }
.btn-primary:hover { background: var(--color-brand-hover); }
.btn-secondary { background: var(--color-surface); color: var(--color-ink); border-color: var(--color-line-strong); }
.btn-secondary:hover { border-color: var(--color-ink-2); }
.btn-ghost { background: transparent; color: var(--color-ink-2); }
.btn-ghost:hover { background: var(--color-hover); color: var(--color-ink); }
.btn-danger { background: var(--color-red-600); color: #fff; }
.btn-danger:hover { background: var(--color-red-700); }
.btn-danger-quiet { background: var(--color-surface); color: var(--color-red-600); border-color: #F1C7C0; }
.btn-danger-quiet:hover { border-color: var(--color-red-600); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 0 22px; font-size: var(--text-md); }
.btn-block { width: 100%; }
.btn-icon { width: var(--tap); padding: 0; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn .spinner { display: none; }
.htmx-request .btn .spinner, .btn.htmx-request .spinner { display: inline-block; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
fieldset.field { border: 0; padding: 0; margin-inline: 0; }
fieldset.field > legend { padding: 0; margin-bottom: 6px; font-size: 14px; font-weight: var(--weight-semibold); color: var(--color-ink); }
fieldset.field > textarea { min-height: 64px; }
.label, .field > label { font-size: 14px; font-weight: var(--weight-semibold); color: var(--color-ink); }
.hint { font-size: var(--text-sm); color: var(--color-muted); }
.input, .select, .textarea,
.field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-md); background: var(--color-surface); color: var(--color-ink); font: inherit; font-size: 15px;
  transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.field textarea, .textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.field select, .select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B6474' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 3px var(--color-brand-50);
}
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 1px; }
.field input[disabled], .field select[disabled], .field textarea[disabled] { background: var(--color-grey-50); color: var(--color-muted); }
.field input[readonly] { background: var(--color-surface-sunk); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--space-5); }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; align-items: center; margin-top: var(--space-5); }
.check { display: flex; align-items: flex-start; gap: var(--space-3); padding: var(--space-3) 0; cursor: pointer; min-height: var(--tap); }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--color-brand); flex-shrink: 0; }
.check-title { font-weight: var(--weight-semibold); font-size: 15px; }
.check-body { font-size: var(--text-sm); color: var(--color-muted); }
.choice { display: flex; align-items: center; gap: var(--space-3); min-height: var(--tap); padding: var(--space-2) var(--space-3); border: 1px solid var(--color-line); border-radius: var(--radius-md); cursor: pointer; }
.choice + .choice { margin-top: var(--space-2); }
.choice input[type="radio"] { width: 18px; height: 18px; accent-color: var(--color-brand); margin: 0; }
.choice:has(input:checked) { border-color: var(--color-brand); background: var(--color-brand-50); }
.choice-wrap { flex-wrap: wrap; padding-block: var(--space-2); }
.choice-wrap input:not([type="radio"]) { flex: 1 1 200px; min-width: 0; max-width: 100%; }
.inline-form { display: inline; }
.input-group { display: flex; gap: var(--space-2); }
.input-group > :first-child { flex: 1; min-width: 0; }

/* Toggle switch (a real button or checkbox underneath) */
.switch {
  position: relative; width: 44px; height: 26px; border-radius: var(--radius-full); border: 0; padding: 0;
  background: #C9CDD4; cursor: pointer; flex-shrink: 0; transition: background var(--duration) var(--ease);
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform var(--duration) var(--ease);
}
.switch[aria-checked="true"], .switch.on { background: var(--color-brand); }
.switch[aria-checked="true"]::after, .switch.on::after { transform: translateX(18px); }
.switch-row { display: flex; align-items: center; gap: var(--space-3); background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-height: var(--tap); color: var(--color-ink); }

/* ---------- Pills, avatars, chips ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--weight-semibold); white-space: nowrap; line-height: 1;
  background: var(--color-grey-50); color: var(--color-grey-700);
}
.pill-green { background: var(--color-brand-50); color: var(--color-brand-700); }
.pill-amber { background: var(--color-amber-50); color: var(--color-amber-700); }
.pill-blue { background: var(--color-blue-50); color: var(--color-blue-700); }
.pill-red { background: var(--color-red-50); color: var(--color-red-700); }
.pill-grey { background: var(--color-grey-50); color: var(--color-grey-700); }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--color-avatar); color: var(--color-ink-2);
  display: inline-flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: var(--weight-semibold); flex-shrink: 0;
}
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.date-chip { width: 52px; border: 1px solid var(--color-line); border-radius: 9px; text-align: center; padding: 5px 0 6px; background: var(--color-paper); flex-shrink: 0; }
.date-chip .d { font-size: 11px; font-weight: var(--weight-semibold); color: var(--color-muted); letter-spacing: .06em; text-transform: uppercase; }
.date-chip .n { font-family: var(--font-serif); font-size: var(--text-xl); line-height: 1.05; }
.chips { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: var(--radius-full);
  border: 1px solid var(--color-line-strong); background: var(--color-surface); color: var(--color-ink-2);
  font-size: 14px; font-weight: var(--weight-medium); white-space: nowrap; cursor: pointer;
}
.chip:hover { border-color: var(--color-ink-2); text-decoration: none; color: var(--color-ink); }
.chip[aria-current="true"], .chip[aria-pressed="true"] { background: var(--color-ink); border-color: var(--color-ink); color: #fff; }
.chip .n { opacity: .75; font-weight: var(--weight-semibold); }
.chip-suggest { border-color: var(--color-brand); color: var(--color-brand); background: var(--color-brand-50); font-weight: var(--weight-semibold); }

/* ---------- KPI strip ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); margin-bottom: var(--space-6); }
.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.kpi { padding: 22px var(--space-6); border-left: 1px solid var(--color-line); min-width: 0; }
.kpi:first-child { border-left: 0; }
.kpi-k { font-size: var(--text-sm); color: var(--color-muted); font-weight: var(--weight-medium); }
.kpi-v { font-size: var(--text-3xl); font-weight: var(--weight-semibold); letter-spacing: -.03em; line-height: 1.15; margin-top: var(--space-2); }
.kpi-v small { font-size: var(--text-lg); font-weight: var(--weight-medium); color: var(--color-muted); letter-spacing: 0; margin-left: 2px; }
.kpi-v.money { font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: var(--text-display); line-height: 1.05; }
.kpi-s { font-size: 13px; color: var(--color-muted); margin-top: var(--space-1); display: flex; align-items: center; gap: 6px; }
.kpi-s.good { color: var(--color-brand-700); }
.kpi-s.bad { color: var(--color-red-700); }
.kpi-s .icon { width: 15px; height: 15px; }

/* ---------- Lists and tables ---------- */
.list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--color-line); }
.list > li { border-bottom: 1px solid var(--color-line); }
.list > li:last-child { border-bottom: 0; }
.list-row {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center;
  padding: 13px var(--space-5); color: inherit; text-decoration: none;
  transition: background var(--duration-fast) var(--ease);
}
a.list-row:hover { background: var(--color-surface-sunk); text-decoration: none; }
.list-row .title { display: flex; align-items: center; gap: var(--space-2); min-width: 0; }
.list-row .name { font-weight: var(--weight-semibold); color: var(--color-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .meta { font-size: var(--text-xs); color: var(--color-muted); white-space: nowrap; }
.list-row .snip { color: var(--color-ink-2); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row .end { display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); text-align: right; }
.list-row.attention { box-shadow: inset 3px 0 0 var(--color-amber-500); }

.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-muted); padding: 10px var(--space-5); border-bottom: 1px solid var(--color-line); background: var(--color-surface-sunk); white-space: nowrap; }
.table td { padding: 14px var(--space-5); border-bottom: 1px solid var(--color-line); vertical-align: middle; color: var(--color-ink-2); }
.table tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; }
.table .strong { color: var(--color-ink); }
.table tbody tr:hover td { background: var(--color-surface-sunk); }

/* Attention items */
.need { display: flex; align-items: center; gap: 14px; padding: 14px var(--space-5); border-top: 1px solid var(--color-line); }
.need-bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--color-amber-500); flex-shrink: 0; }
.need-body { flex: 1; min-width: 0; }
.need-title { font-weight: var(--weight-semibold); }
.need-reason { color: var(--color-ink-2); font-size: 14px; }
.need-meta { color: var(--color-muted); font-size: 13px; margin-top: 2px; }
.need-actions { display: flex; gap: var(--space-2); flex-shrink: 0; }

/* Setup checklist */
.steps { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--color-line); }
.step { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px var(--space-5); border-bottom: 1px solid var(--color-line); }
.step:last-child { border-bottom: 0; }
.step-dot { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--color-line-strong); display: flex; align-items: center; justify-content: center; color: #fff; }
.step.done .step-dot { background: var(--color-brand); border-color: var(--color-brand); }
.step.done .step-title { color: var(--color-muted); text-decoration: line-through; text-decoration-color: var(--color-line-strong); }
.step-title { font-weight: var(--weight-semibold); }
.step-body { font-size: var(--text-sm); color: var(--color-muted); }
.progress { height: 6px; border-radius: var(--radius-full); background: var(--color-grey-50); overflow: hidden; width: 120px; }
.progress > span { display: block; height: 100%; background: var(--color-brand); border-radius: inherit; }

/* Jobs */
.job { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 14px; padding: 14px var(--space-5); border-top: 1px solid var(--color-line); }
.job-time { font-size: 13px; color: var(--color-muted); }
.job-what { font-weight: var(--weight-semibold); }
.job-who { font-size: 14px; color: var(--color-ink-2); }

/* Definition list */
.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 10px var(--space-5); margin: 0; font-size: 14.5px; }
.facts dt { color: var(--color-muted); }
.facts dd { margin: 0; color: var(--color-ink); font-weight: var(--weight-medium); overflow-wrap: anywhere; }

/* ---------- Feedback ---------- */
.alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: 14px var(--space-4); border-radius: var(--radius-md); border: 1px solid; font-size: 14.5px; }
.alert .icon { margin-top: 1px; }
.alert-info { background: var(--color-blue-50); border-color: #CBD8F2; color: var(--color-blue-700); }
.alert-warn { background: var(--color-amber-50); border-color: #EFD9A8; color: var(--color-amber-700); }
.alert-error { background: var(--color-red-50); border-color: #F1C7C0; color: var(--color-red-700); }
.alert-success { background: var(--color-brand-50); border-color: #C6E0D6; color: var(--color-brand-700); }
.alert strong { color: inherit; }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; padding: var(--space-12) var(--space-6); gap: var(--space-2); }
.empty-icon { width: 52px; height: 52px; border-radius: 14px; background: var(--color-paper); border: 1px solid var(--color-line); color: var(--color-brand); display: flex; align-items: center; justify-content: center; margin-bottom: var(--space-2); }
.empty-title { font-family: var(--font-serif); font-size: var(--text-xl); font-weight: var(--weight-medium); color: var(--color-ink); }
.empty-body { color: var(--color-muted); max-width: 420px; font-size: 15px; }
.empty-actions { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; margin-top: var(--space-3); }
.empty-sm { padding: var(--space-8) var(--space-5); }

.toast-container { position: fixed; right: var(--space-6); bottom: var(--space-6); display: flex; flex-direction: column; gap: var(--space-2); z-index: 1000; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 420px; padding: 14px var(--space-4);
  background: var(--color-ink); color: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-lg);
  font-size: 14.5px; font-weight: var(--weight-medium); pointer-events: auto;
  animation: toast-in var(--duration) var(--ease);
}
.toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #5FD39B; flex-shrink: 0; }
.toast.error::before { background: #F97066; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { background: linear-gradient(90deg, var(--color-grey-50) 25%, var(--color-hover) 50%, var(--color-grey-50) 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.htmx-indicator { opacity: 0; transition: opacity var(--duration) var(--ease); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .spinner, .skeleton { animation: none; }
  .toast { animation: none; }
}

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: var(--space-1); border-bottom: 1px solid var(--color-line); margin-bottom: var(--space-6); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 14px; border: 0; background: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; color: var(--color-muted); font-weight: var(--weight-medium);
  font-size: 15px; white-space: nowrap; cursor: pointer;
}
.tab:hover { color: var(--color-ink); text-decoration: none; }
.tab[aria-selected="true"] { color: var(--color-ink); border-bottom-color: var(--color-brand); }

/* ---------- Modal (native <dialog>) ---------- */
dialog.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 0; border-radius: var(--radius-lg);
  background: var(--color-surface); color: var(--color-ink); box-shadow: var(--shadow-lg); overflow: auto;
}
dialog.modal::backdrop { background: rgba(14, 23, 38, .45); }
dialog.modal[open] { animation: modal-in var(--duration) var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-h { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-5) var(--space-6) 0; }
.modal-h h2 { font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: var(--text-xl); }
.modal-b { padding: var(--space-4) var(--space-6) var(--space-6); }
.modal-f { display: flex; gap: var(--space-3); justify-content: flex-end; flex-wrap: wrap; padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-line); }

/* ---------- Integration tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: var(--space-4); }
.tile {
  display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-5); text-align: left; cursor: pointer;
  background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
  color: inherit; font: inherit; transition: border-color var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
}
.tile:hover { border-color: var(--color-line-strong); box-shadow: var(--shadow-md); text-decoration: none; }
.tile-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.tile-logo { width: 40px; height: 40px; border-radius: 10px; border: 1px solid var(--color-line); display: flex; align-items: center; justify-content: center; font-weight: var(--weight-bold); background: var(--color-surface); }
.tile-name { font-weight: var(--weight-semibold); font-size: var(--text-md); }
.tile-desc { color: var(--color-muted); font-size: 14px; flex: 1; }
.tile-cta { font-weight: var(--weight-semibold); color: var(--color-brand); font-size: 14.5px; display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Conversation ---------- */
.chat { display: flex; flex-direction: column; gap: 10px; padding: var(--space-5); background: var(--color-surface-sunk); max-height: 62vh; overflow-y: auto; }
.chat-day { align-self: center; font-size: var(--text-xs); color: var(--color-muted); font-weight: var(--weight-medium); }
.bubble { max-width: min(78%, 560px); padding: 10px 14px; border-radius: 14px; font-size: 15px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-line; }
.bubble.inbound { align-self: flex-start; background: var(--color-surface); border: 1px solid var(--color-line); border-bottom-left-radius: 4px; }
.bubble.outbound { align-self: flex-end; background: var(--color-ink); color: #F4F2EC; border-bottom-right-radius: 4px; }
.bubble-photo { display: block; max-width: min(240px, 100%); max-height: 240px; margin-top: var(--space-2); border-radius: var(--radius-md); object-fit: cover; background: var(--color-line); }
.bubble-meta { display: block; margin-top: 4px; font-size: 12px; white-space: normal; color: var(--color-muted); }
.bubble.outbound .bubble-meta { color: #B8BFCB; text-align: right; }
.bubble.outbound.failed { box-shadow: 0 0 0 2px var(--color-red-600); }
.bubble-meta .tick-read { color: var(--color-blue-50); font-weight: var(--weight-semibold); }
.bubble-meta .tick-failed, .bubble-error { color: var(--color-red-50); font-weight: var(--weight-semibold); }
.bubble-error { display: block; margin-top: 2px; font-size: 12px; white-space: normal; text-align: right; }
.list-row.unread .name, .list-row.unread .snip { font-weight: var(--weight-semibold); color: var(--color-ink); }
.unread-dot { width: 8px; height: 8px; border-radius: var(--radius-full); background: var(--color-brand); flex: none; }
.chat-empty { text-align: center; color: var(--color-muted); padding: var(--space-10) var(--space-4); }
.composer { display: flex; gap: var(--space-2); align-items: flex-end; padding: var(--space-3) var(--space-4); border-top: 1px solid var(--color-line); background: var(--color-surface); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.composer-tools { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4) var(--space-1); border-top: 1px solid var(--color-line); background: var(--color-surface); overflow-x: auto; scrollbar-width: thin; }
.composer-tools > * { flex-shrink: 0; }
.composer-tools .chip { display: inline-block; max-width: 280px; overflow: hidden; text-overflow: ellipsis; line-height: 34px; }
.composer-tools .chip-quiet { border-color: transparent; color: var(--color-brand); }
.composer-tools + .composer { border-top: 0; }

/* The customer record (dashboard/_customer_record.html) */
.record-h { font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-ink); margin: var(--space-5) 0 var(--space-2); }
.record-h:first-of-type { margin-top: 0; }
.record-list { list-style: none; margin: 0; padding: 0; }
.record-list > li { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: var(--tap); padding: var(--space-1) 0; border-bottom: 1px solid var(--color-line); overflow-wrap: anywhere; }
.record-list > li:last-child { border-bottom: 0; }
.record-add > summary { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); cursor: pointer; color: var(--color-brand); font-weight: var(--weight-medium); }
.record-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--space-2); }
.record-photos a { position: relative; display: block; aspect-ratio: 1; border-radius: var(--radius-sm); overflow: hidden; background: var(--color-line); }
.record-photos img { width: 100%; height: 100%; object-fit: cover; }
.record-photos span { position: absolute; left: 4px; bottom: 4px; padding: 1px 6px; border-radius: var(--radius-full); background: rgba(14, 23, 38, .75); color: #fff; font-size: 11px; }
.record-photos .photo-remove { position: absolute; top: 4px; right: 4px; }
.signature { border: 1px solid var(--color-line); border-radius: var(--radius-md); background: var(--color-surface); padding: var(--space-2); color: var(--color-ink); max-width: 420px; }
.signature svg { display: block; width: 100%; height: auto; }
.inline-form { display: inline; }
.composer textarea { flex: 1; min-height: var(--tap); max-height: 160px; resize: none; padding: 10px 12px; border: 1px solid var(--color-line-strong); border-radius: var(--radius-md); font: inherit; }
.composer textarea:focus { outline: none; border-color: var(--color-brand); box-shadow: 0 0 0 3px var(--color-brand-50); }
.note-card { margin: 4px 0; padding: 12px 14px; border-radius: var(--radius-md); border: 1px solid; font-size: 14px; align-self: stretch; }

/* ---------- Charts ---------- */
.chart-box { position: relative; height: 240px; }
.chart-box.tall { height: 300px; }
.bar-list { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) minmax(0, 1fr) auto; gap: var(--space-3); align-items: center; font-size: 14px; }
.bar-track { height: 10px; background: var(--color-grey-50); border-radius: var(--radius-full); overflow: hidden; }
.bar-fill { height: 100%; background: var(--color-brand); border-radius: inherit; min-width: 2px; }
.bar-fill.muted-fill { background: #98A2B3; }
.bar-val { font-weight: var(--weight-semibold); min-width: 48px; text-align: right; }

/* ---------- Auth ---------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.auth-panel { display: flex; flex-direction: column; justify-content: center; padding: var(--space-12) var(--space-8); }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; }
.auth-aside { background: var(--color-ink); color: #E9E6DD; padding: var(--space-12); display: flex; flex-direction: column; justify-content: space-between; }
.auth-aside h2 { color: #fff; font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: 34px; line-height: 1.15; letter-spacing: -.02em; }
.logo { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 18px; color: var(--color-ink); letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo svg { width: 30px; height: 30px; }

/* ---------- Onboarding ---------- */
.onb-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); height: 64px; padding: 0 var(--space-6); background: var(--color-surface); border-bottom: 1px solid var(--color-line); }
.onb-progress { height: 4px; background: var(--color-grey-50); }
.onb-progress > span { display: block; height: 100%; background: var(--color-brand); transition: width var(--duration) var(--ease); }
.onb { display: grid; grid-template-columns: 220px minmax(0, 620px); gap: var(--space-10); justify-content: center; padding: var(--space-10) var(--space-6) var(--space-16); }
.onb-steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--space-1); position: sticky; top: var(--space-6); align-self: start; }
.onb-steps li { display: flex; align-items: center; gap: var(--space-3); min-height: 44px; color: var(--color-muted); font-weight: var(--weight-medium); }
.onb-steps li a { display: flex; align-items: center; gap: var(--space-3); color: inherit; text-decoration: none; }
.onb-steps li.current { color: var(--color-ink); font-weight: var(--weight-semibold); }
.onb-steps li.done { color: var(--color-ink-2); }
.onb-dot { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--color-line-strong); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: var(--weight-semibold); background: var(--color-surface); flex-shrink: 0; }
.onb-steps li.current .onb-dot { border-color: var(--color-brand); color: var(--color-brand); }
.onb-steps li.done .onb-dot { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.onb-card .card-b { padding: var(--space-8); }
.onb-card .form-actions { justify-content: space-between; border-top: 1px solid var(--color-line); padding-top: var(--space-5); margin-top: var(--space-8); }
.onb-card .form-actions form { margin: 0; }
.onb-step-name { display: none; }
.onb-steps li.done:not(.current) .onb-dot { background: var(--color-brand); border-color: var(--color-brand); color: #fff; }
.onb-kicker { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-brand); letter-spacing: .04em; text-transform: uppercase; }
.onb-card h2.card-title { font-size: var(--text-md); }
.onb-section { border-top: 1px solid var(--color-line); padding-top: var(--space-5); margin-top: var(--space-6); }
/* Jobs and prices: one row per job */
.job-rows { display: flex; flex-direction: column; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; list-style: none; }
.job-row { display: grid; grid-template-columns: minmax(0, 1fr) 128px var(--tap); gap: var(--space-2); align-items: center; }
.job-row.removed { opacity: .45; }
.job-row.removed .input { text-decoration: line-through; }
.job-head { display: grid; grid-template-columns: minmax(0, 1fr) 128px var(--tap); gap: var(--space-2); font-size: var(--text-sm); font-weight: var(--weight-semibold); color: var(--color-ink); margin-bottom: 6px; }
.money-input { position: relative; }
.money-input::before { content: "£"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-muted); pointer-events: none; }
.money-input .input { padding-left: 26px; }
.remove-toggle { display: inline-flex; align-items: center; justify-content: center; width: var(--tap); height: var(--tap); border-radius: var(--radius-md); color: var(--color-muted); cursor: pointer; }
.remove-toggle:hover { background: var(--color-hover); color: var(--color-red-600); }
.remove-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.remove-toggle:focus-within { outline: 3px solid var(--color-focus); outline-offset: 1px; }
/* Opening hours: a row per day */
.hours { list-style: none; margin: 0 0 var(--space-4); padding: 0; border-top: 1px solid var(--color-line); }
.hours-row { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: var(--space-3); align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--color-line); min-height: 60px; }
.hours-row .check { padding: 0; align-items: center; }
.hours-times { display: flex; align-items: center; gap: var(--space-2); }
.hours-times .input { max-width: 132px; }
.hours-row:not(:has(input[type="checkbox"]:checked)) .hours-times { display: none; }
.hours-closed { display: none; color: var(--color-muted); font-size: var(--text-sm); }
.hours-row:not(:has(input[type="checkbox"]:checked)) .hours-closed { display: inline; }
/* The Unmissd number, big */
.number-box { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; background: var(--color-paper); border: 1px solid var(--color-line); border-radius: var(--radius-lg); padding: 18px 20px; }
.number-box .serif { font-size: 30px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.status-pills { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.status-pills .pill { white-space: normal; height: auto; min-height: 26px; padding: 4px 10px; line-height: 1.3; font-size: var(--text-sm); }
.status-pills .pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.tick-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: var(--space-2); }
.tick-list li { display: flex; gap: var(--space-2); align-items: flex-start; }
.tick-list .icon { color: var(--color-brand); flex-shrink: 0; margin-top: 2px; }
.how-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: var(--space-2); color: var(--color-ink-2); }
/* Meta's verification code, shown big so it's easy to copy into Facebook's window */
.code-box { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: var(--space-4); border-radius: var(--radius-md); background: var(--color-amber-50); border: 1px solid var(--color-amber-500); }
.code-box .code { font-family: var(--font-mono); font-size: 28px; font-weight: var(--weight-bold); letter-spacing: .08em; color: var(--color-ink); }
.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--color-muted); animation: typing 1.2s infinite var(--ease); }
.typing span:nth-child(2) { animation-delay: .15s; } .typing span:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .typing span { animation: none; opacity: .6; } }
.onb-chat { border: 1px solid var(--color-line); border-radius: var(--radius-lg); overflow: hidden; }
.onb-chat .chat { max-height: 360px; }

/* ---------- Marketing site (landing page) ---------- */
.site-wrap { max-width: 1240px; margin: 0 auto; padding: 0 var(--space-8); }
.site-nav { display: flex; align-items: center; gap: var(--space-10); height: 76px; }
.site-links { display: flex; gap: 28px; flex: 1; font-size: 15px; }
.site-links a, .site-login { color: var(--color-ink-2); font-weight: var(--weight-medium); }
.site-actions { display: flex; align-items: center; gap: var(--space-5); margin-left: auto; }
.hero { display: grid; grid-template-columns: 1.12fr .88fr; gap: 56px; align-items: center; padding-top: 56px; padding-bottom: 72px; }
.eyebrow { display: inline-flex; align-items: center; gap: var(--space-2); padding: 6px 12px 6px 10px; border: 1px solid var(--color-line); border-radius: var(--radius-full); background: var(--color-surface); font-size: 14px; font-weight: var(--weight-medium); color: var(--color-ink-2); }
.hero-title { font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: 58px; line-height: 1.04; letter-spacing: -.025em; margin: 22px 0; }
.hero-title span { display: block; }
.hero-lede { font-size: 19px; line-height: 1.55; color: var(--color-ink-2); max-width: 560px; margin: 0 0 32px; }
.hero-ctas { display: flex; gap: var(--space-3); flex-wrap: wrap; }
.hero-assure { list-style: none; padding: 0; margin: 28px 0 0; display: flex; flex-wrap: wrap; gap: 10px 24px; font-size: 14px; color: var(--color-muted); }
.hero-assure li { display: inline-flex; align-items: center; gap: 6px; }
.hero-assure .icon { color: var(--color-brand); }
.hero-stage { position: relative; padding: 0 0 56px 56px; }
.hero-chat { overflow: hidden; box-shadow: var(--shadow-md); }
.hero-chat .bubble { font-size: 14px; }
.hero-cal { position: absolute; left: 0; bottom: 0; width: 290px; padding: 16px 18px; box-shadow: var(--shadow-md); }
.hero-cal-event { margin-top: 12px; border-left: 3px solid var(--color-brand); padding-left: 12px; }
.site-band { background: var(--color-surface); border-top: 1px solid var(--color-line); border-bottom: 1px solid var(--color-line); padding: 72px 0; }
.site-section { padding-top: 72px; padding-bottom: 72px; }
.site-h2 { font-family: var(--font-serif); font-weight: var(--weight-medium); font-size: 38px; letter-spacing: -.02em; margin-bottom: 36px; }
.site-steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px; }
.site-num { font-family: var(--font-serif); font-size: 22px; color: var(--color-brand); }
.site-steps h3, .site-features h3 { font-size: 18px; margin: 10px 0 6px; }
.site-steps p, .site-features p { color: var(--color-ink-2); }
.site-features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 40px 48px; }
.site-features .icon { color: var(--color-brand); }
.site-pricing { display: grid; grid-template-columns: 1fr 420px; gap: 56px; align-items: center; }
.site-price { padding: 28px; }
.site-price .icon { color: var(--color-brand); }
.site-faq { max-width: 820px; }
.site-faq details { border-bottom: 1px solid var(--color-line); padding: 6px 0; }
.site-faq summary { cursor: pointer; font-weight: var(--weight-semibold); font-size: 17px; min-height: var(--tap); display: flex; align-items: center; list-style: none; }
.site-faq summary::-webkit-details-marker { display: none; }
.site-faq summary::after { content: "+"; margin-left: auto; font-size: 22px; color: var(--color-muted); }
.site-faq details[open] summary::after { content: "–"; }
.site-faq p { color: var(--color-ink-2); padding-bottom: 16px; max-width: 680px; }
.site-foot { border-top: 1px solid var(--color-line); padding: 28px 0 40px; font-size: 14px; }
.site-foot a { color: var(--color-ink-2); }

/* ---------- Mobile ---------- */
@media (max-width: 900px) {
  body { font-size: 15.5px; }
  .app { display: block; }
  .side { display: none; }
  .topbar {
    display: flex; align-items: center; gap: var(--space-3); height: 60px; padding: 0 var(--space-4);
    background: var(--color-surface); border-bottom: 1px solid var(--color-line); position: sticky; top: 0; z-index: 20;
  }
  .topbar .biz-mark { width: 32px; height: 32px; font-size: 12px; }
  .topbar .biz-name { flex: 1; font-size: 15px; }
  .onpill { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: var(--radius-full); background: var(--color-brand-50); color: var(--color-brand-700); font-size: 13px; font-weight: var(--weight-semibold); white-space: nowrap; }
  .onpill.off { background: var(--color-grey-50); color: var(--color-grey-700); }
  .onpill .live-dot { width: 7px; height: 7px; box-shadow: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(4, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
    height: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
    background: var(--color-surface); border-top: 1px solid var(--color-line);
  }
  .tabbar a, .tabbar summary {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; height: var(--tabbar-height);
    font-size: 12px; font-weight: var(--weight-medium); color: var(--color-muted); position: relative; list-style: none; cursor: pointer;
  }
  .tabbar summary::-webkit-details-marker { display: none; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .icon { width: 24px; height: 24px; }
  .tabbar a[aria-current="page"], .tabbar details.current summary { color: var(--color-brand); }
  .tabbar .dot { position: absolute; top: 12px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--color-amber-500); border: 2px solid #fff; }
  .more-menu { position: fixed; left: var(--space-3); right: var(--space-3); bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom) + var(--space-2)); background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); padding: var(--space-2); }
  .more-menu a, .more-menu button { display: flex; flex-direction: row; justify-content: flex-start; gap: var(--space-3); height: 52px; padding: 0 var(--space-4); font-size: 16px; color: var(--color-ink); width: 100%; background: none; border: 0; border-radius: var(--radius-md); cursor: pointer; }
  .more-menu a:hover, .more-menu button:hover { background: var(--color-hover); }
  .more-menu .icon { width: 22px; height: 22px; color: var(--color-muted); }

  .page { padding: var(--space-5) var(--space-4) calc(var(--tabbar-height) + 32px); }
  .page-head { flex-direction: column; align-items: stretch; gap: 14px; margin-bottom: 18px; }
  .page-title { font-size: var(--text-2xl); }
  .page-sub { font-size: 14.5px; }
  .page-actions > * { flex: 1 1 auto; }
  .page-actions .btn { width: 100%; }
  .hide-mobile { display: none !important; }
  .card + .card { margin-top: var(--space-4); }
  .card-h { padding: var(--space-4) var(--space-4) var(--space-3); }
  .card-b { padding: var(--space-4); }
  .card-f { padding: var(--space-3) var(--space-4); }
  .layout-main-side, .layout-side-main { grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
  .grid-2, .grid-3, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: var(--space-4); }
  .kpis-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: var(--space-4); }
  .kpi:nth-child(odd) { border-left: 0; }
  .kpi:nth-child(n+3) { border-top: 1px solid var(--color-line); }
  .kpi-v { font-size: 30px; }
  .kpi-v.money { font-size: 32px; }
  .need { flex-wrap: wrap; padding: 14px var(--space-4); }
  .need-actions { width: 100%; padding-left: 17px; }
  .need-actions .btn { flex: 1; min-height: 48px; }
  .list-row { padding: var(--space-3) var(--space-4); }
  .list-row .hide-sm { display: none; }
  .job, .step { padding: var(--space-3) var(--space-4); }
  .btn { min-height: 48px; }
  .btn-sm { min-height: 40px; }
  .field input:not([type="checkbox"]):not([type="radio"]), .field select, .field textarea, .composer textarea { font-size: 16px; min-height: 48px; }
  .toast-container { left: var(--space-3); right: var(--space-3); bottom: calc(var(--tabbar-height) + var(--space-3)); }
  .toast { min-width: 0; max-width: none; }
  dialog.modal { width: 100vw; max-width: 100vw; max-height: 90vh; margin: auto 0 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-h { padding: var(--space-5) var(--space-4) 0; }
  .modal-b { padding: var(--space-4); }
  .modal-f { padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom)); }
  .modal-f .btn { flex: 1; }
  .banner { padding: 10px var(--space-4); }
  .chat { max-height: none; padding: var(--space-4); }
  .bubble { max-width: 86%; }
  .composer-sticky { position: sticky; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); z-index: 10; }
  .site-wrap { padding: 0 var(--space-4); }
  .site-nav { height: 64px; gap: var(--space-3); }
  .site-links, .site-login { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr); gap: 40px; padding-top: 24px; padding-bottom: 48px; }
  .hero-title { font-size: 40px; margin: 18px 0 16px; }
  .hero-title span { display: inline; }
  .hero-lede { font-size: 17.5px; margin-bottom: 24px; }
  .hero-ctas .btn { width: 100%; }
  .hero-stage { padding: 0; display: flex; flex-direction: column; gap: 12px; }
  .hero-cal { position: static; width: 100%; }
  .hero-chat .chat { padding-bottom: 20px !important; }
  .site-band, .site-section { padding-top: 48px; padding-bottom: 48px; }
  .site-h2 { font-size: 30px; margin-bottom: 24px; }
  .site-steps, .site-features, .site-pricing { grid-template-columns: minmax(0, 1fr); gap: 28px; }
  .onb-top { padding: 0 var(--space-4); height: 56px; }
  .onb { grid-template-columns: minmax(0, 1fr); padding: var(--space-4) var(--space-4) var(--space-10); gap: 0; }
  .onb-card .card-b { padding: var(--space-5) var(--space-4); }
  .onb-card .form-actions { flex-direction: column-reverse; align-items: stretch; }
  .onb-card .form-actions > *, .onb-card .form-actions form .btn { width: 100%; }
  .onb-step-name { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-3); margin-bottom: var(--space-3); }
  .onb-top .onb-count { display: none; }
  .job-row, .job-head { grid-template-columns: minmax(0, 1fr) 92px var(--tap); }
  .hours-row { grid-template-columns: minmax(0, 1fr); gap: var(--space-2); padding: var(--space-3) 0; }
  .hours-times .input { max-width: none; min-width: 0; flex: 1; }
  .hours-closed { padding-left: 32px; }
  .number-box .serif { font-size: 26px; }
  .number-box .btn { width: 100%; }
  .onb-chat .chat { max-height: 50vh; }
  .auth { grid-template-columns: minmax(0, 1fr); }
  .auth-aside { display: none; }
  .auth-panel { padding: var(--space-8) var(--space-5); justify-content: flex-start; }
  /* Tables become stacked cards */
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
  .table-stack tr { padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--color-line); }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: var(--space-4); text-align: right; }
  .table-stack td::before { content: attr(data-label); color: var(--color-muted); font-size: 13px; text-align: left; flex-shrink: 0; }
  .table-stack td[data-label=""]::before, .table-stack td:not([data-label])::before { content: none; }
  .table-stack td.cell-main { font-weight: var(--weight-semibold); color: var(--color-ink); text-align: left; justify-content: flex-start; font-size: 15.5px; }
  .table-stack td.cell-actions { justify-content: flex-start; padding-top: var(--space-2); }
  .table-stack tbody tr:hover td { background: none; }
}

@media (min-width: 901px) {
  .show-mobile { display: none !important; }
}

/* ---------- Spacing utilities (last, so they win over component margins) ---------- */
.mt-2 { margin-top: var(--space-2); } .mt-4 { margin-top: var(--space-4); } .mt-6 { margin-top: var(--space-6); }
.mb-4 { margin-bottom: var(--space-4); } .mb-6 { margin-bottom: var(--space-6); }

@media print {
  .side, .topbar, .tabbar, .toast-container { display: none !important; }
  .app { display: block; }
}

/* Legal pages (privacy, terms) */
.legal { max-width: 760px; }
.legal .page-sub { margin-bottom: var(--space-6); }
.legal h2 { font-size: var(--text-lg); margin: var(--space-8) 0 var(--space-2); }
.legal p, .legal li { color: var(--color-ink-2); line-height: 1.65; }
.legal ul { padding-left: 20px; }
.legal li + li { margin-top: var(--space-2); }

/* Brand (Unmissd): wordmark and app icon images from static/brand/ */
.wordmark { display: block; height: 22px; width: auto; }
.logo-mark { display: block; border-radius: 22%; }
.mt-auto { margin-top: auto; }

/* Invoices (app/services/invoice_service.py). The customer's page (templates/invoice/public.html) is the business's
   own: no Unmissd brand. The owner's editor and list use the usual cards and tables. */
.invoice-body { background: var(--color-paper); }
.invoice-page { max-width: 760px; margin: 0 auto; padding: var(--space-8) var(--space-4); }
.invoice-doc .card-b { padding: var(--space-8); }
.invoice-head { display: flex; justify-content: space-between; gap: var(--space-6); flex-wrap: wrap; }
.invoice-business { font-family: var(--font-serif); font-size: var(--text-2xl); color: var(--color-ink); margin: 0; }
.invoice-address { white-space: pre-line; margin: var(--space-1) 0 0; }
.invoice-meta { display: grid; grid-template-columns: max-content max-content; gap: 4px var(--space-4); margin: 0; font-size: var(--text-sm); }
.invoice-meta dt { color: var(--color-muted); text-align: right; }
.invoice-meta dd { margin: 0; color: var(--color-ink); font-weight: var(--weight-semibold); font-variant-numeric: tabular-nums; }
.invoice-label { font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--color-muted); text-transform: uppercase; letter-spacing: .06em; margin: 0 0 var(--space-1); }
.invoice-label.invoice-or { margin-top: var(--space-6); }
/* Job costing: the job page's "Profit on this job" (owner only) */
.table.costing th[scope=row] { font-weight: var(--weight-semibold); color: var(--color-ink); white-space: nowrap; background: none; text-transform: none; letter-spacing: 0; font-size: inherit; }
.table.costing td:nth-child(2) { color: var(--color-muted); font-size: var(--text-sm); }
.table.costing td:nth-child(2) form { display: inline; }
.costing-total th, .costing-total td { border-top: 2px solid var(--color-line-strong); color: var(--color-ink); }
.costing-total .money { font-family: var(--font-serif); font-size: var(--text-lg); }
.invoice-to { margin: 0; color: var(--color-ink); font-weight: var(--weight-semibold); }
.invoice-lines td.num, .invoice-lines th.num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.invoice-lines th, .invoice-lines td { padding-left: var(--space-3); padding-right: var(--space-3); }
.invoice-totals { display: grid; grid-template-columns: 1fr max-content; gap: 6px var(--space-6); margin: var(--space-4) 0 0; font-variant-numeric: tabular-nums; }
.invoice-totals dt { text-align: right; color: var(--color-muted); }
.invoice-totals dd { margin: 0; text-align: right; color: var(--color-ink); }
.invoice-totals .invoice-total { font-family: var(--font-serif); font-size: var(--text-xl); color: var(--color-ink); font-weight: var(--weight-semibold); }
.invoice-pay { border-top: 1px solid var(--color-line); padding-top: var(--space-5); }
.invoice-pay .card-title, .invoice-edit .card-title { font-size: var(--text-lg); margin: 0; color: var(--color-ink); }
.num-plain { font-variant-numeric: tabular-nums; }
.invoice-edit .line-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 110px 44px; gap: var(--space-2); align-items: end; }
.invoice-edit .line-row + .line-row { margin-top: var(--space-2); }
.invoice-edit .line-row input { width: 100%; }
.invoice-edit .line-head { font-size: var(--text-xs); color: var(--color-muted); font-weight: var(--weight-semibold); }
.invoice-edit .needs-price input[name="price"] { border-color: var(--color-amber-700); }
@media (max-width: 600px) {
  .invoice-page { padding: var(--space-4) var(--space-3); }
  .invoice-doc .card-b { padding: var(--space-5); }
  .invoice-edit .line-row { grid-template-columns: minmax(0, 1fr) 56px 88px 44px; }
}
@media print {
  .invoice-body { background: #fff; }
  .invoice-page { padding: 0; max-width: none; }
  .invoice-doc { box-shadow: none; border: 0; }
  .invoice-actions { display: none; }
}
