:root {
  --paper: #edf1ef;
  --ink: #1c2630;
  --muted: #4e5b64;
  --muted-hero: #45525b;
  --rule: #c9d2d0;
  --rule-soft: #dde3e2;
  --band: #e0e7e8;
  --field: #f6f8f7;
  --field-border: #b9c4c3;
  --pill: rgba(255, 255, 255, 0.6);
  --c-temp: #b33a3a;
  --c-hum: #237a88;
  --c-press: #66579a;
  --c-wind: #56752a;
  --c-rain: #2c5ba6;
  --c-aemet: #3b4a55;
  --c-aemet-bar: #7a8786;
  --pos: #a54a0d;
  --neg: #2f5e9e;
  --notice-bg: #f3e6c8;
  --error-bg: #f2d6d2;
  --thermal: #9cc56a;  /* lo cambia el script según la temperatura */
  --hero-mix: 42%;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #151c22;
    --ink: #e3e9e7;
    --muted: #94a3ab;
    --muted-hero: #a9b6bd;
    --rule: #2c3842;
    --rule-soft: #24303a;
    --band: #1b242c;
    --field: #1c252d;
    --field-border: #3a4752;
    --pill: rgba(255, 255, 255, 0.12);
    --c-temp: #e07a6e;
    --c-hum: #5db8c4;
    --c-press: #a797d8;
    --c-wind: #9dbe62;
    --c-rain: #6e9be6;
    --c-aemet: #b4c0c7;
    --c-aemet-bar: #6c7a83;
    --pos: #f0a070;
    --neg: #8db4f0;
    --notice-bg: #3a3220;
    --error-bg: #42262a;
    --hero-mix: 24%;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}
a { color: var(--ink); text-underline-offset: 0.2em; }
button, select { font: inherit; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
[hidden] { display: none !important; }
.wrap { max-width: 70rem; margin: 0 auto; padding-left: 1.5rem; padding-right: 1.5rem; }

/* ------------------------------------------------------------ navegación */
.topnav { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem 1.5rem; padding: 0.75rem 0; }
.brand { font-size: 1.125rem; font-weight: 600; }
.navlinks { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.navlinks a { display: inline-block; padding: 0.625rem 1rem; border-radius: 999px; font-size: 0.9375rem; text-decoration: none; }
.navlinks a[aria-current="page"] { background: var(--pill); font-weight: 600; }
.navlinks a:hover:not([aria-current="page"]) { text-decoration: underline; }
@media (max-width: 30rem) { .navlinks a[href="#descargas"] { display: none; } }

/* ------------------------------------------------------------ cabecera teñida por la temperatura */
.hero {
  background: var(--paper);
  background: color-mix(in oklab, var(--thermal) var(--hero-mix), var(--paper));
  transition: background-color 1s ease;
}
.hero-grid { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1.5rem 4rem; padding: 1.25rem 0 0.5rem; }
.reading { flex: 1 1 22rem; }
.hero-meta { margin: 0; font-size: 0.9375rem; color: var(--muted-hero); }
.temp {
  display: flex;
  align-items: flex-start;
  margin: 1.25rem 0 0;
  font-size: clamp(6.5rem, 15vw, 13rem);
  font-weight: 300;
  font-stretch: 62%;
  line-height: 0.82;
  letter-spacing: -0.02em;
}
.temp .unit { font-size: 0.26em; font-weight: 400; font-stretch: 87.5%; letter-spacing: 0; margin: 0.3em 0 0 0.12em; }
.today, .feels { margin: 0.75rem 0 0; color: var(--muted-hero); }
.feels { margin-top: 0.25rem; }
.facts { flex: 1 1 24rem; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.25rem 1.5rem; }
.facts dt { font-size: 0.875rem; color: var(--muted-hero); }
.facts dd { margin: 0; font-size: 1.5rem; font-weight: 500; font-stretch: 87.5%; line-height: 1.2; }
.facts .sub { display: block; margin-top: 0.125rem; font-size: 0.875rem; font-weight: 400; font-stretch: 100%; color: var(--muted-hero); line-height: 1.35; }

.scale { position: relative; padding: 1.75rem 0 1.5rem; }
.scale-bar {
  height: 6px;
  border-radius: 3px;
  background: linear-gradient(to right,
    rgb(59 91 169) 0%, rgb(74 144 194) 22.2%, rgb(95 179 163) 37.8%, rgb(156 197 106) 51.1%,
    rgb(240 194 75) 64.4%, rgb(232 131 58) 77.8%, rgb(200 66 59) 91.1%, rgb(200 66 59) 100%);
}
.scale-mark {
  position: absolute;
  top: 1.5rem;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--ink);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--thermal) var(--hero-mix), var(--paper));
  transform: translateX(-50%);
  transition: left 1s ease;
}
.scale-labels { display: flex; justify-content: space-between; margin-top: 0.375rem; font-size: 0.75rem; color: var(--muted-hero); }

/* ------------------------------------------------------------ franja de AEMET en el panel */
.aemet-strip { border-bottom: 1px solid var(--rule); }
.aemet-strip .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 1rem; padding-top: 0.375rem; padding-bottom: 0.375rem; font-size: 0.9375rem; }
.aemet-strip b { font-weight: 600; }
.aemet-strip .muted { color: var(--muted); }
.aemet-strip a { margin-left: auto; display: inline-block; padding: 0.625rem 0; font-weight: 600; }
.swatch { display: inline-block; flex: none; width: 2rem; height: 0; border-top: 3px solid var(--ink); vertical-align: middle; }
.swatch.aemet { border-top: 2px dashed var(--c-aemet); }

/* ------------------------------------------------------------ cabecera de la comparativa */
.cmp-head { background: var(--band); }
.cmp-head h1 { margin: 1.25rem 0 0; font-size: clamp(2.25rem, 4.5vw, 3rem); font-weight: 500; font-stretch: 75%; line-height: 1.05; }
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 1rem 2rem; padding: 1.5rem 0 2rem; }
.field { display: flex; flex-direction: column; gap: 0.375rem; }
.field label { font-size: 0.875rem; color: var(--muted-hero); }
.field select {
  min-height: 44px;
  padding: 0 2.5rem 0 0.875rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background-color: var(--field);
  color: var(--ink);
  font-size: 0.9375rem;
  max-width: 100%;
}

/* ------------------------------------------------------------ contenido */
.page-main { padding-top: 2rem; padding-bottom: 0.5rem; }
.pills { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.pills button {
  font-size: 0.9375rem;
  padding: 0.625rem 1.125rem;
  border-radius: 999px;
  border: 1px solid var(--field-border);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.pills button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.pills button:hover:not([aria-pressed="true"]) { border-color: var(--muted); }
.page-main > .pills { margin-bottom: 1.75rem; }
@media (max-width: 30rem) {
  .pills button { flex: 1 1 auto; padding-left: 0.625rem; padding-right: 0.625rem; white-space: nowrap; font-size: 0.875rem; }
}

.status { margin: -0.75rem 0 1.25rem; color: var(--muted); }
.status:empty { display: none; }
.notice { margin: 0 0 1.5rem; padding: 0.75rem 1rem; border-radius: 8px; background: var(--notice-bg); }
.notice.error { background: var(--error-bg); }

.chart { border-top: 1px solid var(--rule); padding-top: 0.875rem; margin-bottom: 2.5rem; }
.chart-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 1rem; margin-bottom: 0.75rem; }
.chart-head h2, .chart-head h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.chart-head small { font-size: 0.875rem; color: var(--muted); }
.canvas-wrap { position: relative; height: 14rem; }
.chart.wide .canvas-wrap { height: 18rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 27rem), 1fr)); column-gap: 3rem; }

/* comparativa */
.headline { margin-bottom: 3rem; }
.headline-text { margin: 0; max-width: 23em; font-size: clamp(1.75rem, 3.6vw, 2.75rem); font-weight: 400; font-stretch: 75%; line-height: 1.15; }
.headline-detail { margin: 1rem 0 0; max-width: 40em; color: var(--muted); }
.summary h2, .charts-head h2 { margin: 0 0 0.75rem; font-size: 1rem; font-weight: 600; }
.table-scroll { position: relative; overflow-x: auto; }
.summary table { width: 100%; min-width: 47rem; border-collapse: collapse; font-size: 0.9375rem; }
.summary thead th { text-align: left; font-weight: 400; font-size: 0.875rem; color: var(--muted); padding: 0.5rem 1rem; border-bottom: 1px solid var(--rule); }
.summary tbody th { text-align: left; font-weight: 500; padding: 0.875rem 1rem 0.875rem 0; border-bottom: 1px solid var(--rule-soft); }
.summary td { padding: 0.875rem 1rem; border-bottom: 1px solid var(--rule-soft); }
.summary thead th:first-child { padding-left: 0; }
.summary .num { text-align: right; white-space: nowrap; }
.summary .dif { font-weight: 600; }
.summary .dif.pos { color: var(--pos); }
.summary .dif.neg { color: var(--neg); }
.summary .note { color: var(--muted); padding-left: 1.5rem; padding-right: 0; }
.charts-head { margin-bottom: 1.5rem; }
.charts-head .row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1.5rem; }
.charts-head h2 { margin: 0; font-size: 1.375rem; font-weight: 500; font-stretch: 87.5%; }
.charts-head p { margin: 0.375rem 0 0; font-size: 0.875rem; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1.75rem; font-size: 0.9375rem; }
.legend span { display: inline-flex; align-items: center; gap: 0.625rem; }

.site-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 1.5rem; padding-top: 0.5rem; padding-bottom: 3rem; font-size: 0.875rem; color: var(--muted); }
.site-footer a { display: inline-block; padding: 0.625rem 0; font-size: 0.9375rem; }
.site-footer span { padding: 0.625rem 0; }

@media (prefers-reduced-motion: reduce) {
  .hero, .scale-mark { transition: none; }
}

/* ------------------------------------------------------------ menú con usuario */
.nav-form { display: inline; margin: 0; }
.nav-form button {
  font-size: 0.9375rem;
  padding: 0.625rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.nav-form button:hover { text-decoration: underline; }
.nav-user { color: var(--muted-hero) !important; }
@media (max-width: 30rem) { .nav-user { display: none !important; } }

/* ------------------------------------------------------------ controles */
.label { font-size: 0.875rem; color: var(--muted-hero); }
.segmented { display: inline-flex; padding: 3px; border: 1px solid var(--field-border); border-radius: 999px; background: var(--field); }
.segmented button {
  font-size: 0.9375rem;
  padding: 0.5625rem 1rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.segmented button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.controls-note { margin: -1rem 0 0; padding-bottom: 1.75rem; font-size: 0.875rem; color: var(--muted-hero); }
.controls-note:empty { display: none; }
.cmp-head .page-title { margin: 1.25rem 0 1.75rem; font-size: clamp(2.25rem, 4.5vw, 3rem); font-weight: 500; font-stretch: 75%; line-height: 1.05; }
.cmp-head .page-title + .controls-note { margin-top: -1rem; }
.section-title { font-size: 1.375rem !important; font-weight: 500 !important; font-stretch: 87.5%; }
.field.inline { flex-direction: row; align-items: center; gap: 0.625rem; }
.field.inline label { color: var(--muted); }
.year-chips { margin: 0.25rem 0 1.25rem; }
.year-chips button { display: inline-flex; align-items: center; gap: 0.5rem; }
.year-chips .dot { width: 1.125rem; height: 3px; border-radius: 2px; }
.canvas-wrap.tall { height: 20rem; }
.table-note { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--muted); }
.table-note:empty { display: none; }
.swatch-box { display: inline-block; width: 1.5rem; height: 0.875rem; border-radius: 3px; background: rgba(59, 74, 85, 0.12); }
.summary tr.before th, .summary tr.before td { color: var(--muted); }
.summary tr.current th { font-weight: 600; }

/* ------------------------------------------------------------ formularios y ajustes */
.narrow { max-width: 34rem; margin-left: 0; }
.block { border-top: 1px solid var(--rule); padding-top: 1rem; margin-bottom: 3rem; }
.block h2 { margin: 0 0 0.75rem; font-size: 1.375rem; font-weight: 500; font-stretch: 87.5%; }
.block h3 { margin: 1.5rem 0 0.5rem; font-size: 1rem; font-weight: 600; }
.muted { color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 1rem; margin: 1rem 0; }
.form input[type="text"], .form input:not([type]), .form input[type="password"], .form input[type="date"],
.inline-form input {
  min-height: 44px;
  padding: 0 0.875rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  width: 100%;
}
.form small { font-size: 0.8125rem; color: var(--muted); }
.field-row { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; }
.field-row .field { flex: 1 1 14rem; }
.field-row .field.grow { flex: 3 1 20rem; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem 1.25rem; }
.form-actions form { margin: 0; }
.btn {
  min-height: 44px;
  padding: 0 1.25rem;
  border: 1px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  cursor: pointer;
}
.btn:disabled { opacity: 0.55; cursor: progress; }
.btn.secondary { background: transparent; color: var(--ink); }
.btn.link { border-color: transparent; background: transparent; color: var(--ink); text-decoration: underline; text-underline-offset: 0.2em; padding: 0 0.5rem; }
.btn.danger { color: var(--neg); }
.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.9375rem; min-height: 44px; }
.check input { width: 1.125rem; height: 1.125rem; }
.tag { display: inline-block; padding: 0.125rem 0.5rem; border-radius: 999px; font-size: 0.8125rem; background: var(--band); }
.tag.good { background: #d8e8d0; color: #2f5a1e; }
.tag.warn { background: var(--notice-bg); }
.tag.bad { background: var(--error-bg); }
@media (prefers-color-scheme: dark) { .tag.good { background: #263a22; color: #b9dca6; } }
.notice.ok { background: #d8e8d0; }
@media (prefers-color-scheme: dark) { .notice.ok { background: #263a22; } }
.key-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr)); gap: 1.5rem 3rem; margin-bottom: 1rem; }
.key-card h3 { margin-top: 0.5rem; }
.key-value { margin: 0.25rem 0; font-size: 1.25rem; font-stretch: 87.5%; font-variant-numeric: tabular-nums; }
.facts-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr)); gap: 1rem 2rem; margin: 0 0 1.5rem; }
.facts-list dt { font-size: 0.875rem; color: var(--muted); }
.facts-list dd { margin: 0.125rem 0 0; }
.log { margin-top: 1.5rem; }
.log summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.log pre { overflow-x: auto; padding: 0.75rem; border-radius: 8px; background: var(--band); font-size: 0.8125rem; line-height: 1.45; }
.users { width: 100%; min-width: 58rem; border-collapse: collapse; font-size: 0.9375rem; }
.users th, .users td { text-align: left; padding: 0.625rem 0.75rem 0.625rem 0; border-bottom: 1px solid var(--rule-soft); vertical-align: middle; }
.users thead th { font-weight: 400; font-size: 0.875rem; color: var(--muted); border-bottom-color: var(--rule); }
.inline-form { display: flex; gap: 0.5rem; margin: 0; }
.inline-form input { min-width: 11rem; }
.users .actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.users .actions form { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
code { font-size: 0.875em; padding: 0.0625rem 0.3125rem; border-radius: 4px; background: var(--band); }

/* ------------------------------------------------------------ login */
.page-login { max-width: 26rem; padding-top: 12vh; padding-bottom: 4rem; }
.page-login .brand { margin: 0; color: var(--muted); }
.page-login h1 { margin: 0.25rem 0 1.5rem; font-size: 3rem; font-weight: 500; font-stretch: 75%; line-height: 1; }
.page-login .btn { align-self: flex-start; }

/* Histórico: los años se reparten en varias filas en el móvil y la tabla se desplaza en horizontal */
@media (max-width: 30rem) {
  .year-chips { flex-wrap: wrap !important; }
  .year-chips button { flex: none !important; padding-left: 0.875rem; padding-right: 0.875rem; }
}
.years-table { min-width: max-content !important; }
.years-table th, .years-table td { white-space: nowrap; }

/* ------------------------------------------------------------ selector de tipo de gráfica */
.chart-head > div:first-child small { display: block; }
.chart-head { align-items: center; gap: 0.5rem 1rem; }
.tipo-grafica:empty { display: none; }
.tipo-grafica { display: inline-flex; padding: 2px; border: 1px solid var(--field-border); border-radius: 999px; background: var(--field); }
.tipo-grafica button {
  min-height: 38px;
  padding: 0 0.8rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 0.8125rem;
  cursor: pointer;
}
.tipo-grafica button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

/* ------------------------------------------------------------ panel sencillo (letra grande) */
.simple {
  --s-max: #a12f2f;
  --s-min: #24539c;
  --s-lluvia: #245aa6;
  --s-texto: #2f3b45;
  font-size: 1.25rem;
}
@media (prefers-color-scheme: dark) {
  .simple { --s-max: #f08a7e; --s-min: #8db4f0; --s-lluvia: #7aa6ee; --s-texto: #c6d0d5; }
}
.simple-wrap { max-width: 60rem; margin: 0 auto; padding-left: 1.75rem; padding-right: 1.75rem; }
.simple-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 0; }
.simple-brand { font-size: 1.5rem; font-weight: 600; }
.simple-salir { margin: 0; }
.simple-salir button, .simple-periodos button {
  min-height: 3.5rem;
  padding: 0 1.5rem;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  font-size: 1.25rem;
  cursor: pointer;
}
.simple-hero .simple-wrap { padding-bottom: 2.5rem; }
.simple-label { margin: 0.5rem 0 0; font-size: 1.375rem; color: var(--s-texto); }
.simple-label:empty { display: none; }
.simple-temp {
  display: flex;
  align-items: flex-start;
  margin: 0.75rem 0 0;
  font-size: clamp(7.5rem, 22vw, 12.5rem);
  font-weight: 400;
  font-stretch: 62%;
  line-height: 0.85;
}
.simple-temp .unit { font-size: 0.3em; font-stretch: 87.5%; margin: 0.25em 0 0 0.1em; }
.simple-frase { margin: 1rem 0 0; font-size: clamp(1.5rem, 3.4vw, 1.75rem); line-height: 1.35; }
.simple-frase + .simple-frase { margin-top: 0.5rem; }
.simple-main { padding-top: 2rem; padding-bottom: 3.5rem; }
.simple-periodos { display: grid; grid-template-columns: repeat(3, minmax(0, max-content)); gap: 0.625rem; margin-bottom: 2.5rem; }
.simple-periodos button[aria-pressed="true"] { background: var(--ink); color: var(--paper); font-weight: 600; }
@media (max-width: 30rem) {
  .simple-wrap { padding-left: 1.25rem; padding-right: 1.25rem; }
  .simple-periodos { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .simple-periodos button { padding: 0 0.375rem; border-radius: 14px; font-size: 1.125rem; line-height: 1.15; }
}
.simple-aviso { margin: -1.5rem 0 2rem; font-size: 1.25rem; }
.simple-aviso:empty { display: none; }
.simple-seccion { border-top: 2px solid var(--rule); padding-top: 1.25rem; margin-bottom: 3.5rem; }
.simple-seccion h2 { margin: 0; font-size: 2rem; font-weight: 600; line-height: 1.2; }
.simple-leyenda { margin: 0.5rem 0 1.25rem; font-size: 1.25rem; color: var(--s-texto); display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; }
.simple-leyenda span { display: inline-flex; align-items: center; gap: 0.5rem; }
.simple-leyenda i { display: inline-block; width: 1.75rem; height: 0; border-top: 4px solid var(--s-max); }
.simple-leyenda i.min { border-top-style: dashed; border-top-color: var(--s-min); }
.simple-frase-lluvia { margin: 0.5rem 0 1.25rem; font-size: 1.5rem; line-height: 1.35; }
.simple-grafica { position: relative; height: 22rem; }
.simple-grafica.baja { height: 18rem; }
@media (max-width: 30rem) { .simple-grafica { height: 19rem; } .simple-grafica.baja { height: 15rem; } }
.simple-nota { margin: 1.25rem 0 0; font-size: 1.125rem; color: var(--s-texto); }
.simple-cuenta { margin: 0; font-size: 1.125rem; }
.simple-cuenta a { display: inline-block; padding: 0.75rem 0; }

/* ------------------------------------------------------------ elección de panel en Ajustes */
.select-small {
  min-height: 44px;
  padding: 0 2rem 0 0.75rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background-color: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
}
.panel-choice { margin: 0; padding: 0; border: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr)); gap: 0.75rem; }
.panel-choice legend { padding: 0; margin-bottom: 0.625rem; font-size: 0.875rem; color: var(--muted-hero); }
.choice { display: flex; gap: 0.875rem; align-items: flex-start; padding: 1rem 1.125rem; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); cursor: pointer; }
.choice:has(input:checked) { border: 2px solid var(--ink); padding: calc(1rem - 1px) calc(1.125rem - 1px); }
.choice input { width: 1.25rem; height: 1.25rem; margin: 0.2rem 0 0; flex: none; }
.choice b { display: block; font-size: 1.0625rem; }
.choice span span { display: block; margin-top: 0.25rem; color: var(--muted); }

/* ------------------------------------------------------------ varias estaciones */
.extras-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; padding-bottom: 1.25rem; margin-top: -0.75rem; }
.extras-row .year-chips { margin: 0; }
.legend-extras { display: contents; }
.legend-extras > span { display: inline-flex; align-items: center; gap: 0.625rem; }
.estacion-panel { margin-bottom: 1rem; }
.estacion-panel select {
  min-height: 44px;
  padding: 0 2rem 0 0.75rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background-color: var(--field);
  color: var(--ink);
  font-size: 0.9375rem;
}
.stations { width: 100%; min-width: 60rem; border-collapse: collapse; font-size: 0.9375rem; }
.stations th, .stations td { text-align: left; padding: 0.75rem 0.75rem 0.75rem 0; border-bottom: 1px solid var(--rule-soft); vertical-align: top; }
.stations thead th { font-weight: 400; font-size: 0.875rem; color: var(--muted); border-bottom-color: var(--rule); }
.stations .actions { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.stations .actions form { margin: 0; }
.stations .hist-form { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 0; }
.stations .hist-form input[type="date"] {
  min-height: 44px;
  padding: 0 0.625rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
}
.stations small { display: block; color: var(--muted); font-size: 0.8125rem; }

.acciones { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.acciones form { margin: 0; }

/* ------------------------------------------------------------ lista de estaciones de la comparativa */
.station-list { margin-bottom: 2.5rem; }
.station-list h2 { margin: 0; font-size: 1.375rem; font-weight: 500; font-stretch: 87.5%; }
.station-list .muted { margin: 0.25rem 0 1rem; font-size: 0.875rem; }
.estaciones { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.625rem; }
.estacion-item {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.25rem 0.375rem 0.25rem 0.5rem;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--field);
}
.estacion-item.activa { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.estacion-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 40px;
  padding: 0 0.625rem 0 0.25rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 0.9375rem;
  cursor: pointer;
}
.estacion-toggle .caja {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid var(--muted);
  border-radius: 4px;
  display: inline-grid;
  place-items: center;
}
.estacion-toggle[aria-pressed="true"] .caja { background: var(--ink); border-color: var(--ink); }
.estacion-toggle[aria-pressed="true"] .caja::after {
  content: "";
  width: 0.375rem;
  height: 0.625rem;
  border: solid var(--paper);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg) translate(-1px, -1px);
}
.estacion-tipo { font-size: 0.8125rem; color: var(--muted); }
.color-pick { display: inline-flex; width: 2rem; height: 2rem; border-radius: 50%; overflow: hidden; cursor: pointer; flex: none; }
.color-pick input { width: 3rem; height: 3rem; margin: -0.5rem; border: 0; padding: 0; cursor: pointer; background: none; }
.color-pick:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.dot-color { display: inline-block; width: 0.625rem; height: 0.625rem; margin-right: 0.375rem; border-radius: 50%; background: var(--c); vertical-align: 0.05em; }
.dot-color.hueco { background: transparent; box-shadow: inset 0 0 0 2px var(--c); }
.simple-acciones { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.estacion-toggle { text-align: left; }

.site-footer .descargas { display: flex; flex-wrap: wrap; gap: 0 1.5rem; }

.stations .hist-form .select-small { min-height: 40px; font-size: 0.875rem; }

/* ------------------------------------------------------------ tablas de Ajustes en el móvil: una ficha por fila */
@media (max-width: 48rem) {
  .stations, .users { min-width: 0; }
  .stations thead, .users thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .stations tbody, .users tbody { display: block; }
  .stations tr, .users tr { display: block; padding: 0.875rem 0; border-bottom: 1px solid var(--rule); }
  .stations th, .stations td, .users th, .users td { display: block; padding: 0.375rem 0; border: 0; }
  .stations th[scope="row"], .users th[scope="row"] { font-size: 1.0625rem; }
  .stations td[data-label]::before, .users td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    color: var(--muted);
  }
  .stations .celda-acciones:empty, .users .celda-acciones:empty { display: none; }
  .stations .hist-form, .users .inline-form { flex-wrap: wrap; }
}

/* ------------------------------------------------------------ panel: estación y periodo personalizado */
.hero-estacion { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; margin-bottom: 0.75rem; }
.hero-estacion label { font-size: 0.875rem; color: var(--muted-hero); }
.hero-estacion select {
  min-height: 44px;
  max-width: 100%;
  padding: 0 2.25rem 0 0.875rem;
  border: 1px solid rgba(28, 38, 48, 0.25);
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
}
@media (prefers-color-scheme: dark) {
  .hero-estacion select { border-color: rgba(255, 255, 255, 0.25); background-color: rgba(0, 0, 0, 0.25); }
}
.periodo { margin-bottom: 1.5rem; }
.periodo .pills { margin-bottom: 0; }
.rango { margin-top: 1rem; padding: 1rem 1.125rem; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); }
.rango-atajos { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-bottom: 0.875rem; }
.rango-atajos button {
  min-height: 40px;
  padding: 0 0.875rem;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink);
  font-size: 0.875rem;
  cursor: pointer;
}
.rango-fechas { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; }
.rango-fechas .field { flex: 1 1 10rem; max-width: 14rem; }
.rango-fechas input {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--field-border);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
}
.periodo-texto { margin: 0.75rem 0 0; font-size: 0.875rem; color: var(--muted); }
.periodo-texto:empty { display: none; }
.rango-cmp { margin: 0 0 1rem; background: rgba(255, 255, 255, 0.45); }
@media (prefers-color-scheme: dark) { .rango-cmp { background: rgba(0, 0, 0, 0.2); } }
.rango-nota { margin: 0.5rem 0 0; font-size: 0.8125rem; color: var(--muted-hero); }
.rango-nota:empty { display: none; }
.charts-final { margin-top: 3rem; }
