:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --border: #e2e5ea;
  --text: #1a1d23;
  --muted: #667085;
  --primary: #1a73e8;
  --primary-ink: #ffffff;
  --ok: #138a4b;
  --ok-bg: #e7f6ee;
  --warn: #a15c00;
  --warn-bg: #fff4e0;
  --bad: #c62828;
  --bad-bg: #fdecec;
  --info: #1a5fb4;
  --info-bg: #e8f0fd;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --surface-2: #22262e;
    --border: #2e333d;
    --text: #e8eaee;
    --muted: #98a2b3;
    --primary: #5b9cf5;
    --primary-ink: #0b1220;
    --ok: #4cc38a;
    --ok-bg: #12291e;
    --warn: #f0b04a;
    --warn-bg: #2d2311;
    --bad: #f07070;
    --bad-bg: #321717;
    --info: #8ab4f8;
    --info-bg: #172338;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.1rem; margin: 0 0 14px; }
h3 { font-size: 1rem; margin: 18px 0 8px; }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
[hidden] { display: none !important; }

/* Layout */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.brand { font-weight: 700; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-dot { width: 12px; height: 12px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--primary); display: inline-block; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a { color: var(--muted); padding: 6px 10px; border-radius: 8px; }
.nav a:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--surface-2); color: var(--text); font-weight: 600; }
.demo-banner { background: var(--warn-bg); color: var(--warn); text-align: center; font-size: .85rem; font-weight: 600; padding: 6px 16px; border-bottom: 1px solid var(--border); }
.container { max-width: 1280px; margin: 0 auto; padding: 20px 16px 40px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 20px 16px 30px; }
.page-head { margin-bottom: 16px; }
.page-head p { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow); }
.card.narrow { max-width: 460px; margin: 40px auto; }
.card.narrow-left { max-width: 520px; }
.auth h1 { margin-bottom: 14px; }
.auth-brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--muted); margin-bottom: 8px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stats.compact { margin: 14px 0; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.stats.compact .stat { background: var(--surface-2); border-color: transparent; }
.stat-label { color: var(--muted); font-size: .8rem; }
.stat-value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-link { font-size: .8rem; }

/* Usage bars */
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.usage-top { display: flex; justify-content: space-between; gap: 8px; font-size: .9rem; margin-bottom: 6px; }
.usage-top strong { font-variant-numeric: tabular-nums; }
.usage-foot { font-size: .75rem; margin-top: 4px; }
.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar-lg { height: 10px; margin-top: 10px; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .3s ease; }
.bar-ok { background: var(--ok); }
.bar-warn { background: var(--warn); }
.bar-bad { background: var(--bad); }

/* Forms */
.form { display: grid; gap: 14px; }
.form.compact { gap: 8px; margin-top: 8px; }
label { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); font-weight: 500; }
label.inline { display: inline-flex; align-items: center; gap: 6px; }
label.check { display: flex; align-items: flex-start; gap: 8px; color: var(--text); font-weight: 400; font-size: .9rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; min-width: 0; width: 100%;
}
input[type="radio"], input[type="checkbox"] { width: auto; margin-top: 3px; accent-color: var(--primary); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.w-sm { width: 90px; }
label.inline input { width: 80px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row > label { flex: 0 1 220px; }
.row > .grow, .filters > .grow { flex: 1 1 260px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: .85rem; color: var(--muted); font-weight: 500; margin-bottom: 6px; }
.options { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 10px; }
.option {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px; border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; color: var(--text); font-weight: 400;
}
.option:has(input:checked) { border-color: var(--primary); background: var(--info-bg); }
.option span { display: grid; gap: 2px; }
.option small { font-size: .8rem; }
.estimate { margin: 0; font-size: .85rem; color: var(--muted); }
.checklist { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; }
.checklist .ok { color: var(--ok); }
.checklist .bad { color: var(--bad); }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters > label { flex: 0 1 auto; }
.filter-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: .9rem; padding: 8px 14px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.btn-danger { color: var(--bad); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }
.job-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0 8px; }
.job-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.inline-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; align-items: center; }
.inline-actions input { width: 160px; }

/* Alerts & badges */
.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: .9rem; }
.alert-ok { background: var(--ok-bg); color: var(--ok); }
.alert-warn { background: var(--warn-bg); color: var(--warn); }
.alert-err { background: var(--bad-bg); color: var(--bad); }
.alert-info { background: var(--info-bg); color: var(--info); }
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-running, .lead-contacted { background: var(--info-bg); color: var(--info); }
.badge-done, .lead-converted { background: var(--ok-bg); color: var(--ok); }
.badge-stopped, .badge-warn, .lead-interested { background: var(--warn-bg); color: var(--warn); }
.badge-failed, .lead-not_interested { background: var(--bad-bg); color: var(--bad); }
.tag { font-size: .7rem; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.wa { color: var(--ok); font-weight: 600; font-size: .85rem; }
.socials { display: flex; gap: 8px; flex-wrap: wrap; font-size: .8rem; margin-top: 2px; }

/* Tables */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
.table th, .table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; }
.leads td { min-width: 120px; }
.leads td.biz { min-width: 240px; max-width: 360px; }
.biz-name { font-weight: 600; }
details summary { cursor: pointer; color: var(--primary); font-size: .8rem; }
details.edit { margin-top: 6px; min-width: 200px; }
.note-preview { margin-top: 4px; }
.pager { display: flex; gap: 12px; justify-content: center; align-items: center; margin: 16px 0; }

/* Download buttons */
.page-head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.download-group { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.btn-download::before { content: '↓'; font-weight: 700; color: var(--primary); }

/* Cards with a header action, two-column sections */
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; align-items: start; }
.two-col .card { margin-bottom: 0; }
.hint { font-size: .78rem; color: var(--muted); font-weight: 400; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.resume-box { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.resume-box select { width: auto; max-width: 320px; }

/* Usage tables */
.usage-table th .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.usage-table td { min-width: 130px; }
.usage-num { font-variant-numeric: tabular-nums; margin-bottom: 4px; }

/* Free-trial credit */
.credit-panel { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin-top: 12px; display: grid; gap: 8px; }
.credit-panel.credit-off { opacity: .8; }
.credit-panel .alert { margin: 0; }
.credit-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.credit-amount { font-weight: 700; font-variant-numeric: tabular-nums; }
.credits td { min-width: 120px; }
.credit-form input[type="number"] { width: 110px; }
.credit-form input[type="date"] { width: 150px; }

/* API keys */
.keys td { min-width: 110px; }
.keys code { white-space: nowrap; }
.row-muted td { opacity: .6; }
.key-error { color: var(--bad); margin-top: 4px; max-width: 320px; }
.mini-usage { display: grid; grid-template-columns: 80px 70px auto; gap: 8px; align-items: center; margin-bottom: 4px; white-space: nowrap; }
.mini-bar { display: block; height: 6px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.mini-bar .bar-fill { display: block; }
details.guide > summary { list-style: none; }
details.guide > summary::-webkit-details-marker { display: none; }
details.guide > summary h2 { display: inline; color: var(--text); }
details.guide > summary::after { content: ' ▾'; color: var(--muted); }
.steps { padding-left: 20px; display: grid; gap: 8px; font-size: .9rem; }

.log { list-style: none; padding: 0; margin: 0; max-height: 360px; overflow: auto; font-size: .85rem; border: 1px solid var(--border); border-radius: 8px; }
.log li { padding: 6px 10px; border-bottom: 1px solid var(--border); word-break: break-word; }
.log li:last-child { border-bottom: 0; }
.log li.ok { color: var(--ok); }

@media (max-width: 640px) {
  .topbar { position: static; }
  .nav a { padding: 6px 8px; }
  .container { padding: 14px 16px 30px; }
  .nav { margin-left: 0; width: 100%; }
  .row > label, .filters > label { flex: 1 1 100%; }
  .w-sm { width: 100%; }
  .stat-value { font-size: 1.2rem; }
}
