/* 
   LICIT·LAB — styles.css
   Sistema de temas mediante CSS custom properties + [data-theme].

   Estructura:
     :root              → Tema CLARO (por defecto)
     [data-theme="dark"]→ Overrides para tema OSCURO (aspecto original)
     Resto              → Reglas de layout y componentes (neutras)
 */

/* 
   VARIABLES — TEMA CLARO (por defecto)
 */
:root {
  /* Fondos y superficies — paleta ioonic.es (light) */
  --bg:       #f0f4fa;
  --surface:  #ffffff;
  --surface2: #e8edf7;
  --surface3: #dce3f0;

  /* Bordes */
  --border:    #d1d9ec;
  --border2:   #b8c3df;
  --border-hi: #c2cde8;

  /* Acento principal ioonic — azul eléctrico */
  --lime:        #1d4ed8;
  --lime-rgb:    29,78,216;
  --lime-dim:    rgba(29,78,216,.1);

  /* Naranja ioonic */
  --orange:      #ea580c;
  --orange-dim:  rgba(234,88,12,.1);

  /* Cyan / azul claro */
  --cyan:        #0284c7;
  --cyan-dim:    rgba(2,132,199,.1);

  --red:         #be123c;
  --red-dim:     rgba(190,18,60,.1);

  --amber:       #b45309;
  --amber-dim:   rgba(180,83,9,.1);

  --green:       #15803d;
  --green-dim:   rgba(21,128,61,.1);

  /* Texto */
  --text:  #0b1120;
  --text2: #3d4b6e;
  --text3: #6b7a9e;

  /* Helpers dependientes del tema */
  --lime-btn-fg:       #fff;
  --lime-hover-bg:     #1e40af;
  --lime-hover-shadow: rgba(29,78,216,.22);
  --row-hover-bg:      rgba(29,78,216,.04);
  --overlay-bg:        rgba(11,17,32,.55);
  --scrollbar-thumb:   #bec7df;
  --scrollbar-hover:   #98a5c5;

  --radius: 10px;
}

/* 
   VARIABLES — TEMA OSCURO (aspecto original sin cambios)
 */
[data-theme="dark"] {
  /* Fondos oscuros ioonic — navy profundo */
  --bg:       #060a14;
  --surface:  #0b1120;
  --surface2: #101828;
  --surface3: #162032;

  --border:    #1a2540;
  --border2:   #243050;
  --border-hi: #1e2e50;

  /* Azul eléctrico ioonic en oscuro */
  --lime:        #3b82f6;
  --lime-rgb:    59,130,246;
  --lime-dim:    rgba(59,130,246,.12);

  /* Naranja ioonic en oscuro */
  --orange:      #f97316;
  --orange-dim:  rgba(249,115,22,.1);

  --cyan:        #38bdf8;
  --cyan-dim:    rgba(56,189,248,.1);

  --red:         #f23054;
  --red-dim:     rgba(242,48,84,.1);

  --amber:       #fbbf24;
  --amber-dim:   rgba(251,191,36,.1);

  --green:       #34a1d3;
  --green-dim:   rgba(52,211,153,.1);

  --text:  #e2eaf8;
  --text2: #8a9bc0;
  --text3: #3a4a6a;

  --lime-btn-fg:       #fff;
  --lime-hover-bg:     #2563eb;
  --lime-hover-shadow: rgba(59,130,246,.25);
  --row-hover-bg:      rgba(59,130,246,.04);
  --overlay-bg:        rgba(0,0,0,.85);
  --scrollbar-thumb:   #1e2e50;
  --scrollbar-hover:   #304060;
}

/* 
   RESET & BASE
 */
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Instrument Sans', sans-serif;
  font-size: 14px;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background-color .25s ease, color .25s ease;
}

::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* 
   HEADER
 */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 100;
  transition: background-color .25s ease, border-color .25s ease;
}

.logo {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: -0.5px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo em { color: var(--lime); font-style: normal; }
.logo-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--lime);
  box-shadow: 0 0 10px var(--lime);
  animation: pulse 2.5s infinite;
  flex-shrink: 0;
}
@keyframes pulse { 0%,100%{opacity:1}50%{opacity:.3} }
.logo-tag {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--text3);
  letter-spacing: 1.8px;
  font-weight: 300;
  margin-left: 2px;
}

.header-stats { display: flex; gap: 8px; align-items: center; }
.hstat {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 5px 13px;
  border-radius: 5px;
  border: 1px solid var(--border2);
  color: var(--text2);
  background: var(--surface2);
  white-space: nowrap;
  transition: background-color .25s, border-color .25s, color .25s;
}
.hstat.active {
  border-color: rgba(var(--lime-rgb),.4);
  color: var(--lime);
  background: var(--lime-dim);
}
.hstat strong { color: var(--lime); }

/*  THEME TOGGLE BUTTON  */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid var(--border2);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  transition: border-color .2s, color .2s, background-color .2s, transform .2s;
  flex-shrink: 0;
}
.theme-toggle:hover {
  border-color: var(--lime);
  color: var(--lime);
  background: var(--lime-dim);
  transform: rotate(15deg) scale(1.05);
}
.theme-toggle svg { display: block; }

/* 
   TABS
 */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  padding: 0 32px;
  transition: background-color .25s, border-color .25s;
}
.tab {
  padding: 13px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text2);
  border-bottom: 2px solid transparent;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--lime); border-bottom-color: var(--lime); }
.tab-icon { font-size: 14px; }

/* 
   MAIN & TAB CONTENT
 */
main { padding: 24px 32px; max-width: 1800px; margin: 0 auto; }
.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn .2s ease; }
@keyframes fadeIn { from{opacity:0;transform:translateY(5px)} to{opacity:1;transform:none} }

/* 
   UPLOAD
 */
.upload-area { margin-bottom: 0; }
.upload-zone {
  border: 2px dashed var(--border2);
  border-radius: 14px;
  padding: 64px 40px;
  text-align: center;
  cursor: pointer;
  transition: all .3s;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.upload-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 120%, rgba(var(--lime-rgb),.05) 0%, transparent 60%);
  pointer-events: none;
}
.upload-zone:hover,
.upload-zone.drag {
  border-color: var(--lime);
  background: linear-gradient(160deg, var(--surface) 0%, rgba(var(--lime-rgb),.03) 100%);
}
.upload-icon { font-size: 48px; margin-bottom: 16px; }
.upload-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.upload-sub { color: var(--text2); font-size: 13px; line-height: 1.6; }
.upload-sub strong { color: var(--lime); }
.upload-btn {
  margin-top: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 26px;
  background: var(--lime);
  color: var(--lime-btn-fg);
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  border: none;
  font-family: 'Instrument Sans', sans-serif;
  transition: all .2s;
}
.upload-btn:hover {
  background: var(--lime-hover-bg);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--lime-hover-shadow);
}
.demo-row {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.demo-row span { font-size: 12px; color: var(--text3); }

/* Mini upload bar (cuando ya hay datos) */
.upload-mini {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  cursor: pointer;
  transition: border-color .2s;
}
.upload-mini:hover { border-color: var(--lime); }
.upload-mini-icon { font-size: 20px; }
.upload-mini-text { font-size: 13px; color: var(--text2); }
.upload-mini-text strong { color: var(--lime); }

/* 
   BUTTONS
 */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  font-family: 'Instrument Sans', sans-serif;
  transition: all .2s;
  white-space: nowrap;
}
.btn-primary { background: var(--lime); color: var(--lime-btn-fg); }
.btn-primary:hover {
  background: var(--lime-hover-bg);
  box-shadow: 0 4px 16px var(--lime-hover-shadow);
}
.btn-ghost {
  background: transparent;
  color: var(--text2);
  border: 1px solid var(--border2);
}
.btn-ghost:hover { border-color: var(--text3); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* 
   STATS GRID
 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color .2s, transform .2s, background-color .25s;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
.stat-card.lime::before   { background: var(--lime); }
.stat-card.orange::before { background: var(--orange); }
.stat-card.cyan::before   { background: var(--cyan); }
.stat-card.amber::before  { background: var(--amber); }
.stat-card.red::before    { background: var(--red); }
.stat-card.green::before  { background: var(--green); }
.stat-card:hover { border-color: var(--border2); transform: translateY(-2px); }
.stat-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text2);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.stat-value {
  font-family: 'Syne', sans-serif;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
}
.stat-value.lime   { color: var(--lime); }
.stat-value.orange { color: var(--orange); }
.stat-value.cyan   { color: var(--cyan); }
.stat-value.amber  { color: var(--amber); }
.stat-value.red    { color: var(--red); }
.stat-value.green  { color: var(--green); }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 6px; }

/* 
   PANEL
 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
  transition: background-color .25s, border-color .25s;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text2);
  text-transform: uppercase;
}

/* 
   COLUMN SELECTOR
 */
.col-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.col-chip {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  user-select: none;
  white-space: nowrap;
}
.col-chip:hover { border-color: var(--lime); color: var(--lime); }
.col-chip.active {
  background: var(--lime-dim);
  border-color: rgba(var(--lime-rgb),.5);
  color: var(--lime);
}

/* 
   FILTER BAR
 */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: flex-end;
  width: 100%;
  box-sizing: border-box;
}
/* Búsqueda global ocupa 2 columnas */
.filter-group--wide {
  grid-column: span 2;
}
/* Adjudicatario y Órgano ocupan 2 columnas cada uno */
.filter-group--full {
  grid-column: 1 / -1;
}
.filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.filter-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text2);
  text-transform: uppercase;
}
.filter-input,
.filter-select {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Instrument Sans', sans-serif;
  outline: none;
  transition: border-color .2s, background-color .25s;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}
.filter-input:focus,
.filter-select:focus { border-color: var(--lime); }
.filter-input::placeholder { color: var(--text3); }
.filter-select option { background: var(--surface2); color: var(--text); }

/* ── COMBOBOX (adjudicatario / órgano con búsqueda) ── */
.combo-wrapper {
  position: relative;
  width: 100%;
}
.combo-input {
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 7px 32px 7px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Instrument Sans', sans-serif;
  outline: none;
  transition: border-color .2s;
  width: 100%;
  box-sizing: border-box;
  cursor: pointer;
}
.combo-input:focus { border-color: var(--lime); }
.combo-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  font-size: 10px;
  color: var(--text3);
}
.combo-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  width: 100%;
  background: var(--surface2, #1e2028);
  border: 1px solid var(--border2);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 9999;
  max-height: 220px;
  overflow-y: auto;
  display: none;
}
.combo-dropdown.open { display: block; }
.combo-option {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  transition: background .12s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.combo-option:hover,
.combo-option.highlighted { background: var(--surface3, rgba(255,255,255,.07)); }
.combo-option mark {
  background: transparent;
  color: var(--lime, #84cc16);
  font-weight: 700;
}
.combo-empty {
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
}

/* 
   TABLE
 */
.table-toolbar {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.table-count {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: var(--text2);
}
.table-count strong { color: var(--lime); }
.table-scroll { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead th {
  background: var(--surface2);
  padding: 9px 14px;
  text-align: left;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text2);
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: color .15s, background-color .25s;
}
thead th:hover { color: var(--lime); }
thead th.sorted-asc::after  { content: ' ↑'; color: var(--lime); }
thead th.sorted-desc::after { content: ' ↓'; color: var(--lime); }

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background .1s;
  cursor: pointer;
}
tbody tr:hover { background: var(--row-hover-bg); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 9px 14px;
  font-size: 12.5px;
  color: var(--text);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
  transition: color .25s;
}

.mono   { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.amount { font-family: 'JetBrains Mono', monospace; font-size: 12px; color: var(--lime); }
.link-cell { color: var(--cyan); font-size: 12px; text-decoration: none; }
.link-cell:hover { text-decoration: underline; }

/* BADGES */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  white-space: nowrap;
}
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red   { background: var(--red-dim);   color: var(--red); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-cyan  { background: var(--cyan-dim);  color: var(--cyan); }
.badge-lime  { background: var(--lime-dim);  color: var(--lime); }
.badge-gray  { background: var(--surface3);  color: var(--text2); }

/* NO DATA ROW */
.no-data td {
  text-align: center;
  padding: 48px;
  color: var(--text2);
  font-size: 13px;
}

/* 
   PAGINATION
 */
.pagination {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.page-info { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text3); }
.page-btns { display: flex; gap: 4px; }
.page-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  border: 1px solid var(--border2);
  color: var(--text2);
  background: transparent;
  font-family: 'JetBrains Mono', monospace;
  transition: all .15s;
}
.page-btn:hover { border-color: var(--lime); color: var(--lime); }
.page-btn.active {
  background: var(--lime);
  color: var(--lime-btn-fg);
  border-color: var(--lime);
  font-weight: 600;
}
.page-btn:disabled { opacity: .3; cursor: default; }
.page-btn:disabled:hover { border-color: var(--border2); color: var(--text2); }

/* 
   MODAL
 */
.modal-overlay {
  position: fixed; inset: 0;
  background: var(--overlay-bg);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  backdrop-filter: blur(6px);
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 14px;
  width: 100%;
  max-width: 820px;
  max-height: 88vh;
  overflow-y: auto;
  animation: modalIn .2s ease;
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
}
@keyframes modalIn { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:none} }
.modal-head {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  position: sticky; top: 0;
  background: var(--surface);
  z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; line-height: 1.4; color: var(--text); }
.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--text2); font-size: 20px; line-height: 1;
  flex-shrink: 0; border-radius: 6px;
  border: 1px solid var(--border2); background: transparent;
  transition: all .15s;
}
.modal-close::after { content: '✕'; display: block; }
.modal-close:hover { color: var(--text); border-color: var(--text3); background: var(--surface2); }
.modal-body { padding: 22px 24px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 24px;
}
.detail-item { }
.detail-item.full { grid-column: 1 / -1; }
.detail-key {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 1.2px;
  color: var(--text3);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.detail-val {
  font-size: 13.5px;
  color: var(--text);
  word-break: break-word;
  line-height: 1.5;
}
.detail-val a { color: var(--cyan); text-decoration: none; }
.detail-val a:hover { text-decoration: underline; }
.detail-section {
  font-family: 'Syne', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: .5px;
  margin-top: 20px;
  margin-bottom: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  grid-column: 1 / -1;
}

/* 
   ANALYSIS
 */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 900px) { .analysis-grid { grid-template-columns: 1fr; } }
.panel.full { grid-column: 1 / -1; }

.bar-chart { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; }
.bar-label {
  font-size: 12px; color: var(--text2);
  min-width: 150px; max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: default;
}
.bar-track {
  flex: 1; height: 5px;
  background: var(--border);
  border-radius: 3px; overflow: hidden;
}
.bar-fill {
  height: 100%; border-radius: 3px;
  background: var(--lime);
  transition: width .7s cubic-bezier(.4,0,.2,1);
}
.bar-fill.orange { background: var(--orange); }
.bar-fill.cyan   { background: var(--cyan); }
.bar-fill.amber  { background: var(--amber); }
.bar-fill.red    { background: var(--red); }
.bar-fill.green  { background: var(--green); }
.bar-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; color: var(--text2);
  min-width: 110px; text-align: right;
}

/* ── EMPRESA DASHBOARD ── */
.empresa-selector {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 0 4px;
  flex-wrap: wrap;
}
.empresa-selector label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 1px;
  color: var(--text2); text-transform: uppercase;
  white-space: nowrap;
}
.empresa-selector .combo-wrapper { flex: 1; min-width: 260px; max-width: 480px; }

.btn-limpiar-empresa {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 6px 12px;
  color: var(--text3);
  font-size: 11px;
  font-family: 'JetBrains Mono', monospace;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.btn-limpiar-empresa:hover {
  color: var(--red, #ef4444);
  border-color: var(--red, #ef4444);
  background: rgba(239,68,68,.06);
}

.empresa-hero {
  display: flex; align-items: center; gap: 20px;
  padding: 22px 26px;
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface2) 100%);
  border: 1px solid var(--border2);
  border-radius: 12px;
  margin-bottom: 4px;
  position: relative; overflow: hidden;
}
.empresa-hero::before {
  content: '';
  position: absolute; top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: var(--lime); opacity: .04;
  border-radius: 50%;
}
.empresa-avatar {
  width: 54px; height: 54px; border-radius: 13px;
  background: linear-gradient(135deg, var(--lime) 0%, var(--cyan) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; color: #000;
  flex-shrink: 0; letter-spacing: -1px;
  font-family: 'JetBrains Mono', monospace;
}
.empresa-info { flex: 1; min-width: 0; }
.empresa-name {
  font-size: 19px; font-weight: 700; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.empresa-meta { font-size: 12px; color: var(--text3); font-family: 'JetBrains Mono', monospace; }
.empresa-badge {
  display: inline-flex; align-items: center;
  background: rgba(132,204,22,.12); color: var(--lime);
  border: 1px solid rgba(132,204,22,.25);
  border-radius: 20px; padding: 5px 14px;
  font-size: 12px; font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
}

/* KPI cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 10px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 10px;
  padding: 15px 16px;
  display: flex; flex-direction: column; gap: 5px;
  transition: border-color .2s, transform .15s;
  position: relative; overflow: hidden;
  cursor: default;
}
.kpi-card:hover { border-color: var(--lime); transform: translateY(-2px); }
.kpi-card::after {
  content: attr(data-icon);
  position: absolute; right: 10px; bottom: 6px;
  font-size: 26px; opacity: .07; line-height: 1;
}
.kpi-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text3);
}
.kpi-value {
  font-size: 20px; font-weight: 700; color: var(--text);
  font-family: 'JetBrains Mono', monospace; line-height: 1.1;
}
.kpi-value.lime  { color: var(--lime); }
.kpi-value.cyan  { color: var(--cyan); }
.kpi-value.amber { color: var(--amber); }
.kpi-value.red   { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--text3); }

/* Timeline */
.timeline { display: flex; flex-direction: column; }
.timeline-item {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}
.timeline-item:last-child { border-bottom: none; }
.timeline-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--lime); flex-shrink: 0; margin-top: 4px;
  box-shadow: 0 0 0 3px rgba(132,204,22,.15);
}
.timeline-dot.cyan  { background: var(--cyan);  box-shadow: 0 0 0 3px rgba(34,211,238,.15); }
.timeline-dot.amber { background: var(--amber); box-shadow: 0 0 0 3px rgba(251,191,36,.15); }
.timeline-dot.red   { background: var(--red);   box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.timeline-body { flex: 1; min-width: 0; }
.timeline-title {
  font-size: 12px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.timeline-meta { font-size: 11px; color: var(--text3); font-family: 'JetBrains Mono', monospace; margin-top: 2px; }
.timeline-amount {
  font-size: 12px; font-weight: 700; color: var(--lime);
  font-family: 'JetBrains Mono', monospace; flex-shrink: 0; white-space: nowrap;
}

/* Órganos table */
.organos-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.organos-table th {
  font-family: 'JetBrains Mono', monospace; font-size: 9px;
  letter-spacing: 1px; text-transform: uppercase; color: var(--text3);
  padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--border2);
}
.organos-table td {
  padding: 9px 10px; border-bottom: 1px solid var(--border);
  color: var(--text); vertical-align: middle;
}
.organos-table tr:last-child td { border-bottom: none; }
.organos-table tr:hover td { background: var(--surface2); }
.organos-table .num { font-family: 'JetBrains Mono', monospace; color: var(--text2); text-align: right; }
.organos-table .pill {
  display: inline-block; background: rgba(132,204,22,.1); color: var(--lime);
  border-radius: 99px; padding: 2px 8px; font-size: 10px;
  font-family: 'JetBrains Mono', monospace; font-weight: 600;
}

/* ── CHARTS LAYOUT ── */
.charts-main-row {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 14px;
  align-items: start;
}
@media (max-width: 900px) { .charts-main-row { grid-template-columns: 1fr; } }

.charts-bottom-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 800px) { .charts-bottom-grid { grid-template-columns: 1fr; } }

.chart-panel {
  padding: 18px 20px 22px !important;
  border-radius: 12px !important;
}
.chart-panel--tall { min-height: 220px; }

.chart-panel-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.chart-panel-icon {
  font-size: 10px; color: var(--lime);
  font-family: 'JetBrains Mono', monospace;
}
.chart-panel-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; letter-spacing: 1.2px;
  text-transform: uppercase; color: var(--text2);
  font-weight: 600;
}

/* ── COLUMN CHART (barras verticales estilo imagen referencia) ── */
.col-chart-wrap {
  display: flex;
  flex-direction: column;
  gap: 0;
  width: 100%;
}
.col-chart-grid-lines {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 140px;
  padding: 0 4px;
  border-left: 1px solid var(--border2);
}
.col-chart-grid-lines::before,
.col-chart-grid-lines::after,
.col-grid-mid {
  position: absolute; left: 0; right: 0;
  border-top: 1px dashed var(--border);
  pointer-events: none;
}
.col-chart-grid-lines::before { content:''; top: 0; }
.col-chart-grid-lines::after  { content:''; top: 50%; }
.col-grid-mid { top: 25%; }
.col-grid-75  { position:absolute;left:0;right:0;top:75%;border-top:1px dashed var(--border); }

.col-bar-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  height: 100%;
  justify-content: flex-end;
  position: relative;
}
.col-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 5px 5px 0 0;
  transition: all .6s cubic-bezier(.4,0,.2,1);
  cursor: default;
  position: relative;
  min-height: 4px;
}
.col-bar:hover { filter: brightness(1.12); }
.col-bar-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px; font-weight: 700;
  color: var(--text2);
  text-align: center;
  position: absolute;
  top: -18px; left: 0; right: 0;
}
.col-chart-labels {
  display: flex;
  gap: 10px;
  padding: 6px 4px 0;
  border-top: 2px solid var(--border2);
}
.col-chart-label {
  flex: 1;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px; color: var(--text3);
  text-align: center;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Paleta de azules para columnas (inspirada en imagen ref) */
.col-teal    { background: #2dd4bf; }
.col-blue1   { background: #38bdf8; }
.col-blue2   { background: #60a5fa; }
.col-blue3   { background: #818cf8; }
.col-blue4   { background: #a78bfa; }
.col-blue5   { background: #4f46e5; }
.col-blue6   { background: #0ea5e9; }
.col-blue7   { background: #6366f1; }
.col-blue8   { background: #2563eb; }
.col-blue9   { background: #7c3aed; }
.col-blue10  { background: #0284c7; }

/* ── VBAR horizontal ── */
.vbar-chart { display: flex; flex-direction: column; gap: 10px; }
.vbar-row {
  display: grid;
  grid-template-columns: 130px 1fr auto;
  gap: 6px 10px;
  align-items: center;
}
.vbar-label {
  font-size: 11px; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  grid-column: 1;
}
.vbar-track {
  height: 10px;
  background: var(--surface2);
  border-radius: 99px; overflow: hidden;
  grid-column: 2;
}
.vbar-fill {
  height: 100%; border-radius: 99px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.vbar-fill.blue1  { background: linear-gradient(90deg,#2563eb,#38bdf8); }
.vbar-fill.blue2  { background: linear-gradient(90deg,#0284c7,#38bdf8); }
.vbar-fill.teal   { background: linear-gradient(90deg,#0d9488,#2dd4bf); }
.vbar-fill.amber  { background: linear-gradient(90deg,#b45309,#fbbf24); }
.vbar-fill.red    { background: linear-gradient(90deg,#be123c,#fb7185); }
.vbar-fill.purple { background: linear-gradient(90deg,#7c3aed,#a78bfa); }
.vbar-fill.slate  { background: linear-gradient(90deg,#475569,#94a3b8); }
.vbar-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600; color: var(--text2);
  white-space: nowrap; text-align: right;
  grid-column: 3;
}

/* ── DONUT mejorado ── */
.donut-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; padding-top: 4px; }
.donut-item { display: flex; flex-direction: column; align-items: center; gap: 7px; min-width: 68px; }
.donut-ring {
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  box-shadow: 0 3px 14px rgba(0,0,0,.12);
}
.donut-ring::after {
  content: '';
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--surface); position: absolute;
  box-shadow: inset 0 1px 4px rgba(0,0,0,.12);
}
.donut-inner {
  font-size: 12px; font-weight: 700; color: var(--text);
  font-family: 'JetBrains Mono', monospace;
  position: relative; z-index: 1;
}
.donut-label {
  font-size: 10px; color: var(--text3); text-align: center;
  font-family: 'JetBrains Mono', monospace; line-height: 1.3;
}

/* ── IMPORTE POR AÑO (barras horizontales con importe) ── */
.importe-anio-chart { display: flex; flex-direction: column; gap: 10px; }
.importe-anio-row {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 6px 10px;
  align-items: center;
}
.importe-anio-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 700; color: var(--text2);
}
.importe-anio-track {
  height: 10px; background: var(--surface2);
  border-radius: 99px; overflow: hidden;
}
.importe-anio-fill {
  height: 100%; border-radius: 99px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
  background: linear-gradient(90deg, #4f46e5, #818cf8);
}
.importe-anio-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px; font-weight: 600; color: var(--text2);
  white-space: nowrap; text-align: right;
}


.empresa-empty {
  text-align: center; padding: 60px 20px; color: var(--text3); font-size: 14px;
}
.empresa-empty .big { font-size: 40px; margin-bottom: 12px; }


/* 
   RELACIONES
 */
.rel-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.rel-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.rel-list { display: flex; flex-direction: column; gap: 12px; }

.rel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border2);
  border-radius: var(--radius);
  padding: 16px 18px;
  transition: all .2s;
}
.rel-card:hover { border-color: var(--border2); transform: translateX(3px); }
.rel-card.risk-high { border-left-color: var(--red); }
.rel-card.risk-med  { border-left-color: var(--amber); }
.rel-card.risk-low  { border-left-color: var(--lime); }

.rel-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: 12px;
}
.rel-org { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; }
.rel-org small {
  display: block;
  font-size: 11px; font-weight: 400; color: var(--text2); margin-top: 2px;
}
.rel-risk-badge { flex-shrink: 0; }

.rel-adjudicatarios { display: flex; flex-direction: column; gap: 7px; }
.rel-adj-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  background: var(--surface2);
  border-radius: 6px;
  border: 1px solid var(--border);
}
.rel-adj-name {
  font-size: 12.5px; color: var(--text);
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.rel-adj-count { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--text2); white-space: nowrap; }
.rel-adj-count strong { color: var(--lime); }
.rel-adj-amount { font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--green); white-space: nowrap; }
.rel-adj-pct { font-family: 'JetBrains Mono', monospace; font-size: 11px; white-space: nowrap; }
.pct-high { color: var(--red); }
.pct-med  { color: var(--amber); }
.pct-low  { color: var(--text3); }

/* 
   ALERTS
 */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  border: 1px solid;
  line-height: 1.5;
}
.alert-warning { background: var(--amber-dim); border-color: rgba(180,83,9,.3); color: var(--amber); }
.alert-info    { background: var(--cyan-dim);  border-color: rgba(3,105,161,.3); color: var(--cyan); }

/* 
   EMPTY STATE
 */
.empty-state { text-align: center; padding: 80px 40px; }
.empty-icon { font-size: 48px; margin-bottom: 16px; opacity: .3; }
.empty-title {
  font-family: 'Syne', sans-serif;
  font-size: 22px; font-weight: 700;
  color: var(--text3); margin-bottom: 8px;
}
.empty-sub { font-size: 13px; color: var(--text3); }

/* 
   IA TAB — correcciones para tema claro
   Los estilos base de IA usan var() y se adaptan automáticamente.
   Aquí solo corregimos los colores hardcoded que fallan en blanco.
 */

/* Sombra de hover — más suave en tema claro */
[data-theme="light"] .ia-card:hover {
  box-shadow: 0 4px 24px rgba(0,0,0,.1);
}

/* Pros/contras — colores originales (#34d399 teal, #ff8fa3 rosa)
   tienen bajo contraste sobre blanco; sustituir por equivalentes oscuros */
[data-theme="light"] .ia-list-favor  li { color: #15803d; }
[data-theme="light"] .ia-list-contra li { color: #be123c; }

/* Chips de datos — fondo morado casi invisible en blanco */
[data-theme="light"] .ia-licit-data span {
  background: rgba(29,78,216,.07);
  border-color: rgba(29,78,216,.22);
  color: var(--text2);
}

/* Consejo — borde y fondo más visibles en claro */
[data-theme="light"] .ia-consejo {
  background: rgba(29,78,216,.06);
  border-color: rgba(29,78,216,.2);
}

/* 
   RESPONSIVE
 */
@media (max-width: 768px) {
  header { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  main { padding: 16px; }
  .tabs { padding: 0 16px; overflow-x: auto; }
  .detail-grid { grid-template-columns: 1fr; }
}


/*  Groq IA (Recomendación)  */
.groq-pre{
  margin-top:8px;
  padding:10px 12px;
  border:1px solid var(--border2, rgba(255,255,255,.12));
  border-radius:12px;
  background: rgba(255,255,255,.03);
  white-space: pre-wrap;     /* respeta saltos de línea del modelo */
  word-break: break-word;
  line-height: 1.45;
  font-size: .88rem;
}
.groq-label{ display:block; margin-bottom:6px; font-weight:700; }
.groq-loading{ opacity:.9; }
.groq-error{ opacity:.95; }

/*  Filtro CPV  */
.cpv-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  background: var(--surface);
  max-width: 200px;
  min-width: 120px;
}
.cpv-chip:hover {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(29,78,216,.06));
}
.cpv-chip.active {
  border-color: var(--accent);
  background: var(--accent-dim, rgba(29,78,216,.1));
  box-shadow: 0 0 0 1px var(--accent);
}
.cpv-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .05em;
}
.cpv-chip.active .cpv-code {
  color: var(--accent);
}
.cpv-label {
  font-size: .68rem;
  color: var(--text2);
  line-height: 1.3;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.cpv-chip.active .cpv-label {
  color: var(--text);
}