/* ==========================================================================
   POLIMUR INTELLIGENCE — Design system
   ========================================================================== */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ee;
  --border-soft: #eef0f4;
  --text-primary: #12141c;
  --text-secondary: #5d6270;
  --text-tertiary: #9598a3;

  --brand: #2451ff;
  --brand-dark: #1637c9;
  --brand-light: #eef2ff;
  --brand-soft: #e3e9ff;

  --accent-teal: #0ea5a3;
  --accent-teal-light: #e6f8f7;

  --score-veryhigh: #16a34a;
  --score-veryhigh-bg: #e9f8ee;
  --score-high: #2451ff;
  --score-high-bg: #eef2ff;
  --score-medium: #d97706;
  --score-medium-bg: #fef3e2;
  --score-low: #94a0b3;
  --score-low-bg: #f1f2f5;

  --danger: #dc2626;
  --danger-bg: #fdecec;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-xs: 0 1px 2px rgba(20, 24, 40, 0.04);
  --shadow-sm: 0 2px 6px rgba(20, 24, 40, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 24, 40, 0.08);
  --shadow-lg: 0 16px 40px rgba(20, 24, 40, 0.12);

  --sidebar-w: 264px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4, p { margin: 0; }
input, select, textarea { font-family: inherit; font-size: 14px; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d6d9e2; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ SHELL ============ */
#app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 40;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 22px 20px 18px;
}
.brand-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  color: #fff;
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 800; font-size: 14.5px; letter-spacing: 0.02em; }
.brand-sub { font-weight: 600; font-size: 10px; color: var(--text-tertiary); letter-spacing: 0.08em; }
.sidebar-close { display: none; margin-left: auto; background: none; border: none; color: var(--text-secondary); font-size: 16px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 6px 12px; }
.nav-group { display: flex; flex-direction: column; gap: 2px; margin-bottom: 6px; }
.nav-divider {
  margin: 18px 10px 8px;
  padding-top: 14px;
  border-top: 1px solid var(--border-soft);
}
.nav-divider span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
}
.nav-item i { width: 16px; text-align: center; font-size: 14px; color: var(--text-tertiary); transition: color 0.15s; }
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.nav-item.active i { color: var(--brand); }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--border-soft);
}
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12.5px; flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11.5px; color: var(--text-tertiary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(15,17,25,0.4); z-index: 39; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 60px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.mobile-only { display: none; }
.icon-btn {
  background: none; border: none; color: var(--text-secondary);
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; position: relative; flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.dot-badge { position: absolute; top: 6px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--danger); border: 1.5px solid var(--surface); }

.topbar-search {
  flex: 1; max-width: 420px;
  display: flex; align-items: center; gap: 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 13px;
  color: var(--text-tertiary);
}
.topbar-search input { flex: 1; border: none; background: none; outline: none; color: var(--text-primary); }
.topbar-search input::placeholder { color: var(--text-tertiary); }

.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-ai-btn { display: flex; align-items: center; gap: 7px; }

.app-content { flex: 1; padding: 28px 32px 56px; max-width: 1360px; width: 100%; margin: 0 auto; }

/* ============ TYPOGRAPHY / HELPERS ============ */
.page-header { margin-bottom: 22px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 5px; }
.eyebrow { font-size: 11px; font-weight: 700; letter-spacing: 0.07em; color: var(--brand); text-transform: uppercase; }
.demo-tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; color: var(--text-tertiary); font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border-soft);
  border-radius: 20px; padding: 3px 10px; margin-top: 6px;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-weight: 600; font-size: 13.5px;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: var(--surface); color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface-2); border-color: #d3d7e0; }
.btn-ghost { background: none; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text-primary); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }
.btn-lg { padding: 12px 22px; font-size: 14.5px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-danger-ghost { background: none; color: var(--danger); }
.btn-danger-ghost:hover { background: var(--danger-bg); }
.btn-icon-only { padding: 8px; width: 36px; }

/* ============ CARD ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: 20px 22px; }

/* ============ KPI GRID ============ */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.kpi-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; box-shadow: var(--shadow-xs);
  display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow 0.15s, transform 0.15s;
}
.kpi-card:hover { box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi-icon { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.kpi-value { font-size: 30px; font-weight: 800; letter-spacing: -0.02em; }
.kpi-label { color: var(--text-secondary); font-size: 13px; font-weight: 500; }
.kpi-trend { font-size: 11.5px; font-weight: 600; }
.kpi-trend.up { color: var(--score-veryhigh); }

/* ============ SECTION ============ */
.section-block { margin-bottom: 30px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-size: 16.5px; font-weight: 700; }
.section-link { font-size: 12.5px; font-weight: 600; color: var(--brand); }
.section-link:hover { text-decoration: underline; }

/* ============ OPPORTUNITY SCORE ============ */
.score-badge { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; flex-shrink: 0; position: relative; cursor: help; }
.score-ring { width: 54px; height: 54px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 18px; font-weight: 800; border: 3px solid; }
.score-ring.veryhigh { border-color: var(--score-veryhigh); color: var(--score-veryhigh); background: var(--score-veryhigh-bg); }
.score-ring.high { border-color: var(--score-high); color: var(--score-high); background: var(--score-high-bg); }
.score-ring.medium { border-color: var(--score-medium); color: var(--score-medium); background: var(--score-medium-bg); }
.score-ring.low { border-color: var(--score-low); color: var(--score-low); background: var(--score-low-bg); }
.score-tier-label { font-size: 9.5px; font-weight: 800; letter-spacing: 0.04em; margin-top: 4px; }
.score-tier-label.veryhigh { color: var(--score-veryhigh); }
.score-tier-label.high { color: var(--score-high); }
.score-tier-label.medium { color: var(--score-medium); }
.score-tier-label.low { color: var(--score-low); }

.score-badge[data-tooltip] { }
.score-badge .tooltip-box {
  position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%);
  width: 220px; background: #1a1c25; color: #fff; font-size: 11.5px; font-weight: 500;
  padding: 9px 11px; border-radius: 8px; line-height: 1.4;
  opacity: 0; pointer-events: none; transition: opacity 0.15s; z-index: 50;
  box-shadow: var(--shadow-md);
}
.score-badge:hover .tooltip-box { opacity: 1; }

.pill-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.03em;
  padding: 3px 9px; border-radius: 20px;
}
.pill-badge.veryhigh { background: var(--score-veryhigh-bg); color: var(--score-veryhigh); }
.pill-badge.high { background: var(--score-high-bg); color: var(--score-high); }
.pill-badge.medium { background: var(--score-medium-bg); color: var(--score-medium); }
.pill-badge.low { background: var(--score-low-bg); color: var(--score-low); }

/* status badge */
.status-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 20px; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-new { background: #eef2ff; color: #3651d4; }
.status-new::before { background: #3651d4; }
.status-pending { background: #fef3e2; color: #b8720c; }
.status-pending::before { background: #b8720c; }
.status-contacted { background: #e6f4fb; color: #0284c7; }
.status-contacted::before { background: #0284c7; }
.status-interested { background: #e9f8ee; color: #16a34a; }
.status-interested::before { background: #16a34a; }
.status-followup { background: #fdf1de; color: #c2610a; }
.status-followup::before { background: #c2610a; }
.status-notinterested { background: #f1f2f5; color: #6b7280; }
.status-notinterested::before { background: #6b7280; }
.status-converted { background: #ecfdf5; color: #059669; }
.status-converted::before { background: #059669; }

/* ============ OPPORTUNITY CARD (dashboard) ============ */
.opp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.opp-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow 0.15s, transform 0.15s; box-shadow: var(--shadow-xs);
}
.opp-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.opp-card-top { display: flex; justify-content: space-between; gap: 10px; }
.opp-card-name { font-weight: 700; font-size: 15px; line-height: 1.3; }
.opp-card-sector { color: var(--text-secondary); font-size: 12.5px; margin-top: 2px; }
.opp-meta-row { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12.5px; color: var(--text-secondary); }
.opp-meta-row span { display: flex; align-items: center; gap: 5px; }
.opp-meta-row i { color: var(--text-tertiary); font-size: 11.5px; }
.opp-reason { background: var(--brand-light); border-radius: 9px; padding: 9px 11px; font-size: 12px; color: #3547b0; line-height: 1.45; display: flex; gap: 7px; }
.opp-reason i { color: var(--brand); margin-top: 1px; flex-shrink: 0; }
.opp-card-actions { display: flex; gap: 8px; margin-top: auto; }

/* ============ VISIT BANNER ============ */
.visit-banner {
  background: linear-gradient(120deg, #10193f 0%, #1a2b6b 55%, #2451ff 130%);
  border-radius: var(--radius-xl);
  padding: 26px 28px;
  color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px; flex-wrap: wrap;
  position: relative; overflow: hidden;
}
.visit-banner::after {
  content: ''; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(255,255,255,0.14), transparent 70%);
}
.visit-banner-left { max-width: 560px; position: relative; z-index: 1; }
.visit-tag { display: inline-flex; align-items: center; gap: 6px; background: rgba(255,255,255,0.14); border-radius: 20px; padding: 4px 11px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.02em; margin-bottom: 12px; }
.visit-banner h3 { font-size: 19px; font-weight: 700; margin-bottom: 6px; line-height: 1.4; }
.visit-banner .visit-client { font-weight: 800; }
.visit-highlight { font-size: 15px; font-weight: 600; margin-top: 10px; background: rgba(255,255,255,0.12); display: inline-block; padding: 8px 14px; border-radius: 10px; }
.visit-banner-right { position: relative; z-index: 1; flex-shrink: 0; }

/* ============ FILTERS BAR ============ */
.filters-bar { display: flex; flex-direction: column; gap: 14px; margin-bottom: 20px; }
.search-row { display: flex; gap: 10px; }
.search-input-wrap { flex: 1; display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 15px; }
.search-input-wrap i { color: var(--text-tertiary); }
.search-input-wrap input { flex: 1; border: none; outline: none; background: none; }
.filter-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.filter-select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 9px;
  padding: 9px 12px; font-size: 12.5px; font-weight: 500; color: var(--text-primary);
  outline: none; cursor: pointer;
}
.filter-select:hover { border-color: #ccd1dc; }
.chips-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--brand-light); color: var(--brand-dark);
  border-radius: 20px; padding: 5px 6px 5px 12px; font-size: 12px; font-weight: 600;
}
.chip button { background: rgba(255,255,255,0.6); border: none; width: 18px; height: 18px; border-radius: 50%; color: var(--brand-dark); display: flex; align-items: center; justify-content: center; font-size: 10px; }
.chip button:hover { background: #fff; }
.chip-clear { background: none; color: var(--text-tertiary); font-size: 12px; font-weight: 600; padding: 5px 4px; }
.chip-clear:hover { color: var(--danger); }

.results-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.results-count { font-weight: 700; font-size: 15px; }
.results-count span { color: var(--brand); }
.sort-row { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-secondary); }

/* ============ COMPANY LIST ROW ============ */
.company-list { display: flex; flex-direction: column; gap: 12px; }
.company-row {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; display: flex; gap: 18px; align-items: center;
  transition: box-shadow 0.15s, transform 0.15s;
}
.company-row:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.company-row-main { flex: 1; min-width: 0; }
.company-row-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.company-name { font-weight: 700; font-size: 15.5px; }
.company-desc { color: var(--text-secondary); font-size: 12.5px; margin: 4px 0 10px; line-height: 1.4; }
.company-meta { display: flex; flex-wrap: wrap; gap: 16px; font-size: 12.5px; color: var(--text-secondary); margin-bottom: 10px; }
.company-meta span { display: flex; align-items: center; gap: 6px; }
.company-meta i { color: var(--text-tertiary); width: 13px; text-align: center; }
.worked-tag { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: #b8720c; background: #fef3e2; padding: 3px 9px; border-radius: 20px; font-weight: 600; }
.company-row-side { display: flex; flex-direction: column; align-items: center; gap: 10px; flex-shrink: 0; }
.company-row-actions { display: flex; gap: 8px; flex-shrink: 0; }
.company-row-actions .btn { white-space: nowrap; }

/* ============ EMPTY STATE ============ */
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 60px 20px; color: var(--text-secondary); }
.empty-state i { font-size: 34px; color: var(--text-tertiary); margin-bottom: 14px; }
.empty-state h4 { font-size: 15px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 340px; }

/* ============ SKELETON ============ */
.skeleton { background: linear-gradient(90deg, #eceef3 25%, #f5f6f9 37%, #eceef3 63%); background-size: 400% 100%; animation: skeleton-loading 1.4s ease infinite; border-radius: 8px; }
@keyframes skeleton-loading { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.skeleton-row { height: 100px; border-radius: var(--radius-lg); margin-bottom: 12px; }

/* ============ TOAST ============ */
.toast-container { position: fixed; bottom: 22px; right: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast {
  background: #1a1c25; color: #fff; padding: 12px 16px; border-radius: 10px;
  font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 9px;
  box-shadow: var(--shadow-lg); animation: toast-in 0.25s ease;
  max-width: 320px;
}
.toast i { color: var(--score-veryhigh); }
.toast.error i { color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.hide { animation: toast-out 0.2s ease forwards; }
@keyframes toast-out { to { opacity: 0; transform: translateY(6px); } }

/* ============ MAP ============ */
.map-layout { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
#map-canvas { height: 640px; border-radius: var(--radius-lg); border: 1px solid var(--border); box-shadow: var(--shadow-xs); z-index: 0; }
.map-controls-card { display: flex; flex-direction: column; gap: 16px; }
.radius-options { display: flex; gap: 6px; flex-wrap: wrap; }
.radius-btn { border: 1px solid var(--border); background: var(--surface); padding: 7px 12px; border-radius: 20px; font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.radius-btn:hover { border-color: var(--brand); color: var(--brand); }
.radius-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.map-legend { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.map-legend-item { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); }
.legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend-dot.veryhigh { background: var(--score-veryhigh); }
.legend-dot.high { background: var(--score-high); }
.legend-dot.medium { background: var(--score-medium); }
.legend-dot.low { background: var(--score-low); }
.legend-dot.client { background: #12141c; }
.map-popup-card { min-width: 220px; }
.map-popup-card h4 { font-size: 13.5px; margin-bottom: 6px; }
.map-popup-meta { font-size: 11.5px; color: var(--text-secondary); display: flex; flex-direction: column; gap: 3px; margin-bottom: 8px; }
.leaflet-popup-content-wrapper { border-radius: 12px; }

.near-search-card { display: flex; flex-direction: column; gap: 12px; }
.near-search-row { display: flex; flex-direction: column; gap: 8px; }
.near-search-row label { font-size: 11.5px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.03em; }
.near-search-input { border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13px; background: var(--surface-2); }
.ai-note-box { background: var(--brand-light); border-radius: 10px; padding: 11px 13px; font-size: 12px; color: #3547b0; line-height: 1.45; display: flex; gap: 8px; }
.ai-note-box i { color: var(--brand); margin-top: 1px; }

/* ============ COMPANY DETAIL ============ */
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.back-link { display: inline-flex; align-items: center; gap: 7px; color: var(--text-secondary); font-size: 12.5px; font-weight: 600; margin-bottom: 14px; }
.back-link:hover { color: var(--brand); }
.detail-title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.detail-title { font-size: 24px; font-weight: 800; }
.detail-layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.info-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 24px; }
.info-item label { display: block; font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 5px; }
.info-item .info-value { font-size: 14.5px; font-weight: 600; }
.info-item .info-value.link { color: var(--brand); }

.ai-reason-card { background: linear-gradient(135deg, #f4f6ff, #eef2ff); border: 1px solid var(--brand-soft); border-radius: var(--radius-lg); padding: 20px; }
.ai-reason-top { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ai-avatar { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.ai-reason-name { font-weight: 700; font-size: 13.5px; }
.ai-reason-text { font-size: 13.5px; line-height: 1.6; color: #2c3350; margin-bottom: 16px; }
.factor-list { display: flex; flex-direction: column; gap: 12px; }
.factor-item { display: grid; grid-template-columns: 140px 1fr 40px; align-items: center; gap: 10px; font-size: 12.5px; }
.factor-bar-track { height: 7px; border-radius: 6px; background: #e2e6f5; overflow: hidden; }
.factor-bar-fill { height: 100%; border-radius: 6px; background: linear-gradient(90deg, var(--brand), #6a8bff); }
.factor-value { font-weight: 700; text-align: right; }
.final-score-row { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--brand-soft); }
.final-score-label { font-weight: 700; font-size: 13.5px; }
.final-score-num { font-size: 22px; font-weight: 800; color: var(--brand-dark); }

.contact-card { display: flex; align-items: flex-start; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border-soft); }
.contact-card:last-child { border-bottom: none; }
.contact-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--brand-light); color: var(--brand-dark); font-weight: 700; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.contact-name { font-weight: 700; font-size: 13.5px; }
.contact-role { color: var(--text-secondary); font-size: 12px; margin: 2px 0 4px; }
.contact-email { font-size: 12px; color: var(--brand); }

.crm-field { margin-bottom: 16px; }
.crm-field label { display: block; font-size: 11px; font-weight: 700; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.03em; margin-bottom: 7px; }
.crm-select { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13.5px; font-weight: 600; background: var(--surface-2); outline: none; }
.assignee-row { display: flex; align-items: center; gap: 9px; padding: 10px 12px; background: var(--surface-2); border-radius: 9px; border: 1px solid var(--border); }
.activity-type-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.activity-type-btn { border: 1px solid var(--border); background: var(--surface); padding: 6px 11px; border-radius: 20px; font-size: 11.5px; font-weight: 600; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.activity-type-btn:hover { border-color: var(--brand); color: var(--brand); }
.activity-type-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.note-textarea { width: 100%; border: 1px solid var(--border); border-radius: 9px; padding: 10px 12px; font-size: 13px; resize: vertical; min-height: 64px; outline: none; margin-bottom: 10px; }
.note-textarea:focus { border-color: var(--brand); }

.timeline { display: flex; flex-direction: column; gap: 0; margin-top: 16px; }
.timeline-item { display: flex; gap: 12px; position: relative; padding-bottom: 18px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot-col { display: flex; flex-direction: column; align-items: center; }
.timeline-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex-shrink: 0; }
.timeline-line { flex: 1; width: 1.5px; background: var(--border); margin-top: 4px; }
.timeline-item:last-child .timeline-line { display: none; }
.timeline-content { flex: 1; }
.timeline-meta { font-size: 11.5px; color: var(--text-tertiary); font-weight: 600; margin-bottom: 3px; }
.timeline-text { font-size: 13px; color: var(--text-primary); line-height: 1.5; }

/* ============ KANBAN ============ */
.view-toggle { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.view-toggle button { border: none; background: none; padding: 7px 13px; font-size: 12.5px; font-weight: 600; border-radius: 7px; color: var(--text-secondary); display: flex; align-items: center; gap: 6px; }
.view-toggle button.active { background: var(--surface); color: var(--text-primary); box-shadow: var(--shadow-xs); }

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.kanban-col { background: var(--surface-2); border-radius: var(--radius-lg); padding: 12px; width: 260px; flex-shrink: 0; min-height: 200px; border: 1px solid var(--border-soft); }
.kanban-col-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 6px 12px; }
.kanban-col-title { font-size: 12px; font-weight: 800; letter-spacing: 0.03em; color: var(--text-secondary); text-transform: uppercase; }
.kanban-col-count { font-size: 11.5px; font-weight: 700; background: var(--surface); border-radius: 20px; padding: 1px 8px; color: var(--text-tertiary); }
.kanban-cards { display: flex; flex-direction: column; gap: 10px; min-height: 60px; }
.kanban-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px;
  cursor: grab; box-shadow: var(--shadow-xs); transition: box-shadow 0.15s, transform 0.15s;
}
.kanban-card:hover { box-shadow: var(--shadow-sm); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-name { font-weight: 700; font-size: 13px; margin-bottom: 5px; }
.kanban-card-meta { font-size: 11.5px; color: var(--text-secondary); display: flex; justify-content: space-between; align-items: center; }
.kanban-col.drag-over { background: var(--brand-light); }

/* ============ ASSISTANT ============ */
.assistant-layout { display: flex; flex-direction: column; height: calc(100vh - 155px); }
.assistant-body { flex: 1; overflow-y: auto; padding: 6px 4px 20px; display: flex; flex-direction: column; gap: 18px; }
.chat-msg { display: flex; gap: 12px; max-width: 780px; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
.chat-avatar { width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.chat-avatar.ai { background: linear-gradient(135deg, var(--brand), var(--brand-dark)); color: #fff; }
.chat-avatar.user { background: var(--brand-soft); color: var(--brand-dark); }
.chat-bubble-col { display: flex; flex-direction: column; gap: 8px; }
.chat-name { font-size: 11.5px; font-weight: 700; color: var(--text-tertiary); margin-bottom: 3px; }
.chat-msg.user .chat-bubble-col { align-items: flex-end; }
.chat-bubble { padding: 12px 15px; border-radius: 14px; font-size: 13.5px; line-height: 1.55; }
.chat-msg.ai .chat-bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; }
.chat-msg.user .chat-bubble { background: var(--brand); color: #fff; border-top-right-radius: 4px; }
.chat-thinking { display: flex; flex-direction: column; gap: 7px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 15px; font-size: 12.5px; color: var(--text-secondary); }
.chat-thinking-step { display: flex; align-items: center; gap: 8px; opacity: 0.4; transition: opacity 0.2s; }
.chat-thinking-step.active { opacity: 1; color: var(--text-primary); font-weight: 600; }
.chat-thinking-step.done { opacity: 0.75; color: var(--score-veryhigh); }
.chat-thinking-step i.fa-circle-check { color: var(--score-veryhigh); }
.chat-thinking-step .spinner { width: 11px; height: 11px; border: 2px solid #d6d9e2; border-top-color: var(--brand); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.mini-company-cards { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 4px; }
.mini-company-card { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; padding: 11px 13px; min-width: 168px; display: flex; flex-direction: column; gap: 6px; }
.mini-company-card:hover { border-color: var(--brand); cursor: pointer; box-shadow: var(--shadow-sm); }
.mini-company-name { font-size: 12.5px; font-weight: 700; }
.mini-company-score { font-size: 20px; font-weight: 800; }

.chat-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.suggestion-chip { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 20px; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.suggestion-chip:hover { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

.assistant-input-row { display: flex; gap: 10px; padding-top: 14px; border-top: 1px solid var(--border); flex-shrink: 0; }
.assistant-input-row input { flex: 1; border: 1px solid var(--border); border-radius: 12px; padding: 13px 16px; font-size: 13.5px; outline: none; }
.assistant-input-row input:focus { border-color: var(--brand); }
.assistant-send-btn { width: 46px; height: 46px; border-radius: 12px; background: var(--brand); color: #fff; border: none; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.assistant-send-btn:hover { background: var(--brand-dark); }

/* ============ ICP ============ */
.icp-layout { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start; }
.checkbox-list { display: flex; flex-direction: column; gap: 4px; }
.checkbox-row { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-radius: 8px; font-size: 13.5px; font-weight: 500; }
.checkbox-row:hover { background: var(--surface-2); }
.checkbox-row input { width: 17px; height: 17px; accent-color: var(--brand); cursor: pointer; }
.range-row { margin-bottom: 18px; }
.range-row label { display: flex; justify-content: space-between; font-size: 12.5px; font-weight: 600; margin-bottom: 8px; color: var(--text-secondary); }
.range-row label b { color: var(--text-primary); }
.range-row input[type=range] { width: 100%; accent-color: var(--brand); }
.dual-range { display: flex; gap: 12px; align-items: center; }
.dual-range input[type=number] { width: 90px; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.weight-row { display: grid; grid-template-columns: 160px 1fr 46px; align-items: center; gap: 12px; margin-bottom: 16px; }
.weight-row label { font-size: 13px; font-weight: 600; }
.weight-row input[type=range] { accent-color: var(--brand); }
.weight-total-row { display: flex; justify-content: space-between; align-items: center; padding-top: 14px; border-top: 1px solid var(--border); font-weight: 700; font-size: 14px; }
.weight-total-row span#weight-total-value { color: var(--brand); }

/* ============ ACTIVITY ============ */
.activity-feed { display: flex; flex-direction: column; }
.activity-row { display: flex; gap: 14px; padding: 15px 0; border-bottom: 1px solid var(--border-soft); }
.activity-row:last-child { border-bottom: none; }
.activity-icon { width: 34px; height: 34px; border-radius: 9px; background: var(--brand-light); color: var(--brand); display: flex; align-items: center; justify-content: center; font-size: 13px; flex-shrink: 0; }
.activity-text { font-size: 13.5px; line-height: 1.5; }
.activity-when { font-size: 11.5px; color: var(--text-tertiary); margin-top: 3px; }

/* ============ USERS ============ */
.users-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.user-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; text-align: center; }
.user-card .user-avatar { width: 54px; height: 54px; font-size: 18px; margin: 0 auto 12px; }
.user-card h4 { font-size: 14.5px; font-weight: 700; margin-bottom: 3px; }
.user-card p { font-size: 12.5px; color: var(--text-secondary); }
.user-card .badge-current { display: inline-block; margin-top: 10px; font-size: 10.5px; font-weight: 700; background: var(--brand-light); color: var(--brand-dark); padding: 3px 10px; border-radius: 20px; }
.user-card .user-stat-row { display: flex; justify-content: center; gap: 18px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.user-card .user-stat { display: flex; flex-direction: column; }
.user-card .user-stat b { font-size: 16px; font-weight: 800; }
.user-card .user-stat span { font-size: 10.5px; color: var(--text-tertiary); text-transform: uppercase; font-weight: 600; }

/* ============ SETTINGS ============ */
.settings-list { display: flex; flex-direction: column; }
.settings-row { display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--border-soft); gap: 16px; }
.settings-row:last-child { border-bottom: none; }
.settings-row-label { font-weight: 600; font-size: 13.5px; }
.settings-row-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.toggle-switch { width: 42px; height: 24px; border-radius: 20px; background: var(--border); position: relative; flex-shrink: 0; border: none; cursor: pointer; transition: background 0.2s; }
.toggle-switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s; box-shadow: var(--shadow-xs); }
.toggle-switch.on { background: var(--brand); }
.toggle-switch.on::after { transform: translateX(18px); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1100px) {
  .detail-layout { grid-template-columns: 1fr; }
  .icp-layout { grid-template-columns: 1fr; }
  .map-layout { grid-template-columns: 1fr; }
  #map-canvas { height: 420px; }
}

@media (max-width: 860px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .info-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .sidebar { position: fixed; left: -100%; top: 0; height: 100vh; transition: left 0.25s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .sidebar-close { display: block; }
  .sidebar-overlay.show { display: block; }
  .mobile-only { display: flex; }
  .app-content { padding: 18px 14px 90px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 24px; }
  .topbar-search { display: none; }
  .company-row { flex-direction: column; align-items: stretch; }
  .company-row-side { flex-direction: row; justify-content: space-between; width: 100%; }
  .company-row-actions { flex-direction: column; width: 100%; }
  .opp-grid { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .assistant-layout { height: calc(100vh - 220px); }
  .chat-msg { max-width: 92%; }
  .detail-title { font-size: 19px; }
  .weight-row { grid-template-columns: 1fr; gap: 4px; }
  .factor-item { grid-template-columns: 100px 1fr 34px; }
  .users-grid { grid-template-columns: 1fr 1fr; }
  .visit-banner { flex-direction: column; align-items: flex-start; }
  .kanban-board { padding-bottom: 4px; }
}

@media (max-width: 480px) {
  .users-grid { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}
