:root {
  --bg: #f3f5f9;
  --surface: #ffffff;
  --ink: #0f1b2d;
  --ink-2: #3d4b60;
  --ink-3: #6b778a;
  --line: #e2e7ef;
  --navy: #0f1b2d;
  --accent: #1d4ed8;
  --accent-soft: #e6edff;
  --wa: #128c4a;
  --danger: #c0262d;
  --good: #11804a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 27, 45, .06), 0 4px 16px rgba(15, 27, 45, .05);
  font-family: 'Plus Jakarta Sans', -apple-system, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  font-weight: 500;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); font-weight: 700; text-decoration: none; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 18px; font-weight: 800; }
h3 { font-size: 15px; font-weight: 800; }
.muted { color: var(--ink-3); font-weight: 600; }
.small { font-size: 13px; }
.boot { display: grid; place-items: center; height: 100vh; font-weight: 800; font-size: 22px; color: var(--ink-3); }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 22px 14px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; }
.brand { font-weight: 800; font-size: 20px; padding: 4px 12px 18px; letter-spacing: -.02em; }
.brand span { color: #8fb0ff; }
.nav-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #c8d3e6; font-weight: 700; font-size: 15px; padding: 11px 12px; border-radius: 10px; cursor: pointer; text-align: left; }
.nav-btn:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-btn.on { background: #fff; color: var(--navy); }
.nav-btn .ico { width: 20px; text-align: center; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.who { font-weight: 800; font-size: 14px; }
.who small { display: block; color: #9fb0c9; font-weight: 600; }
.main { padding: 26px 30px 90px; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.topbar h1 { margin-right: auto; }
.lang-toggle { display: inline-flex; background: rgba(255, 255, 255, .1); border-radius: 999px; padding: 3px; }
.lang-toggle button { border: 0; background: none; color: #c8d3e6; font-weight: 800; font-size: 13px; padding: 5px 12px; border-radius: 999px; cursor: pointer; }
.lang-toggle button.on { background: #fff; color: var(--navy); }
.mobile-nav { display: none; }

/* ---------- controls ---------- */
.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 800; font-size: 14px; cursor: pointer; background: var(--accent); color: #fff; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--surface); color: var(--ink); border: 1.5px solid var(--line); }
.btn.wa { background: var(--wa); }
.btn.danger { background: var(--surface); color: var(--danger); border: 1.5px solid #f2c9cb; }
.btn.sm { padding: 7px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.input, select.input, textarea.input { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; font-weight: 600; font-size: 14px; outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { min-height: 80px; resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 13px; color: var(--ink-2); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 700; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---------- cards ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.card-h { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-h h2, .card-h h3 { margin-right: auto; }

/* ---------- stage chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.chip { border: 1.5px solid var(--line); background: var(--surface); border-radius: 999px; padding: 7px 13px; font-weight: 800; font-size: 13px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 7px; align-items: center; }
.chip b { background: var(--bg); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip.on b { background: rgba(255, 255, 255, .18); }
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }

.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.st-new { background: #1d4ed8; } .st-contacted { background: #0e7490; } .st-qualified { background: #7c3aed; }
.st-appointment { background: #c2410c; } .st-viewed { background: #a16207; } .st-booking { background: #15803d; }
.st-spa { background: #065f46; } .st-lost { background: #9aa3b2; }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-size: 12.5px; background: var(--bg); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }

/* ---------- lead list ---------- */
.lead-list { display: flex; flex-direction: column; gap: 8px; }
.lead { display: grid; grid-template-columns: 26px 1.6fr 1.2fr 1fr 1fr auto; gap: 12px; align-items: center; background: var(--surface); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); cursor: pointer; border: 1.5px solid transparent; }
.lead:hover { border-color: var(--accent-soft); }
.lead.no-check { grid-template-columns: 1.6fr 1.2fr 1fr 1fr auto; }
.lead .nm { font-weight: 800; font-size: 15px; }
.lead .sub { font-size: 13px; color: var(--ink-3); font-weight: 600; margin-top: 2px; }
.lead .proj { font-weight: 700; font-size: 14px; }
.lead .acts { display: flex; gap: 6px; }
.icon-btn { width: 36px; height: 36px; border-radius: 10px; border: 0; display: grid; place-items: center; cursor: pointer; font-size: 16px; text-decoration: none; }
.icon-btn.wa { background: #e3f5ea; color: var(--wa); }
.icon-btn.tel { background: var(--accent-soft); color: var(--accent); }
.tag { display: inline-block; font-size: 11.5px; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: var(--bg); color: var(--ink-2); margin-right: 4px; }
.tag.ad { background: #fff2dc; color: #8a4b00; }
.bulkbar { position: sticky; bottom: 16px; background: var(--navy); color: #fff; border-radius: 14px; padding: 10px 14px; display: flex; gap: 10px; align-items: center; margin-top: 12px; box-shadow: 0 8px 30px rgba(15, 27, 45, .3); font-weight: 800; }
.bulkbar select { max-width: 200px; }
.empty { text-align: center; padding: 50px 10px; color: var(--ink-3); font-weight: 700; }

/* ---------- drawer ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); z-index: 50; display: flex; justify-content: flex-end; }
.drawer { background: var(--bg); width: min(560px, 100%); height: 100%; overflow-y: auto; padding: 20px; animation: slide .18s ease-out; }
@keyframes slide { from { transform: translateX(30px); } }
.modal-wrap { position: fixed; inset: 0; background: rgba(15, 27, 45, .45); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 16px; padding: 22px; width: min(480px, 100%); max-height: 92vh; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.drawer-h { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.drawer-h .t { margin-right: auto; }
.drawer-h .t .sub { font-weight: 700; color: var(--ink-3); margin-top: 3px; }
.stage-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-picker button { border: 1.5px solid var(--line); background: var(--surface); padding: 7px 11px; border-radius: 9px; font-weight: 800; font-size: 13px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; }
.stage-picker button.on { border-color: var(--navy); background: var(--navy); color: #fff; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--ink-3); font-weight: 700; }
.kv dd { margin: 0; font-weight: 700; word-break: break-word; }
.timeline { display: flex; flex-direction: column; gap: 10px; }
.tl { display: grid; grid-template-columns: 30px 1fr; gap: 10px; }
.tl .ic { width: 30px; height: 30px; border-radius: 9px; background: var(--bg); display: grid; place-items: center; font-size: 14px; }
.tl .tx { font-weight: 600; font-size: 14px; white-space: pre-wrap; word-break: break-word; }
.tl .meta { font-size: 12px; color: var(--ink-3); font-weight: 700; margin-top: 2px; }

/* ---------- reports ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.kpi .l { font-size: 13px; font-weight: 800; color: var(--ink-3); }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 4px; letter-spacing: -.02em; }
.kpi .s { font-size: 12.5px; font-weight: 700; color: var(--ink-3); margin-top: 2px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.two .card + .card { margin-top: 0; }
table.t { width: 100%; border-collapse: collapse; font-size: 14px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 800; padding: 8px 10px; border-bottom: 1.5px solid var(--line); white-space: nowrap; }
table.t td { padding: 10px; border-bottom: 1px solid var(--line); font-weight: 600; vertical-align: middle; }
table.t td.n, table.t th.n { text-align: right; font-variant-numeric: tabular-nums; }
table.t td b { font-weight: 800; }
table.t tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.good { color: var(--good); font-weight: 800; }
.bad { color: var(--danger); font-weight: 800; }
.bars { position: relative; display: flex; align-items: flex-end; gap: 2px; height: 150px; padding-top: 10px; border-bottom: 1.5px solid var(--line); }
.bars .b { flex: 1; max-width: 36px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; cursor: default; }
.bars .b:hover { background: var(--navy); }
.bars-x { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--ink-3); margin-top: 6px; }
.tip { position: fixed; pointer-events: none; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 700; padding: 6px 9px; border-radius: 8px; z-index: 100; white-space: nowrap; }
.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; font-weight: 600; background: var(--bg); padding: 8px 10px; border-radius: 8px; word-break: break-all; display: block; }
.status { font-weight: 800; font-size: 13px; }
.status.ok { color: var(--good); } .status.no { color: var(--danger); }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--navy); }
.auth .card { width: min(400px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px; }
.auth .brand { color: var(--navy); padding: 0; font-size: 26px; }
.auth .brand span { color: var(--accent); }
.err { color: var(--danger); font-weight: 800; font-size: 14px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 800; z-index: 200; box-shadow: 0 8px 30px rgba(0, 0, 0, .25); }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { display: none; }
  .main { padding: 16px 14px 96px; }
  .mobile-nav { display: flex; position: fixed; bottom: 0; left: 0; right: 0; background: var(--navy); padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 40; justify-content: space-around; }
  .mobile-nav button { background: none; border: 0; color: #9fb0c9; font-weight: 800; font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; border-radius: 10px; flex: 1; cursor: pointer; }
  .mobile-nav button .ico { font-size: 18px; }
  .mobile-nav button.on { color: #fff; background: rgba(255, 255, 255, .1); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .q { grid-column: 1 / -1; }
  .lead, .lead.no-check { grid-template-columns: 1fr auto; grid-template-areas: "a acts" "b b"; gap: 8px; }
  .lead .c-check, .lead .c-proj, .lead .c-caller, .lead .c-stage { display: none; }
  .lead .c-main { grid-area: a; }
  .lead .c-mob { grid-area: b; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
  .lead .acts { grid-area: acts; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .two { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .bulkbar { bottom: 80px; }
  h1 { font-size: 21px; }
}
@media (min-width: 861px) { .lead .c-mob { display: none; } }

.lead .sub.remark { color: var(--ink-2); font-weight: 700; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.lead .c-main { min-width: 0; }
