/* =========================================================
   MarketFlow CRM · design tokens
   ========================================================= */
:root {
  /* canvas & ink */
  --bg: #eef1f8;             /* cool porcelain */
  --surface: #ffffff;
  --ink: #0f1729;            /* slate navy */
  --ink-2: #47526b;
  --ink-3: #8b95ab;
  --line: #e4e8f2;

  /* signal violet — every action in the app */
  --brand: #5a4af4;
  --brand-dark: #4436d6;
  --brand-soft: #eeecff;

  /* petrol teal — reserved for intelligence / research features */
  --accent: #0ea5a5;
  --accent-soft: #e2f7f6;

  --sidebar: #0b1220;        /* deep slate */
  --sidebar-ink: #9aa5c0;

  --won: #0fa36b;
  --won-soft: #e4f7ef;
  --warn: #e08a00;
  --warn-soft: #fdf1de;
  --lost: #e8465f;
  --lost-soft: #fdeaee;
  --hold: #64748b;
  --hold-soft: #eef1f5;

  --radius: 14px;
  --shadow: 0 1px 2px rgba(15, 23, 41, .04), 0 6px 20px -6px rgba(15, 23, 41, .10);
  --shadow-lift: 0 2px 4px rgba(15, 23, 41, .05), 0 14px 34px -10px rgba(15, 23, 41, .18);

  --font: "Plus Jakarta Sans", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: "Roboto Mono", ui-monospace, "Cascadia Code", "SF Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); background: var(--bg); color: var(--ink); font-size: 14.5px; }
button { font-family: inherit; cursor: pointer; }
code { font-family: var(--mono); font-size: .85em; }

/* =========== shell =========== */
.shell { display: flex; min-height: 100vh; }

/* =========== sidebar =========== */
.sidebar {
  width: 244px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 20px 18px 16px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; background: linear-gradient(135deg, var(--brand), #7b8cff);
  color: #fff; font-weight: 800; font-size: 19px; display: grid; place-items: center;
}
.brand-name { color: #fff; font-weight: 700; font-size: 15px; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--sidebar-ink); }

.nav { flex: 1; padding: 4px 10px; overflow-y: auto; }
.nav-group {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em;
  color: #5d6685; padding: 16px 10px 6px; font-weight: 700;
}
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--sidebar-ink); text-decoration: none; font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; position: relative;
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active { background: var(--brand); color: #fff; }
.nav a svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; flex-shrink: 0; }
.nav-dot {
  margin-left: auto; width: 8px; height: 8px; border-radius: 50%;
  background: #5d6685;
}
.nav-dot.on { background: #34d399; box-shadow: 0 0 6px #34d39988; }

.sidebar-foot { padding: 14px 18px; border-top: 1px solid rgba(255,255,255,.08); font-size: 11.5px; }
.foot-line { color: #cdd4ea; margin-bottom: 3px; }
.foot-line.dim { color: #5d6685; }
.sidebar-foot code { color: #8fa0d8; }

/* =========== main / topbar =========== */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; padding: 14px 26px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 18px; font-weight: 700; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.filters { display: flex; gap: 8px; }
.chip-select {
  border: 1px solid var(--line); border-radius: 999px; background: #fff;
  padding: 7px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2);
  font-family: inherit; outline: none;
}
.chip-select:focus { border-color: var(--brand); }

.menu-btn { display: none; }
.icon-btn {
  background: none; border: none; padding: 6px; border-radius: 8px; color: var(--ink-2);
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--bg); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.content { padding: 24px 26px 60px; max-width: 1280px; width: 100%; }

/* =========== buttons =========== */
.btn {
  border: none; border-radius: 9px; padding: 9px 16px; font-size: 13.5px; font-weight: 600;
  transition: background .15s, box-shadow .15s;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-won { background: var(--won); color: #fff; }
.btn-won:hover { filter: brightness(.94); }
.btn-ghost { background: #fff; border: 1px solid var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--ink-3); }
.btn-danger-link { background: none; color: var(--lost); padding: 6px 4px; font-weight: 600; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* =========== cards & grids =========== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.stat-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin-bottom: 20px; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head {
  display: flex; align-items: center; gap: 8px; padding: 14px 18px;
  border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px;
}
.card-head .hint { margin-left: auto; font-size: 12px; color: var(--ink-3); font-weight: 500; }

.stat { padding: 16px 18px; }
.stat .label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.stat .value { font-size: 22px; font-weight: 800; margin-top: 6px; }
.stat .sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.stat.brand .value { color: var(--brand); }
.stat.won .value { color: var(--won); }
.stat.warn .value { color: var(--warn); }

/* =========== forms =========== */
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.form-grid .span2 { grid-column: 1 / -1; }
.field label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .07em; color: var(--ink-3); margin-bottom: 5px;
}
.field label .req { color: var(--lost); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px;
  font-size: 13.5px; font-family: inherit; color: var(--ink); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { resize: vertical; }
.form-error { color: var(--lost); font-weight: 600; font-size: 13px; }
.form-note { font-size: 12px; color: var(--warn); font-weight: 600; }

/* =========== tables =========== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 760px; }
thead th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-3); font-weight: 700; padding: 11px 14px; background: #f8f9fc;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #eef0f6; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.rowlink { cursor: pointer; transition: background .12s; }
tbody tr.rowlink:hover { background: var(--brand-soft); }
tfoot td { padding: 12px 14px; font-weight: 800; background: #f8f9fc; border-top: 2px solid var(--line); }
.t-right { text-align: right; }
.mono { font-family: var(--mono); font-size: 12px; color: var(--ink-2); }
.cell-main { font-weight: 600; }
.cell-sub { font-size: 12px; color: var(--ink-3); }
.muted { color: var(--ink-3); font-style: italic; }

/* =========== badges & stage pills =========== */
.badge {
  display: inline-flex; align-items: center; gap: 4px; border-radius: 999px;
  padding: 3px 10px; font-size: 11px; font-weight: 700; border: 1px solid transparent; white-space: nowrap;
}
.badge.L1 { background: var(--brand-soft); color: var(--brand-dark); border-color: #ccd6ff; }
.badge.Discussion { background: var(--warn-soft); color: var(--warn); border-color: #f6d9ac; }
.badge.Won { background: var(--won-soft); color: var(--won); border-color: #b5e6d3; }
.badge.Lost { background: var(--lost-soft); color: var(--lost); border-color: #f5c1c1; }
.badge.Hold { background: var(--hold-soft); color: var(--hold); border-color: #d5dbe4; }

.stagebar { display: inline-flex; align-items: center; gap: 3px; }
.stagebar i { width: 15px; height: 5px; border-radius: 99px; background: var(--line); }
.stagebar i.on { background: var(--brand); }
.stagebar span { font-size: 10px; font-weight: 700; color: var(--ink-3); margin-left: 4px; }

/* =========== drawer (lead detail) =========== */
.overlay { position: fixed; inset: 0; background: rgba(16, 21, 40, .45); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(680px, 100%);
  background: var(--bg); z-index: 50; overflow-y: auto;
  box-shadow: -12px 0 40px rgba(16,21,40,.25);
  animation: slideIn .22s ease;
}
@keyframes slideIn { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } }
.hidden { display: none !important; }

.drawer-head { background: var(--surface); border-bottom: 1px solid var(--line); padding: 18px 22px 14px; position: sticky; top: 0; z-index: 5; }
.drawer-head .row1 { display: flex; align-items: flex-start; gap: 10px; }
.drawer-title { font-size: 17px; font-weight: 800; }
.drawer-meta { font-size: 12px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 3px; }
.drawer-body { padding: 18px 22px 40px; display: flex; flex-direction: column; gap: 14px; }

/* stepper */
.stepper { display: flex; align-items: center; margin-top: 14px; }
.step { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 76px; }
.step .dot {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: 12px; font-weight: 800; background: var(--line); color: var(--ink-2);
}
.step.active .dot { background: var(--brand); color: #fff; }
.step.done .dot { background: var(--won); color: #fff; }
.step .lbl { font-size: 10px; font-weight: 700; color: var(--ink-3); text-align: center; }
.step.active .lbl { color: var(--brand); }
.step-line { flex: 1; height: 2px; background: var(--line); margin: 0 4px 16px; border-radius: 2px; }
.step-line.done { background: var(--won); }

/* step section cards inside drawer */
.sec { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); padding: 16px 18px; }
.sec.done { border-color: #b5e6d3; background: #fbfefd; }
.sec.locked { background: #f7f8fb; }
.sec.active { border-color: #ccd6ff; }
.sec-head { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.sec-num {
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; font-weight: 800; color: #fff; background: var(--ink-3);
}
.sec.active .sec-num { background: var(--brand); }
.sec.done .sec-num { background: var(--won); }
.sec-title { font-weight: 700; font-size: 13.5px; }
.sec-tag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--won); }
.sec-lock { font-size: 12.5px; color: var(--ink-3); }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 20px; font-size: 13px; }
.kv .span2 { grid-column: 1 / -1; }
.kv dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
.kv dd { margin-top: 2px; }
.link-btn { background: none; border: none; color: var(--brand); font-weight: 700; font-size: 12px; padding: 4px 0; }
.link-btn:hover { text-decoration: underline; }

.ai-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-chip {
  border: 1px solid #ccd6ff; background: var(--brand-soft); color: var(--brand-dark);
  border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 700;
}
.ai-chip:hover { background: #e0e6ff; }
.ai-out {
  margin-top: 10px; background: #f8f9fc; border: 1px solid var(--line); border-radius: 9px;
  padding: 12px 14px; font-size: 13px; white-space: pre-wrap; line-height: 1.55;
}

/* =========== team list =========== */
.team-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid #eef0f6; }
.team-item:last-child { border-bottom: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; font-weight: 800; font-size: 13px; flex-shrink: 0;
}
.team-item .info { flex: 1; min-width: 0; }
.team-item .n { font-weight: 700; font-size: 13.5px; }
.team-item .d { font-size: 12px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count-pill { background: var(--hold-soft); border-radius: 999px; padding: 3px 10px; font-size: 11.5px; font-weight: 700; color: var(--ink-2); }

/* =========== AI chat page =========== */
.chat-wrap { display: flex; flex-direction: column; height: calc(100vh - 170px); min-height: 420px; }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 4px 2px 12px; }
.msg { max-width: 78%; padding: 11px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.ai.thinking { color: var(--ink-3); font-style: italic; }
.chat-input { display: flex; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.chat-input textarea {
  flex: 1; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-family: inherit; font-size: 13.5px; resize: none; outline: none; background: #fff;
}
.chat-input textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 4px; }

.notice { border-radius: 10px; padding: 12px 16px; font-size: 13px; font-weight: 600; }
.notice.warn { background: var(--warn-soft); color: #92510a; border: 1px solid #f6d9ac; }
.notice.ok { background: var(--won-soft); color: #0b6e4e; border: 1px solid #b5e6d3; }

/* =========== empty state / toast =========== */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty .big { font-size: 15px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--sidebar); color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; z-index: 90; box-shadow: var(--shadow);
}

/* alerts on dashboard */
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 9px 0; border-bottom: 1px solid #eef0f6; font-size: 13px; }
.alert-item:last-child { border-bottom: none; }
.alert-ico { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.alert-ico.warn { background: var(--warn); }
.alert-ico.brand { background: var(--brand); }

/* =========== responsive =========== */
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; transform: translateX(-100%); transition: transform .2s; z-index: 60; }
  .sidebar.open { transform: none; }
  .menu-btn { display: grid; }
  .content { padding: 18px 14px 60px; }
  .form-grid { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .topbar { padding: 12px 14px; flex-wrap: wrap; }
  .topbar-right { width: 100%; }
}
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* =========== MEDDPICC =========== */
.md-extra { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.md-list { display: flex; flex-direction: column; gap: 10px; }
.md-row { display: flex; gap: 12px; align-items: flex-start; padding: 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.md-letter { width: 26px; height: 26px; border-radius: 7px; background: var(--brand-soft); color: var(--brand-dark); font-weight: 800; display: grid; place-items: center; flex-shrink: 0; font-size: 13px; }
.md-main { flex: 1; min-width: 0; }
.md-head { display: flex; flex-direction: column; margin-bottom: 5px; }
.md-label { font-weight: 700; font-size: 13px; }
.md-hint { font-size: 11px; color: var(--ink-3); }
.md-notes { width: 100%; border: 1px solid var(--line); border-radius: 7px; padding: 7px 9px; font-family: inherit; font-size: 12.5px; resize: vertical; outline: none; }
.md-notes:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.md-scorebox { flex-shrink: 0; text-align: center; }
.md-scorebox label { display: block; font-size: 9.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 700; margin-bottom: 3px; }
.md-score { border: 1px solid var(--line); border-radius: 7px; padding: 6px 8px; font-size: 14px; font-weight: 700; font-family: inherit; outline: none; text-align: center; }
.md-score:focus { border-color: var(--brand); }

.md-scorebar { margin-top: 14px; }
.md-scoretrack { height: 12px; background: #f0f2f7; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.md-scorefill { height: 100%; border-radius: 8px; transition: width .3s; }
.md-scorefill.won { background: var(--won); }
.md-scorefill.warn { background: var(--warn); }
.md-scorefill.lost { background: var(--lost); }
.md-scoretext { font-size: 13px; font-weight: 600; }

.md-list-view { display: flex; flex-direction: column; gap: 8px; }
.md-row-view { display: flex; gap: 12px; align-items: center; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.md-dots { display: flex; align-items: center; gap: 3px; flex-shrink: 0; }
.md-dots i { width: 11px; height: 11px; border-radius: 50%; background: var(--line); }
.md-dots i.on { background: var(--brand); }
.md-dots span { font-size: 11px; font-weight: 700; color: var(--ink-3); margin-left: 4px; }

/* collapsible panel */
.md-panel { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.md-panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #f8f9fc; cursor: pointer; user-select: none; }
.md-panel-head .chev { margin-left: auto; transition: transform .2s; color: var(--ink-3); }
.md-panel.open .md-panel-head .chev { transform: rotate(90deg); }
.md-panel-body { padding: 16px; display: none; }
.md-panel.open .md-panel-body { display: block; }
@media (max-width: 640px) { .md-extra { grid-template-columns: 1fr; } }

/* =========== Dashboard (redesigned) =========== */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.kpi-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); font-weight: 700; }
.kpi-value { font-size: 26px; font-weight: 800; margin: 8px 0 4px; line-height: 1.1; letter-spacing: -.5px; }
.kpi-sub { font-size: 12px; color: var(--ink-3); }

.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

/* funnel */
.funnel { display: flex; flex-direction: column; gap: 14px; padding: 6px 0; }
.funnel-row { display: flex; align-items: center; gap: 14px; }
.funnel-label { width: 120px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); flex-shrink: 0; }
.funnel-track { flex: 1; height: 26px; background: #f0f2f7; border-radius: 7px; overflow: hidden; }
.funnel-fill { height: 100%; border-radius: 7px; min-width: 3px; transition: width .35s ease; }
.funnel-count { width: 62px; text-align: right; font-size: 15px; font-weight: 800; color: var(--ink); flex-shrink: 0; }
.funnel-pct { font-size: 11px; font-weight: 600; color: var(--ink-3); margin-left: 5px; }

/* activity / alert feed — consistent small dots (fixes oversized markers) */
.feed { display: flex; flex-direction: column; }
.feed-item { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; background: none; border: none; border-bottom: 1px solid #eef0f6; padding: 11px 4px; cursor: pointer; font-family: inherit; transition: background .12s; border-radius: 6px; }
.feed-item:last-child { border-bottom: none; }
.feed-item:hover { background: var(--brand-soft); }
.feed-item .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.feed-item .dot.brand { background: var(--brand); }
.feed-item .dot.won { background: var(--won); }
.feed-item .dot.warn { background: var(--warn); }
.feed-item .dot.lost { background: var(--lost); }
.feed-text { flex: 1; font-size: 13.5px; color: var(--ink); line-height: 1.4; }
.feed-item .badge { flex-shrink: 0; }

@media (max-width: 1000px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .kpi-row { grid-template-columns: 1fr; }
  .funnel-label { width: 90px; font-size: 11.5px; }
}

/* =========== Email preview modal =========== */
.mail-overlay { position: fixed; inset: 0; background: rgba(16,21,40,.55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 24px; }
.mail-modal { background: var(--surface); border-radius: 14px; width: min(760px, 100%); max-height: 90vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(16,21,40,.3); overflow: hidden; }
.mail-loading { padding: 40px; text-align: center; color: var(--ink-3); font-size: 14px; }
.mail-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.mail-title { font-size: 16px; font-weight: 800; }
.mail-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.mail-head .icon-btn { margin-left: auto; }
.mail-body { padding: 18px 22px; overflow-y: auto; flex: 1; }
.mail-from { font-size: 12.5px; color: var(--ink-2); background: #f8f9fc; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; margin-bottom: 14px; }
.mail-fields { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.mail-field { display: flex; align-items: center; gap: 10px; }
.mail-field span { width: 62px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; flex-shrink: 0; }
.mail-field input { flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; font-size: 13.5px; font-family: inherit; outline: none; }
.mail-field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.mail-tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 0; }
.mail-tab { background: none; border: none; padding: 9px 14px; font-size: 12.5px; font-weight: 700; color: var(--ink-3); font-family: inherit; border-bottom: 2px solid transparent; }
.mail-tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.mail-pane { border: 1px solid var(--line); border-top: none; border-radius: 0 0 9px 9px; overflow: hidden; }
.mail-pane iframe { width: 100%; height: 360px; border: none; display: block; background: #f2f4f8; }
.mail-pane textarea { width: 100%; border: none; padding: 14px; font-family: var(--mono); font-size: 12px; line-height: 1.6; resize: vertical; outline: none; color: var(--ink); }
.mail-foot { display: flex; align-items: center; gap: 10px; padding: 14px 22px; border-top: 1px solid var(--line); background: #f8f9fc; }
.mail-hint { margin-left: auto; font-size: 11.5px; color: var(--ink-3); }
@media (max-width: 640px) {
  .mail-overlay { padding: 0; }
  .mail-modal { max-height: 100vh; border-radius: 0; }
  .mail-field { flex-direction: column; align-items: stretch; gap: 4px; }
  .mail-field span { width: auto; }
}

/* =========== Lead documents =========== */
.doc-upload { display: flex; flex-direction: column; gap: 5px; padding: 11px 13px; border: 1px dashed var(--line); border-radius: 9px; background: #fbfcfe; }
.doc-upload input[type=file] { font-size: 12.5px; font-family: inherit; }
.doc-chip { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #b5e6d3; background: #fbfefd; border-radius: 9px; }
.doc-ico { font-size: 16px; flex-shrink: 0; }
.doc-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.doc-name { font-size: 13px; font-weight: 700; color: var(--brand-dark); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-name:hover { text-decoration: underline; }
.doc-link {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 6px;
  background: var(--brand-soft); border: 1px solid #ccd6ff; color: var(--brand-dark);
  font-size: 11.5px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.doc-link:hover { background: #e0e6ff; }
.doc-link.missing { background: var(--warn-soft); border-color: #f6d9ac; color: var(--warn); }
.mail-attach { border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; margin-bottom: 14px; background: #f8f9fc; display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.mail-attach-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; width: 100%; }

/* =========== Login screen =========== */
body.locked { overflow: hidden; }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(160deg, #101528 0%, #1b2340 55%, #232c52 100%); padding: 24px; }
.login-card { background: var(--surface); border-radius: 16px; padding: 34px 34px 28px; width: min(420px, 100%); box-shadow: 0 24px 70px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 13px; margin-bottom: 22px; }
.login-card .field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 6px; }
.login-card .field label { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 700; }
.login-card .field input { border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; font-size: 14px; font-family: inherit; outline: none; }
.login-card .field input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.login-btn { width: 100%; padding: 12px; font-size: 14.5px; margin-top: 4px; }
.login-links { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.login-foot { color: #8a92ab; font-size: 12px; margin-top: 22px; }

/* =========== User chip (sidebar) =========== */
.user-chip { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid rgba(255,255,255,.08); }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, var(--brand), #7b8cff); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 13px; flex-shrink: 0; }
.user-meta { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-role { color: #8a92ab; font-size: 11px; text-transform: capitalize; }
.user-chip .icon-btn { color: #8a92ab; }
.user-chip .icon-btn:hover { color: #fff; }

/* =========== Company research (business info) =========== */
.research-panel { border: 1px solid #ccd6ff; background: var(--brand-soft); border-radius: 10px; padding: 14px 16px; }
.research-box {
  margin-top: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px;
  padding: 14px 16px; max-height: 420px; overflow-y: auto;
  font-size: 12.5px; line-height: 1.65; color: var(--ink);
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* =========== 8-step progress tracker (lead drawer) =========== */
.stepper8 { display: flex; gap: 4px; margin-top: 16px; overflow-x: auto; padding-bottom: 4px; }
.s8 { flex: 1; min-width: 58px; display: flex; flex-direction: column; align-items: center; gap: 5px; position: relative; }
.s8:not(:last-child)::after { content: ""; position: absolute; top: 11px; left: calc(50% + 14px); right: calc(-50% + 14px); height: 2px; background: var(--line); }
.s8.done:not(:last-child)::after { background: var(--won); }
.s8-dot { width: 22px; height: 22px; border-radius: 50%; background: #e8ebf3; color: var(--ink-3); display: flex; align-items: center; justify-content: center; font-size: 10.5px; font-weight: 800; z-index: 1; }
.s8.done .s8-dot { background: var(--won); color: #fff; }
.s8.active .s8-dot { background: var(--brand); color: #fff; box-shadow: 0 0 0 4px var(--brand-soft); }
.s8-lbl { font-size: 9px; font-weight: 700; color: var(--ink-3); text-align: center; line-height: 1.25; max-width: 74px; }
.s8.active .s8-lbl { color: var(--brand); }
.s8.done .s8-lbl { color: var(--ink-2); }
@media (max-width: 640px) { .s8-lbl { display: none; } .s8 { min-width: 30px; } }

/* =========================================================
   THEME LAYER — "instrument panel"
   Cool porcelain canvas · slate rails · violet action colour
   Teal reserved for intelligence · tabular mono for figures
   ========================================================= */

body { -webkit-font-smoothing: antialiased; letter-spacing: -.005em; }

/* numbers read like a monitoring readout: aligned, tabular */
.kpi-value, .funnel-count, .mono, tfoot td, .t-right,
.stat .value, .s8-dot { font-variant-numeric: tabular-nums; }

/* keyboard users always see where they are */
:where(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px;
}

/* ---------- sidebar: slate with a luminous rail ---------- */
.sidebar {
  background:
    radial-gradient(120% 60% at 0% 0%, #16243f 0%, rgba(11,18,32,0) 60%),
    linear-gradient(180deg, #0d1526 0%, #0b1220 100%);
  border-right: 1px solid rgba(255,255,255,.06);
}
.brand { padding: 22px 18px 18px; }
.brand-mark {
  background: linear-gradient(140deg, var(--brand) 0%, #8b7bff 55%, var(--accent) 100%);
  box-shadow: 0 6px 18px -6px rgba(90,74,244,.8);
  border-radius: 12px;
}
.brand-name { letter-spacing: -.2px; }

.nav a { font-weight: 600; letter-spacing: -.01em; }
.nav a::before {
  content: ""; position: absolute; left: -10px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 0; border-radius: 0 3px 3px 0;
  background: linear-gradient(180deg, #8b7bff, var(--accent));
  transition: height .18s ease;
}
.nav a.active::before { height: 22px; }
.nav a.active {
  background: linear-gradient(90deg, rgba(90,74,244,.22), rgba(90,74,244,.06));
  color: #fff;
}
.nav a.active svg { stroke-width: 2; }
.nav-group { color: #56617f; }

.user-chip { background: rgba(255,255,255,.03); }
.sidebar-foot { background: rgba(0,0,0,.15); }

/* ---------- topbar: quiet glass ---------- */
.topbar {
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(1.6) blur(10px);
  -webkit-backdrop-filter: saturate(1.6) blur(10px);
  padding: 15px 28px;
}
.topbar h1 { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.chip-select { border-radius: 10px; background: var(--bg); border-color: transparent; }
.chip-select:hover { background: #e6eaf5; }
.chip-select:focus { background: #fff; border-color: var(--brand); }

/* ---------- buttons ---------- */
.btn { border-radius: 10px; letter-spacing: -.01em; transition: transform .12s, box-shadow .15s, background .15s; }
.btn-primary {
  background: linear-gradient(135deg, var(--brand), #7a6bff);
  box-shadow: 0 6px 16px -8px rgba(90,74,244,.9);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-dark), #6a59f5); transform: translateY(-1px); }
.btn-primary:active { transform: none; }
.btn-won { background: linear-gradient(135deg, var(--won), #23c088); box-shadow: 0 6px 16px -8px rgba(15,163,107,.9); }
.btn-ghost { background: #fff; border-color: var(--line); }
.btn-ghost:hover { border-color: #c3cbdd; background: #fbfcff; }
@media (prefers-reduced-motion: reduce) { .btn:hover { transform: none; } }

/* ---------- cards ---------- */
.card { border-color: var(--line); }
.card-head { font-size: 14.5px; letter-spacing: -.01em; padding: 15px 20px; }

/* ---------- KPI tiles: tinted, rail on top, mono figure ---------- */
.kpi-card {
  position: relative; overflow: hidden; border-radius: var(--radius);
  transition: transform .15s, box-shadow .15s;
}
.kpi-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: linear-gradient(90deg, var(--brand), #8b7bff 60%, var(--accent));
}
.kpi-card:nth-child(2)::before { background: linear-gradient(90deg, var(--accent), #4ad6d6); }
.kpi-card:nth-child(3)::before { background: linear-gradient(90deg, var(--won), #3fd39a); }
.kpi-card:nth-child(4)::before { background: linear-gradient(90deg, var(--warn), #f5b544); }
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lift); }
.kpi-label { font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3); }
.kpi-value { font-size: 27px; font-weight: 800; letter-spacing: -.03em; }
@media (prefers-reduced-motion: reduce) { .kpi-card:hover { transform: none; } }

/* ---------- funnel ---------- */
.funnel-track { background: #e7ebf5; border-radius: 8px; height: 28px; }
.funnel-fill { border-radius: 8px; }
.funnel-label { font-weight: 700; color: var(--ink-2); }

/* ---------- tables ---------- */
thead th { background: #f6f8fd; color: var(--ink-3); letter-spacing: .09em; }
tbody tr.rowlink:hover { background: #f7f6ff; }
tbody td { border-bottom-color: #f0f3f9; }
tfoot td { background: #f6f8fd; }

/* ---------- badges: solid tint, no border ---------- */
.badge { border: none; padding: 4px 11px; font-size: 11px; letter-spacing: .01em; }
.badge.L1 { background: var(--brand-soft); color: var(--brand-dark); }
.badge.Discussion { background: var(--warn-soft); color: #a96700; }
.badge.Won { background: var(--won-soft); color: #0b7d52; }
.badge.Lost { background: var(--lost-soft); color: #c02b45; }
.badge.Hold { background: var(--hold-soft); color: var(--hold); }

.stagebar i { height: 6px; border-radius: 99px; }
.stagebar i.on { background: linear-gradient(90deg, var(--brand), #8b7bff); }

/* ---------- step cards: the rail marks where you are ---------- */
.sec { position: relative; overflow: hidden; padding: 18px 20px; }
.sec::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent;
}
.sec.active::before { background: linear-gradient(180deg, var(--brand), #8b7bff); }
.sec.done::before { background: var(--won); }
.sec.active { border-color: #d9d5ff; background: #fdfdff; }
.sec.done { border-color: #cdeee0; }
.sec.locked { background: #f5f7fb; border-style: dashed; }
.sec-num { box-shadow: 0 4px 10px -4px rgba(15,23,41,.4); }
.sec.active .sec-num { background: linear-gradient(135deg, var(--brand), #8b7bff); }
.sec-title { font-size: 14px; letter-spacing: -.01em; }

/* 8-step tracker */
.s8.active .s8-dot { box-shadow: 0 0 0 4px rgba(90,74,244,.15); }
.s8.done .s8-dot { background: var(--won); }

/* ---------- intelligence surfaces use teal, not violet ---------- */
.research-panel {
  background: linear-gradient(135deg, var(--accent-soft), #eef7ff);
  border-color: #bfe8e6;
}
.research-panel .btn-primary {
  background: linear-gradient(135deg, var(--accent), #37c2c2);
  box-shadow: 0 6px 16px -8px rgba(14,165,165,.9);
}
.research-box { border-color: #d7e6e6; }
.ai-chip:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- drawer ---------- */
.drawer { box-shadow: -20px 0 60px -20px rgba(15,23,41,.45); }
.drawer-head { padding: 20px 24px 16px; }
.drawer-title { font-size: 18px; letter-spacing: -.02em; }

/* ---------- feed rows ---------- */
.feed-item:hover { background: #f7f6ff; }
.feed-item .dot.brand { background: var(--brand); }

/* ---------- login: aurora over slate ---------- */
.login-wrap {
  background:
    radial-gradient(70% 55% at 15% 10%, rgba(90,74,244,.45) 0%, rgba(90,74,244,0) 60%),
    radial-gradient(60% 50% at 85% 85%, rgba(14,165,165,.40) 0%, rgba(14,165,165,0) 60%),
    linear-gradient(160deg, #0d1526 0%, #0b1220 60%, #131c33 100%);
}
.login-card { border-radius: 18px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.55); }
.login-card .field input { border-radius: 10px; }
.login-foot { color: #7c88a8; }

/* ---------- notices ---------- */
.notice { border-radius: 10px; }

/* ---------- density on small screens ---------- */
@media (max-width: 720px) {
  .topbar { padding: 12px 16px; }
  .content { padding: 18px 16px 48px; }
  .kpi-value { font-size: 23px; }
}
