:root {
  --violet: #6b3df0; --violet-dark: #5326d6; --violet-soft: #f1ecff;
  --bg: #f6f6f9; --panel: #ffffff; --line: #e6e4ee; --text: #1d1b26; --muted: #6c6879;
  --green: #138a4f; --green-soft: #e4f6ec; --red: #c4302b; --red-soft: #fde9e8;
  --amber: #a86200; --amber-soft: #fff2dc; --blue: #2457c5; --blue-soft: #e7eefc;
  --radius: 10px; --shadow: 0 1px 2px rgba(20, 10, 50, .06), 0 2px 8px rgba(20, 10, 50, .04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  font-size: 14px; color: var(--text); background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); }
a { color: var(--violet); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13px; margin: 0 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: #17132a; color: #d9d4ee; padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; color: #fff; font-size: 16px; padding: 4px 8px 18px; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--violet); display: grid; place-items: center; }
.nav a { display: flex; align-items: center; gap: 10px; color: #cfc9e6; padding: 9px 10px; border-radius: 8px; margin-bottom: 2px; }
.nav a:hover { background: rgba(255, 255, 255, .06); text-decoration: none; }
.nav a.active { background: var(--violet); color: #fff; }
.nav .count { margin-left: auto; background: rgba(255,255,255,.14); border-radius: 999px; padding: 0 7px; font-size: 12px; }
.sidebar .me { margin-top: auto; font-size: 12px; padding: 8px 10px; color: #a9a2c6; }
.sidebar .me button { background: none; border: 0; color: #cfc9e6; padding: 0; cursor: pointer; font-size: 12px; text-decoration: underline; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar .menu-btn { display: none; }
.search-wrap { position: relative; flex: 1; max-width: 460px; }
.search-wrap input { width: 100%; }
.search-results { position: absolute; top: 40px; left: 0; right: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); max-height: 380px; overflow: auto; z-index: 10; }
.search-results a { display: block; padding: 8px 12px; color: var(--text); border-bottom: 1px solid var(--line); }
.search-results a:hover, .search-results a.sel { background: var(--violet-soft); text-decoration: none; }
.search-results small { color: var(--muted); margin-left: 6px; }
.content { padding: 22px 24px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }

/* controls */
input, select, textarea { font: inherit; color: inherit; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--violet-soft); border-color: var(--violet); }
textarea { resize: vertical; min-height: 70px; width: 100%; }
button, .btn { font: inherit; cursor: pointer; border-radius: 8px; padding: 8px 14px; border: 1px solid var(--line); background: #fff; color: var(--text); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
button:hover, .btn:hover { border-color: #cfcade; text-decoration: none; }
.primary { background: var(--violet); border-color: var(--violet); color: #fff; }
.primary:hover { background: var(--violet-dark); border-color: var(--violet-dark); }
.danger { color: var(--red); }
.small { padding: 4px 9px; font-size: 12px; }
.link { background: none; border: 0; padding: 0; color: var(--violet); }
button:disabled { opacity: .5; cursor: default; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: 0; border-radius: 0; border-right: 1px solid var(--line); }
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--violet-soft); color: var(--violet-dark); font-weight: 600; }

/* cards & tables */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.grid { display: grid; gap: 16px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin-bottom: 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.detail { grid-template-columns: 340px minmax(0, 1fr); align-items: start; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #faf9fc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click:hover { background: #faf8ff; cursor: pointer; }
.empty { padding: 30px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

.pill { display: inline-block; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: #eeedf3; color: #4a4659; white-space: nowrap; }
.pill.New { background: var(--blue-soft); color: var(--blue); }
.pill.Contacted { background: var(--amber-soft); color: var(--amber); }
.pill.Qualified, .pill.won, .pill.Done { background: var(--green-soft); color: var(--green); }
.pill.Unqualified, .pill.lost, .pill.overdue, .pill.High { background: var(--red-soft); color: var(--red); }
.pill.Converted { background: var(--violet-soft); color: var(--violet-dark); }

.fields { display: grid; grid-template-columns: 110px 1fr; gap: 8px 10px; font-size: 13px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; word-break: break-word; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0 4px; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.status-row button.on { background: var(--violet); color: #fff; border-color: var(--violet); }

/* timeline */
.composer { display: grid; gap: 8px; margin-bottom: 16px; }
.composer .row { display: flex; gap: 8px; align-items: center; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.timeline .ico { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: #eeedf3; font-size: 14px; }
.timeline .ico.Call { background: var(--green-soft); } .timeline .ico.WhatsApp { background: #dcf8e7; }
.timeline .ico.Email { background: var(--blue-soft); } .timeline .ico.Meeting { background: var(--amber-soft); }
.timeline .ico.Note { background: var(--violet-soft); }
.timeline .meta { font-size: 12px; color: var(--muted); }
.timeline .body { white-space: pre-wrap; margin-top: 2px; }

/* tasks */
.task { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-top: 1px solid var(--line); }
.task:first-child { border-top: 0; }
.task input[type=checkbox] { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--violet); }
.task .t-title { font-weight: 500; }
.task.done .t-title { text-decoration: line-through; color: var(--muted); }
.task .t-meta { font-size: 12px; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.task .t-meta .late { color: var(--red); font-weight: 600; }

/* kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 10px; }
.col { background: #eeecf4; border-radius: var(--radius); padding: 10px; min-height: 300px; }
.col.over { outline: 2px dashed var(--violet); background: var(--violet-soft); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 2px; }
.col-sum { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.deal-card { background: #fff; border-radius: 8px; padding: 10px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: grab; border: 1px solid var(--line); }
.deal-card:hover { border-color: var(--violet); }
.deal-card .dc-title { font-weight: 600; }
.deal-card .dc-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.deal-card .dc-val { font-weight: 600; margin-top: 6px; }
.bar { height: 8px; background: #eeedf3; border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--violet); }
.stage-line { display: grid; grid-template-columns: 120px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 10px; font-size: 13px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(20, 14, 40, .45); display: grid; place-items: start center; padding: 6vh 16px; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 620px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal header h2 { margin: 0; }
.modal .mbody { padding: 18px 20px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.form-grid label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.form-grid label.full { grid-column: 1 / -1; }
.form-grid label.check { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); }
.form-grid input, .form-grid select, .form-grid textarea { width: 100%; font-weight: 400; color: var(--text); }
.error { background: var(--red-soft); color: var(--red); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #17132a; color: #fff; padding: 10px 16px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 60; }
#toast.show { opacity: 1; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(135deg, #17132a, #3b2394); }
.auth .card { width: 100%; max-width: 380px; padding: 28px; }
.auth h1 { margin-bottom: 4px; }
.auth form { display: grid; gap: 12px; margin-top: 18px; }
.auth label { display: grid; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
code, pre { font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
pre { background: #17132a; color: #e9e5fb; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; z-index: 40; width: 240px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .topbar { padding: 10px 16px; }
  .topbar .menu-btn { display: inline-flex; }
  .content { padding: 16px 16px 60px; }
  .two, .detail { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .hide-sm { display: none; }
}
a.card { color: inherit; } a.card:hover { text-decoration: none; border-color: var(--violet); }
.form-grid label.check input { width: auto; flex: none; accent-color: var(--violet); }
