:root {
  color-scheme: light;
  --blue: #2563eb;
  --blue-light: #eff6ff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --red: #dc2626;
  --red-light: #fef2f2;
  --orange: #d97706;
  --orange-light: #fffbeb;
  --green: #16a34a;
  --green-light: #f0fdf4;
  --purple: #7c3aed;
  --purple-light: #f5f3ff;
  --teal: #0d9488;
  --teal-light: #f0fdfa;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
}
.app { max-width: 1180px; margin: 0 auto; padding: 20px 24px 60px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 10px; }
.topbar h1 { font-size: 19px; margin: 0; font-weight: 700; }
.topbar .actions { display: flex; gap: 8px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--gray-200); }
.tab {
  padding: 9px 14px; cursor: pointer; font-weight: 600; color: var(--gray-500);
  border-bottom: 2px solid transparent; font-size: 13.5px; display: flex; align-items: center; gap: 6px;
}
.tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.badge {
  background: var(--gray-200); color: var(--gray-700); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-weight: 700;
}
.badge.alert { background: var(--red); color: white; }
.btn {
  background: var(--blue); color: white; border: none; border-radius: 7px; padding: 8px 13px;
  font-size: 13px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { opacity: 0.9; }
.btn.secondary { background: white; color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn.ghost { background: transparent; color: var(--blue); padding: 6px 8px; }
.btn.danger { background: var(--red); }
.btn.success { background: var(--green); }
.btn.success-outline { background: var(--green-light); color: var(--green); border: 1px solid var(--green); }
.btn.warn-outline { background: var(--red-light); color: var(--red); border: 1px solid var(--red); }
.btn.sm { padding: 5px 9px; font-size: 12px; }
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); max-width: min(560px, 92vw);
  background: var(--gray-900); color: white; padding: 11px 10px 11px 16px; border-radius: 10px;
  display: flex; align-items: center; gap: 10px; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,0.3); z-index: 200;
}
.toast span { flex: 1; }
.toast button { background: transparent; border: 1px solid rgba(255,255,255,0.4); color: white; padding: 4px 11px; border-radius: 6px; font-size: 12px; cursor: pointer; flex-shrink: 0; }
.toast button:hover { background: rgba(255,255,255,0.15); }
.card {
  background: white; border: 1px solid var(--gray-200); border-radius: 10px; padding: 14px 16px; margin-bottom: 10px;
}
.empty { color: var(--gray-500); text-align: center; padding: 40px 10px; font-size: 13.5px; }
.todo-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.todo-left { display: flex; flex-direction: column; gap: 3px; min-width: 220px; }
.todo-name { font-weight: 700; font-size: 14.5px; }
.todo-sub { color: var(--gray-500); font-size: 12.5px; }
.todo-reason { font-size: 12.5px; margin-top: 2px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 700; }
.pill.overdue { background: var(--red-light); color: var(--red); }
.pill.today { background: var(--orange-light); color: var(--orange); }
.todo-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.board { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.column { background: var(--gray-100); border-radius: 10px; padding: 10px; min-height: 200px; }
.column h3 { font-size: 13px; margin: 4px 6px 10px; display: flex; justify-content: space-between; align-items: center; }
.pcard { background: white; border: 1px solid var(--gray-200); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; cursor: pointer; }
.pcard:hover { border-color: var(--blue); }
.pcard .name { font-weight: 700; font-size: 13.5px; }
.pcard .co { color: var(--gray-500); font-size: 12px; margin-top: 2px; }
.pcard .fu { font-size: 11.5px; margin-top: 6px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11.5px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.03em; padding: 8px 10px; border-bottom: 1px solid var(--gray-200); }
td { padding: 9px 10px; border-bottom: 1px solid var(--gray-100); font-size: 13.5px; vertical-align: middle; }
tr.clickable:hover { background: var(--gray-50); cursor: pointer; }
.stage-tag { padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.stage-not_contacted { background: var(--gray-200); color: var(--gray-700); }
.stage-attempted { background: var(--orange-light); color: var(--orange); }
.stage-engaged { background: var(--blue-light); color: var(--blue); }
.stage-not_interested { background: var(--red-light); color: var(--red); }
.stage-booked_meeting { background: var(--green-light); color: var(--green); }
.link { color: var(--blue); text-decoration: none; }
.link:hover { text-decoration: underline; }
.searchbar { padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: 7px; font-size: 13px; width: 220px; }
.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,0.45); display: flex; align-items: flex-start;
  justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal { background: white; border-radius: 12px; padding: 22px 24px; width: 100%; max-width: 520px; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .close { float: right; cursor: pointer; color: var(--gray-500); font-size: 18px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--gray-700); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--gray-200); border-radius: 7px; font-size: 13.5px; font-family: inherit;
}
.field textarea { min-height: 60px; resize: vertical; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.activity-item { border-left: 2px solid var(--gray-200); padding: 4px 56px 4px 12px; margin-bottom: 8px; font-size: 12.5px; position: relative; }
.activity-item .meta { color: var(--gray-500); }
.activity-undo { position: absolute; top: 4px; right: 0; font-size: 11px; padding: 3px 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.outcome-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 8px; margin-top: 8px; }
.outcome-choices button { width: 100%; justify-content: center; text-align: center; }
.org-tree-scroll { overflow-x: auto; padding: 16px 4px 24px; margin-bottom: 14px; }
.org-tree, .org-tree ul { list-style: none; margin: 0; padding: 0; position: relative; display: flex; }
.org-tree { justify-content: center; }
.org-tree ul { padding-top: 24px; }
.org-tree li { display: flex; flex-direction: column; align-items: center; position: relative; padding: 24px 10px 0; }
.org-tree li::before, .org-tree li::after {
  content: ''; position: absolute; top: 0; right: 50%; border-top: 2px solid var(--gray-200); width: 50%; height: 24px;
}
.org-tree li::after { right: auto; left: 50%; border-left: 2px solid var(--gray-200); }
.org-tree li:only-child::after, .org-tree li:only-child::before { display: none; }
.org-tree li:only-child { padding-top: 0; }
.org-tree li:first-child::before, .org-tree li:last-child::after { border: 0 none; }
.org-tree li:last-child::before { border-right: 2px solid var(--gray-200); border-radius: 0 6px 0 0; }
.org-tree li:first-child::after { border-radius: 6px 0 0 0; }
.org-tree ul::before {
  content: ''; position: absolute; top: 0; left: 50%; border-left: 2px solid var(--gray-200); width: 0; height: 24px;
}
.org-tree > li { padding-top: 0; }
.org-tree > li::before, .org-tree > li::after { display: none; }
.org-node {
  display: inline-block; padding: 8px 12px; border-radius: 8px; font-size: 12px; text-align: center;
  border: 1.5px solid var(--gray-200); background: white; min-width: 130px; line-height: 1.4;
}
.org-node.company-root { background: var(--blue-light); border-color: var(--blue); font-weight: 700; }
.org-node.filled { background: var(--green-light); border-color: var(--green); }
.org-node.missing { background: var(--red-light); border-color: var(--red); border-style: dashed; }
.comp-banner { background: linear-gradient(135deg, var(--purple), var(--blue)); border-radius: 14px; padding: 20px 22px; color: #fff; margin-bottom: 18px; }
.comp-banner-top { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.comp-headline { font-size: 19px; font-weight: 800; }
.comp-range { font-size: 12.5px; opacity: 0.85; margin-top: 3px; }
.comp-period-toggle { display: flex; gap: 4px; background: rgba(255,255,255,0.15); padding: 3px; border-radius: 9px; }
.comp-period-btn { background: transparent; border: none; color: #fff; padding: 7px 13px; border-radius: 6px; font-size: 12.5px; font-weight: 700; cursor: pointer; opacity: 0.8; }
.comp-period-btn.active { background: rgba(255,255,255,0.95); color: var(--purple); opacity: 1; }
.comp-banner-stats { display: flex; gap: 26px; flex-wrap: wrap; }
.comp-stat-num { font-size: 23px; font-weight: 800; line-height: 1.2; }
.comp-stat-label { font-size: 11.5px; opacity: 0.85; margin-top: 2px; }
.comp-stat-highlight .comp-stat-num { color: #fde68a; }
.comp-section-title { font-size: 14.5px; font-weight: 700; margin: 20px 0 10px; }
.comp-subtle { font-weight: 400; color: var(--gray-500); font-size: 12px; }
.comp-leaderboard { display: flex; flex-direction: column; gap: 8px; margin-bottom: 6px; }
.comp-rep-card { display: flex; align-items: center; gap: 12px; background: white; border: 1px solid var(--gray-200); border-left: 4px solid; border-radius: 10px; padding: 10px 14px; }
.comp-rank { font-size: 18px; font-weight: 800; width: 32px; text-align: center; flex-shrink: 0; }
.comp-avatar { width: 34px; height: 34px; border-radius: 50%; color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12.5px; flex-shrink: 0; }
.comp-rep-info { flex: 1; min-width: 0; }
.comp-rep-name { font-weight: 700; font-size: 13.5px; }
.comp-rep-stats { font-size: 11.5px; color: var(--gray-500); margin-top: 2px; }
.comp-score-wrap { text-align: center; flex-shrink: 0; }
.comp-score { font-size: 18px; font-weight: 800; color: var(--purple); }
.comp-score-label { font-size: 10px; color: var(--gray-500); }
.comp-charts-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; margin-bottom: 6px; }
.comp-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 12px; }
.comp-bar-label { width: 92px; flex-shrink: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--gray-700); }
.comp-bar-track { flex: 1; background: var(--gray-100); border-radius: 6px; height: 10px; overflow: hidden; }
.comp-bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s; }
.comp-bar-value { width: 24px; text-align: right; font-weight: 700; color: var(--gray-700); flex-shrink: 0; }
.comp-donut-wrap { display: flex; align-items: center; gap: 24px; flex-wrap: wrap; }
.comp-donut { width: 140px; height: 140px; border-radius: 50%; flex-shrink: 0; }
.comp-donut-legend { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.comp-legend-item { display: flex; align-items: center; gap: 8px; }
.comp-legend-swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.comp-rewards-card { margin-bottom: 8px; background: linear-gradient(135deg, #fff7ed, #fef9c3); border: 1px solid #fde68a; }
.comp-rewards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 10px; }
.comp-reward-box { background: white; border: 1px solid var(--gray-200); border-radius: 10px; padding: 12px 14px; }
.comp-reward-label { font-size: 12px; font-weight: 700; color: var(--gray-700); margin-bottom: 6px; }
.comp-reward-leader { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.comp-reward-prize { font-size: 13px; color: var(--orange); font-weight: 700; }
.comp-progress-track { background: var(--gray-100); border-radius: 6px; height: 10px; overflow: hidden; margin-bottom: 6px; }
.comp-progress-fill { height: 100%; border-radius: 6px; background: var(--blue); transition: width 0.3s; }
.comp-progress-fill.reached { background: var(--green); }
.conflict-banner {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px;
  background: var(--orange-light); border: 1px solid var(--orange); color: var(--orange);
  border-radius: 10px; padding: 10px 14px; font-size: 13px; font-weight: 600; margin-bottom: 16px;
}
#login-gate { display: flex; align-items: center; justify-content: center; height: 100vh; }
#login-gate h1 { font-size: 22px; margin-bottom: 4px; }
