/* ═══════════════════════════════════════════════════
   Elevate CRM — Styles
   EDR Brand: teal #1b8f99 / #2cb7c1  Dark: #103047
   ═══════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --edr-dark:   #103047;
  --edr-mid:    #1b526d;
  --edr-teal:   #1b8f99;
  --edr-light:  #2cb7c1;
  --edr-pale:   #e8f8f9;
  --text:       #18283b;
  --text-mid:   #5f7488;
  --text-light: #94a3b8;
  --border:     rgba(15,23,42,.1);
  --bg:         #f0f4f8;
  --card:       #fff;
  --sb-w:       224px;
  --hdr-h:      56px;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Layout ─────────────────────────────────────────── */
.crm-wrap { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sb-w);
  background: linear-gradient(180deg, #103047 0%, #0d2538 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 50;
}

.crm-main {
  margin-left: var(--sb-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Sidebar Brand ──────────────────────────────────── */
.sb-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sb-logo {
  height: 28px;
  width: auto;
  background: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  flex-shrink: 0;
}
.sb-brand-name {
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -.2px;
  white-space: nowrap;
}

/* ── Firm Switcher ──────────────────────────────────── */
.sb-firm-wrap {
  padding: 12px 14px 10px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sb-firm-label {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: rgba(255,255,255,.45);
  margin-bottom: 6px;
}
.sb-firm-sel {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 7px;
  color: #fff;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 10px;
  cursor: pointer;
  outline: none;
}
.sb-firm-sel option { background: #1b526d; color: #fff; }

/* ── Sidebar Nav ────────────────────────────────────── */
.sb-nav { flex: 1; padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }

.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: rgba(255,255,255,.65);
  border-radius: 8px;
  cursor: pointer;
  transition: color .12s, background .12s;
  white-space: nowrap;
  position: relative;
}
.sb-item:hover { color: #fff; background: rgba(255,255,255,.08); }
.sb-item.active { color: #fff; background: rgba(44,183,193,.22); }
.sb-ico { font-size: 15px; width: 20px; text-align: center; flex-shrink: 0; }
.sb-sep { height: 1px; background: rgba(255,255,255,.08); margin: 4px 2px; }

.sb-badge {
  position: absolute;
  right: 10px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  border-radius: 99px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}

/* ── Sidebar Footer ─────────────────────────────────── */
.sb-foot {
  padding: 14px 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.sb-user { font-size: 11px; font-weight: 600; color: rgba(255,255,255,.5); word-break: break-all; }
.sb-signout {
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 7px;
  color: rgba(255,255,255,.75);
  padding: 6px 10px;
  cursor: pointer;
  transition: background .12s;
  text-align: left;
}
.sb-signout:hover { background: rgba(255,255,255,.18); }
.sb-back-link {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,.35);
  text-decoration: none;
}
.sb-back-link:hover { color: rgba(255,255,255,.65); }

/* ── Header ─────────────────────────────────────────── */
.crm-hdr {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--hdr-h);
  background: #fff;
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
}
.crm-hdr-left { flex: 1; min-width: 0; }
.crm-hdr-sub { font-size: 11px; font-weight: 700; color: var(--text-light); text-transform: uppercase; letter-spacing: .08em; }
.crm-hdr-title { font-size: 17px; font-weight: 900; color: var(--text); letter-spacing: -.2px; line-height: 1.1; }
.crm-hdr-firm { font-size: 13px; font-weight: 700; color: var(--edr-teal); }
.crm-hdr-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

/* ── Pages ──────────────────────────────────────────── */
.page { display: none; padding: 24px; }
.page.active { display: block; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 22px 22px 18px;
  margin-bottom: 16px;
}
.card:last-child { margin-bottom: 0; }
.card-title {
  font-size: 13px;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.1px;
  margin-bottom: 16px;
}
.sec-lbl {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-light);
  margin-bottom: 10px;
}
.hint { font-size: 12px; font-weight: 500; color: var(--text-mid); line-height: 1.5; }

/* ── KPI Row ────────────────────────────────────────── */
.kpi-row { display: grid; grid-template-columns: repeat(4,1fr); gap: 12px; }
@media (max-width: 900px) { .kpi-row { grid-template-columns: repeat(2,1fr); } }
.kpi-card {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 11px;
  padding: 16px;
}
.kpi-label { font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--text-light); margin-bottom: 6px; }
.kpi-val { font-size: 26px; font-weight: 900; color: var(--text); letter-spacing: -.5px; line-height: 1; margin-bottom: 4px; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: 11px; font-weight: 600; color: var(--text-light); }

/* ── Toolbar ────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.task-add-bar { flex-wrap: nowrap; }
.tb-search {
  height: 36px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1.5px solid rgba(15,23,42,.14);
  border-radius: 9px;
  outline: none;
  min-width: 200px;
  transition: border-color .15s;
}
.tb-search:focus { border-color: var(--edr-teal); }
.tb-sel {
  height: 36px;
  padding: 0 10px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: #fff;
  border: 1.5px solid rgba(15,23,42,.14);
  border-radius: 9px;
  outline: none;
  cursor: pointer;
}
.tb-spacer { flex: 1; }

/* ── Buttons ────────────────────────────────────────── */
.btn-pri {
  height: 36px;
  padding: 0 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(180deg, #2cb7c1, #1b8f99);
  border: none;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: filter .15s;
}
.btn-pri:hover { filter: brightness(1.07); }
.btn-pri:disabled { opacity: .6; cursor: default; }

.btn-sec {
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s;
}
.btn-sec:hover { border-color: var(--edr-teal); color: var(--edr-teal); }

.btn-ghost {
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, color .15s;
}
.btn-ghost:hover { border-color: var(--edr-teal); color: var(--edr-teal); }
.btn-ghost.mini { height: 28px; padding: 0 10px; font-size: 12px; }

.btn-danger {
  height: 36px;
  padding: 0 14px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: #b91c1c;
  background: rgba(239,68,68,.08);
  border: 1.5px solid rgba(239,68,68,.25);
  border-radius: 9px;
  cursor: pointer;
}
.btn-danger:hover { background: rgba(239,68,68,.14); }

/* ── Tables ─────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.dtbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.dtbl th {
  text-align: left;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-light);
  padding: 10px 14px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
  background: #f8fafb;
}
.dtbl td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(15,23,42,.06);
  color: var(--text);
  font-weight: 500;
  vertical-align: middle;
}
.dtbl tr:last-child td { border-bottom: none; }
.dtbl tbody tr:hover td { background: #f8fafb; }
.dtbl .lead-name { font-weight: 700; }
.dtbl .dim { color: var(--text-light); }

.empty-msg { text-align: center; padding: 48px 20px; font-size: 13px; font-weight: 600; color: var(--text-light); }

/* ── Badges ─────────────────────────────────────────── */
.stage-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.badge-yes { background: rgba(22,163,74,.1); color: #15803d; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; }
.badge-no  { background: rgba(239,68,68,.1); color: #b91c1c; font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 99px; }
.ppc-badge { background: rgba(99,102,241,.12); color: #4f46e5; font-size: 10px; font-weight: 800; padding: 2px 7px; border-radius: 99px; }

/* ── Pipeline ────────────────────────────────────────── */
.pipeline-board {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding: 0 24px 24px;
  padding-top: 4px;
}
.pipeline-col {
  flex: 0 0 240px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.pipe-col-hdr {
  padding: 12px 14px 10px;
  border-bottom: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 7px;
}
.stage-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.pipe-col-name { font-size: 12px; font-weight: 800; color: var(--text); flex: 1; }
.pipe-col-count { font-size: 12px; font-weight: 800; color: var(--text-light); }
.pipe-col-val { font-size: 11px; font-weight: 700; color: var(--edr-teal); padding: 4px 14px; border-bottom: 1px solid var(--border); background: var(--edr-pale); }
.pipe-cards { padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.pipe-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color .12s, box-shadow .12s;
}
.pipe-card:hover { border-color: var(--edr-light); box-shadow: 0 3px 10px rgba(27,143,153,.12); }
.pipe-card-name { font-size: 13px; font-weight: 700; color: var(--text); margin-bottom: 3px; }
.pipe-card-sub { font-size: 11px; color: var(--text-light); font-weight: 500; }
.pipe-card-val { font-size: 12px; font-weight: 800; color: var(--edr-teal); margin-top: 5px; }
.pipe-empty { font-size: 12px; color: var(--text-light); font-weight: 500; text-align: center; padding: 16px 8px; }

/* ── Tasks ───────────────────────────────────────────── */
.task-group { margin-bottom: 20px; }
.task-group-hdr {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-mid);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.task-count {
  background: var(--border);
  color: var(--text-light);
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 99px;
}
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  margin-bottom: 6px;
}
.task-item.done { opacity: .55; }
.task-item input[type="checkbox"] { margin-top: 2px; flex-shrink: 0; accent-color: var(--edr-teal); width: 15px; height: 15px; }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 13px; font-weight: 700; color: var(--text); }
.task-item.done .task-title { text-decoration: line-through; }
.task-lead { font-size: 11px; color: var(--text-mid); font-weight: 600; margin-top: 3px; }
.task-due { font-size: 11px; font-weight: 600; color: var(--text-light); margin-top: 2px; }
.task-due.overdue { color: #dc2626; }

/* ── Marketing ───────────────────────────────────────── */
.cost-input {
  width: 90px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 13px;
  text-align: right;
  color: var(--text);
  background: #fff;
}
.cost-input:focus { outline: none; border-color: var(--edr-teal); }

/* ── Integrations ────────────────────────────────────── */
.int-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
@media (max-width: 800px) { .int-grid { grid-template-columns: 1fr 1fr; } }
.int-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  opacity: .6;
}
.int-icon { font-size: 26px; flex-shrink: 0; }
.int-body { flex: 1; min-width: 0; }
.int-name { font-size: 14px; font-weight: 800; color: var(--text); margin-bottom: 3px; }
.int-desc { font-size: 12px; color: var(--text-mid); font-weight: 500; }
.int-card .coming { font-size: 11px; font-weight: 700; color: var(--text-light); white-space: nowrap; background: rgba(15,23,42,.06); border: 1px solid var(--border); border-radius: 6px; padding: 3px 9px; }

/* ── Setup ───────────────────────────────────────────── */
.setup-menu { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; }
@media (max-width: 700px) { .setup-menu { grid-template-columns: 1fr 1fr; } }
.setup-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  padding: 20px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color .15s, box-shadow .15s;
}
.setup-tile:hover { border-color: var(--edr-light); box-shadow: 0 6px 18px rgba(27,143,153,.1); }
.st-ico { font-size: 24px; }
.st-title { font-size: 14px; font-weight: 800; color: var(--text); }
.st-desc { font-size: 12px; color: var(--text-mid); font-weight: 500; }

.setup-sec { display: none; }
.props-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 20px; }
@media (max-width: 640px) { .props-grid { grid-template-columns: 1fr; } }

.staff-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.staff-row input { flex: 1; }

.stage-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.stage-row input[type="color"] { width: 36px; height: 36px; padding: 2px; border: 1.5px solid var(--border); border-radius: 7px; cursor: pointer; background: none; }
.stage-row input[type="text"] { flex: 1; }

.list-editor { display: flex; flex-direction: column; gap: 6px; }
.list-row { display: flex; gap: 6px; align-items: center; }
.list-row input { flex: 1; }
.list-row button { flex-shrink: 0; width: 28px; height: 28px; border: 1.5px solid var(--border); border-radius: 6px; background: #fff; cursor: pointer; font-size: 14px; color: var(--text-light); }
.list-row button:hover { border-color: #b91c1c; color: #b91c1c; }

.setup-savebar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}
.setup-save-msg { font-size: 13px; font-weight: 700; color: #15803d; }

/* ── Form ────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 600px) { .form-grid, .form-grid.three { grid-template-columns: 1fr; } }
.fld.full { grid-column: 1 / -1; }

.fld label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-mid);
  margin-bottom: 5px;
}
.fld-hint { font-size: 10px; font-weight: 600; color: var(--text-light); text-transform: none; letter-spacing: 0; }

.fld input, .fld select, .fld textarea {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: #f8fafb;
  border: 1.5px solid rgba(15,23,42,.12);
  border-radius: 9px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .15s;
}
.fld input:focus, .fld select:focus, .fld textarea:focus { border-color: var(--edr-teal); background: #fff; }
.fld textarea { resize: vertical; min-height: 80px; }

/* ── Modals ──────────────────────────────────────────── */
.modal-ov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  overflow-y: auto;
}
.modal-ov.open { display: flex; }

.modal {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.22);
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
}
.modal.modal-lg { max-width: 820px; }

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}
.modal-hdr h3 { font-size: 16px; font-weight: 900; color: var(--text); }
.modal-x {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-light);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
}
.modal-x:hover { color: var(--text); }

.modal-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}
.mtab {
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-mid);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 12px 18px;
  cursor: pointer;
  white-space: nowrap;
  transition: color .12s;
  margin-bottom: -1.5px;
}
.mtab:hover { color: var(--text); }
.mtab.active { color: var(--edr-teal); border-bottom-color: var(--edr-teal); }

.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px; }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

.modal-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
}

/* ── Activity Log ────────────────────────────────────── */
.activity-hdr { font-size: 12px; font-weight: 800; color: var(--text-mid); text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px; padding-top: 4px; border-top: 1.5px solid var(--border); }
.activity-item { padding: 10px 0; border-bottom: 1px solid rgba(15,23,42,.06); }
.activity-item:last-child { border-bottom: none; }
.activity-meta { font-size: 11px; font-weight: 600; color: var(--text-light); margin-bottom: 3px; }
.activity-text { font-size: 13px; font-weight: 600; color: var(--text); }

/* ── Toast ───────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  background: #18283b;
  color: #fff;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 12px 18px;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.3);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: #b91c1c; }

/* ── Print ───────────────────────────────────────────── */
@media print {
  .sidebar, .crm-hdr, .toolbar, .modal-ov, .toast { display: none !important; }
  .crm-main { margin-left: 0; }
  .page { display: block !important; padding: 0; }
}
