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

:root {
  --azul:    #003366;
  --azul-2:  #004999;
  --gris-bg: #f0f2f5;
  --gris-1:  #e0e0e0;
  --texto:   #1a1a1a;
  --suave:   #666;
  --sombra:  0 1px 6px rgba(0,0,0,.09);
  --r:       12px;
}

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--gris-bg);
  color: var(--texto);
  max-width: 600px;
  margin: 0 auto;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
header {
  background: var(--azul);
  padding: 14px 16px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}

.logo {
  height: 38px;
  object-fit: contain;
}

/* ── Tabs ── */
.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--gris-1);
  position: sticky;
  top: 66px;
  z-index: 99;
}

.tab {
  flex: 1;
  padding: 13px 0;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--suave);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s;
  letter-spacing: .2px;
}

.tab.active {
  color: var(--azul);
  border-bottom-color: var(--azul);
}

/* ── Tab content ── */
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Grid de iconos ── */
.filtro-seccion {
  padding: 16px 0 4px;
}

.filtro-seccion-titulo {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--suave);
  padding: 0 16px 10px;
}

.icono-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 0 12px 8px;
}

.icono-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 2px;
  -webkit-tap-highlight-color: transparent;
}

.icono-btn:active .icono-wrap {
  transform: scale(.90);
  opacity: .85;
}

.icono-wrap {
  width: 62px;
  height: 62px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
  transition: transform .12s ease, opacity .12s ease;
}

.icono-label {
  font-size: 10.5px;
  font-weight: 600;
  color: #222;
  text-align: center;
  line-height: 1.25;
  max-width: 68px;
  word-break: break-word;
}

/* ── Cabecera filtro activo ── */
.filtro-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  position: sticky;
  top: 112px;
  z-index: 98;
  border-bottom: 1px solid var(--gris-1);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.btn-volver {
  background: var(--gris-bg);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  color: var(--azul);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.filtro-titulo {
  font-size: 17px;
  font-weight: 700;
  color: var(--azul);
}

/* ── Cards de noticias ── */
#news-list,
#feed-list {
  padding: 12px;
}

.card {
  background: #fff;
  border-radius: var(--r);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: var(--sombra);
  animation: fadeIn .22s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card img {
  width: 100%;
  height: auto;
  display: block;
}

.card-body {
  padding: 14px 14px 12px;
}

/* ── Badge / categoría ── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .7px;
  padding: 3px 9px;
  border-radius: 20px;
  background: var(--azul);
  color: #fff;
  margin-bottom: 9px;
}

.badge.deportes    { background: #1a7a2e; }
.badge.cultura     { background: #6b3fa0; }
.badge.sociedad    { background: #c45e00; }
.badge.tráfico     { background: #c0392b; }
.badge.meteorología{ background: #0077b6; }
.badge.eventos     { background: #c2185b; }
.badge.obras       { background: #8d6e00; }
.badge.turismo     { background: #00796b; }
.badge.emergencias { background: #c0392b; }
.badge.política    { background: #1565c0; }
.badge.gibraltar   { background: #c62828; }
.badge.economía    { background: #2e7d32; }
.badge.ciencia     { background: #00838f; }

/* ── Texto noticia ── */
.texto {
  font-size: 15px;
  line-height: 1.6;
  color: #222;
  margin-bottom: 10px;
  word-break: break-word;
}

/* ── Tiempo ── */
.tiempo {
  font-size: 12px;
  color: #aaa;
  font-weight: 500;
}

/* ── Loading spinner ── */
#loading {
  display: none;
  text-align: center;
  padding: 24px 0 32px;
}

.spinner {
  display: inline-block;
  width: 28px;
  height: 28px;
  border: 3px solid var(--gris-1);
  border-top-color: var(--azul);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Sin resultados ── */
.empty {
  text-align: center;
  padding: 60px 24px;
  color: var(--suave);
  font-size: 15px;
}



/* ── Modal legal ── */
#modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,.5);
  align-items: flex-end;
}

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

.modal-box {
  background: #fff;
  border-radius: 20px 20px 0 0;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: var(--gris-bg);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  cursor: pointer;
  color: #555;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  overflow-y: auto;
  padding: 24px 20px 28px;
  font-size: 14px;
  line-height: 1.7;
  color: #333;
  position: relative;
}

.modal-body h2 {
  font-size: 18px;
  color: var(--azul);
  margin-bottom: 16px;
  padding-right: 36px;
}

.modal-body h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--azul);
  margin: 18px 0 6px;
}

.modal-body p { margin-bottom: 10px; }

.modal-body table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin: 10px 0;
}

.modal-body th,
.modal-body td {
  border: 1px solid var(--gris-1);
  padding: 7px 9px;
  text-align: left;
}

.modal-body th {
  background: var(--gris-bg);
  font-weight: 700;
}

/* ── Empresas placeholder ── */
.empresas-wrap {
  text-align: center;
  padding: 60px 28px 80px;
}

.empresas-icon {
  font-size: 56px;
  margin-bottom: 20px;
}

.empresas-wrap h2 {
  font-size: 22px;
  color: var(--azul);
  margin-bottom: 12px;
  line-height: 1.3;
}

.empresas-wrap p {
  font-size: 15px;
  color: var(--suave);
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto 16px;
}

.coming-soon {
  display: inline-block;
  font-size: 13px !important;
  font-weight: 700;
  color: var(--azul) !important;
  border: 2px solid var(--azul);
  border-radius: 20px;
  padding: 6px 18px;
  margin-top: 8px;
}
