*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --azul: #1a1a2e;
  --rojo: #e63946;
  --gris: #6b7280;
  --borde: #e5e7eb;
  --fondo: #f9fafb;
  --texto: #111827;
  --radio: 10px;
  /* alias usados en login */
  --surface: #ffffff;
  --border: var(--borde);
  --muted: var(--gris);
  --error: var(--rojo);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: 40px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--azul);
  color: white;
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo { font-weight: 700; font-size: 18px; }
.back { color: white; text-decoration: none; font-size: 15px; }

.btn-salir {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.35);
  color: white;
  font-size: 13px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.scraper-toggle {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.scraper-toggle.scraper-pausado {
  background: rgba(255, 80, 80, 0.4);
}

.badge {
  background: var(--rojo);
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 13px;
  font-weight: 600;
}

/* Lista de alertas */
.lista { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.alerta-card {
  background: white;
  border-radius: var(--radio);
  padding: 16px;
  border: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alerta-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fuente { font-size: 13px; color: var(--gris); font-weight: 500; }

.score {
  font-size: 13px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 8px;
}

.score-alta { background: #fef2f2; color: var(--rojo); }
.score-media { background: #fffbeb; color: #d97706; }

.razon { font-size: 13px; color: var(--gris); }

.titular { font-size: 16px; font-weight: 600; line-height: 1.4; }

/* Editor */
#editor { padding: 16px; display: flex; flex-direction: column; gap: 20px; }

.fuentes { display: flex; flex-direction: column; gap: 8px; }
.fuentes h3 { font-size: 13px; color: var(--gris); text-transform: uppercase; letter-spacing: .05em; }

.fuente-link {
  display: block;
  padding: 10px 14px;
  background: white;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  text-decoration: none;
  color: var(--texto);
  font-size: 14px;
}

.fuente-primaria { border-color: #bfdbfe; background: #eff6ff; }

.form { display: flex; flex-direction: column; gap: 16px; }

.campo { display: flex; flex-direction: column; gap: 6px; }
.campo label { font-size: 13px; font-weight: 600; color: var(--gris); }
.campo small { font-weight: 400; }

input[type="text"], textarea, select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  font-size: 15px;
  font-family: inherit;
  background: white;
  color: var(--texto);
  -webkit-appearance: none;
}

textarea { resize: vertical; min-height: 180px; line-height: 1.6; }

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--azul);
}

.slug-preview { display: flex; align-items: center; gap: 0; }
.slug-base {
  background: #f3f4f6;
  border: 1px solid var(--borde);
  border-right: none;
  border-radius: var(--radio) 0 0 var(--radio);
  padding: 10px 10px;
  font-size: 13px;
  color: var(--gris);
  white-space: nowrap;
}
.slug-preview input { border-radius: 0 var(--radio) var(--radio) 0; }

.contador { font-size: 12px; color: var(--gris); text-align: right; }

/* Botones */
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.acciones-editor { display: flex; flex-direction: column; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border-radius: var(--radio);
  font-size: 15px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}

.btn:active { opacity: .8; }

.btn-primary { background: var(--azul); color: white; }
.btn-secondary { background: white; color: var(--texto); border: 1px solid var(--borde); }
.btn-danger { background: var(--rojo); color: white; }
.btn-danger-outline { background: white; color: var(--rojo); border: 1px solid var(--rojo); }
.btn-grande { padding: 14px; font-size: 16px; width: 100%; }

/* Modal de confirmación */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.visible {
  display: flex;
}

.modal-box {
  background: white;
  border-radius: var(--radio);
  padding: 24px 20px;
  max-width: 360px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-pregunta { font-size: 17px; font-weight: 700; line-height: 1.4; }
.modal-aviso { font-size: 14px; color: var(--gris); }
.modal-acciones { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }

/* Estados */
.loading, .vacio, .error { padding: 40px 16px; text-align: center; color: var(--gris); }
.error { color: var(--rojo); }

.mensaje {
  padding: 12px 16px;
  border-radius: var(--radio);
  font-weight: 600;
  text-align: center;
}
.mensaje.exito { background: #f0fdf4; color: #16a34a; }
.mensaje.error { background: #fef2f2; color: var(--rojo); }

/* ── Tabs ──────────────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid #e5e7eb;
  background: white;
  padding: 0 16px;
  gap: 4px;
  position: sticky;
  top: 56px;
  z-index: 10;
}
.tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.tab.active {
  color: var(--texto);
  border-bottom-color: var(--azul);
}
.tab-badge {
  background: #ef4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  border-radius: 10px;
  padding: 1px 6px;
  min-width: 18px;
  text-align: center;
}
.tab-badge:empty { display: none; }

/* ── Fecha en card ─────────────────────────────────────────────────────── */
.fecha {
  font-size: 11px;
  color: #9ca3af;
  margin-left: auto;
}
.header-acciones {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Tabla fuentes ─────────────────────────────────────────────────────── */
.tabla-fuentes { width: 100%; border-collapse: collapse; background: white; border-radius: var(--radio); overflow: hidden; border: 1px solid var(--borde); }
.tabla-fuentes th { text-align: left; padding: 12px 14px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--gris); border-bottom: 1px solid var(--borde); }
.tabla-fuentes td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--borde); vertical-align: middle; }
.tabla-fuentes tr:last-child td { border-bottom: none; }
.fila-inactiva { opacity: .55; }
.fuente-nombre { font-weight: 600; }
.fuente-url { font-size: 12px; color: var(--gris); margin-top: 2px; word-break: break-all; }
.tag-tipo { background: #f3f4f6; color: var(--gris); font-size: 12px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.toggle-activa { border: none; background: none; cursor: pointer; font-size: 13px; font-weight: 600; padding: 4px 8px; border-radius: 6px; }
.toggle-activa.activa { color: #16a34a; background: #f0fdf4; }
.toggle-activa.inactiva { color: var(--gris); background: #f3f4f6; }
.acciones-fuente { display: flex; gap: 6px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
