:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --ink: #101828;
  --muted: #667085;
  --line: #e4e7ec;
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --green: #16a34a;
  --green-bg: #dcfce7;
  --amber: #b45309;
  --amber-bg: #fef3c7;
  --red: #dc2626;
  --red-bg: #fee2e2;
  --gray: #475467;
  --gray-bg: #f2f4f7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.1);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif; color: var(--ink); background: var(--bg); line-height: 1.55; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.2; }
code { background: #f2f4f7; padding: .1em .4em; border-radius: 6px; font-size: .9em; }

.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 560px; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: .85em; }
.section { padding: 72px 0; }
.section.alt { background: #fff; }
.section h2 { font-size: 2rem; margin-bottom: 14px; text-align: center; }
.lead-text { max-width: 640px; margin: 0 auto 34px; text-align: center; color: var(--muted); font-size: 1.05rem; }
.cta { text-align: center; background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff; }
.cta h2 { color: #fff; }
.cta .lead-text { color: rgba(255,255,255,.85); }
.cta .btn-lg { background: #fff; color: var(--brand-dark); border: none; }

.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--ink); padding: 9px 16px; border-radius: 9px; font-size: .95rem; font-weight: 600; cursor: pointer; transition: all .15s ease; text-decoration: none; line-height: 1.4; }
.btn:hover { text-decoration: none; background: #f9fafb; border-color: #d0d5dd; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-ghost { background: transparent; }
.btn-lg { padding: 13px 26px; font-size: 1.05rem; }
.btn-sm { padding: 5px 11px; font-size: .85rem; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-group { display: flex; gap: 8px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; letter-spacing: .02em; }
.badge-high, .badge-intent-high { background: var(--green-bg); color: var(--green); }
.badge-medium, .badge-intent-medium { background: var(--amber-bg); color: var(--amber); }
.badge-low, .badge-intent-low { background: var(--gray-bg); color: var(--gray); }
.badge-status.badge-new { background: var(--brand-soft); color: var(--brand); }
.badge-status.badge-contacted { background: var(--gray-bg); color: var(--gray); }
.badge-status.badge-follow_up { background: var(--amber-bg); color: var(--amber); }
.badge-status.badge-converted { background: var(--green-bg); color: var(--green); }
.badge-status.badge-lost { background: var(--red-bg); color: var(--red); }

.score { display: inline-block; min-width: 34px; text-align: center; padding: 3px 8px; border-radius: 8px; font-weight: 700; font-size: .85rem; }
.score-hi { background: var(--brand-soft); color: var(--brand); }
.score-mid { background: var(--amber-bg); color: var(--amber); }
.score-lo { background: var(--gray-bg); color: var(--gray); }

.alert { padding: 11px 14px; border-radius: var(--radius); margin-bottom: 16px; font-size: .93rem; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-info { background: var(--gray-bg); color: var(--gray); }
.alert-demo { background: var(--amber-bg); color: var(--amber); }
.alert-warning { background: var(--amber-bg); color: var(--amber); }
.warning-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #101828; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 60; font-size: .93rem; max-width: 90vw; }

.onboard-steps { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 18px; }
.onboard-step { display: inline-flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--muted); background: var(--gray-bg); padding: 5px 10px; border-radius: 999px; font-weight: 600; }
.onboard-step.done { background: var(--green-bg); color: var(--green); }
.os-num { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: #fff; color: var(--muted); font-size: .7rem; font-weight: 800; }
.onboard-step.done .os-num { background: var(--green); color: #fff; }

.badge-status.badge-active { background: var(--green-bg); color: var(--green); }
.badge-status.badge-disabled { background: var(--red-bg); color: var(--red); }
.badge-status.badge-pending { background: var(--amber-bg); color: var(--amber); }
.badge-status.badge-completed { background: var(--green-bg); color: var(--green); }
.badge-status.badge-cancelled { background: var(--gray-bg); color: var(--gray); }
.key-text { font-size: .85rem; }

.alert.flash { animation: fadein .3s ease; }
@keyframes fadein { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; } }

input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: .95rem; font-family: inherit; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .9rem; }
textarea { resize: vertical; }

/* ---------- app shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 232px; background: #101828; color: #fff; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 1.05rem; }
.brand-logo { width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0; }
.landing-nav .brand-logo, .landing-footer .brand-logo { width: 34px; height: 34px; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: linear-gradient(135deg,#4f46e5,#7c3aed); color: #fff; display: grid; place-items: center; font-size: .8rem; font-weight: 800; }
.sidebar .brand-name { color: #fff; }
.nav { margin-top: 26px; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-link { color: #cbd5e1; padding: 9px 12px; border-radius: 8px; font-weight: 600; font-size: .95rem; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; text-decoration: none; }
.sidebar-foot { margin-top: 12px; }
.sidebar-foot .btn { color: #e2e8f0; border-color: #334155; }
.sidebar-foot .btn:hover { background: #1e293b; color: #fff; }

.topbar { display: flex; align-items: center; gap: 14px; background: #fff; border-bottom: 1px solid var(--line); padding: 13px 24px; position: sticky; top: 0; z-index: 20; }
.topbar-title { font-weight: 700; font-size: 1.05rem; flex: 1; }
.topbar-user { color: var(--muted); font-size: .9rem; }
.menu-toggle { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; }
.main { flex: 1; min-width: 0; }
.content { padding: 24px; }

/* stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(180px,1fr)); gap: 14px; margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 20px; }
.stat { padding: 18px; }
.stat-label { color: var(--muted); font-size: .85rem; font-weight: 600; }
.stat-value { font-size: 2rem; font-weight: 800; margin-top: 4px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 1.15rem; }
.card-foot { padding-top: 12px; border-top: 1px solid var(--line); font-size: .9rem; }

/* table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.empty-state { text-align: center; padding: 46px 20px; }
.empty-icon { font-size: 2.6rem; }
.empty-state h3 { margin-bottom: 6px; }
.empty-state p { color: var(--muted); margin-bottom: 16px; }

.filters { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.filters select { width: 150px; }
.filters input { flex: 1; min-width: 200px; }

/* forms inside cards */
.inline-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }

/* lead detail */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 840px) { .grid-2 { grid-template-columns: 1fr; } }
.kv { display: grid; grid-template-columns: 110px 1fr; row-gap: 10px; font-size: .95rem; }
.kv dt { color: var(--muted); font-weight: 600; }
.score-ring { display: flex; align-items: center; gap: 12px; margin: 8px 0; }
.score-ring .score { font-size: 1.6rem; padding: 10px 16px; min-width: 60px; }
.summary { font-size: 1.02rem; }
.quote { background: #f9fafb; border-left: 3px solid var(--brand); padding: 14px 16px; border-radius: 8px; white-space: pre-wrap; }
.response-box { font-family: inherit; background: #fbfcfe; }
.tick-list { list-style: none; }
.tick-list li { padding: 5px 0 5px 22px; position: relative; }
.tick-list li::before { content: "✓"; color: var(--green); position: absolute; left: 0; font-weight: 700; }
.kv-list { list-style: none; }
.kv-list li { padding: 7px 0; border-bottom: 1px solid var(--line); }

/* ---------- auth ---------- */
.auth-body { min-height: 100vh; display: grid; place-items: center; background: linear-gradient(160deg,#eef2ff,#f6f7fb); padding: 24px; }
.auth-card { background: #fff; border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 34px; width: 100%; max-width: 420px; }
.auth-title { font-size: 1.5rem; margin: 18px 0 4px; }
.auth-brand { margin-bottom: 8px; }
.auth-brand .brand-name { color: var(--ink); }

/* ---------- landing ---------- */
.landing-body { background: #fff; }
.landing-nav { position: sticky; top: 0; background: rgba(255,255,255,.92); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); z-index: 30; }
.nav-inner { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; padding-bottom: 14px; gap: 16px; flex-wrap: wrap; }
.landing-links { display: flex; gap: 22px; font-weight: 600; color: var(--ink); }
.landing-links a { color: var(--ink); }
.landing-links a:hover { color: var(--brand); text-decoration: none; }
.nav-cta { display: flex; gap: 10px; align-items: center; }

.hero { background: linear-gradient(180deg,#eef2ff 0%,#fdf4ff 60%,#fff 100%); padding: 96px 0 84px; text-align: center; }
.hero h1 { font-size: clamp(2.2rem, 5vw, 3.4rem); max-width: 760px; margin: 0 auto 20px; letter-spacing: -.02em; }
.hero-sub { font-size: 1.2rem; color: var(--muted); max-width: 620px; margin: 0 auto 30px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.hero-note { margin-top: 18px; color: var(--muted); font-size: .9rem; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(280px,1fr)); gap: 18px; }
.feature h3 { margin-bottom: 8px; font-size: 1.05rem; }
.feature p { color: var(--muted); font-size: .95rem; }

.steps { display: grid; grid-template-columns: repeat(auto-fit,minmax(210px,1fr)); gap: 20px; }
.step { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.step-num { width: 34px; height: 34px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 800; margin-bottom: 12px; }
.step h3 { font-size: 1.02rem; margin-bottom: 6px; }
.step p { color: var(--muted); font-size: .93rem; }

.preview-panel { background: #101828; border-radius: 16px; padding: 26px; color: #fff; max-width: 760px; margin: 0 auto; }
.mini-stats { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; margin-bottom: 20px; }
.mini-stats b { display: block; font-size: 1.6rem; }
.mini-stats span { color: #94a3b8; font-size: .82rem; }
.mini-table { border: 1px solid #263244; border-radius: 10px; overflow: hidden; }
.mini-row { display: grid; grid-template-columns: 1.4fr .6fr .8fr .9fr; gap: 10px; padding: 10px 14px; border-bottom: 1px solid #263244; align-items: center; font-size: .9rem; }
.mini-row.head { color: #94a3b8; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; background: #16233a; }
.mini-row:last-child { border-bottom: none; }

.pricing { display: grid; grid-template-columns: repeat(auto-fit,minmax(240px,1fr)); gap: 18px; max-width: 900px; margin: 0 auto; }
.pricing-col { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 26px; text-align: center; }
.pricing-col.featured { border: 2px solid var(--brand); box-shadow: var(--shadow-lg); }
.pricing-col h3 { font-size: 1.1rem; }
.price { font-size: 2.2rem; font-weight: 800; margin: 10px 0 16px; }
.price span { font-size: 1rem; color: var(--muted); font-weight: 600; }
.pricing-col ul { list-style: none; text-align: left; margin-bottom: 20px; }
.pricing-col li { padding: 6px 0 6px 24px; position: relative; color: var(--gray); }
.pricing-col li::before { content: "✓"; color: var(--brand); position: absolute; left: 0; font-weight: 800; }
/* pricing on auth page (no container) */
.auth-card .pricing { max-width: none; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 10px; padding: 20px 0; }
.auth-card .pricing-col { padding: 18px; }
.auth-card .price { font-size: 1.7rem; }

#faq details { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 12px; }
#faq summary { font-weight: 700; cursor: pointer; }
#faq details p { color: var(--muted); margin-top: 10px; font-size: .95rem; }

.landing-footer { border-top: 1px solid var(--line); padding: 26px 0; text-align: center; }

/* ---------- responsive ---------- */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -240px; top: 0; transition: left .2s ease; z-index: 40; }
  .sidebar.open { left: 0; }
  .menu-toggle { display: block; }
  .table { font-size: .85rem; }
}
@media (max-width: 560px) {
  .container { padding: 0 16px; }
  .hero { padding: 64px 0; }
  .content { padding: 16px; }
  .mini-stats { grid-template-columns: repeat(2,1fr); }
  .mini-row { grid-template-columns: 1.3fr .5fr .7fr .8fr; font-size: .8rem; }
  .nav-inner .brand-name { display: none; }
}