:root {
  --brand: #6b4423;
  --brand-2: #8b5e34;
  --bg: #faf7f3;
  --card: #ffffff;
  --ink: #1f1a16;
  --muted: #7a6f66;
  --line: #ebe3da;
  --danger: #c0392b;
  --ok: #1e8449;
  --wa: #25d366;
  --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* ---------- Layout ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--brand); color: #fff;
  padding: 14px 16px 12px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 19px; margin: 0; flex: 1; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .icon-btn { background: rgba(255,255,255,.15); border: 0; color: #fff; width: 40px; height: 40px;
  border-radius: 12px; display: grid; place-items: center; font-size: 20px; }
main { padding: 12px 14px calc(170px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
.demo-banner { background: #fff4d6; color: #6b5200; font-size: 13px; padding: 8px 14px; text-align: center; }
.offline-banner { background: #fdecea; color: var(--danger); font-size: 13px; padding: 8px 14px; text-align: center; }

/* ---------- Bottom nav ---------- */
nav.bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: 1fr 1fr 1fr; padding: 6px 8px calc(6px + var(--safe-b)); }
nav.bottom button { background: none; border: 0; padding: 6px 0; display: flex; flex-direction: column; align-items: center;
  gap: 2px; font-size: 12px; color: var(--muted); }
nav.bottom button .i { font-size: 22px; line-height: 1; }
nav.bottom button.on { color: var(--brand); font-weight: 600; }
nav.bottom .add { margin-top: -26px; }
nav.bottom .add .i { background: var(--brand); color: #fff; width: 58px; height: 58px; border-radius: 50%;
  display: grid; place-items: center; font-size: 30px; box-shadow: 0 6px 16px rgba(107,68,35,.35); }

/* ---------- Search & chips ---------- */
.search { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; margin-bottom: 10px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 8px; margin: 0 -14px 6px; padding-left: 14px; padding-right: 14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 7px 13px; font-size: 14px; white-space: nowrap; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip .n { opacity: .7; margin-left: 4px; font-size: 12px; }

/* ---------- Lead cards ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 12px 12px 14px;
  margin-bottom: 10px; display: flex; gap: 10px; align-items: center; }
.card .body { flex: 1; min-width: 0; }
.card .name { font-weight: 650; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .meta { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.card .due { color: var(--danger); font-weight: 600; }
.round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; font-size: 19px; flex: none; }
.round.call { background: #f1ebe4; color: var(--brand); }
.round.wa { background: var(--wa); color: #fff; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; color: #fff; }
.src { font-size: 12px; padding: 2px 7px; border-radius: 6px; background: #f1ebe4; color: var(--brand); }
.empty { text-align: center; color: var(--muted); padding: 50px 20px; }
.empty .big { font-size: 42px; }

/* ---------- Detail ---------- */
.hero { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.hero .name { font-size: 22px; font-weight: 700; }
.hero .phone { color: var(--muted); margin-top: 2px; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.btn { border: 0; border-radius: 12px; padding: 13px 14px; font-weight: 650; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.call { background: #f1ebe4; color: var(--brand); }
.btn.wa { background: var(--wa); color: #fff; }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: transparent; color: var(--danger); border: 1px solid #f2c9c4; }
.btn[disabled] { opacity: .5; }
.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 2px 8px; }
.stages { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stage { border: 1.5px solid var(--line); background: #fff; border-radius: 12px; padding: 10px 4px; font-size: 14px; font-weight: 600; }
.stage.on { color: #fff; }

/* ---------- Forms ---------- */
.form { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
label.f { display: block; margin-bottom: 14px; }
label.f > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.in { width: 100%; padding: 12px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fdfcfa; }
.in:focus { outline: 2px solid var(--brand-2); border-color: transparent; }
textarea.in { min-height: 90px; resize: vertical; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { border: 1px solid var(--line); background: #fdfcfa; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.pick button.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.quick { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.quick button { border: 1px solid var(--line); background: #fff; border-radius: 9px; padding: 6px 10px; font-size: 13px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.hint { font-size: 13px; color: var(--muted); margin-top: -6px; margin-bottom: 12px; }
.sticky-save { position: fixed; left: 0; right: 0; bottom: calc(68px + var(--safe-b)); padding: 10px 14px; background: linear-gradient(transparent, var(--bg) 35%); z-index: 4; }
.sticky-save .btn { max-width: 612px; margin: 0 auto; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 30px 24px; background: var(--brand); color: #fff; }
.login .logo { width: 84px; height: 84px; border-radius: 22px; background: #fff; color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 32px; }
.login h1 { margin: 16px 0 4px; font-size: 24px; }
.login p { margin: 0 0 22px; opacity: .8; }
.dots { display: flex; gap: 14px; margin-bottom: 22px; height: 18px; }
.dots i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; }
.dots i.on { background: #fff; }
.pad { display: grid; grid-template-columns: repeat(3, 76px); gap: 14px; }
.pad button { height: 76px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; font-size: 28px; font-weight: 500; }
.pad button:active { background: rgba(255,255,255,.3); }
.login .err { color: #ffd2cc; min-height: 22px; margin-bottom: 8px; font-size: 15px; }

/* ---------- Stats ---------- */
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.kpi .v { font-size: 26px; font-weight: 750; }
.kpi .l { font-size: 13px; color: var(--muted); }
.bars { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.bar { display: grid; grid-template-columns: minmax(0,1.3fr) 1fr 30px; align-items: center; gap: 8px; margin: 8px 0; font-size: 14px; }
.bar .track { background: #f3ede6; border-radius: 6px; height: 12px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--brand-2); border-radius: 6px; }
.bar > span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .n { text-align: right; font-weight: 650; }
.seg { display: flex; gap: 6px; background: #efe8e0; padding: 4px; border-radius: 12px; margin-bottom: 12px; }
.seg button { flex: 1; border: 0; background: transparent; padding: 8px; border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* ---------- Toast ---------- */
#toast { position: fixed; left: 50%; bottom: calc(150px + var(--safe-b)); transform: translateX(-50%) translateY(20px);
  background: #2a221c; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 15px; opacity: 0; pointer-events: none;
  transition: .25s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 50px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.top .icon-btn.lang { width: auto; padding: 0 12px; font-size: 14px; font-weight: 700; }

nav.bottom.four { grid-template-columns: repeat(4, 1fr); }
.kpi[data-filter-go] { cursor: pointer; }
.emp { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; cursor: pointer; }
.emp-h { display: flex; align-items: center; gap: 10px; }
.emp-h .body { flex: 1; min-width: 0; }
.emp-h .name { font-weight: 700; }
.emp-h .sub { font-size: 13px; color: var(--muted); }
.emp-rev { font-weight: 750; white-space: nowrap; }
.av { width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 700; flex: none; }
.emp .track { background: #f3ede6; border-radius: 6px; height: 8px; overflow: hidden; margin: 10px 0 12px; }
.emp .fill { height: 100%; background: var(--brand-2); border-radius: 6px; }
.emp-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; }
.emp-grid .c { background: var(--bg); border-radius: 10px; padding: 8px; text-align: center; }
.emp-grid .c b { display: block; font-size: 17px; }
.emp-grid .c span { font-size: 12px; color: var(--muted); }
.emp-grid .c.bad b { color: var(--danger); }
