/* =============================================
   ROOT VARIABLES
   ============================================= */
:root {
  --bg-primary: #080e1c;
  --bg-secondary: #0f1829;
  --bg-card: #111f33;
  --bg-card-hover: #162540;
  --bg-sidebar: #0c1626;
  --bg-modal: #0f1a2e;

  --accent-gold: #c9a84c;
  --accent-gold-light: #e8c97a;
  --accent-gold-dim: rgba(201, 168, 76, 0.12);

  --color-tier1: #c9a84c;
  --color-tier2: #4a9eff;
  --color-tier3: #64748b;

  --color-green: #10b981;
  --color-blue: #3b82f6;
  --color-amber: #f59e0b;
  --color-orange: #f97316;
  --color-red: #ef4444;
  --color-gray: #64748b;

  --text-primary: #e8edf5;
  --text-secondary: #8ea3bf;
  --text-muted: #4d6480;

  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-main: rgba(255, 255, 255, 0.08);
  --border-accent: rgba(201, 168, 76, 0.25);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-modal: 0 20px 80px rgba(0, 0, 0, 0.8);

  --sidebar-w: 260px;
  --header-h: 68px;

  --font: -apple-system, 'Inter', 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Consolas', monospace;
}

/* =============================================
   RESET & BASE
   ============================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 14px; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* =============================================
   HEADER
   ============================================= */
.header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 100;
  gap: 20px;
}

.header-left { display: flex; align-items: center; gap: 16px; }

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  font-size: 24px;
  color: var(--accent-gold);
  line-height: 1;
  opacity: 0.9;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.header-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-top: 1px;
}

.header-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-md);
  padding: 6px 14px;
  min-width: 90px;
}

.stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.stat-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-gold);
  font-variant-numeric: tabular-nums;
  margin-top: 1px;
}

/* =============================================
   LAYOUT
   ============================================= */
.layout {
  display: flex;
  margin-top: var(--header-h);
  min-height: calc(100vh - var(--header-h));
}

/* =============================================
   SIDEBAR
   ============================================= */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-main);
  padding: 20px 16px;
  position: sticky;
  top: var(--header-h);
  height: calc(100vh - var(--header-h));
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-main); border-radius: 4px; }

/* Search */
.search-wrap {
  position: relative;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  padding: 9px 10px 9px 32px;
  outline: none;
  transition: border-color 0.2s;
  font-family: var(--font);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { border-color: var(--accent-gold); }

/* Filter sections */
.filter-section { display: flex; flex-direction: column; gap: 8px; }

.filter-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.filter-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font);
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

.filter-btn.active {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  font-weight: 600;
}

.filter-btn.tier1.active { background: rgba(201,168,76,0.15); border-color: var(--color-tier1); color: var(--color-tier1); }
.filter-btn.tier2.active { background: rgba(74,158,255,0.12); border-color: var(--color-tier2); color: var(--color-tier2); }
.filter-btn.tier3.active { background: rgba(100,116,139,0.15); border-color: var(--color-tier3); color: var(--color-tier3); }

/* AUM Slider */
.aum-slider-wrap { display: flex; flex-direction: column; gap: 6px; }

.aum-slider {
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  background: var(--border-main);
  border-radius: 2px;
  outline: none;
  cursor: pointer;
}

.aum-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-gold);
  cursor: pointer;
  border: 2px solid var(--bg-sidebar);
  box-shadow: 0 0 0 2px var(--accent-gold-dim);
}

.aum-slider-labels {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

#aumSliderVal {
  color: var(--accent-gold);
  font-weight: 600;
}

/* Toggles */
.filter-toggles { display: flex; flex-direction: column; gap: 10px; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  user-select: none;
}

.toggle-label input { display: none; }

.toggle-track {
  width: 30px;
  height: 16px;
  border-radius: 8px;
  background: rgba(255,255,255,0.08);
  border: 1px solid var(--border-main);
  position: relative;
  flex-shrink: 0;
  transition: all 0.2s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.2s;
}

.toggle-label input:checked + .toggle-track {
  background: var(--accent-gold-dim);
  border-color: var(--accent-gold);
}

.toggle-label input:checked + .toggle-track::after {
  left: 16px;
  background: var(--accent-gold);
}

/* Sort */
.sort-select {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 12px;
  padding: 8px 10px;
  outline: none;
  cursor: pointer;
  font-family: var(--font);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%234d6480'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

.sort-select option { background: #1a2a3a; }

/* Reset button */
.reset-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--text-muted);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
  margin-top: auto;
}

.reset-btn:hover {
  border-color: var(--accent-gold);
  color: var(--accent-gold);
}

/* =============================================
   MAIN CONTENT
   ============================================= */
.main {
  flex: 1;
  padding: 20px 24px;
  min-width: 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.results-count {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.legend {
  display: flex;
  align-items: center;
  gap: 14px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.tier-1-dot { background: var(--color-tier1); }
.tier-2-dot { background: var(--color-tier2); }
.tier-3-dot { background: var(--color-tier3); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 14px;
}

.loading-state {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 60px;
  font-size: 13px;
}

.no-results {
  grid-column: 1/-1;
  text-align: center;
  color: var(--text-muted);
  padding: 60px;
  font-size: 13px;
}

/* =============================================
   CARDS
   ============================================= */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-main);
  border-radius: var(--radius-lg);
  padding: 18px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.card.tier-1::before { background: linear-gradient(90deg, var(--color-tier1), transparent); }
.card.tier-2::before { background: linear-gradient(90deg, var(--color-tier2), transparent); }
.card.tier-3::before { background: linear-gradient(90deg, var(--color-tier3), transparent); }

.card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-2px);
  box-shadow: var(--shadow-card);
}

/* Card header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.card-name-wrap { flex: 1; min-width: 0; }

.card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-hq {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.card-badges {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Badges */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 4px;
  white-space: nowrap;
  letter-spacing: 0.02em;
  font-family: var(--font-mono);
}

.badge-tier {
  border: 1px solid transparent;
}

.badge-tier-1 { background: rgba(201,168,76,0.15); color: var(--color-tier1); border-color: rgba(201,168,76,0.3); }
.badge-tier-2 { background: rgba(74,158,255,0.12); color: var(--color-tier2); border-color: rgba(74,158,255,0.25); }
.badge-tier-3 { background: rgba(100,116,139,0.12); color: var(--color-tier3); border-color: rgba(100,116,139,0.25); }

.badge-rating {
  border: 1px solid transparent;
}

.rating-aaa { background: rgba(16,185,129,0.12); color: #10b981; border-color: rgba(16,185,129,0.3); }
.rating-aa  { background: rgba(59,130,246,0.12); color: #60a5fa; border-color: rgba(59,130,246,0.3); }
.rating-a   { background: rgba(245,158,11,0.12); color: #fbbf24; border-color: rgba(245,158,11,0.3); }
.rating-bbb { background: rgba(249,115,22,0.12); color: #fb923c; border-color: rgba(249,115,22,0.3); }
.rating-nr  { background: rgba(100,116,139,0.12); color: var(--color-gray); border-color: rgba(100,116,139,0.2); }

/* Card type strip */
.card-type {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.type-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-gold);
  opacity: 0.6;
}

/* AUM bar */
.aum-section { display: flex; flex-direction: column; gap: 5px; }

.aum-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.aum-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.aum-value {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}

.aum-unit {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 2px;
}

.aum-bar-track {
  height: 3px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}

.aum-bar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.tag {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 3px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  white-space: nowrap;
}

.tag-green { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.2); color: #10b981; }
.tag-blue  { background: rgba(59,130,246,0.08); border-color: rgba(59,130,246,0.2); color: #60a5fa; }
.tag-gold  { background: rgba(201,168,76,0.08); border-color: rgba(201,168,76,0.2); color: var(--accent-gold); }
.tag-red   { background: rgba(239,68,68,0.08); border-color: rgba(239,68,68,0.2); color: #ef4444; }

/* Status badge */
.status-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-active-prospect { background: rgba(16,185,129,0.12); color: #10b981; }
.status-target { background: rgba(201,168,76,0.12); color: var(--accent-gold); }
.status-watch  { background: rgba(100,116,139,0.12); color: var(--color-gray); }
.status-client { background: rgba(59,130,246,0.12); color: #60a5fa; }

/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-modal);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 860px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-modal);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal::-webkit-scrollbar { width: 5px; }
.modal::-webkit-scrollbar-track { background: transparent; }
.modal::-webkit-scrollbar-thumb { background: var(--border-main); border-radius: 4px; }

.modal-close {
  position: sticky;
  top: 16px;
  float: right;
  margin: 16px 16px 0 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-main);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  z-index: 10;
}

.modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.modal-content { padding: 24px 28px 32px; clear: both; }

/* Modal sections */
.modal-hero {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-main);
}

.modal-hero-left { flex: 1; }

.modal-hero-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: 4px;
}

.modal-hero-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.modal-hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.modal-hero-right {
  text-align: right;
  flex-shrink: 0;
}

.modal-aum-big {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-gold);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.modal-aum-unit {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
}

.modal-aum-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  max-width: 200px;
  text-align: right;
  line-height: 1.4;
}

/* Grid layout for modal body */
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.modal-grid-full { grid-column: 1 / -1; }

.modal-section { display: flex; flex-direction: column; gap: 8px; }

.modal-section-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  display: flex;
  align-items: center;
  gap: 6px;
}

.modal-section-title::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--accent-gold);
  border-radius: 1px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  gap: 12px;
}

.info-row:last-child { border-bottom: none; }

.info-key {
  color: var(--text-muted);
  flex-shrink: 0;
}

.info-val {
  color: var(--text-primary);
  text-align: right;
  font-weight: 500;
}

/* Contacts */
.contacts-list { display: flex; flex-direction: column; gap: 10px; }

.contact-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.contact-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-gold-dim);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--accent-gold);
  font-weight: 700;
  flex-shrink: 0;
}

.contact-info { flex: 1; min-width: 0; }

.contact-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.contact-dm-badge {
  font-size: 8px;
  padding: 1px 5px;
  background: rgba(201,168,76,0.12);
  color: var(--accent-gold);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 3px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.contact-role {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.contact-note {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
  font-style: italic;
}

/* Tags list */
.tags-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.modal-tag {
  font-size: 11px;
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border-main);
  color: var(--text-secondary);
}

/* Notes */
.notes-box {
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--border-subtle);
  border-left: 3px solid var(--accent-gold);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Bool indicators */
.bool-yes { color: var(--color-green); font-weight: 600; }
.bool-no  { color: var(--color-gray); }
.bool-partial { color: var(--accent-gold); font-weight: 600; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 900px) {
  .header-stats { display: none; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-main);
  }
  .modal-grid { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .modal-hero { flex-direction: column; }
  .modal-hero-right { text-align: left; }
  .modal-aum-note { text-align: left; }
}
