:root {
  --neutral-50: #f8fafc;
  --neutral-100: #f1f5f9;
  --neutral-200: #e2e8f0;
  --neutral-400: #94a3b8;
  --neutral-500: #64748b;
  --neutral-700: #334155;
  --neutral-900: #0f172a;

  /* Color SOLO comunica estado — nada más lleva color */
  --status-ok-bg: #ecfdf5;
  --status-ok-fg: #047857;
  --status-warn-bg: #fffbeb;
  --status-warn-fg: #b45309;
  --status-bad-bg: #fff1f2;
  --status-bad-fg: #be123c;
  --status-neutral-bg: #f1f5f9;
  --status-neutral-fg: #475569;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--neutral-900);
  background: #fff;
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; }

.transition { transition: all 150ms ease; }

/* ---------- Header ---------- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--neutral-100);
}
.search-box { position: relative; width: 100%; max-width: 340px; }
.search-box input {
  width: 100%;
  padding: 0.4rem 0.6rem 0.4rem 2rem;
  border: 1px solid var(--neutral-200);
  border-radius: 6px;
  font-size: 0.85rem;
}
.search-box svg { position: absolute; left: 0.55rem; top: 0.5rem; width: 16px; height: 16px; color: var(--neutral-400); }
.search-results {
  position: absolute;
  z-index: 30;
  margin-top: 4px;
  width: 100%;
  background: #fff;
  border: 1px solid var(--neutral-100);
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  max-height: 260px;
  overflow-y: auto;
}
.search-results button { display: block; width: 100%; text-align: left; padding: 0.5rem 0.75rem; }
.search-results button:hover { background: var(--neutral-50); }
.search-results .sub { display: block; font-size: 0.75rem; color: var(--neutral-400); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
}
.btn-primary { background: var(--neutral-900); color: #fff; }
.btn-secondary { border: 1px solid var(--neutral-200); color: var(--neutral-700); }
.avatar { width: 32px; height: 32px; border-radius: 999px; background: var(--neutral-200); }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; padding: 1rem; }
@media (min-width: 640px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .kpis { grid-template-columns: repeat(5, 1fr); } }
.kpi-card { border: 1px solid var(--neutral-100); border-radius: 8px; padding: 0.75rem; }
.kpi-card .value { font-size: 1.15rem; font-weight: 600; margin: 0.4rem 0 0.1rem; }
.kpi-card .label { font-size: 0.75rem; color: var(--neutral-400); }

/* ---------- Layout dashboard ---------- */
.dashboard-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; padding: 0 1rem 1rem; }
@media (min-width: 1024px) { .dashboard-grid { grid-template-columns: 1fr 2fr 1fr; } }

/* ---------- Filtros ---------- */
.filters { display: flex; flex-direction: column; gap: 1rem; }
.field label { display: block; font-size: 0.72rem; font-weight: 500; color: var(--neutral-500); margin-bottom: 0.25rem; }
.field input, .field select {
  width: 100%; padding: 0.4rem 0.5rem; border: 1px solid var(--neutral-200); border-radius: 6px; font-size: 0.85rem;
}
.field input[type="range"] { padding: 0; }
.btn-clear { width: 100%; border: 1px solid var(--neutral-200); border-radius: 6px; padding: 0.4rem; color: var(--neutral-500); }

/* ---------- Tabla de venues ---------- */
.venue-table-wrap { border: 1px solid var(--neutral-100); border-radius: 8px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
thead { background: var(--neutral-50); text-align: left; font-size: 0.72rem; color: var(--neutral-500); }
th, td { padding: 0.55rem 0.7rem; }
tbody tr { border-top: 1px solid var(--neutral-50); cursor: pointer; }
tbody tr:hover { background: var(--neutral-50); }

.status-badge {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 500;
}
.status-activo { background: var(--status-ok-bg); color: var(--status-ok-fg); }
.status-en_negociacion { background: var(--status-warn-bg); color: var(--status-warn-fg); }
.status-prospecto, .status-inactivo { background: var(--status-neutral-bg); color: var(--status-neutral-fg); }
.status-descartado { background: var(--status-bad-bg); color: var(--status-bad-fg); }

.pagination { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.7rem; border-top: 1px solid var(--neutral-100); font-size: 0.75rem; color: var(--neutral-400); }
.pagination button:disabled { opacity: 0.3; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: 0.5rem; padding: 3rem 1rem; text-align: center; }
.empty-state svg { width: 32px; height: 32px; color: var(--neutral-200); }
.empty-state .title { font-weight: 500; }
.empty-state .desc { max-width: 260px; color: var(--neutral-400); }

/* mobile cards para tabla de venues */
.venue-cards { display: none; }
.venue-card { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem; border-top: 1px solid var(--neutral-50); cursor: pointer; }
.venue-card .name { font-weight: 500; }
.venue-card .meta { font-size: 0.75rem; color: var(--neutral-400); }
@media (max-width: 767px) {
  .venue-table-wrap table { display: none; }
  .venue-cards { display: block; }
}

/* ---------- Mapa ---------- */
#map { height: 320px; border-radius: 8px; }
@media (min-width: 1024px) { #map { height: 100%; } }
.leaflet-popup-content { font-size: 0.85rem; }
.popup-link { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.3rem; font-weight: 500; }

/* ---------- Ficha de venue ---------- */
.detail-header { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--neutral-100); }
.back-btn { padding: 0.25rem; border-radius: 6px; }
.back-btn:hover { background: var(--neutral-100); }
.detail-header h1 { font-size: 1.05rem; margin: 0; }

.tabs { display: flex; gap: 0.25rem; overflow-x: auto; border-bottom: 1px solid var(--neutral-100); padding: 0 1rem; }
.tab {
  white-space: nowrap; padding: 0.6rem 0.75rem; font-size: 0.85rem; font-weight: 500;
  color: var(--neutral-400); border-bottom: 2px solid transparent;
}
.tab.active { color: var(--neutral-900); border-color: var(--neutral-900); }

.tab-content { padding: 1rem; }

.info-grid { display: grid; grid-template-columns: 1fr; gap: 1.5rem; }
@media (min-width: 1024px) { .info-grid { grid-template-columns: 1fr 1fr; } }
.campo { margin-bottom: 1rem; }
.campo label { display: block; font-size: 0.72rem; font-weight: 500; color: var(--neutral-500); margin-bottom: 0.2rem; }
.campo .valor { font-size: 0.9rem; }
.notas-box { background: var(--neutral-50); border: 1px solid var(--neutral-100); border-radius: 6px; padding: 0.75rem; font-size: 0.85rem; color: var(--neutral-700); }

/* Contactos / lists */
.list { border: 1px solid var(--neutral-100); border-radius: 8px; }
.list li { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 0.6rem 0.75rem; border-top: 1px solid var(--neutral-50); }
.list li:first-child { border-top: none; }
.list ul { margin: 0; padding: 0; }
.contacto-actions { display: flex; gap: 0.6rem; color: var(--neutral-400); }
.contacto-actions svg { width: 16px; height: 16px; }
.contacto-actions a:hover svg, .contacto-actions button:hover svg { color: var(--neutral-700); }

.top-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-bottom: 0.75rem; }

/* Modalidades timeline */
.modalidad-item { border-radius: 8px; border: 1px solid var(--neutral-100); padding: 0.75rem; margin-bottom: 0.75rem; }
.modalidad-item.vigente { border-color: #a7f3d0; background: #ecfdf520; }
.modalidad-item.cerrada { opacity: 0.6; }
.modalidad-item .top-row { display: flex; justify-content: space-between; font-size: 0.85rem; }
.modalidad-item .grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.4rem; font-size: 0.75rem; color: var(--neutral-500); margin-top: 0.5rem; }
@media (min-width: 640px) { .modalidad-item .grid { grid-template-columns: repeat(4, 1fr); } }

/* Seguimientos timeline */
.timeline { position: relative; border-left: 1px solid var(--neutral-100); padding-left: 1rem; margin: 0; }
.timeline li { list-style: none; position: relative; margin-bottom: 1rem; }
.timeline .dot { position: absolute; left: -1.31rem; top: 0.25rem; width: 10px; height: 10px; border-radius: 999px; }
.timeline .meta-row { display: flex; justify-content: space-between; font-size: 0.72rem; color: var(--neutral-400); }
.pill-pendiente { background: var(--status-warn-bg); color: var(--status-warn-fg); padding: 0.05rem 0.5rem; border-radius: 999px; }

/* Drawer (vista lateral, nunca modal centrado) */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.2);
  opacity: 0; pointer-events: none; transition: opacity 150ms ease; z-index: 40;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; right: 0; top: 0; height: 100%; width: 100%; max-width: 380px;
  background: #fff; box-shadow: -8px 0 24px rgba(0,0,0,.12);
  transform: translateX(100%); transition: transform 150ms ease; z-index: 41;
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer-header { display: flex; justify-content: space-between; align-items: center; padding: 0.75rem 1rem; border-bottom: 1px solid var(--neutral-100); }
.drawer-header h2 { font-size: 0.9rem; margin: 0; }
.drawer-body { padding: 1rem; overflow-y: auto; flex: 1; }

.form-field { margin-bottom: 0.75rem; }
.form-field label { display: block; font-size: 0.72rem; font-weight: 500; color: var(--neutral-500); margin-bottom: 0.25rem; }
.form-field input, .form-field select, .form-field textarea {
  width: 100%; padding: 0.4rem 0.5rem; border: 1px solid var(--neutral-200); border-radius: 6px; font-size: 0.85rem; font-family: inherit;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.form-check { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--neutral-700); }
.form-submit { width: 100%; background: var(--neutral-900); color: #fff; padding: 0.5rem; border-radius: 6px; font-weight: 500; margin-top: 0.5rem; }
.form-hint { font-size: 0.72rem; color: var(--neutral-400); margin-bottom: 0.5rem; }
