:root {
  --navy: #0a1018;
  --navy-soft: #131e2e;
  --cream: #f3ebdd;
  --cream-soft: #faf5ea;
  --gold: #b58a5a;
  --gold-dark: #9a744a;
  --espresso: #1b1511;
  --muted: #6f6455;
  --line: #e0d4bd;
  --card: #fffdf8;
  --danger: #a33b2e;
  --ok: #2e7d4f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(27, 21, 17, 0.12), 0 4px 14px rgba(27, 21, 17, 0.06);
  --shadow-lg: 0 2px 6px rgba(27, 21, 17, 0.10), 0 10px 28px rgba(27, 21, 17, 0.08);
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --sidebar-w: 248px;

  /* Per-status colors */
  --st-new: #b58a5a;
  --st-drafted: #5b7a99;
  --st-approved: #6e5a9e;
  --st-sent: #c06b2d;
  --st-replied: #3e9b4f;
  --st-won: #0e7a5f;
  --st-skipped: #9a8f83;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--cream-soft);
  color: var(--espresso);
  font-size: 15px;
  line-height: 1.45;
}

a { color: var(--gold-dark); }

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

.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 30;
  width: var(--sidebar-w);
  background: var(--navy); color: var(--cream);
  display: flex; flex-direction: column;
  padding: 18px 14px 14px;
}
.side-brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--cream); text-decoration: none;
  padding: 2px 8px 16px;
  border-bottom: 1px solid rgba(243, 235, 221, 0.12);
}
.side-logo {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 9px;
  background: var(--gold); color: var(--navy);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.side-name { font-weight: 700; font-size: 16.5px; letter-spacing: 0.2px; white-space: nowrap; }
.side-name .accent { color: var(--gold); }

.side-nav { display: flex; flex-direction: column; gap: 4px; margin-top: 16px; }
.side-nav a {
  display: flex; align-items: center; gap: 10px;
  color: var(--cream); text-decoration: none;
  padding: 9px 10px; border-radius: 8px; font-size: 14px; font-weight: 600;
  opacity: 0.78;
}
.side-nav a svg {
  width: 17px; height: 17px; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.side-nav a:hover { opacity: 1; background: rgba(243, 235, 221, 0.08); }
.side-nav a.active { opacity: 1; background: rgba(181, 138, 90, 0.22); color: #fff; box-shadow: inset 3px 0 0 var(--gold); }

.side-user {
  margin-top: auto; padding: 14px 8px 2px;
  border-top: 1px solid rgba(243, 235, 221, 0.12);
  display: flex; flex-direction: column; gap: 10px;
}
.side-user .who {
  font-size: 12.5px; opacity: 0.75; line-height: 1.4;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.btn-logout {
  display: inline-flex; align-items: center; gap: 8px;
  background: transparent; border: 1px solid rgba(243, 235, 221, 0.35); color: var(--cream);
  padding: 7px 12px; border-radius: 7px; cursor: pointer; font-size: 13px; font-family: var(--font);
  align-self: flex-start;
}
.btn-logout svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.btn-logout:hover { border-color: var(--gold); color: #fff; }

.main { flex: 1 1 auto; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 245, 234, 0.92); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 12px 22px;
}
.page-title { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.topbar-search { flex: 1 1 220px; max-width: 460px; margin-left: auto; }
.search-input {
  width: 100%; padding: 9px 13px; font-size: 14px; font-family: var(--font);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--espresso);
}
.search-input:focus { outline: 2px solid rgba(181, 138, 90, 0.45); border-color: var(--gold); }
.topbar .btn { white-space: nowrap; }

.content { padding: 20px 22px 30px; width: 100%; }

/* ---------- Dashboard stats ---------- */
.stats {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px 12px;
}
.stat-label {
  display: flex; align-items: center; gap: 7px;
  font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
}
.stat-label .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; background: var(--gold); }
.stat-value { font-size: 27px; font-weight: 700; line-height: 1.15; margin-top: 5px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

.dot-new { background: var(--st-new); }
.dot-drafted { background: var(--st-drafted); }
.dot-approved { background: var(--st-approved); }
.dot-sent { background: var(--st-sent); }
.dot-replied { background: var(--st-replied); }
.dot-won { background: var(--st-won); }
.dot-skipped { background: var(--st-skipped); }

/* ---------- Dashboard panels: pipeline + activity ---------- */
.dash-grid {
  display: grid; gap: 16px;
  grid-template-columns: 3fr 2fr;
  align-items: start;
  margin-bottom: 22px;
}
.dash-panel { margin-bottom: 0; }
.dash-panel h2 { display: flex; align-items: center; gap: 8px; }

.pipe-row {
  display: grid; grid-template-columns: 108px 1fr 34px; align-items: center; gap: 10px;
  padding: 5px 0;
}
.pipe-label { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; }
.pipe-label .dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; }
.pipe-track { background: var(--cream); border: 1px solid var(--line); border-radius: 999px; height: 12px; overflow: hidden; }
.pipe-fill { height: 100%; border-radius: 999px; min-width: 0; transition: width 0.3s ease; }
.fill-new { background: var(--st-new); }
.fill-drafted { background: var(--st-drafted); }
.fill-approved { background: var(--st-approved); }
.fill-sent { background: var(--st-sent); }
.fill-replied { background: var(--st-replied); }
.fill-won { background: var(--st-won); }
.fill-skipped { background: var(--st-skipped); }
.pipe-count { font-size: 13px; font-weight: 700; text-align: right; }

.pill {
  display: inline-block; border-radius: 999px; padding: 1px 9px;
  font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.pill-new { background: #f1e4cc; color: #7c5a26; }
.pill-drafted { background: #dfe8f0; color: #3d5a74; }
.pill-approved { background: #e6e0f2; color: #4e3d78; }
.pill-sent { background: #f7e3ce; color: #8f4e1b; }
.pill-replied { background: #ddf0e1; color: #1f6038; }
.pill-won { background: #d2ede4; color: #0a5c46; }
.pill-skipped { background: #eae5de; color: #6f6455; }

.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 6px; border-bottom: 1px solid var(--line);
  cursor: pointer; border-radius: 6px;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--cream-soft); }
.activity-title {
  flex: 1 1 auto; min-width: 0; font-size: 13.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.activity-time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.dash-empty { font-size: 13.5px; color: var(--muted); padding: 10px 0 6px; text-align: center; }

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; margin: 2px 0 14px;
}
.filter-group { display: flex; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.filter-label {
  flex: 0 0 62px; padding-top: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted);
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 0; min-width: 0; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--espresso);
  border-radius: 999px; padding: 4px 11px; font-size: 12.5px; font-weight: 600;
  cursor: pointer; font-family: var(--font); white-space: nowrap;
}
.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--navy); color: var(--cream); border-color: var(--navy); }
.chip-count { margin-left: 5px; font-size: 11.5px; font-weight: 700; opacity: 0.6; }
.filter-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding-top: 2px; }
.filter-showing { font-size: 12.5px; color: var(--muted); }
.clear-filters {
  background: none; border: none; padding: 2px 0; cursor: pointer;
  font-family: var(--font); font-size: 12.5px; font-weight: 700;
  color: var(--gold-dark); text-decoration: underline;
}
.clear-filters:hover { color: var(--navy); }
.type-pill {
  display: inline-block; border-radius: 999px; padding: 0 8px;
  background: #f1e4cc; color: #7c5a26; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
}

/* ---------- Board ---------- */
.board-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  margin: 4px 0 10px;
}
.board-head h2 { margin: 0; font-size: 17px; }
.board-head #total-line { color: var(--muted); font-size: 13px; }

.board {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 2px 2px 10px; overflow-x: auto; min-height: 40vh;
}
.column {
  flex: 0 0 292px; width: 292px;
  background: var(--cream); border: 1px solid var(--line); border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 120px);
}
.column.drag-over { outline: 2px dashed var(--gold); outline-offset: -4px; }
.column h2 {
  margin: 0; padding: 12px 14px 8px; font-size: 13px; text-transform: uppercase;
  letter-spacing: 0.08em; display: flex; justify-content: space-between; align-items: center;
}
.column h2::before {
  content: ""; width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold); margin-right: 8px; flex: 0 0 auto;
}
.column[data-status="new"] h2::before { background: var(--st-new); }
.column[data-status="drafted"] h2::before { background: var(--st-drafted); }
.column[data-status="approved"] h2::before { background: var(--st-approved); }
.column[data-status="sent"] h2::before { background: var(--st-sent); }
.column[data-status="replied"] h2::before { background: var(--st-replied); }
.column[data-status="won"] h2::before { background: var(--st-won); }
.column[data-status="skipped"] h2::before { background: var(--st-skipped); }
.column h2 .count-badge { margin-left: auto; }
.count-badge {
  background: var(--navy); color: var(--cream); border-radius: 999px;
  font-size: 12px; padding: 1px 9px; letter-spacing: 0;
}
.cards { overflow-y: auto; padding: 2px 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--gold);
  border-radius: 8px; padding: 10px 12px; cursor: pointer; box-shadow: var(--shadow);
}
.column[data-status="new"] .card { border-left-color: var(--st-new); }
.column[data-status="drafted"] .card { border-left-color: var(--st-drafted); }
.column[data-status="approved"] .card { border-left-color: var(--st-approved); }
.column[data-status="sent"] .card { border-left-color: var(--st-sent); }
.column[data-status="replied"] .card { border-left-color: var(--st-replied); }
.column[data-status="won"] .card { border-left-color: var(--st-won); }
.column[data-status="skipped"] .card { border-left-color: var(--st-skipped); }
.card:hover { border-color: var(--gold); box-shadow: var(--shadow-lg); }
.card.dragging { opacity: 0.5; }
.card h3 { margin: 0 0 4px; font-size: 14px; line-height: 1.35; }
.card .meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; }
.card .meta .has-contact { color: var(--ok); font-weight: 600; }
.card .meta .no-contact { color: var(--danger); }
.empty-note { font-size: 13px; color: var(--muted); text-align: center; padding: 10px 0 14px; }

/* ---------- Buttons / forms ---------- */
.btn {
  background: var(--gold); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font);
}
.btn:hover { background: var(--gold-dark); }
.btn.secondary { background: #fff; color: var(--espresso); border: 1px solid var(--line); }
.btn.secondary:hover { border-color: var(--gold); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 13px; }

label.field { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--espresso); }
label.field span.hint { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
select, textarea {
  width: 100%; margin-top: 5px; padding: 9px 11px; font-size: 14px; font-family: var(--font);
  border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--espresso);
}
textarea { min-height: 90px; resize: vertical; }
textarea.tall { min-height: 180px; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(181, 138, 90, 0.45); border-color: var(--gold); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 6px 0; }
.form-ok { color: var(--ok); font-size: 13px; min-height: 18px; margin: 6px 0; }

/* ---------- Pages ---------- */
.page { max-width: 860px; margin: 0 auto; padding: 2px 0 20px; }
.page h1 { font-size: 22px; margin: 6px 0 4px; }
.page .sub { color: var(--muted); margin: 0 0 20px; }
.panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.panel h2 { margin: 0 0 12px; font-size: 16px; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
table.users th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy); padding: 20px; }
.login-card {
  background: var(--cream); border-radius: 14px; padding: 30px 28px; width: 100%; max-width: 380px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.35);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 18px; color: var(--muted); font-size: 14px; }
.login-card .btn { width: 100%; padding: 11px; }

/* ---------- Drawer (lead detail) ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(10, 16, 24, 0.5); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100dvh; width: min(520px, 100vw);
  background: var(--cream-soft); z-index: 51; box-shadow: -8px 0 30px rgba(0,0,0,0.25);
  transform: translateX(102%); transition: transform 0.18s ease;
  overflow-y: auto; padding: 18px 20px 30px;
}
.drawer.open { transform: translateX(0); }
.drawer header { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.drawer h2 { font-size: 18px; margin: 0; line-height: 1.3; }
.icon-btn { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.drawer .row-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.drawer .readonly { font-size: 14px; margin: 4px 0 12px; white-space: pre-wrap; word-break: break-word; }
.drawer .readonly-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-top: 14px; }

/* ---------- Modal (add lead) ---------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(10, 16, 24, 0.5); z-index: 60;
  display: none; align-items: flex-start; justify-content: center; overflow-y: auto; padding: 30px 14px;
}
.modal-backdrop.open { display: flex; }
.modal { background: var(--cream-soft); border-radius: 12px; width: 100%; max-width: 560px; padding: 20px 22px 24px; }
.modal header { display: flex; justify-content: space-between; align-items: center; }
.modal h2 { margin: 0; font-size: 18px; }

/* ---------- Responsive ---------- */
@media (max-width: 1020px) {
  .dash-grid { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    position: static; width: auto; flex-direction: row; align-items: center;
    flex-wrap: wrap; gap: 6px 14px; padding: 10px 14px;
  }
  .side-brand { padding: 2px 4px; border-bottom: none; }
  .side-nav { flex-direction: row; flex-wrap: wrap; margin-top: 0; }
  .side-nav a { padding: 7px 9px; }
  .side-nav a.active { box-shadow: inset 0 -3px 0 var(--gold); }
  .side-user {
    margin: 0 0 0 auto; padding: 0; border-top: none;
    flex-direction: row; align-items: center; gap: 10px;
  }
  .side-user .who { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 14px; }
  .content { padding: 14px 14px 22px; }
}

@media (max-width: 640px) {
  .column { flex-basis: 84vw; width: 84vw; max-height: none; }
  .board { padding: 2px 0 10px; }
  .topbar-search { order: 3; flex-basis: 100%; max-width: none; margin-left: 0; }
  .stat-value { font-size: 23px; }
}

/* Potential-charge chip + priority strip (2026-12-06) */
.price-chip {
  background: #f6e8c8; color: #7a5510; font-weight: 700;
  padding: 1px 7px; border-radius: 999px; white-space: nowrap;
}
.priority-panel { margin-bottom: 16px; }
.priority-list { display: flex; flex-direction: column; }
.priority-item {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 4px; border-bottom: 1px solid var(--line); cursor: pointer;
}
.priority-item:last-child { border-bottom: none; }
.priority-item:hover { background: rgba(0,0,0,0.03); }
.priority-title { font-weight: 600; font-size: 13.5px; }
.priority-reasons { color: var(--muted); font-size: 12px; margin-left: auto; }
