:root {
  --navy: #0B2545;
  --navy-2: #143263;
  --gold: #C9A227;
  --gold-2: #E0B83A;
  --gain: #067647;
  --loss: #B42318;
  --gray-bg: #F2F4F7;
  --gray-line: #E4E7EC;
  --text: #1d2939;
  --muted: #667085;

  /* Glassmorphism tokens */
  --glass-bg: rgba(255, 255, 255, 0.62);
  --glass-bg-strong: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-shadow: 0 10px 40px -10px rgba(11, 37, 69, 0.25),
                  0 2px 6px -2px rgba(11, 37, 69, 0.08);
  --glass-blur: 22px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text); font-size: 14px; min-height: 100vh;
}

/* Fondo animado con orbes (glassmorphism 2026) */
body {
  background:
    radial-gradient(900px 700px at 8% 4%, rgba(99, 132, 255, 0.32), transparent 60%),
    radial-gradient(800px 600px at 95% 12%, rgba(201, 162, 39, 0.22), transparent 60%),
    radial-gradient(900px 700px at 50% 100%, rgba(20, 50, 99, 0.30), transparent 60%),
    linear-gradient(180deg, #eef2ff 0%, #f5f7fb 40%, #eaf0fb 100%);
  background-attachment: fixed;
}

/* ---------- Topbar (vidrio navy) ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  margin: 16px 18px 0; padding: 14px 22px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap;
  background: linear-gradient(135deg, rgba(11,37,69,0.85), rgba(20,50,99,0.78));
  color: #fff;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
  box-shadow: 0 12px 36px -10px rgba(11,37,69,0.45),
              inset 0 1px 0 rgba(255,255,255,0.10);
  overflow: hidden;
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 40%, var(--gold-2) 60%, transparent);
  opacity: 0.85;
}
.topbar { position: relative; }
.topbar .brand strong { font-size: 18px; letter-spacing: .2px; }
.topbar .brand .muted { margin-left: 12px; opacity: .8; font-size: 12px; color: rgba(255,255,255,.78); }
.topbar .actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ---------- Panel (tarjeta de vidrio) ---------- */
.panel {
  margin: 18px; padding: 20px 24px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(160%);
  box-shadow: var(--glass-shadow);
}
.panel h3 { margin: 0 0 14px; color: var(--navy); font-size: 15px; letter-spacing: .2px; }

/* ---------- Forms ---------- */
.search-form .row, .filters {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: end;
  margin-bottom: 10px;
}
.filters input, .filters select { padding: 9px 11px; }
label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
label.check { flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
label.grow { flex: 1; min-width: 280px; }

input, select, textarea {
  padding: 9px 12px;
  border: 1px solid rgba(255,255,255,0.55);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: rgba(255,255,255,0.65);
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
  backdrop-filter: blur(8px);
}
input:focus, select:focus, textarea:focus {
  border-color: rgba(20, 50, 99, 0.55);
  box-shadow: 0 0 0 4px rgba(20, 50, 99, 0.10);
  background: rgba(255,255,255,0.92);
}

/* ---------- Botones ---------- */
.btn {
  padding: 9px 16px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.55);
  background: rgba(255,255,255,0.70);
  color: var(--text);
  cursor: pointer; font-weight: 600; font-size: 13px;
  backdrop-filter: blur(10px);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease, color .12s ease;
}
.btn:hover {
  transform: translateY(-1px);
  background: rgba(255,255,255,0.95);
  box-shadow: 0 6px 18px -8px rgba(11,37,69,0.35);
}
.btn:active { transform: translateY(0); }

.btn.primary {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 100%);
  color: #fff; border-color: rgba(255,255,255,0.20);
  box-shadow: 0 8px 22px -8px rgba(11,37,69,0.55),
              inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn.primary:hover {
  background: linear-gradient(135deg, #143263 0%, #1B4084 100%);
  box-shadow: 0 12px 28px -8px rgba(11,37,69,0.55);
}

.btn.ghost {
  background: rgba(255,255,255,0.08);
  color: #fff; border-color: rgba(255,255,255,0.28);
}
.btn.ghost:hover {
  background: rgba(255,255,255,0.20);
  color: #fff;
  box-shadow: 0 6px 18px -8px rgba(0,0,0,0.35);
}

.btn.gold {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-2) 100%);
  color: #2a1d00; border-color: rgba(255,255,255,0.30);
  box-shadow: 0 8px 22px -8px rgba(201,162,39,0.55),
              inset 0 1px 0 rgba(255,255,255,0.40);
}
.btn.gold:hover { filter: brightness(1.05); }

.btn.small { padding: 6px 12px; font-size: 12px; }
.btn.icon-only {
  padding: 6px 8px;
  font-size: 16px;
  line-height: 1;
  background: transparent;
  border: 1px solid rgba(11, 37, 69, 0.12);
  color: var(--navy);
  min-width: 0;
}
.btn.icon-only:hover {
  background: rgba(11, 37, 69, 0.06);
  border-color: rgba(11, 37, 69, 0.25);
}

/* ---------- Tabla ---------- */
table.prospects {
  width: 100%; border-collapse: separate; border-spacing: 0; margin-top: 8px;
  background: rgba(255,255,255,0.45);
  border-radius: var(--radius-md);
  overflow: hidden;
}
table.prospects th, table.prospects td {
  border-bottom: 1px solid rgba(228,231,236,0.7);
  padding: 12px 10px; text-align: left; vertical-align: top;
}
table.prospects thead th {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  color: #fff; font-weight: 600; font-size: 12px; letter-spacing: .3px;
  text-transform: uppercase;
}
table.prospects thead th a.sort-link {
  color: #fff; text-decoration: none; cursor: pointer; display: inline-block;
}
table.prospects thead th a.sort-link:hover { text-decoration: underline; }
table.prospects thead th a.sort-link.active::after { color: var(--gold-2); }
table.prospects tbody tr { transition: background .12s ease; }
table.prospects tbody tr:hover { background: rgba(99, 132, 255, 0.06); }
.company strong { display: block; color: var(--navy); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.empty { text-align: center; color: var(--muted); padding: 40px !important; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 11px;
  background: rgba(242,244,247,0.85); color: var(--text); font-weight: 600;
  border: 1px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(6px);
}
.badge.sector-GWO { background: #DBEAFE; color: #1E40AF; }
.badge.sector-IRATA { background: #FCE7F3; color: #9D174D; }
.badge.sector-AELEC { background: #FEF3C7; color: #92400E; }
.badge.sector-PRL { background: #DCFCE7; color: #166534; }
.badge.sector-CONSTRUCCION { background: #E0E7FF; color: #3730A3; }
.badge.status-new { background: var(--gray-bg); }
.badge.status-contacted { background: #FEF3C7; color: #92400E; }
.badge.status-qualified { background: #DBEAFE; color: #1E40AF; }
.badge.status-proposal { background: #E0E7FF; color: #3730A3; }
.badge.status-won { background: #DCFCE7; color: #166534; }
.badge.status-lost { background: #FEE2E2; color: #991B1B; }
.badge.known-yes { background: #DCFCE7; color: #166534; }

.ok-banner {
  background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(16,185,129,0.08));
  border-left: 4px solid #10B981; padding: 14px 18px;
  color: #065F46;
}
.error-banner {
  background: linear-gradient(135deg, rgba(239,68,68,0.18), rgba(239,68,68,0.08));
  border-left: 4px solid #EF4444; padding: 14px 18px; color: #7f1d1d;
}

.score {
  display: inline-block; min-width: 36px; padding: 5px 10px; border-radius: 8px;
  font-weight: 700; text-align: center; color: white;
  box-shadow: 0 4px 10px -4px rgba(0,0,0,0.25);
}
.score.s0 { background: #9CA3AF; }
.score.s1 { background: #F59E0B; }
.score.s2 { background: #EAB308; }
.score.s3 { background: #65A30D; }
.score.s4, .score.s5 { background: var(--gain); }

.row-actions { white-space: nowrap; }
.row-actions .btn { margin-right: 4px; }
.contact-cell div { line-height: 1.5; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0;
  background: rgba(11,37,69,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-start; justify-content: center; z-index: 50;
  padding: 5vh 20px; overflow-y: auto;
  animation: fadeIn .18s ease;
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  max-width: 880px; width: 100%;
  padding: 30px; position: relative;
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  box-shadow: 0 30px 80px -20px rgba(11,37,69,0.45),
              inset 0 1px 0 rgba(255,255,255,0.55);
  animation: slideUp .25s cubic-bezier(.16,1,.3,1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.modal-content .close {
  position: absolute; top: 14px; right: 16px; background: transparent;
  border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1;
}
.modal-content .close:hover { color: var(--navy); }
.detail h2, .detail h3 { color: var(--navy); margin-top: 0; }
.detail .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail .kv { list-style: none; padding: 0; }
.detail .kv li { padding: 4px 0; border-bottom: 1px dashed var(--gray-line); }
.detail .kv b { display: inline-block; min-width: 110px; color: var(--muted); font-weight: 500; }
.ai-summary {
  background: rgba(250,251,255,0.7);
  border-left: 3px solid var(--gold); padding: 14px 18px;
  border-radius: var(--radius-sm); line-height: 1.55; margin: 10px 0;
}
.detail-actions { margin-top: 18px; display: flex; gap: 10px; }
.spinner { padding: 30px; text-align: center; color: var(--muted); }
.error { color: var(--loss); padding: 14px; }
.ok { color: var(--gain); margin-left: 8px; }

/* ---------- Stats panel ---------- */
.stats-panel { padding: 16px 18px; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}
.stat-card {
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius-md);
  padding: 14px 16px; text-align: center;
  backdrop-filter: blur(10px);
  transition: transform .15s ease, box-shadow .15s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px -10px rgba(11,37,69,0.30);
}
.stat-value {
  font-size: 28px; font-weight: 700; color: var(--navy); line-height: 1.1;
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.stat-value .stat-sub {
  font-size: 13px; color: var(--muted); font-weight: 500;
  -webkit-text-fill-color: var(--muted);
}
.stat-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stats-sectors { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---------- Roadmap modal ---------- */
.roadmap h2 {
  margin: 0 0 6px; color: var(--navy);
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.roadmap .subtitle { color: var(--muted); margin-bottom: 22px; font-size: 13px; }
.roadmap ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.roadmap li {
  display: flex; gap: 14px; align-items: flex-start;
  background: rgba(255,255,255,0.55);
  border: 1px solid rgba(255,255,255,0.65);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  backdrop-filter: blur(10px);
}
.roadmap .rico { font-size: 22px; line-height: 1; }
.roadmap .rtitle { font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.roadmap .rdesc { color: var(--text); font-size: 13px; line-height: 1.5; }
.roadmap .rtag {
  display: inline-block; margin-left: 8px; vertical-align: middle;
  font-size: 10px; font-weight: 700; letter-spacing: .5px;
  padding: 3px 8px; border-radius: 999px;
}
.roadmap .rtag.pending { background: #FEF3C7; color: #92400E; }
.roadmap .rtag.planning { background: #DBEAFE; color: #1E40AF; }
.roadmap .rtag.idea { background: #E0E7FF; color: #3730A3; }
.roadmap-footnote {
  margin-top: 20px; padding-top: 14px; border-top: 1px dashed var(--gray-line);
  color: var(--muted); font-size: 12px;
}
