:root {
  --bg: #f4f5f2;
  --surface: #ffffff;
  --surface-2: #f8f9f6;
  --text: #1c2321;
  --muted: #66706c;
  --line: #e2e5df;
  --accent: #0f6b5c;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1ed;
  --hot: #c2410c;
  --hot-soft: #fdeee4;
  --warm: #a16207;
  --warm-soft: #fbf3dc;
  --cool: #475569;
  --cool-soft: #eef1f5;
  --ok: #15803d;
  --bad: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 2px 8px rgba(20, 30, 25, .04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121615;
    --surface: #1a1f1e;
    --surface-2: #202624;
    --text: #e6ebe8;
    --muted: #96a19c;
    --line: #2d3532;
    --accent: #3fb59d;
    --accent-ink: #0c1311;
    --accent-soft: #19332d;
    --hot: #fb923c;
    --hot-soft: #3a2316;
    --warm: #facc15;
    --warm-soft: #352e12;
    --cool: #a9b4c2;
    --cool-soft: #252b33;
    --ok: #4ade80;
    --bad: #f87171;
    --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 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mt { margin-top: 1.4rem; }
.hidden { display: none !important; }
.hot-t { color: var(--hot); }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--accent); color: var(--accent-ink); font-size: .8rem; letter-spacing: .02em;
}
.nav { display: flex; gap: .25rem; flex-wrap: wrap; }
.nav a { padding: .4rem .7rem; border-radius: 7px; color: var(--text); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a.on { background: var(--accent-soft); color: var(--accent); }
.nav a.muted { color: var(--muted); }
.demo-banner {
  background: var(--warm-soft); color: var(--text); padding: .55rem 1.25rem; font-size: .88rem;
  border-bottom: 1px solid var(--line);
}

.wrap { max-width: 1320px; margin: 0 auto; padding: 1.25rem 16px 3rem; }
.wrap.narrow { max-width: 480px; padding-top: 3rem; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.25rem; box-shadow: var(--shadow); min-width: 0;
}
.card.narrow { max-width: 420px; margin: 2rem auto; }
.card.narrow-wide { max-width: 720px; margin: 1rem auto; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: .5rem; }
.wrap-row { flex-wrap: wrap; gap: .75rem; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow); }
.stat .num { display: block; font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .lbl { color: var(--muted); font-size: .84rem; }
.stat.hot .num { color: var(--hot); }

/* Forms */
.stack { display: grid; gap: 1rem; }
label { display: grid; gap: .3rem; font-weight: 500; font-size: .9rem; }
input[type=text], input[type=search], input[type=password], input[type=email], input[type=date], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: .55rem .7rem; min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
fieldset.coverage { border: 1px solid var(--line); border-radius: 8px; padding: .5rem .75rem .75rem; margin: 0; }
fieldset.coverage legend { font-weight: 500; font-size: .9rem; padding: 0 .3rem; }
label.opt { display: flex; gap: .6rem; align-items: flex-start; font-weight: 400; padding: .45rem .2rem; cursor: pointer; }
label.opt input { margin-top: .3rem; accent-color: var(--accent); }
label.opt small { display: block; }
label.check { display: inline-flex; align-items: center; gap: .4rem; font-weight: 400; white-space: nowrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: inherit; font-weight: 600; font-size: .9rem; padding: .5rem .9rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.big { padding: .75rem 1rem; font-size: 1rem; }
.btn:disabled { opacity: .6; cursor: default; }
button.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; }

.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--line); background: var(--surface-2); }
.alert.error { border-color: var(--bad); color: var(--bad); }
.alert.ok { border-color: var(--ok); color: var(--ok); }
.alert.warn { background: var(--warm-soft); border-color: transparent; }

/* Recent + legend */
.recent, .legend { list-style: none; margin: 0; padding: 0; }
.recent li { padding: .6rem 0; border-bottom: 1px solid var(--line); display: grid; gap: .1rem; }
.recent li:last-child { border-bottom: 0; }
.legend li { display: flex; align-items: flex-start; gap: .6rem; padding: .3rem 0; }
.legend li > :first-child { flex: none; }

/* Badges */
.badge { display: inline-block; font-size: .75rem; font-weight: 600; padding: .15rem .5rem; border-radius: 999px; white-space: nowrap; }
.badge.hot { background: var(--hot-soft); color: var(--hot); }
.badge.warm { background: var(--warm-soft); color: var(--warm); }
.badge.cool { background: var(--cool-soft); color: var(--cool); }
.score {
  display: inline-grid; place-items: center; min-width: 2.4rem; padding: .2rem .45rem; border-radius: 7px;
  font-weight: 700; font-size: .85rem; font-variant-numeric: tabular-nums; cursor: help;
}
.score.hi { background: var(--accent); color: var(--accent-ink); }
.score.mid { background: var(--accent-soft); color: var(--accent); }
.score.lo { background: var(--surface-2); color: var(--muted); }
.tag { background: var(--surface-2); border-radius: 5px; padding: 0 .35rem; width: fit-content; }

/* Summary tiles on lead page */
.summary { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0; }
.sum-item {
  display: grid; padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  color: var(--text); min-width: 120px; font-size: .82rem;
}
.sum-item .num { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.sum-item:hover { background: var(--surface-2); text-decoration: none; }
.sum-item.on { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sum-item.hot .num { color: var(--hot); }

.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem; background: var(--surface-2); border-radius: 8px; }
.filters input[type=search] { flex: 1 1 220px; width: auto; }
.filters select { width: auto; flex: 0 1 auto; }
.toolbar { margin: 1rem 0 .6rem; }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); }
th, td { padding: .65rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--surface-2); }
table.leads { min-width: 1050px; }
table.leads td { font-size: .9rem; }
td.biz, td.contact, td.web, td.g, td.fu { display: table-cell; }
td.biz > *, td.contact > *, td.web > *, td.g > * { display: block; }
td.biz { max-width: 320px; }
.addr { color: var(--muted); margin: .15rem 0; }
td.contact { width: 190px; }
.phone { font-weight: 600; font-variant-numeric: tabular-nums; }
.wa { color: var(--ok); }
td.web { width: 190px; }
td.web .badge { width: fit-content; margin-bottom: .2rem; }
.trunc { max-width: 170px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-status { margin-top: .15rem; }
.site-status.bad { color: var(--bad); }
td.fu { width: 210px; }
td.fu .inline { margin-bottom: .3rem; padding: .3rem .45rem; font-size: .85rem; }
td.contact .inline { margin-top: .35rem; padding: .3rem .45rem; font-size: .85rem; }
textarea.notes { resize: vertical; min-height: 32px; overflow: hidden; }
.inline.saved { outline: 2px solid var(--ok); outline-offset: -1px; }
.inline.err { outline: 2px solid var(--bad); outline-offset: -1px; }
select.st-interested, select.st-proposal { color: var(--accent); font-weight: 600; }
select.st-won { color: var(--ok); font-weight: 700; }
select.st-not_interested { color: var(--muted); }
select.st-follow_up { color: var(--warm); font-weight: 600; }
.empty { padding: 2rem; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 1rem; align-items: center; justify-content: center; margin-top: 1rem; }

/* Progress */
.progress { height: 12px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 1.25rem 0 .5rem; border: 1px solid var(--line); }
.progress .bar { height: 100%; background: var(--accent); transition: width .3s ease; }
.progress-text { font-variant-numeric: tabular-nums; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .topbar { padding: .6rem 16px; }
  .card { padding: 1rem; }
  .stat .num { font-size: 1.3rem; }
  .filters select, .filters input[type=search] { flex: 1 1 100%; width: 100%; }
  .summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sum-item { min-width: 0; }
  .toolbar .row.gap { flex-wrap: wrap; width: 100%; }
  .toolbar .btn { flex: 1 1 100%; white-space: normal; }
  .nav a { padding: .35rem .5rem; }
}
