:root {
  --bg:#f6f7f9; --card:#fff; --ink:#1b1f24; --muted:#667085; --line:#e4e7ec; --accent:#1f6feb;
  --red:#c62828; --redbg:#fdecea; --green:#1b7f3b; --greenbg:#e7f6ec; --amber:#8a5a00; --amberbg:#fff4d6;
  --hot:#d9480f; --warm:#e0a100; --cold:#98a2b3; --bar:#1f6feb;
}
* { box-sizing:border-box; }
body { margin:0; font:14px/1.45 system-ui,-apple-system,Segoe UI,Roboto,sans-serif; background:var(--bg); color:var(--ink); }
header { padding:12px 24px; background:var(--card); border-bottom:1px solid var(--line); display:flex; gap:12px; align-items:center; flex-wrap:wrap; position:sticky; top:0; z-index:500; }
header h1 { font-size:17px; margin:0 8px 0 0; }
nav { display:flex; gap:4px; flex-wrap:wrap; }
nav button { border:0; background:none; font-weight:600; color:var(--muted); }
nav button.active { background:#eaf1fe; color:var(--accent); }
.spacer { flex:1; }
.pill { font-size:12px; padding:2px 8px; border-radius:999px; background:#eef2f7; color:var(--muted); }
.pill.on { background:var(--greenbg); color:var(--green); }
.pill.warn { background:var(--amberbg); color:var(--amber); }
main { padding:20px 24px; max-width:1700px; margin:0 auto; }
.panel { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:16px; margin-bottom:16px; }
.panel h3 { margin:0 0 12px; font-size:14px; }
.row { display:flex; gap:10px; flex-wrap:wrap; align-items:center; }
label.chk { display:inline-flex; gap:6px; align-items:center; padding:6px 10px; border:1px solid var(--line); border-radius:8px; cursor:pointer; user-select:none; background:#fff; }
input[type=text], input[type=date], input[type=number], input[type=url], input[type=password], select, textarea { padding:8px 10px; border:1px solid var(--line); border-radius:8px; font:inherit; background:#fff; color:inherit; }
input#location { min-width:240px; }
button { padding:8px 14px; border-radius:8px; border:1px solid var(--line); background:#fff; font:inherit; cursor:pointer; color:inherit; }
button.primary { background:var(--accent); color:#fff; border-color:var(--accent); }
button.small { padding:4px 9px; font-size:12px; }
button:disabled { opacity:.5; cursor:wait; }
#msg { color:var(--muted); }
#msg.err { color:var(--red); }
.sub { color:var(--muted); font-size:12px; }
a { color:var(--accent); text-decoration:none; }
a:hover { text-decoration:underline; }
code { background:#f0f2f5; padding:1px 4px; border-radius:4px; font-size:12px; }

.stats { display:flex; gap:22px; flex-wrap:wrap; }
.stats b { font-size:18px; display:block; }
.stats .due b { color:var(--red); }

.tabs { display:flex; gap:4px; flex-wrap:wrap; margin-bottom:12px; }
.tab { padding:8px 14px; border-radius:8px 8px 0 0; border:1px solid var(--line); border-bottom:0; background:#eef2f7; cursor:pointer; font-weight:600; color:var(--muted); }
.tab.active { background:var(--card); color:var(--ink); box-shadow:inset 0 3px 0 var(--accent); }
.tab .n { font-weight:400; margin-left:4px; }
.tab.due .n { background:var(--red); color:#fff; border-radius:999px; padding:0 6px; font-size:12px; }

.tablewrap { overflow-x:auto; }
table.leads, table.plain { width:100%; border-collapse:collapse; background:var(--card); }
table.leads th, table.leads td, table.plain th, table.plain td { text-align:left; padding:8px 10px; border-bottom:1px solid var(--line); vertical-align:top; }
table.leads th, table.plain th { background:#fafbfc; font-size:12px; color:var(--muted); text-transform:uppercase; letter-spacing:.03em; }
tr.nosite td { background:#fff8f7; }
tr.done td { opacity:.55; }
tr.done .name { text-decoration:line-through; }
td.chk { width:34px; text-align:center; }
td.chk input { width:20px; height:20px; cursor:pointer; }
.name { font-weight:600; cursor:pointer; }
.name:hover { color:var(--accent); }
.badge { display:inline-block; font-size:11px; font-weight:600; padding:2px 7px; border-radius:6px; white-space:nowrap; margin:1px 2px 1px 0; }
.b-red { background:var(--redbg); color:var(--red); }
.b-green { background:var(--greenbg); color:var(--green); }
.b-amber { background:var(--amberbg); color:var(--amber); }
.b-gray { background:#eef2f7; color:var(--muted); }
.b-blue { background:#eaf1fe; color:var(--accent); }
.score { display:inline-flex; align-items:center; justify-content:center; min-width:38px; height:28px; border-radius:8px; font-weight:700; color:#fff; cursor:help; }
.score.hot { background:var(--hot); } .score.warm { background:var(--warm); color:#3b2a00; } .score.cold { background:var(--cold); }
.socials a { margin-right:6px; }
.overdue { color:var(--red); font-weight:600; }
td select, td input[type=date] { padding:4px 6px; font-size:12px; margin-top:4px; }

/* drawer */
#backdrop { position:fixed; inset:0; background:rgba(16,24,40,.35); z-index:900; }
#drawer { position:fixed; top:0; right:0; bottom:0; width:min(560px,100vw); background:var(--card); z-index:1000; overflow-y:auto; box-shadow:-8px 0 24px rgba(0,0,0,.15); padding:18px 20px 40px; }
#drawer h2 { margin:0; font-size:19px; }
#drawer h4 { margin:18px 0 8px; font-size:13px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
#drawer .close { float:right; }
.callbtn { display:block; text-align:center; background:var(--green); color:#fff !important; font-size:17px; font-weight:700; padding:12px; border-radius:10px; margin:12px 0; }
.callbtn:hover { text-decoration:none; filter:brightness(1.05); }
.script { white-space:pre-wrap; background:#f8fafc; border:1px solid var(--line); border-radius:8px; padding:12px; font-size:13.5px; line-height:1.55; }
.outcomes { display:grid; grid-template-columns:repeat(3,1fr); gap:6px; }
.outcomes button { font-weight:600; }
.outcomes .o-good { border-color:var(--green); color:var(--green); }
.outcomes .o-bad { border-color:var(--red); color:var(--red); }
#drawer textarea, #drawer input[type=text], #drawer input[type=url], #drawer input[type=number] { width:100%; }
.field { display:grid; grid-template-columns:110px 1fr; gap:8px; align-items:center; margin-bottom:8px; }
.history { list-style:none; padding:0; margin:0; }
.history li { padding:6px 0; border-bottom:1px solid var(--line); font-size:13px; }
.reasons { margin:6px 0 0; padding-left:18px; font-size:12px; color:var(--muted); }

/* map */
#map { height:calc(100vh - 210px); min-height:420px; border-radius:10px; border:1px solid var(--line); }
.legend { display:inline-flex; gap:6px; align-items:center; font-size:12px; color:var(--muted); }
.legend i { width:12px; height:12px; border-radius:50%; display:inline-block; margin-left:8px; }

/* dashboard */
.tiles { display:grid; grid-template-columns:repeat(auto-fill,minmax(170px,1fr)); gap:12px; margin-bottom:16px; }
.tile { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px 16px; }
.tile .v { font-size:26px; font-weight:700; }
.tile .l { color:var(--muted); font-size:12px; }
.grid2 { display:grid; grid-template-columns:repeat(auto-fit,minmax(380px,1fr)); gap:16px; }
.vbars { display:flex; align-items:flex-end; gap:6px; height:180px; border-bottom:1px solid var(--line); padding-top:18px; }
.vbars .col { flex:1; display:flex; flex-direction:column; align-items:center; justify-content:flex-end; height:100%; position:relative; }
.vbars .bar { width:70%; max-width:28px; background:var(--bar); border-radius:4px 4px 0 0; min-height:0; }
.vbars .col:hover .bar { filter:brightness(1.15); }
.vbars .val { font-size:11px; color:var(--muted); margin-bottom:2px; }
.vlabels { display:flex; gap:6px; }
.vlabels span { flex:1; text-align:center; font-size:10px; color:var(--muted); }
.hbar { display:grid; grid-template-columns:140px 1fr 44px; gap:8px; align-items:center; margin-bottom:8px; font-size:13px; }
.hbar .track { background:#f0f2f5; border-radius:4px; height:14px; }
.hbar .fill { background:var(--bar); height:100%; border-radius:0 4px 4px 0; }
.hbar .num { text-align:right; font-variant-numeric:tabular-nums; }

#scriptFields label { display:block; font-weight:600; margin:14px 0 4px; }
#scriptFields textarea { width:100%; min-height:120px; font-size:13px; }

/* phones */
@media (max-width: 820px) {
  header { padding:10px 14px; position:static; }
  main { padding:14px 12px; }
  .pill { display:none; }
  table.leads thead { display:none; }
  table.leads, table.leads tbody, table.leads tr, table.leads td { display:block; width:100%; }
  table.leads tr { border-bottom:6px solid var(--bg); padding:8px 0; position:relative; }
  table.leads td { border:0; padding:3px 12px; }
  table.leads td:empty { display:none; }
  td.chk { position:absolute; right:6px; top:8px; width:auto; }
  .grid2 { grid-template-columns:1fr; }
  input#location { min-width:0; width:100%; }
  #map { height:calc(100vh - 230px); }
}
