:root {
  --ground: #F6F5F1;
  --card: #FFFFFF;
  --ink: #16181D;
  --ink-2: #3D4047;
  --muted: #5B5F66;
  --line: #E6E3DA;
  --line-2: #D8D5CC;
  --accent: #FDBA12;
  --green: #17663A;
  --green-bg: #EEF8F1;
  --green-line: #CFE6D7;
  --red: #8A1F0B;
  --red-bg: #FFE2DC;
  --blue: #173E80;
  --blue-bg: #E3ECFB;
  --amber-bg: #FFF1CC;
  --amber-line: #F0D27A;
  --amber-ink: #4A3600;
  --radius: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ground); color: var(--ink); }
body {
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
a { color: #1a56b8; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; letter-spacing: -0.2px; }
.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ---------- layout ---------- */
.screen {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
.screen.wide { max-width: 1040px; }
.screen.no-nav { padding-bottom: 24px; }
.pad { padding: 0 16px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.bold { font-weight: 700; }
.hide { display: none !important; }
.sr { position: absolute; left: -9999px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  position: sticky; top: 0; background: var(--ground); z-index: 5;
}
.top h1 { font-size: 19px; font-weight: 800; }
.logo {
  width: 40px; height: 40px; border-radius: 11px; flex-shrink: 0;
  background: #2F6B3A; color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 19px; overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.logo.big { width: 84px; height: 84px; border-radius: 22px; font-size: 40px; }
.chip-link {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 12px;
  background: var(--blue-bg); color: var(--blue); font-size: 12px; font-weight: 700; text-decoration: none;
}

/* ---------- cards & controls ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.card.tight { padding: 12px; }
.label-cap { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.4px; text-transform: uppercase; }
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 14px; border: none; cursor: pointer;
  background: var(--ink); color: #fff; font-weight: 700; font-size: 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
}
.btn.block { width: 100%; }
.btn.light { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn.green { background: var(--green-bg); color: var(--green); border: 1px solid var(--green-line); }
.btn.yellow { background: var(--accent); color: var(--ink); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid #F3B9AC; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: 0.55; cursor: default; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line-2); background: #fff;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; text-decoration: none; color: var(--ink);
}
.icon-btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.icon-btn.wa { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.pill {
  min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--line-2); background: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap; color: var(--ink);
  display: inline-flex; align-items: center; text-decoration: none;
}
.pill.on { background: var(--ink); border-color: var(--ink); color: #fff; font-weight: 700; }
.pills { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.tag { font-size: 12px; font-weight: 700; padding: 4px 9px; border-radius: 10px; white-space: nowrap; background: #EDEBE4; color: var(--ink-2); }
.tag.new { background: var(--red-bg); color: var(--red); }
.tag.calling { background: var(--blue-bg); color: var(--blue); }
.tag.won { background: var(--green-bg); color: var(--green); }
.tag.lost { background: #EDEBE4; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lbl { font-size: 14px; font-weight: 600; }
.input, select.input, textarea.input {
  min-height: 50px; border: 1.5px solid var(--line-2); border-radius: 12px; background: #fff; padding: 10px 14px; width: 100%;
  font-size: 16px; outline: none;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--ink); }
.pin { letter-spacing: 8px; font-size: 22px; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.check input { width: 20px; height: 20px; }

/* ---------- inbox ---------- */
.banner {
  display: flex; gap: 12px; align-items: center; border-radius: 14px; padding: 12px 14px;
  background: var(--amber-bg); border: 1px solid var(--amber-line); color: var(--amber-ink);
}
.banner.ok { background: var(--green-bg); border-color: var(--green-line); color: var(--green); }
.banner.info { background: var(--blue-bg); border-color: #C8D7F3; color: var(--blue); }
.lead-card { display: flex; flex-direction: column; gap: 10px; cursor: pointer; text-decoration: none; color: inherit; }
.lead-card .name { font-size: 16px; font-weight: 700; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }

/* ---------- bottom nav ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: #fff; border-top: 1px solid #E0DDD4;
  padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.nav-in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.nav a {
  display: flex; flex-direction: column; align-items: center; gap: 3px; min-height: 48px; justify-content: center;
  color: var(--muted); font-size: 12px; font-weight: 600; text-decoration: none; position: relative;
}
.nav a.on { color: var(--ink); font-weight: 800; }
.badge {
  position: absolute; top: 2px; left: 55%; background: #C2410C; color: #fff; font-size: 11px; font-weight: 800;
  min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(86px + env(safe-area-inset-bottom)); z-index: 9;
  width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--ink);
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.18); text-decoration: none;
}

/* ---------- sheet ---------- */
.sheet-back { position: fixed; inset: 0; background: rgba(22,24,29,.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--ground); width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; overflow-y: auto;
}
.opt-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.opt {
  min-height: 48px; border-radius: 12px; border: 1.5px solid var(--line-2); background: #fff; font-weight: 600; font-size: 14px;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 6px; cursor: pointer;
}
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.opt:has(input:checked) { border-color: var(--ink); background: var(--ink); color: #fff; }

/* ---------- reports ---------- */
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .v { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; background: #EFEDE6; gap: 2px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 600; padding: 6px 4px; }
.table td { border-top: 1px solid #EFEDE6; padding: 9px 4px; }
.scroll-x { overflow-x: auto; }

/* ---------- activity ---------- */
.act { display: flex; gap: 10px; padding-top: 10px; border-top: 1px solid #EFEDE6; }
.act:first-of-type { border-top: none; padding-top: 0; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--line-2); margin-top: 7px; flex-shrink: 0; }

#toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 12px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 30; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }

.powered { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--muted); padding: 18px 0; }
.powered b { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); }
.powered i { width: 18px; height: 18px; border-radius: 5px; background: var(--accent); font-style: normal; font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }

@media (min-width: 900px) {
  .admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
