:root {
  --bg: #f6f7fb; --card: #ffffff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --brand: #4f46e5; --brand-2: #4338ca; --brand-soft: #eef2ff; --ok: #16a34a; --ok-soft: #dcfce7;
  --warn: #b45309; --warn-soft: #fef3c7; --bad: #dc2626; --bad-soft: #fee2e2; --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.5; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }

/* Top bar */
.topbar { background: #0f172a; color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar .in { max-width: 1200px; margin: 0 auto; display: flex; align-items: center; gap: 16px; padding: 0 16px; height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: linear-gradient(135deg, #6366f1, #22c55e); display: grid; place-items: center; font-size: 13px; color: #fff; font-weight: 800; }
.brand small { font-weight: 500; color: #94a3b8; font-size: 12px; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav a { color: #cbd5e1; padding: 8px 12px; border-radius: 8px; white-space: nowrap; font-weight: 500; }
.nav a:hover { background: #1e293b; color: #fff; text-decoration: none; }
.nav a.on { background: #1e293b; color: #fff; }
.me { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.me a { color: #cbd5e1; }
.me form { margin: 0; }
.linkbtn { background: none; border: 0; color: #cbd5e1; cursor: pointer; font: inherit; padding: 0; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 20px 16px 60px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }

/* Cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g2 { grid-template-columns: 1fr 1fr; }
.g-main { grid-template-columns: 1.4fr 1fr; }
.kpi .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .val { font-size: 28px; font-weight: 700; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 12px; }
.kpi a.val { color: var(--text); display: block; }

/* Buttons & forms */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 8px 14px; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.wa { background: #25d366; border-color: #25d366; color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.btn.block { width: 100%; justify-content: center; }
label { display: block; font-weight: 600; font-size: 12px; color: #374151; margin: 0 0 4px; }
input, select, textarea { width: 100%; font: inherit; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid #c7d2fe; border-color: var(--brand); }
textarea { min-height: 70px; resize: vertical; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }
.row > .btn { flex: none; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters input, .filters select { width: auto; min-width: 150px; flex: 1; }
.filters .btn { flex: none; }

/* Alerts */
.alert { padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.alert.ok { background: var(--ok-soft); color: #14532d; }
.alert.bad { background: var(--bad-soft); color: #7f1d1d; }
.alert.info { background: var(--brand-soft); color: #312e81; }
.alert.warn { background: var(--warn-soft); color: #78350f; }

/* Tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: #fff; color: var(--text); font-weight: 600; font-size: 13px; }
.tabs a.on { background: #0f172a; color: #fff; border-color: #0f172a; }
.tabs a:hover { text-decoration: none; }
.count { display: inline-block; background: rgba(0,0,0,.08); border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 4px; }
.tabs a.on .count { background: rgba(255,255,255,.2); }

/* Table */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); background: #f9fafb; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #fafafa; }
.tablecard { padding: 0; overflow: hidden; }
.who { display: flex; gap: 10px; align-items: center; }
.who .name { font-weight: 600; color: var(--text); }
.who .ph { color: var(--muted); font-size: 12px; }
.quick { display: flex; gap: 6px; }
.icon { width: 30px; height: 30px; border-radius: 8px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: #fff; font-size: 14px; }
.icon:hover { text-decoration: none; background: #f3f4f6; }
.icon.wa { color: #16a34a; }
select.stage { width: auto; padding: 5px 8px; font-size: 12px; font-weight: 600; border-radius: 999px; }
select.assign { width: auto; padding: 5px 8px; font-size: 12px; }

/* Pills */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #f3f4f6; color: #374151; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.pill.src { background: var(--brand-soft); color: #3730a3; }
.pill.ok { background: var(--ok-soft); color: #166534; }
.pill.bad { background: var(--bad-soft); color: #991b1b; }
.pill.warn { background: var(--warn-soft); color: #92400e; }
.overdue { color: var(--bad); font-weight: 600; }

/* Bars */
.bar { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.bar .lbl { width: 150px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.bar .track { flex: 1; background: #f3f4f6; height: 10px; border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; }
.bar .n { width: 36px; text-align: right; font-weight: 600; }

/* Lead page */
.lead-head { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.lead-head .avatar { width: 48px; height: 48px; font-size: 16px; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 10px 0 10px 18px; border-left: 2px solid var(--line); position: relative; margin-left: 6px; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 15px; width: 10px; height: 10px; border-radius: 50%; background: #cbd5e1; }
.timeline li.remark::before { background: var(--brand); }
.timeline li.stage::before { background: var(--ok); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.signal { border-radius: 10px; padding: 12px; font-size: 13px; }
.signal.live { background: #ecfdf5; border: 1px solid #a7f3d0; }
.signal.off { background: #f8fafc; border: 1px solid var(--line); }
.stage-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.stage-buttons button { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.stage-buttons button.on { background: #0f172a; color: #fff; border-color: #0f172a; }
.stage-buttons button:hover { background: #f3f4f6; }
.stage-buttons button.on:hover { background: #0f172a; }

/* Auth & public pages */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 20% 0%, #e0e7ff, transparent 40%), radial-gradient(circle at 100% 100%, #dcfce7, transparent 40%), var(--bg); }
.auth { width: 100%; max-width: 400px; }
.auth .brand { color: var(--text); justify-content: center; margin-bottom: 16px; font-size: 20px; }
.hero { max-width: 1000px; margin: 0 auto; padding: 60px 20px; }
.hero h1 { font-size: 40px; line-height: 1.15; letter-spacing: -.02em; }
.hero p.lead { font-size: 18px; color: #374151; max-width: 640px; }
.flow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 28px 0; }
.flow .step { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; font-weight: 600; box-shadow: var(--shadow); }
.flow .arrow { color: var(--muted); }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 30px; }
.pubbar { background: #fff; border-bottom: 1px solid var(--line); }
.pubbar .in { max-width: 1000px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; padding: 14px 20px; }
.pubbar .brand { color: var(--text); }
.legal { max-width: 800px; margin: 0 auto; padding: 30px 20px 60px; }
.legal h2 { margin-top: 24px; }
footer.pub { text-align: center; color: var(--muted); font-size: 12px; padding: 30px; }
footer.pub a { margin: 0 8px; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #0f172a; color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 14px; align-items: center; }
.copy { cursor: pointer; }
.hide-sm { }
.only-sm { display: none; }

@media (max-width: 900px) {
  .g4 { grid-template-columns: 1fr 1fr; }
  .g2, .g-main, .features { grid-template-columns: 1fr; }
  .hero h1 { font-size: 30px; }
}
@media (max-width: 720px) {
  .wrap { padding: 14px 12px 60px; }
  .topbar .in { gap: 8px; }
  .brand small, .me .uname { display: none; }
  .hide-sm { display: none; }
  .only-sm { display: initial; }
  .kv { grid-template-columns: 110px 1fr; }
  /* table rows become cards on phones */
  .table.cards thead { display: none; }
  .table.cards, .table.cards tbody, .table.cards tr, .table.cards td { display: block; width: 100%; }
  .table.cards tr { border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .table.cards td { border: 0; padding: 4px 0; }
  .table.cards td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: 12px; }
  .bar .lbl { width: 110px; }
}
