:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e2e5ea;
  --text: #1f2430;
  --muted: #8a92a3;
  --primary: #3b5bdb;
  --primary-dark: #2f49b0;
  --danger: #e03131;
  --chip-bg: #eef1f6;      /* subtle neutral fill (badges, counts) */
  --chip-accent: #eef1fd;  /* subtle primary-tinted fill (active card, org chip) */
  --row-hover: #fafbfc;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
}

/* Dark theme — flips the shared variables; everything built on them follows. */
:root[data-theme="dark"] {
  --bg: #14171c;
  --panel: #1c2128;
  --border: #2b313b;
  --text: #e6e9ee;
  --muted: #9aa3b2;
  --primary: #6b8afd;
  --primary-dark: #5a79ec;
  --danger: #ff6b6b;
  --chip-bg: #2b313b;
  --chip-accent: #24304d;
  --row-hover: #232a33;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.3);
}

* { box-sizing: border-box; }

/* Form controls follow the theme (default to panel bg so light is unchanged). */
input, select, textarea { background: var(--panel); color: var(--text); }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.brand { font-weight: 700; letter-spacing: -0.5px; }
.brand span { color: var(--primary); }
.brand.small { font-size: 16px; margin: 0; }

/* ===== Buttons ===== */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 10px; font-size: 12px; }

/* ===== Auth view ===== */
.auth-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
}
.auth-card {
  width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-card h1 { text-align: center; margin: 0 0 20px; font-size: 24px; }
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 8px; border: none; background: transparent;
  cursor: pointer; color: var(--muted); border-bottom: 2px solid var(--border);
}
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.auth-form input {
  padding: 9px 11px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; color: var(--text);
}
.auth-form input:focus { outline: none; border-color: var(--primary); }
.error { color: var(--danger); font-size: 13px; margin-top: 12px; text-align: center; }

/* Honeypot decoy field (see register-form in index.html). Off-screen, not
   display:none/visibility:hidden — some bots skip fields hidden that way, and
   off-screen is simpler than faking a zero-size element some crawlers also
   detect. Real users never see or reach it (also unfocusable via tabindex="-1"). */
.hp-field { position: absolute; left: -9999px; top: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ===== Topbar ===== */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--border);
}
.topbar-right { display: flex; align-items: center; gap: 12px; }
.theme-toggle { padding: 5px 9px; font-size: 15px; line-height: 1; }
.org-chip {
  font-size: 12px; font-weight: 600; color: var(--primary);
  background: var(--chip-accent); border: 1px solid var(--border); border-radius: 20px; padding: 3px 12px;
}

/* ===== Layout ===== */
.layout { display: flex; gap: 16px; padding: 16px 20px; align-items: flex-start; }
.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px;
}
.sidebar h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin: 0 0 12px; }
.accounts-list { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.account-item { border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px; cursor: pointer; transition: border-color 0.12s, background 0.12s; }
.account-item:hover { border-color: var(--primary); }
.account-item.active { border-color: var(--primary); background: var(--chip-accent); }
.account-item .addr { font-weight: 600; word-break: break-all; }
.account-item .meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 6px; }
.account-item .count {
  margin-left: auto; font-size: 11px; color: var(--muted);
  background: var(--chip-bg); border-radius: 20px; padding: 1px 8px; min-width: 20px; text-align: center;
}
.account-item.active .count { background: var(--primary); color: #fff; }
.account-item.stale { border-color: #ffd8a8; background: #fff9f2; }
.reconnect-warn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 8px; padding-top: 8px; border-top: 1px dashed #ffd8a8;
  font-size: 12px; color: #e8590c;
}
.reconnect-btn { color: #e8590c; border-color: #ffd8a8; }
.reconnect-btn:hover { background: #fff4e6; border-color: #e8590c; }
/* "All contacts" row: no last-sync line, so its meta sits flush */
.account-item.all-row .meta { margin-top: 0; }
.provider-tag { font-size: 11px; text-transform: capitalize; color: var(--muted); }
.connect-buttons { display: flex; gap: 8px; }

.content { flex: 1; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; min-width: 0; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type="search"] { flex: 1; min-width: 180px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; }
.toolbar select { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }

/* ===== Contacts table ===== */
.contacts-table { width: 100%; border-collapse: collapse; }
.contacts-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.contacts-table th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.contacts-table th.sortable:hover { color: var(--text); }
.contacts-table th.active-sort { color: var(--primary); }
.contacts-table td { padding: 10px; border-bottom: 1px solid var(--border); }
.contacts-table tbody tr:hover { background: var(--row-hover); }
.contacts-table .name { font-weight: 600; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px;
  background: var(--chip-bg); color: var(--muted); text-transform: capitalize;
}
.badge.organization { background: #e7f5ec; color: #2b8a3e; }
.badge.specific { background: #fff4e6; color: #e8590c; }
.empty { text-align: center; padding: 30px; }

/* Pagination bar */
.pagination { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.pagination label { display: flex; align-items: center; gap: 6px; }
.pagination select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; }
.pager-buttons { margin-left: auto; display: flex; gap: 8px; }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn:disabled:hover { border-color: var(--border); }

/* ===== Pipeline / Kanban board ===== */
/* Board toolbar: the same "chrome" as the contacts/companies toolbar, but its
   search filters cards in place across columns instead of paginating. */
.board-toolbar {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
}
.board-toolbar input[type="search"] { flex: 0 1 340px; min-width: 160px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; }
.board-toolbar select { padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel); }
.board-toolbar #deal-new { margin-left: auto; }
#pipeline-switcher { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; }
.board {
  display: flex; gap: 14px; align-items: flex-start;
  padding: 16px 20px; overflow-x: auto; min-height: calc(100vh - 130px);
}
.stage-col {
  flex: 0 0 280px; width: 280px; background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: calc(100vh - 150px);
}
.stage-col.drop-target { border-color: var(--primary); box-shadow: inset 0 0 0 2px var(--primary); }
.stage-col.stage-dragging { opacity: 0.4; }
.stage-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.stage-head .stage-grip { cursor: grab; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 1px; user-select: none; }
.stage-head .stage-grip:active { cursor: grabbing; }
.stage-head .stage-name { font-weight: 600; font-size: 13px; flex: 1; }
.stage-head .stage-count { font-size: 11px; color: var(--muted); background: var(--chip-bg); border-radius: 20px; padding: 1px 8px; }
.stage-head .stage-total { font-size: 11px; color: var(--muted); }
.stage-actions { display: flex; gap: 2px; }
.stage-actions button { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 13px; padding: 2px 4px; border-radius: 4px; line-height: 1; }
.stage-actions button:hover { color: var(--text); background: var(--chip-bg); }
.stage-cards { padding: 10px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.deal-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  cursor: grab; box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.deal-card:hover { border-color: var(--primary); }
.deal-card.dragging { opacity: 0.5; }
.deal-card .deal-title-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.deal-card .deal-title { font-weight: 600; font-size: 13px; }
.deal-card .deal-title-row .temp-cap { margin-left: 0; flex-shrink: 0; }
.deal-card .deal-company { display: flex; align-items: center; gap: 6px; margin-bottom: 7px; font-size: 11px; color: var(--muted); }
.deal-card .deal-company-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co-mono.mono-sm { width: 18px; height: 18px; flex: 0 0 18px; font-size: 9px; border-radius: 5px; }
.deal-card .deal-meta { display: flex; justify-content: space-between; align-items: center; font-size: 11px; color: var(--muted); gap: 6px; }
.deal-card .deal-value { font-weight: 600; color: var(--text); }
.deal-card .deal-owner { background: var(--chip-accent); color: var(--primary); border-radius: 20px; padding: 1px 7px; white-space: nowrap; }
.deal-card .deal-contact { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stage-total {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  padding: 8px 12px; margin-top: auto; border-top: 1px solid var(--border);
}
.stage-total .stage-total-label { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.stage-total .stage-total-value { font-size: 13px; font-weight: 700; color: var(--text); }
.add-deal-btn { margin: 0 10px 10px; }
.add-stage-col { flex: 0 0 200px; }
.add-stage-col .btn { width: 100%; }

/* Excluded (tombstoned) contacts */
.excluded-list { max-height: 55vh; overflow-y: auto; margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.excluded-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
}
.excluded-who { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.excluded-name { font-weight: 600; font-size: 13px; }
.excluded-email { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.excluded-meta { font-size: 11px; color: var(--muted); }

/* Companies list */
.single-view { padding: 20px; }   /* a view with no sidebar: same card look as contacts' .content */
.company-table { width: 100%; border-collapse: collapse; }
.company-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.company-table td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.company-table th.num, .company-table td.num { text-align: right; }
.company-table tbody tr { cursor: pointer; }
.company-table tbody tr:hover { background: var(--row-hover); }

/* Monogram: initials on a hue-tinted tile, colour derived from the name so each
   company is recognisable at a glance without needing a logo. */
.co-cell .co-flex { display: flex; align-items: center; gap: 11px; }
.co-mono {
  --h: 220;
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  background: hsl(var(--h) 60% 50% / 0.16); color: hsl(var(--h) 60% 40%);
}
:root[data-theme="dark"] .co-mono { background: hsl(var(--h) 55% 55% / 0.22); color: hsl(var(--h) 70% 70%); }
.co-name { font-weight: 600; }
.co-industry { color: var(--muted); }
.co-web { color: var(--muted); font-size: 13px; }
.co-count {
  display: inline-block; min-width: 22px; padding: 2px 10px; border-radius: 20px;
  background: var(--chip-bg); color: var(--muted); font-size: 12px; font-weight: 600; text-align: center;
}
.section-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 0 8px; }
.web-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; margin-left: 6px; border-radius: 4px;
  font-size: 12px; line-height: 1; text-decoration: none; vertical-align: middle;
  background: var(--chip-accent); color: var(--primary);
}
.web-badge:hover { background: var(--primary); color: #fff; }
/* Folder badge: amber, so it's distinct from the blue website badge at a glance. */
.folder-badge { background: hsl(38 90% 50% / 0.16); color: hsl(38 85% 38%); }
.folder-badge:hover { background: hsl(38 85% 45%); color: #fff; }
:root[data-theme="dark"] .folder-badge { background: hsl(38 80% 55% / 0.22); color: hsl(40 90% 66%); }
/* In the company list, give the LinkedIn badge the same tile shape as the others. */
.co-name .li-badge { width: 18px; height: 18px; justify-content: center; border-radius: 4px; background: var(--chip-accent); line-height: 1; }

/* Searchable combobox (deal contact picker) */
.combo-item.combo-add { color: var(--primary); font-weight: 600; border-bottom: 1px solid var(--border); }
.combo-hint {
  position: sticky; bottom: 0; padding: 6px 10px; font-size: 11px; color: var(--muted);
  background: var(--panel); border-top: 1px solid var(--border); text-align: center; cursor: default;
}
.combo { position: relative; }
.combo > input[type="text"] { width: 100%; }
.combo-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin-top: 3px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  max-height: 220px; overflow-y: auto; box-shadow: 0 6px 18px rgba(0,0,0,0.15);
}
.combo-item { padding: 7px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.combo-item:hover { background: var(--chip-bg); }
.combo-none { color: var(--muted); border-bottom: 1px solid var(--border); }
.deal-outcome { margin-right: auto; display: flex; gap: 6px; }
.deal-outcome .btn.small { padding: 4px 9px; }
.archive-btn { color: var(--primary); border-color: var(--chip-accent); }

/* Multi-contact list in the deal popup */
.deal-contacts-list { display: flex; flex-direction: column; gap: 8px; }
.deal-contacts-list.hidden { display: none; }
.deal-contact-row { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; }
.deal-contact-row-top { display: flex; align-items: center; gap: 8px; }
.deal-contact-name { font-weight: 600; font-size: 13px; }
.deal-contact-company { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deal-contact-row-top .btn.small { margin-left: auto; padding: 3px 8px; font-size: 11px; }
.primary-badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  background: var(--chip-accent); color: var(--primary); border-radius: 20px; padding: 1px 8px;
}
.deal-contact-note {
  width: 100%; margin-top: 6px; font-size: 12px; padding: 6px 8px;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
  font-family: inherit; resize: vertical; min-height: 44px;
}
.deal-contacts-empty { font-size: 12px; color: var(--muted); padding: 4px 2px; }

.closed-deals { padding: 16px 20px; overflow-x: auto; }
.closed-deals-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.closed-deals-table th, .closed-deals-table td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); }
.closed-deals-table th { color: var(--muted); font-weight: 600; }
.outcome-pill { font-weight: 600; }
.outcome-pill.won { color: #2b8a3e; }
.outcome-pill.lost { color: #e8590c; }
.outcome-pill.archived { color: var(--muted); }
#closed-deals-empty { padding: 12px 0; }

/* ===== Password banner ===== */
.banner {
  background: #fff4e6; border-bottom: 1px solid #ffd8a8; color: #e8590c;
  padding: 10px 20px; display: flex; align-items: center; gap: 10px; font-size: 13px;
}
.link-btn {
  background: none; border: none; color: var(--primary); cursor: pointer;
  font-weight: 600; text-decoration: underline; font-size: 13px; padding: 0;
}
.banner.impersonation {
  background: #eef2ff; border-bottom-color: #c7d2fe; color: #4338ca;
}
:root[data-theme="dark"] .banner.impersonation {
  background: hsl(243 60% 25% / 0.4); border-bottom-color: hsl(243 60% 45%); color: hsl(235 90% 82%);
}

/* ===== Admin view ===== */
.admin-main { padding: 20px; display: flex; flex-direction: column; gap: 20px; max-width: 1100px; }
.admin-panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.admin-panel h2 { margin: 0 0 14px; font-size: 16px; }

.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.setting-row-text strong { font-size: 14px; }
.setting-row-text p { margin: 4px 0 0; max-width: 46em; }

/* Toggle switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track {
  position: absolute; inset: 0; background: var(--chip-bg); border: 1px solid var(--border);
  border-radius: 22px; transition: background 0.15s, border-color 0.15s;
}
.switch-track::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  background: var(--panel); border-radius: 50%; box-shadow: 0 1px 2px rgba(0,0,0,0.25);
  transition: transform 0.15s;
}
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::before { transform: translateX(18px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--primary); outline-offset: 2px; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.inline-form input, .inline-form select {
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.inline-form input:focus, .inline-form select:focus { outline: none; border-color: var(--primary); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px;
  color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.admin-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.status-active { color: #2b8a3e; font-weight: 600; }
.status-inactive { color: var(--danger); font-weight: 600; }
.row-you { font-size: 11px; color: var(--muted); }

.contacts-table tbody tr { cursor: pointer; }
.li-badge {
  display: inline-flex; align-items: center; margin-left: 6px; color: #0a66c2;
  vertical-align: middle; line-height: 0;
}
.li-badge:hover { color: #084d94; }

/* Temperature capsule beside the name */
.temp-cap {
  display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 20px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.3px;
  vertical-align: middle;
}
.temp-hot  { background: #ffe3e3; color: #c92a2a; }
.temp-warm { background: #fff3bf; color: #e67700; }
.temp-cold { background: #e7f5ff; color: #1971c2; }

/* Outreach status badges */
.badge.outreach-not_started     { background: #f1f3f5; color: #868e96; }
.badge.outreach-connection_sent { background: #e7f5ff; color: #1971c2; }
.badge.outreach-message_sent    { background: #fff3bf; color: #e67700; }
.badge.outreach-replied         { background: #e7f5ec; color: #2b8a3e; }
.badge.outreach-bad_contact     { background: #ffe3e3; color: #c92a2a; }

/* Right-align the count + top pager + Add button as a group */
#contacts-count { margin-left: auto; }

/* Compact top pager (in the toolbar) */
.pager-top { display: inline-flex; align-items: center; gap: 6px; }
.icon-btn {
  padding: 4px 9px; font-size: 15px; line-height: 1; font-weight: 600;
  border-radius: 7px; min-width: 30px;
}

/* ===== Overlays (drawer + modal) ===== */
.overlay {
  position: fixed; inset: 0; background: rgba(20, 24, 33, 0.4);
  display: flex; justify-content: flex-end; z-index: 50;
}
.overlay.center { align-items: center; justify-content: center; }

/* ===== Add contact modal ===== */
.modal {
  width: 480px; max-width: 92vw; max-height: 90vh; overflow-y: auto;
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px; position: relative; animation: popin 0.14s ease-out;
}
.modal.wide { width: 620px; }
@keyframes popin { from { transform: scale(0.98); opacity: 0.7; } to { transform: none; opacity: 1; } }
.modal-title { margin: 0 0 18px; font-size: 18px; }
.modal-form { display: flex; flex-direction: column; gap: 14px; }
.modal-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.modal-form input, .modal-form select, .modal-form textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; color: var(--text);
  font-family: inherit;
}
.modal-form textarea { resize: vertical; min-height: 120px; }
.modal-form input:focus, .modal-form select:focus, .modal-form textarea:focus { outline: none; border-color: var(--primary); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* CSV bulk import */
.csv-import { border: 1px dashed var(--border); border-radius: 8px; padding: 12px; margin-bottom: 14px; }
.csv-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.csv-head a { color: var(--primary); text-decoration: none; font-size: 12px; }
.csv-head a:hover { text-decoration: underline; }
#csv-file { font-size: 13px; color: var(--text); width: 100%; }
.csv-import.dragover { border-color: var(--primary); border-style: solid; background: var(--chip-accent); }
.csv-import.dragover .csv-drop-hint { color: var(--primary); font-weight: 600; }
.csv-drop-hint { text-align: center; margin-top: 6px; }
#csv-status { margin: 8px 0 0; white-space: pre-line; }
.csv-or { text-align: center; color: var(--muted); font-size: 12px; margin: 4px 0 14px; }

.emails-block { border-top: 1px solid var(--border); padding-top: 12px; }
.emails-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.email-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.email-row .email-input { width: 100%; }
.email-row-bottom { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.email-row-bottom .source-badge { order: 5; }
.email-row-bottom .remove-email { margin-left: auto; }
.email-row-bottom .email-label { width: 100px; }
.email-row-bottom .primary-radio { flex-direction: row; align-items: center; gap: 4px; font-size: 12px; color: var(--text); white-space: nowrap; }
.email-row-bottom .remove-email { padding: 4px 9px; }

.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.drawer {
  width: 420px; max-width: 92vw; height: 100%; background: var(--panel);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12); padding: 24px 24px 40px;
  overflow-y: auto; position: relative;
  animation: slidein 0.16s ease-out;
}
@keyframes slidein { from { transform: translateX(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.drawer-close {
  position: absolute; top: 14px; right: 16px; border: none; background: none;
  font-size: 26px; line-height: 1; color: var(--muted); cursor: pointer;
}
.drawer-close:hover { color: var(--text); }

.detail-name { font-size: 20px; font-weight: 700; margin: 0 8px 2px 0; }
.detail-sub { color: var(--muted); margin-bottom: 16px; }
.detail-actions { display: flex; gap: 8px; margin-bottom: 18px; }
.btn.danger-btn { color: var(--danger); border-color: #f3c3c3; }
.btn.danger-btn:hover { background: #fff5f5; border-color: var(--danger); }

/* Sharing controls */
.share-visibility { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; }
.member-box { flex-direction: column; gap: 6px; margin-bottom: 10px; }
.member-item { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.share-actions { display: flex; align-items: center; gap: 10px; }
.detail-section { margin-bottom: 22px; }
.detail-section h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.6px;
  color: var(--muted); margin: 0 0 8px; border-bottom: 1px solid var(--border); padding-bottom: 5px;
}
.detail-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; }
.detail-row .k { color: var(--muted); }
.detail-row .v { text-align: right; word-break: break-word; }
.email-line { display: flex; align-items: center; gap: 8px; padding: 4px 0; flex-wrap: wrap; }
.email-line .tag { font-size: 11px; color: var(--muted); }
.pill-primary { font-size: 10px; background: var(--primary); color: #fff; padding: 1px 7px; border-radius: 20px; }
.source-badge {
  font-size: 10px; color: var(--muted); border: 1px solid var(--border);
  padding: 1px 7px; border-radius: 20px; white-space: nowrap;
}

/* Awareness panels */
.awareness { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: #fbfbfd; }
.awareness.warn { background: #fff9f4; border-color: #ffe0c2; }
.awareness-item { padding: 5px 0; border-bottom: 1px dashed var(--border); }
.awareness-item:last-child { border-bottom: none; }
.awareness-item .who { font-weight: 600; }
.awareness-empty { color: var(--muted); font-size: 13px; }
.notes-text { white-space: pre-wrap; font-size: 13px; line-height: 1.5; }
.detail-row .v a { color: var(--primary); text-decoration: none; }
.detail-row .v a:hover { text-decoration: underline; }

/* ===== KPI views ===== */
.kpi-content { display: flex; flex-direction: column; gap: 16px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.kpi-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi-card h3 { margin: 0 0 12px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.kpi-card h3 .muted { text-transform: none; font-weight: 400; letter-spacing: normal; }
.kpi-card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.kpi-card-head h3 { margin: 0; }
.kpi-card-head select { padding: 5px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); font-size: 12px; }
.kpi-wide { width: 100%; }
.kpi-stat { display: flex; align-items: baseline; gap: 8px; }
.kpi-stat-num { font-size: 28px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi-bars { display: flex; flex-direction: column; gap: 8px; }
.kpi-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.kpi-bar-label { width: 64px; flex-shrink: 0; color: var(--muted); text-transform: capitalize; }
.kpi-bar-track { flex: 1; height: 8px; border-radius: 4px; background: var(--chip-bg); overflow: hidden; }
.kpi-bar-fill { height: 100%; border-radius: 4px; background: var(--primary); }
.kpi-bar-fill.hot  { background: #e03131; }
.kpi-bar-fill.warm { background: #e8590c; }
.kpi-bar-fill.cold { background: #1971c2; }
.kpi-bar-fill.none { background: var(--muted); }
.kpi-bar-fill.won  { background: #2f9e44; }
.kpi-bar-fill.lost { background: #c92a2a; }
.kpi-bar-count { width: 28px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text); }
.kpi-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kpi-table th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border);
}
.kpi-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.kpi-table th.num, .kpi-table td.num { text-align: right; }
.kpi-table tbody tr:last-child td { border-bottom: none; }
.kpi-table tbody tr:hover { background: var(--row-hover); }
.kpi-pie { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.kpi-value-charts { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }
.kpi-value-chart-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-bottom: 6px; }
.kpi-value-bar-row { display: flex; align-items: center; gap: 8px; font-size: 12px; margin-bottom: 5px; }
.kpi-value-bar-label { width: 90px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.kpi-value-bar-track { flex: 1; height: 10px; border-radius: 4px; background: var(--chip-bg); overflow: hidden; }
.kpi-value-bar-fill { height: 100%; border-radius: 4px; }
.kpi-value-bar-amount { width: 120px; flex-shrink: 0; text-align: right; font-variant-numeric: tabular-nums; }
.kpi-legend { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.kpi-legend-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.kpi-legend-swatch { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.kpi-legend-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kpi-legend-value { color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-pie-toolbar { display: flex; align-items: center; gap: 10px; }
.kpi-toggle { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.kpi-toggle button {
  border: none; background: var(--panel); color: var(--muted); padding: 6px 12px;
  font-size: 12px; cursor: pointer;
}
.kpi-toggle button + button { border-left: 1px solid var(--border); }
.kpi-toggle button.active { background: var(--chip-accent); color: var(--primary); font-weight: 600; }

/* ===== My Account ===== */
.account-content { display: flex; flex-direction: column; gap: 16px; max-width: 480px; }
.account-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px;
}
.account-card h3 { margin: 0 0 12px; font-size: 14px; }
.pw-field { display: flex; gap: 8px; align-items: center; }
.pw-field input { flex: 1; }
.pw-toggle {
  flex-shrink: 0; background: none; border: 1px solid var(--border); border-radius: 6px;
  color: var(--muted); cursor: pointer; font-size: 12px; padding: 6px 10px;
}
.pw-toggle:hover { color: var(--text); border-color: var(--primary); }
