:root {
  --green: #25d366;
  --green-dark: #128c4a;
  --ink: #0f172a;
  --ink-soft: #475569;
  --bg: #f6f8fa;
  --card: #ffffff;
  --border: #e2e8f0;
  --danger: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
}
* { box-sizing: border-box; }
html, body { padding: 0; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: inherit; }
button { font-family: inherit; }

/* ---------------- Public / marketing ---------------- */
body.public { background: #ffffff; }
.pub-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 40px; border-bottom: 1px solid var(--border);
}
.pub-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; }
.pub-brand .brand-mark { background: var(--green); color: #fff; width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-weight: 900; }
.pub-nav a { margin-left: 24px; text-decoration: none; color: var(--ink-soft); font-weight: 600; font-size: 14px; }
.pub-nav a.btn-primary { background: var(--green); color: #fff; padding: 10px 18px; border-radius: 8px; }

.hero { max-width: 900px; margin: 80px auto 40px; text-align: center; padding: 0 20px; }
.hero .eyebrow { color: var(--green-dark); font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.hero h1 { font-size: 48px; line-height: 1.1; margin: 16px 0; letter-spacing: -0.02em; }
.hero p.sub { font-size: 19px; color: var(--ink-soft); max-width: 640px; margin: 0 auto 32px; }
.hero-cta { display: flex; gap: 14px; justify-content: center; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 13px 24px; border-radius: 10px; font-weight: 700; font-size: 15px; border: none; cursor: pointer; text-decoration: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-dark); }
.btn-outline { background: #fff; color: var(--ink); border: 1.5px solid var(--border); }
.btn-outline:hover { border-color: var(--ink-soft); }
.btn-sm { padding: 7px 14px; font-size: 13px; border-radius: 8px; }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-block { width: 100%; }

.section { max-width: 1080px; margin: 90px auto; padding: 0 20px; }
.section h2 { font-size: 30px; text-align: center; margin-bottom: 8px; }
.section p.lede { text-align: center; color: var(--ink-soft); max-width: 560px; margin: 0 auto 44px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.feature-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 26px; }
.feature-card .icon { font-size: 26px; margin-bottom: 12px; }
.feature-card h3 { margin: 0 0 8px; font-size: 17px; }
.feature-card p { margin: 0; color: var(--ink-soft); font-size: 14.5px; line-height: 1.5; }

.pricing-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.price-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 30px 26px; position: relative; }
.price-card.featured { border-color: var(--green); box-shadow: 0 0 0 3px rgba(37,211,102,0.12); }
.price-card .tag { position: absolute; top: -12px; right: 20px; background: var(--green); color: #fff; font-size: 11px; font-weight: 800; padding: 4px 10px; border-radius: 999px; letter-spacing: .03em; }
.price-card h3 { margin: 0 0 4px; font-size: 18px; }
.price-card .price { font-size: 36px; font-weight: 800; margin: 10px 0 4px; }
.price-card .price span { font-size: 15px; font-weight: 500; color: var(--ink-soft); }
.price-card ul { list-style: none; padding: 0; margin: 20px 0; display: flex; flex-direction: column; gap: 10px; }
.price-card li { font-size: 14px; color: var(--ink-soft); padding-left: 22px; position: relative; }
.price-card li::before { content: "✓"; position: absolute; left: 0; color: var(--green-dark); font-weight: 800; }

.pub-footer { text-align: center; padding: 40px 20px 60px; color: var(--ink-soft); font-size: 13px; }

/* ---------------- Auth pages ---------------- */
.auth-wrap { max-width: 420px; margin: 70px auto; padding: 0 20px; }
.auth-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 34px; box-shadow: var(--shadow); }
.auth-card h1 { font-size: 22px; margin: 0 0 6px; }
.auth-card p.sub { color: var(--ink-soft); font-size: 14px; margin: 0 0 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 6px; color: var(--ink); }
.field .hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 5px; }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number], textarea, select {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--border); border-radius: 8px; font-size: 14.5px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green); }
textarea { resize: vertical; min-height: 80px; }
.auth-alt { text-align: center; margin-top: 18px; font-size: 13.5px; color: var(--ink-soft); }
.error-box { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 16px; }

/* ---------------- App shell ---------------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: #0f172a; color: #cbd5e1; display: flex; flex-direction: column; padding: 20px 14px; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: #fff; padding: 0 8px 18px; }
.sidebar-brand .brand-mark { background: var(--green); color: #fff; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 14px; }
.sidebar-biz { padding: 10px 12px 16px; border-bottom: 1px solid #1e293b; margin-bottom: 12px; }
.biz-name { color: #fff; font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plan-badge { font-size: 11.5px; color: #94a3b8; text-transform: capitalize; margin-top: 2px; }
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; text-decoration: none; font-size: 14px; font-weight: 600; color: #cbd5e1; }
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--green); color: #fff; }
.nav-icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar-footer { padding-top: 12px; border-top: 1px solid #1e293b; display: flex; flex-direction: column; gap: 10px; }
.mode-pill { font-size: 12px; font-weight: 700; padding: 6px 10px; border-radius: 999px; width: fit-content; }
.mode-pill.test { background: #422006; color: #fbbf24; }
.mode-pill.live { background: #052e1c; color: #4ade80; }
.link-btn { background: none; border: none; color: #94a3b8; font-size: 13px; cursor: pointer; padding: 4px 8px; text-align: left; }
.link-btn:hover { color: #fff; }

.main-content { flex: 1; padding: 28px 36px 60px; max-width: 1180px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; flex-wrap: wrap; gap: 12px; }
.page-header h1 { font-size: 24px; margin: 0 0 4px; }
.page-header p { margin: 0; color: var(--ink-soft); font-size: 14px; }

.flash { padding: 11px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600; margin-bottom: 18px; }
.flash.success { background: #dcfce7; color: #166534; }
.flash.info { background: #dbeafe; color: #1e40af; }
.flash.error { background: #fee2e2; color: #991b1b; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card h2.no-margin { margin: 0; }
.card p.card-sub { margin: 0 0 16px; color: var(--ink-soft); font-size: 13.5px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 22px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat-card .label { font-size: 12.5px; color: var(--ink-soft); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px; }
.stat-card .value.green { color: var(--green-dark); }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); padding: 10px 12px; border-bottom: 1.5px solid var(--border); }
td { padding: 13px 12px; border-bottom: 1px solid var(--border); font-size: 14px; vertical-align: middle; }
tr:last-child td { border-bottom: none; }

.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; text-transform: capitalize; }
.pill.new { background: #e0e7ff; color: #3730a3; }
.pill.qualifying { background: #fef3c7; color: #92400e; }
.pill.qualified { background: #dbeafe; color: #1e40af; }
.pill.booked { background: #dcfce7; color: #166534; }
.pill.lost { background: #f1f5f9; color: #64748b; }
.pill.open { background: #dbeafe; color: #1e40af; }
.pill.needs_human { background: #fee2e2; color: #991b1b; }
.pill.closed { background: #f1f5f9; color: #64748b; }
.pill.pending { background: #fef3c7; color: #92400e; }
.pill.confirmed { background: #dcfce7; color: #166534; }
.pill.cancelled { background: #f1f5f9; color: #64748b; }

.score-bar { width: 90px; height: 7px; background: #e2e8f0; border-radius: 999px; overflow: hidden; display: inline-block; vertical-align: middle; margin-right: 8px; }
.score-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--amber), var(--green)); }

/* ---------------- Inbox ---------------- */
.inbox-wrap { display: grid; grid-template-columns: 300px 1fr; gap: 18px; height: calc(100vh - 150px); min-height: 500px; }
.conv-list { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow-y: auto; }
.conv-list-header { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.conv-item { display: block; padding: 13px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.conv-item:hover { background: #f8fafc; }
.conv-item.active { background: #ecfdf5; }
.conv-item .cname { font-weight: 700; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }
.conv-item .cpreview { font-size: 12.5px; color: var(--ink-soft); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .cbadges { margin-top: 6px; display: flex; gap: 6px; }
.empty-state { padding: 30px 20px; text-align: center; color: var(--ink-soft); font-size: 13.5px; }

.chat-pane { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.chat-header { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.chat-header .who { font-weight: 700; font-size: 15px; }
.chat-header .sub { font-size: 12.5px; color: var(--ink-soft); }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; background: #e5ecf3; }
.bubble { max-width: 70%; padding: 10px 13px; border-radius: 12px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; }
.bubble.customer { align-self: flex-start; background: #fff; border-bottom-left-radius: 3px; }
.bubble.agent { align-self: flex-end; background: #d9fdd3; border-bottom-right-radius: 3px; }
.bubble.system { align-self: center; background: #fff7ed; color: #92400e; font-size: 12.5px; padding: 6px 12px; }
.chat-input-row { padding: 14px; border-top: 1px solid var(--border); display: flex; gap: 10px; background: #fff; }
.chat-input-row input { flex: 1; }
.chat-empty { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); font-size: 14px; }

/* ---------------- Onboarding ---------------- */
.onboard-wrap { max-width: 640px; margin: 50px auto; padding: 0 20px; }
.onboard-steps { display: flex; gap: 8px; margin-bottom: 26px; }
.onboard-steps .step { flex: 1; height: 5px; border-radius: 999px; background: var(--border); }
.onboard-steps .step.done { background: var(--green); }
.faq-row, .qq-row { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 10px; }
.faq-row input, .faq-row textarea { flex: 1; }
.remove-btn { background: #fee2e2; color: var(--danger); border: none; border-radius: 8px; width: 34px; height: 34px; cursor: pointer; font-size: 15px; flex-shrink: 0; }
.add-btn { background: #f1f5f9; border: 1.5px dashed #cbd5e1; color: var(--ink-soft); border-radius: 8px; padding: 9px 14px; font-size: 13.5px; font-weight: 700; cursor: pointer; width: 100%; text-align: center; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-row .t-label { font-weight: 700; font-size: 14px; }
.toggle-row .t-sub { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.switch { position: relative; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .15s; cursor: pointer; }
.switch .track::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .15s; }
.switch input:checked + .track { background: var(--green); }
.switch input:checked + .track::before { transform: translateX(18px); }

code.copy { background: #f1f5f9; padding: 8px 10px; border-radius: 6px; font-size: 12.5px; display: block; word-break: break-all; }

@media (max-width: 900px) {
  .feature-grid, .pricing-grid, .form-grid-2 { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .inbox-wrap { grid-template-columns: 1fr; height: auto; }
}
