:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafd;
  --border: #dfe5ee;
  --border-2: #ccd5e2;
  --text: #13203a;
  --muted: #5b6578;
  --faint: #8590a3;
  --brand: #1f5fd6;
  --brand-ink: #ffffff;
  --brand-soft: #e0eafc;
  --accent: #1f5fd6;
  --urgent: #b3261e;
  --urgent-soft: #fdecea;
  --hot: #9a6200;
  --hot-soft: #fdf3e1;
  --ok: #1f7a4d;
  --ok-soft: #e5f4ec;
  --warn-soft: #fdf3e1;
  --bubble-in: #ffffff;
  --bubble-out: #1f5fd6;
  --bubble-out-ink: #ffffff;
  --bubble-ai: #e0eafc;
  --bubble-ai-ink: #10284a;
  --side: #0d2240;
  --side-2: #163259;
  --side-ink: #d3ddef;
  --shadow: none;
  --radius: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 24px; letter-spacing: -.01em; }
h2 { font-size: 17px; }
h3 { font-size: .95rem; }
p { margin: 0 0 .8em; }
small, .muted { color: var(--muted); }
.faint { color: var(--faint); }
code { background: var(--surface-2); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; font-size: .9em; word-break: break-all; }

/* Layout: dark sidebar, like RentalBook */
.shell { display: grid; grid-template-columns: 236px 1fr; min-height: 100vh; }
.side { background: var(--side); color: var(--side-ink); padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.side .brandmark { font-weight: 800; color: #fff; font-size: 18px; padding: 4px 10px 14px; letter-spacing: -.01em; text-decoration: none; }
.side .biz { background: var(--side-2); border-radius: 8px; padding: 10px; margin-bottom: 14px; font-size: 13px; }
.side .biz span { color: #9fb0c8; font-size: 12px; }
.side .biz strong { display: block; color: #fff; font-size: 14px; }
.side .biz form { margin: 8px 0 0; }
.side .biz button { width: 100%; background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 6px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.side nav a { display: flex; gap: 10px; align-items: center; color: var(--side-ink); text-decoration: none; padding: 8px 10px; border-radius: 7px; font-size: 14.5px; }
.side nav a svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.side nav a.on { background: var(--brand); color: #fff; }
.side nav .sep { height: 1px; background: #2c302c; margin: 10px 4px; }
.side nav .navlabel { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7f857b; padding: 12px 10px 4px; }
.side .who { margin-top: auto; padding: 18px 10px 0; font-size: 12.5px; color: #9aa096; border-top: 1px solid #2c302c; }
.side .who .who-name { color: #fff; font-weight: 600; font-size: 13.5px; }
.side .who a, .side .who .link-btn { color: #c9cec4; font-size: 12.5px; }
.mtop { display: none; }
.content { padding: 26px 30px 60px; max-width: 1180px; width: 100%; min-width: 0; }
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; z-index: 50; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .mtop { display: flex; align-items: center; gap: 12px; background: var(--side); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 40; }
  .mtop button { background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; line-height: 1; }
  .content { padding: 18px 16px 50px; }
}
.narrow { max-width: 760px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { margin: 2px 0 0; color: var(--muted); }

/* Cards and grids */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 16px; }
.card > h2:first-child, .card > h3:first-child { margin-top: 0; }
.card.flush { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.stat .n { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: .85rem; }

/* Forms */
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 5px; }
.field { margin-bottom: 14px; }
.field .help { font-size: .84rem; color: var(--muted); margin-top: 4px; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=url], input[type=time], input[type=date], input[type=number], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-2); border-radius: 7px; padding: 8px 10px; font-size: 14.5px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 35%, transparent); border-color: var(--brand); }
.check { display: flex; gap: 9px; align-items: flex-start; font-weight: 400; margin-bottom: 10px; }
.check input { margin-top: 4px; width: 16px; height: 16px; flex: none; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { flex: 1 1 180px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-size: 14px; font-weight: 600; border-radius: 7px; padding: 8px 14px; border: 1px solid transparent; cursor: pointer; background: var(--brand); color: var(--brand-ink); text-decoration: none !important; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border-2); }
.btn.secondary:hover { filter: none; border-color: #b8b8ae; }
.btn.danger { background: var(--surface); color: var(--urgent); border-color: var(--border); }
.btn.small { padding: 5px 10px; font-size: .86rem; }
.btn.block { width: 100%; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; color: var(--brand); cursor: pointer; }
form.inline { display: inline; margin: 0; }

/* Alerts */
.flash { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; border: 1px solid var(--border); background: var(--surface); }
.flash.success { background: var(--ok-soft); border-color: transparent; }
.flash.error { background: var(--urgent-soft); border-color: transparent; }
.flash.warning { background: var(--warn-soft); border-color: transparent; }
.notice { background: var(--warn-soft); border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 650; padding: 2px 8px; border-radius: 999px; background: #eeeeea; color: #5d5e58; border: 1px solid transparent; white-space: nowrap; }
.badge.urgent { background: var(--urgent); color: #fff; border-color: transparent; }
.badge.hot { background: var(--hot-soft); color: var(--hot); border-color: transparent; }
.badge.spam { opacity: .7; }
.badge.ok, .badge.active { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.trial { background: var(--brand-soft); color: var(--brand); border-color: transparent; }
.badge.past_due, .badge.paused, .badge.cancelled { background: var(--urgent-soft); color: var(--urgent); border-color: transparent; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; white-space: nowrap; }

/* Inbox */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.tabs a { padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); color: var(--text); font-size: 13.5px; font-weight: 600; }
.tabs a.on { background: var(--text); color: #fff; border-color: var(--text); }
.tabs a:hover { text-decoration: none; }
.tabs form { margin-left: auto; flex: 0 1 240px; }
.conv-list a.conv { display: flex; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); color: var(--text); align-items: flex-start; }
.conv-list a.conv:last-child { border-bottom: 0; }
.conv-list a.conv:hover { background: var(--surface-2); text-decoration: none; }
.conv-list a.conv.is-urgent { box-shadow: inset 4px 0 0 var(--urgent); }
.conv-list a.conv.is-hot { box-shadow: inset 4px 0 0 var(--hot); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: flex; align-items: center; justify-content: center; font-weight: 700; flex: none; font-size: .9rem; }
.conv .main { flex: 1; min-width: 0; }
.conv .top { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.conv .name { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv.unread .name::after { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-left: 7px; vertical-align: middle; }
.conv .when { color: var(--faint); font-size: .82rem; white-space: nowrap; }
.conv .summary { color: var(--text); font-size: .92rem; margin-top: 2px; }
.conv .preview { color: var(--muted); font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* Conversation */
.thread-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 880px) { .thread-wrap { grid-template-columns: 1fr; } }
.thread { padding: 16px; display: flex; flex-direction: column; gap: 8px; min-height: 300px; max-height: 62vh; overflow-y: auto; background: var(--surface-2); }
.msg { max-width: 78%; display: flex; flex-direction: column; }
.msg .b { padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg .meta { font-size: .74rem; color: var(--faint); margin-top: 3px; padding: 0 4px; }
.msg.in { align-self: flex-start; }
.msg.in .b { background: var(--bubble-in); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.out { align-self: flex-end; align-items: flex-end; }
.msg.out .b { background: var(--bubble-out); color: var(--bubble-out-ink); border-bottom-right-radius: 4px; }
.msg.out.ai .b, .msg.out.auto .b { background: var(--bubble-ai); color: var(--bubble-ai-ink); }
.msg.failed .b { outline: 2px solid var(--urgent); }
.msg.note { align-self: center; max-width: 92%; text-align: center; }
.msg.note .b { background: none; color: var(--muted); font-size: .84rem; padding: 2px 6px; }
.composer { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.composer textarea { min-height: 44px; height: 44px; flex: 1; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: .92rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Hours editor */
.hours { display: grid; grid-template-columns: 100px 1fr 1fr auto; gap: 8px 10px; align-items: center; }
.hours .closed { font-weight: 400; display: flex; gap: 6px; align-items: center; margin: 0; white-space: nowrap; }
@media (max-width: 520px) { .hours { grid-template-columns: 1fr 1fr; } .hours .day { grid-column: 1 / -1; font-weight: 600; margin-top: 6px; } }

/* Steps */
.steps { counter-reset: s; padding: 0; list-style: none; margin: 0; }
.steps li { counter-increment: s; position: relative; padding: 0 0 16px 40px; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .88rem; }

/* Auth pages */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth .box { width: 100%; max-width: 420px; }
.auth .brand { text-align: center; margin-bottom: 18px; font-weight: 800; font-size: 20px; letter-spacing: -.01em; color: var(--text); display: flex; align-items: center; justify-content: center; gap: 8px; }
.auth .brand .dot { display: none; }
.install .box { max-width: 640px; }
.checklist { list-style: none; padding: 0; margin: 0 0 8px; }
.checklist li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.checklist li:last-child { border-bottom: 0; }
.checklist .y { color: var(--ok); font-weight: 700; }
.checklist .n { color: var(--urgent); font-weight: 700; }
.copy { display: flex; gap: 6px; }
.copy input[readonly] { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
@media (max-width: 600px) { .card { padding: 15px; } h1 { font-size: 1.25rem; } .msg { max-width: 90%; } .hide-sm { display: none; } }
@media (max-width: 700px) {
  .topbar .in { flex-wrap: wrap; height: auto; padding-top: 8px; gap: 4px 12px; }
  .topbar .logo { flex: 1; }
  .topbar nav { order: 3; flex: 1 0 100%; margin: 0 -6px; padding-bottom: 6px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .n { font-size: 1.3rem; }
  .tabs form { flex: 1 0 100%; margin-left: 0; }
}

/* ---------- Self-serve: products, home, billing ---------- */
.badge.trialing, .badge.manual, .badge.comped { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.cancelling, .badge.pending_checkout, .badge.pending_approval, .badge.pending { background: var(--warn-soft); color: var(--hot); border-color: transparent; }
.badge.soon { background: var(--surface-2); color: var(--faint); }
.small { font-size: .86rem; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 16px; }
.product-grid .card { margin: 0; display: flex; flex-direction: column; }
.card.product.on { border-color: var(--ok); box-shadow: inset 0 3px 0 var(--ok), var(--shadow); }
.card.product.highlight { outline: 3px solid var(--accent); outline-offset: 2px; }
.product-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.product-top h2 { margin: 0; font-size: 1.1rem; }
.product .tagline { margin: 4px 0 8px; font-weight: 600; color: var(--brand); }
.product .price { font-size: 1.5rem; font-weight: 800; margin: 0; }
.product .price span { font-size: .9rem; font-weight: 400; color: var(--muted); }
.ticks { list-style: none; padding: 0; margin: 0 0 12px; }
.ticks li { padding-left: 22px; position: relative; margin: 3px 0; }
.ticks li::before { content: "✓"; position: absolute; left: 2px; color: var(--ok); font-weight: 700; }
.product-actions { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.product-actions form { margin: 0; }
.product-actions p { width: 100%; margin: 0; }
.narrow-card { max-width: 480px; }
.totals { width: 100%; border-collapse: collapse; }
.totals td { padding: 4px 0; }
.totals td:last-child { text-align: right; }
.totals tr.sum td { border-top: 1px solid var(--border); font-weight: 700; padding-top: 8px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form select { width: auto; }
.number-list { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); }
.number-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; margin: 0; }
.number-row + .number-row { border-top: 1px solid var(--border); }
.home-item { display: block; padding: 10px 0; border-top: 1px solid var(--border); color: inherit; text-decoration: none; }
.home-item:hover strong { text-decoration: underline; }
.empty-state { text-align: center; padding: 32px 20px; }
.row.four > .field { flex-basis: 120px; }
details.product-edit > summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.row-actions select { width: auto; font-size: .85rem; padding: 4px 6px; }
.row-actions form { display: flex; gap: 6px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.row-actions { width: 1%; }
.row-actions select { max-width: 140px; }
.badge.chat { background: #eaf0fb; color: #1e3a8a; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 14px; margin: 10px 0 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }

/* Upcove brand mark */
.side .brandmark { display: flex; align-items: center; gap: 10px; }
.side .brandmark svg, .auth .brand svg { width: 26px; height: 26px; flex: none; }
/* Public demo banner */
.demo-banner { position: sticky; top: 0; z-index: 60; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; justify-content: space-between; padding: 10px 16px; background: #12305a; color: #eef3fb; font-size: 14px; }
.demo-banner a { color: #fff; font-weight: 600; }
.demo-banner .demo-actions { display: flex; gap: 14px; align-items: center; }
.demo-banner .demo-cta { background: #1f6feb; padding: 6px 12px; border-radius: 999px; text-decoration: none; }
/* Free trial */
.trial-banner { background: #0d2240; }
.demo-banner button.demo-cta { border: 0; color: #fff; font: inherit; font-weight: 600; cursor: pointer; }
.trial-steps { margin: 0; padding-left: 22px; }
.trial-steps li { margin: 4px 0; }
.trial-steps li.done { color: var(--muted, #667085); }
