:root {
  --bg: #07070c;
  --panel: #0e0e17;
  --panel2: #12121d;
  --line: #1e1e2e;
  --gold: #c9a227;
  --gold2: #e0b84a;
  --ink: #f2f2f6;
  --muted: #9aa1ad;
  --green: #10b981;
  --blue: #3b82f6;
  --red: #ef4444;
  --amber: #f59e0b;
  --purple: #8b5cf6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; line-height: 1.5; font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea {
  background: var(--panel2); color: var(--ink); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px 12px; font-size: 14px; font-family: inherit; width: 100%;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 5px; font-weight: 600; letter-spacing: .3px; }

/* ---- auth screen ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #141421 0%, var(--bg) 60%); }
.auth-card { width: 100%; max-width: 430px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand .mark { width: 42px; height: 42px; border-radius: 10px; background: linear-gradient(135deg, var(--gold), #8a6d16);
  display: flex; align-items: center; justify-content: center; font-weight: 900; font-size: 20px; color: #0a0a0a; font-family: Georgia, serif; }
.brand .nm { font-family: Georgia, serif; font-size: 20px; font-weight: 700; color: var(--gold); letter-spacing: .3px; }
.brand .sb { font-size: 11px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; }
.tabs { display: flex; gap: 4px; background: var(--panel2); border-radius: 10px; padding: 4px; margin-bottom: 22px; }
.tabs button { flex: 1; padding: 9px; border: none; background: transparent; color: var(--muted); border-radius: 8px; font-weight: 600; }
.tabs button.active { background: var(--gold); color: #0a0a0a; }
.field { margin-bottom: 14px; }
.btn { width: 100%; padding: 12px; border: none; border-radius: 10px; font-weight: 700; font-size: 14px;
  background: linear-gradient(135deg, var(--gold), #b8912a); color: #0a0a0a; transition: transform .1s, filter .15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(.99); }
.btn.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.btn.danger { background: var(--red); color: #fff; }
.btn.sm { width: auto; padding: 7px 12px; font-size: 12px; border-radius: 8px; }
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-box { flex: 0 0 180px; height: 60px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); cursor: pointer; }
.captcha-box svg { display: block; width: 100%; height: 100%; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.err { color: var(--red); font-size: 12px; margin-top: 8px; min-height: 16px; }
.ok { color: var(--green); font-size: 12px; margin-top: 8px; }
.notice { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }

/* ---- app shell ---- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: 230px; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .brand { padding: 18px 20px; margin-bottom: 0; border-bottom: 1px solid var(--line); }
.nav { flex: 1; padding: 12px; overflow-y: auto; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; color: var(--muted);
  font-weight: 600; cursor: pointer; margin-bottom: 3px; transition: background .12s, color .12s; }
.nav-item:hover { background: var(--panel2); color: var(--ink); }
.nav-item.active { background: linear-gradient(135deg, rgba(201,162,39,.18), rgba(201,162,39,.06)); color: var(--gold2); }
.nav-item .ico { width: 20px; text-align: center; font-size: 16px; }
.nav-item .badge { margin-left: auto; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 10px; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 14px; padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line); }
.topbar .title { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .av { width: 34px; height: 34px; border-radius: 50%; background: var(--gold); color: #0a0a0a; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.user-chip .meta .n { font-weight: 700; font-size: 13px; }
.user-chip .meta .r { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.content { flex: 1; overflow-y: auto; padding: 22px; }
.view { display: none; }
.view.active { display: block; }

/* ---- stat cards ---- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .5px; text-transform: uppercase; }
.stat .v { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat .d { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat.gold .v { color: var(--gold2); } .stat.green .v { color: var(--green); }
.stat.blue .v { color: var(--blue); } .stat.red .v { color: var(--red); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px; margin-bottom: 20px; }
.panel h3 { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .grid2 { grid-template-columns: 1fr; } .sidebar { width: 64px; } .sidebar .brand .nm, .sidebar .brand .sb, .nav-item span:not(.ico) { display: none; } .nav-item { justify-content: center; } }

/* ---- table ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-weight: 700; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); }
tr:hover td { background: var(--panel2); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill.new { background: rgba(59,130,246,.15); color: var(--blue); }
.pill.contacted { background: rgba(139,92,246,.15); color: var(--purple); }
.pill.qualified { background: rgba(16,185,129,.15); color: var(--green); }
.pill.appointment { background: rgba(245,158,11,.15); color: var(--amber); }
.pill.offer { background: rgba(201,162,39,.15); color: var(--gold2); }
.pill.negotiation { background: rgba(240,171,252,.15); color: #f0abfc; }
.pill.closed_won { background: rgba(16,185,129,.25); color: var(--green); }
.pill.closed_lost { background: rgba(239,68,68,.15); color: var(--red); }
.pill.active { background: rgba(16,185,129,.15); color: var(--green); }
.pill.pending { background: rgba(245,158,11,.15); color: var(--amber); }
.pill.suspended, .pill.rejected { background: rgba(239,68,68,.15); color: var(--red); }
.pill.buyer { background: rgba(59,130,246,.15); color: var(--blue); }
.pill.seller { background: rgba(16,185,129,.15); color: var(--green); }
.pill.referral { background: rgba(139,92,246,.15); color: var(--purple); }
.pill.hot { background: rgba(239,68,68,.18); color: #ff6b6b; }
.pill.warm { background: rgba(245,158,11,.15); color: var(--amber); }
.pill.cold { background: rgba(139,155,180,.15); color: #8b9bb4; }

/* ---- smart tabs ---- */
.smart-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.stab { padding: 7px 13px; border: 1px solid var(--line); background: var(--panel2); color: var(--muted); border-radius: 20px; font-weight: 600; font-size: 12px; }
.stab.on { background: var(--gold); color: #0a0a0a; border-color: var(--gold); }

/* ---- funnel ---- */
.frow { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.flbl { width: 90px; font-size: 12px; color: var(--muted); }
.fbar { flex: 1; height: 18px; background: var(--panel2); border-radius: 5px; overflow: hidden; }
.ffill { height: 100%; background: linear-gradient(90deg, var(--gold2), var(--gold)); border-radius: 5px; }
.fnum { width: 30px; text-align: right; font-size: 12px; font-weight: 700; color: var(--ink); }

/* ---- kanban ---- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.kcol { flex: 1; min-width: 150px; background: var(--panel2); border: 1px solid var(--line); border-radius: 12px; padding: 10px; }
.kcol h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); padding: 4px 6px 10px; display: flex; justify-content: space-between; }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 11px; margin-bottom: 8px; cursor: pointer; }
.kcard:hover { border-color: var(--gold); }
.kcard .nm { font-weight: 700; font-size: 13px; }
.kcard .sub { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---- activity ---- */
.act { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.act:last-child { border-bottom: none; }
.act .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); margin-top: 6px; flex-shrink: 0; }
.act .t { font-size: 13px; } .act .t b { color: var(--gold2); }
.act .ts { font-size: 11px; color: var(--muted); }

/* ---- bar chart ---- */
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bar { flex: 1; background: linear-gradient(180deg, var(--gold2), var(--gold)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bar .lbl { position: absolute; bottom: -18px; left: 50%; transform: translateX(-50%); font-size: 9px; color: var(--muted); white-space: nowrap; }

/* ---- modal ---- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-back.open { display: flex; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; }
.modal h3 { margin-bottom: 18px; }
.modal .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal .actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---- toast ---- */
#toast { position: fixed; bottom: 20px; right: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.5); display: none; z-index: 200; }
#toast.show { display: block; }
#toast.ok { border-color: var(--green); } #toast.err { border-color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 13px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }
.search { max-width: 280px; }
