/* Tramia · monitor territorial v4. Layout y componentes (DESIGN.md §3 y §4). Los valores viven en tokens.css. */

/* ── 0. Base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font: var(--t-body-weight) var(--t-body-size)/var(--t-body-lh) var(--font);
  color: var(--c-ink);
  background: var(--c-canvas);
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, summary, select, label { cursor: pointer; }
h1, h2, h3, p, ul, ol { margin: 0; }
ul { padding: 0; list-style: none; }
a { color: var(--c-brand); }
a:hover { color: var(--c-brand-strong); }
[hidden] { display: none !important; }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--c-ink-muted); }
.small { font-size: var(--t-small-size); line-height: var(--t-small-lh); }

:where(button, input, select, textarea, summary, a, [tabindex]):focus-visible {
  outline: 3px solid var(--c-brand);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--c-surface);
}

/* ── 1. Cabecera ─────────────────────────────────────────── */
.topbar {
  min-height: var(--header-h);
  display: flex; align-items: center; gap: var(--s-4);
  padding: var(--s-2) var(--s-5);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-line);
  position: relative; z-index: var(--z-panel);
}
.topbar-spacer { flex: 0 0 0; margin-left: auto; }
/* Celular angosto: con 4 pestañas la primera fila lleva solo las pestañas y los tres botones; el control de fechas va en la segunda */
@media (max-width: 479px) {
  .topbar { gap: var(--s-1); padding-left:  6px; padding-right:  6px; }
  .topbar .brand, .topbar .territories { display: none; }
  .topbar .mode-nav { padding: 2px; }
  .topbar .mode-nav a { padding: 0 5px; font-size: 12px; min-height: 32px; }
  .topbar .icon-link { min-width: 32px; width: 32px; height: 36px; padding: 0; }
  .topbar .logout-label { display: none; }
}
/* Con menos de 1100 px el control de fechas pasa a una fila fina debajo del encabezado */
@media (max-width: 1099px) {
  :root { --header-h: 96px; }
  .topbar { flex-wrap: wrap; align-content: center; row-gap: 0; height: var(--header-h); box-sizing: border-box; padding-top: var(--s-1); padding-bottom: var(--s-1); }
  .tl-compact { order: 20; flex: 1 0 100%; height: 36px; }
}
.brand {
  display: inline-flex; align-items: center; gap: var(--s-2);
  color: var(--c-brand); text-decoration: none;
  font-size: 20px; font-weight: 700; letter-spacing: -.02em;
  min-height: var(--touch-size);
}
.brand-mark { width: 24px; height: 24px; flex: none; background: url("../img/tramia-mark.svg") center / contain no-repeat; }
.mode-nav { display: flex; gap: var(--s-1); padding: var(--s-1); background: var(--c-surface-alt); border-radius: var(--r-pill); }
.mode-nav a {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-4);
  border-radius: var(--r-pill); color: var(--c-ink); text-decoration: none; white-space: nowrap;
  font-size: var(--t-body-size); font-weight: 500;
}
.mode-nav a:hover { background: var(--c-line); }
.mode-nav a[aria-current="page"] { background: var(--c-brand); color: var(--c-on-brand); font-weight: 600; }
.territories { position: relative; }
.territories-chip {
  display: inline-flex; align-items: center; gap: var(--s-2); min-height: var(--touch-size); padding: 0 var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-pill); font-size: var(--t-body-size);
}
.territories-chip #territories-label { max-width: 38ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.territories-chip svg { width: 16px; height: 16px; fill: none; stroke: var(--c-brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.territories-chip .chev { width: 14px; height: 14px; stroke: var(--c-ink-muted); }
.territories-chip[aria-expanded="true"] .chev { transform: rotate(180deg); }
.menu {
  position: absolute; z-index: var(--z-dialog); top: calc(100% + var(--s-1)); left: 0; min-width: 240px;
  padding: var(--s-3); display: grid; gap: var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float);
}
.menu-title { font-size: var(--t-small-size); font-weight: 600; color: var(--c-ink-muted); }
.menu-list { display: grid; gap: var(--s-1); }
.menu-list li { display: flex; align-items: center; gap: var(--s-2); min-height: 32px; }
.menu-list li::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c-ok); }
.menu-link { display: inline-flex; align-items: center; min-height: var(--touch-size); font-weight: 600; font-size: var(--t-small-size); }
.service-chip {
  display: inline-flex; align-items: center; gap: var(--s-2);
  max-width: 42ch; min-height: 28px;
  font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.service-chip::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--c-warn); }
.service-chip.is-ok::before { background: var(--c-ok); }
.service-chip.is-warn::before { background: var(--c-warn); }
.service-chip.is-error { color: var(--c-error); }
.service-chip.is-error::before { background: var(--c-error); }
.icon-link {
  display: inline-grid; place-items: center; width: var(--touch-size); height: var(--touch-size);
  border: 1px solid var(--c-line); border-radius: var(--r-md); color: var(--c-ink);
}
.logout { position: relative; }
.logout-btn { width: auto; min-width: var(--touch-size); grid-auto-flow: column; gap: var(--s-2); padding: 0 var(--s-3); background: var(--c-surface); font: inherit; font-size: var(--t-small-size); font-weight: 600; cursor: pointer; }
.logout-btn:hover { background: var(--c-surface-alt); }
.logout-confirm { left: auto; right: 0; width: 220px; }
.logout-actions { display: flex; gap: var(--s-2); margin-top: var(--s-2); }
@media (max-width: 767px) { .logout-label { display: none; } .logout-btn { padding: 0; width: var(--touch-size); } }
.icon-link svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-link[aria-current="page"] { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }

/* ── 2. Estructura ───────────────────────────────────────── */
.workspace {
  display: grid; grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--conv-w);
  height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); min-height: 0;
}
.sidebar {
  grid-column: 1; grid-row: 1; min-width: 0;
  background: var(--c-surface); border-right: 1px solid var(--c-line);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--c-line) transparent;
}
.map-shell { grid-column: 2; grid-row: 1; position: relative; min-width: 0; min-height: 0; background: var(--c-canvas); }
#map { position: absolute; inset: 0; z-index: 0; background: var(--c-canvas); }
.side-panel { grid-column: 3; grid-row: 1; min-width: 0; min-height: 0; }
.mobile-only { display: none !important; }
.mode-panel { padding: var(--s-5); display: grid; gap: var(--s-4); align-content: start; }
.panel-head h1 { font-size: 20px; line-height: 26px; font-weight: 700; }
.panel-head p { margin-top: var(--s-1); font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.sheet-head { align-items: center; justify-content: space-between; padding: var(--s-2) var(--s-3) var(--s-2) var(--s-5); position: sticky; top: 0; z-index: 1; background: var(--c-surface); border-bottom: 1px solid var(--c-line); }
.section-title, .card h2, .legend-block h2 { font-size: var(--t-body-size); line-height: var(--t-body-lh); font-weight: 600; }
.btn-primary, .btn-secondary {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--touch-size); padding: 0 var(--s-4);
  border-radius: var(--r-md); font-size: var(--t-body-size); font-weight: 600; text-decoration: none; text-align: center;
}
.btn-primary { background: var(--c-brand); color: var(--c-on-brand); border: 1px solid var(--c-brand); }
.btn-primary:hover:not(:disabled) { background: var(--c-brand-strong); color: var(--c-on-brand); }
.btn-primary:disabled { background: var(--c-ink-muted); border-color: var(--c-ink-muted); cursor: default; }
.btn-secondary { background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line-strong); }
.btn-secondary:hover { background: var(--c-surface-alt); color: var(--c-ink); }
.btn-compact { min-height: 40px; }
.link-strong { display: inline-flex; align-items: center; min-height: var(--touch-size); font-size: var(--t-small-size); font-weight: 600; }

/* ── 3. Tarjetas del panel ───────────────────────────────── */
.card { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--c-line); border-radius: 12px; background: var(--c-surface); }
.card-tinted { background: var(--c-surface-alt); border-color: transparent; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.rain-table { width: 100%; border-collapse: collapse; font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.rain-table th { text-align: left; font-weight: 500; color: var(--c-ink-muted); padding: 0 0 var(--s-2); }
.rain-table th.num, .rain-table td.num { text-align: right; }
.rain-table td { padding: var(--s-1) 0; font-weight: 400; }
.rain-table td.num { font-weight: 600; }
.rain-table td.forecast { color: var(--c-info); }
.site-status-list { display: grid; gap: var(--s-1); }
.site-status { width: 100%; display: flex; align-items: center; gap: var(--s-3); min-height: var(--touch-size); padding: var(--s-1); text-align: left; background: transparent; border: 0; border-radius: var(--r-md); }
.site-status:hover { background: var(--c-surface-alt); }
.site-status.is-selected { background: var(--c-surface-alt); }
.site-icon {
  --site-ring: var(--d-site-nodata); --site-fill: var(--d-site-nodata-bg);
  flex: none; display: grid; place-items: center; width: 32px; height: 32px; box-sizing: border-box;
  border: 3px solid var(--site-ring); border-radius: 50%; background: var(--site-fill); color: var(--site-ring);
}
.site-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.site-icon.is-dry { --site-ring: var(--d-site-dry); --site-fill: var(--d-site-dry-bg); }
.site-icon.is-water_near { --site-ring: var(--d-site-near); --site-fill: var(--d-site-near-bg); box-shadow: inset 0 0 0 2px var(--c-surface), inset 0 0 0 3px var(--d-site-near); }
.site-icon.is-flooded { --site-ring: var(--d-site-flood); --site-fill: var(--d-site-flood-bg); border-width: 4px; box-shadow: 0 0 0 2px var(--c-surface), 0 0 0 4px var(--d-site-flood); }
.site-icon.is-no_data { border-style: dashed; }
.status-copy { flex: 1 1 8ch; min-width: 8ch; display: grid; overflow-wrap: anywhere; text-align: left; }
.status-copy strong { font-size: var(--t-body-size); font-weight: 600; }
.status-copy span { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }

.layer-item { display: grid; gap: var(--s-2); }
.layer-row { display: flex; align-items: center; gap: var(--s-3); min-height: var(--touch-size); font-size: var(--t-body-size); }
input[role="switch"] {
  -webkit-appearance: none; appearance: none;
  position: relative; flex: none; margin: 0;
  width: var(--switch-w); height: var(--switch-h); border-radius: var(--r-pill);
  border: 2px solid var(--c-ink-muted); background: var(--c-surface);
  transition: background-color .15s, border-color .15s;
}
input[role="switch"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%;
  background: var(--c-ink-muted); transition: transform .15s, background-color .15s;
}
input[role="switch"]:checked { background: var(--c-brand); border-color: var(--c-brand); }
input[role="switch"]:checked::after { transform: translateX(16px); background: var(--c-on-brand); }

.how { border-top: 1px solid var(--c-line); }
.how > .helper { padding: 0 0 var(--s-2); }
summary {
  display: flex; align-items: center; min-height: 32px; border-radius: var(--r-sm);
  font-size: var(--t-small-size); font-weight: 600; color: var(--c-ink-muted);
}
/* El foco del resumen se dibuja solo con teclado: un clic de mouse no deja contorno. */
summary:focus:not(:focus-visible) { outline: none; box-shadow: none; }
summary:focus-visible { outline: 3px solid var(--c-brand); outline-offset: 2px; box-shadow: 0 0 0 2px var(--c-surface); }

.legend { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); }
.legend li { display: inline-flex; align-items: center; gap: var(--s-2); font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.legend-col { flex-direction: column; flex-wrap: nowrap; gap: var(--s-2); }
.legend-col li { gap: var(--s-3); }
.legend .sw, .legend-map .sw { flex: none; display: inline-block; }
.legend-block { display: grid; gap: var(--s-2); }
.sw-area { width: 16px; height: 10px; border-radius: 2px; }
.sw-line { width: 28px; height: 4px; border-radius: 2px; }
.sw-optical { background: var(--d-water-optical); opacity: .7; }
.sw-radar { background: var(--d-water-radar); opacity: .7; }
.sw-both { background: var(--d-water-both); opacity: .8; }
.sw-dry { background: var(--d-water-dry); opacity: .5; }
.sw-nodata-solid { background: var(--c-surface); border: 1px solid var(--c-line-strong); }
.sw-road-zero { background: var(--d-road-zero); }
.sw-road-1 { background: var(--d-road-1); }
.sw-road-2 { background: var(--d-road-2); height: 5px; }
.sw-road-3 { background: var(--d-road-3); height: 6px; }
.sw-road-4 { background: var(--d-road-4); height: 7px; }
.sw-road-unknown { height: 2px; background: var(--d-road-unknown); }
.sw-road-permanent { height: 3px; background: var(--d-road-permanent); }
.sw-limited { opacity: .5; vertical-align: middle; }
.sw-route-shortest { background: var(--d-route-shortest); height: 4px; width: 22px; }
.sw-route-lower { background: var(--d-route-lower); height: 6px; width: 22px; }
.sw-route-unmonitored { background: repeating-linear-gradient(90deg, var(--c-ink-muted) 0 6px, transparent 6px 10px); height: 4px; width: 22px; }

.scale { display: grid; gap: 2px; }
.scale-title { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.scale-bar { display: grid; grid-template-columns: repeat(5, 1fr); height: 8px; border-radius: 2px; overflow: hidden; }
.scale-values { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.rain-0 { background: var(--d-rain-0); } .rain-1 { background: var(--d-rain-1); } .rain-2 { background: var(--d-rain-2); }
.rain-3 { background: var(--d-rain-3); } .rain-4 { background: var(--d-rain-4); }

.layer-status {
  font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted);
  display: flex; align-items: flex-start; gap: var(--s-2);
}
.layer-status:empty { display: none; }
.layer-status.is-info { color: var(--c-info); }
.layer-status.is-warn { color: var(--c-warn); background: var(--c-warn-bg); padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); }
.layer-status.is-error { color: var(--c-error); background: var(--c-error-bg); padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); }
.layer-status.is-loading::before {
  content: ""; flex: none; width: 12px; height: 12px; margin-top: 3px; border-radius: 50%;
  border: 2px solid var(--c-line); border-top-color: var(--c-brand);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.helper { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }

.field { display: grid; gap: var(--s-1); }
.field > label, .trip-step > label { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink-muted); }
select, .site-form input {
  width: 100%; min-height: 40px; padding: var(--s-1) var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-line-strong); border-radius: 8px;
  font-size: var(--t-body-size);
}
.basemap-field { padding-top: var(--s-2); border-top: 1px solid var(--c-line); }

/* Historial: períodos y resumen */
.period-field { border: 0; padding: 0; margin: 0; display: grid; gap: var(--s-2); min-width: 0; }
.period-field legend { padding: 0; margin-bottom: var(--s-2); font-size: var(--t-small-size); font-weight: 600; }
.period-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.period-grid label:last-child:nth-child(odd) { grid-column: 1 / -1; }
.period-grid label {
  position: relative; display: flex; align-items: center; justify-content: center; min-height: var(--touch-size);
  border: 1px solid var(--c-line); border-radius: 8px; font-size: var(--t-small-size); background: var(--c-surface);
}
.period-grid label:hover { background: var(--c-surface-alt); }
.period-grid input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.period-grid label:has(input:checked) { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); font-weight: 600; }
.period-grid label:has(input:focus-visible) { outline: 3px solid var(--c-brand); outline-offset: 2px; }
.period-custom { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s-2); }
.period-custom-pick {
  position: relative; display: inline-flex; align-items: center; min-height: var(--touch-size); padding: 0 var(--s-3);
  border: 1px solid var(--c-line); border-radius: 8px; background: var(--c-surface); font-size: var(--t-small-size);
}
.period-custom-pick input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.period-custom-pick:has(input:checked) { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); font-weight: 600; }
.period-custom-pick:has(input:focus-visible) { outline: 3px solid var(--c-brand); outline-offset: 2px; }
.stepper { display: inline-flex; align-items: stretch; border: 1px solid var(--c-line-strong); border-radius: 8px; overflow: hidden; background: var(--c-surface); }
.stepper-btn { width: var(--control-size); min-height: var(--touch-size); padding: 0; background: var(--c-surface); color: var(--c-brand); border: 0; font-size: 20px; line-height: 1; }
.stepper-btn:hover:not(:disabled) { background: var(--c-surface-alt); }
.stepper-btn:disabled { color: var(--c-ink-muted); opacity: .55; cursor: default; }
.stepper input { width: 52px; min-height: var(--touch-size); padding: 0; text-align: center; border: 0; border-left: 1px solid var(--c-line); border-right: 1px solid var(--c-line); border-radius: 0; font-size: var(--t-body-size); background: var(--c-surface); color: var(--c-ink); -moz-appearance: textfield; appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.period-custom-unit { font-size: var(--t-small-size); color: var(--c-ink-muted); }
.km-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3); }
.km-grid > div { display: grid; }
.stat { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Mis viajes: formulario, recientes, tarjetas */
.trip-form { display: grid; gap: var(--s-2); padding: var(--s-4); background: var(--c-surface-alt); border-radius: 12px; }
.trip-recent { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.trip-item { width: 100%; display: grid; gap: 2px; padding: var(--s-3); text-align: left; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.trip-item:hover { background: var(--c-surface-alt); }
.trip-item.is-selected { border: 2px solid var(--c-brand); padding: calc(var(--s-3) - 1px); }
.trip-item strong { font-size: var(--t-body-size); font-weight: 600; }
.trip-item span { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.trip-result { display: grid; gap: var(--s-3); }
.trip-result h3 { font-size: 18px; line-height: 24px; font-weight: 700; }
.route-card { display: grid; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--c-line); border-radius: 12px; }
.route-card.is-lower { border: 2px solid var(--d-route-lower); padding: calc(var(--s-4) - 1px); }
.route-card-head { display: flex; align-items: center; gap: var(--s-2); }
.route-card-head h4 { margin: 0; font-size: 15px; line-height: 22px; font-weight: 700; }
.route-line { flex: none; display: inline-block; width: 22px; border-radius: 2px; }
.route-line.is-shortest { height: 4px; background: var(--d-route-shortest); }
.route-line.is-lower { height: 6px; background: var(--d-route-lower); }
.route-delta { margin-left: auto; padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--t-micro-size); font-weight: 600; color: var(--c-warn); background: var(--c-warn-bg); }
.route-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.route-stats div { display: grid; }
.route-stats strong { font-size: 18px; line-height: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.route-paved { margin: 0; }
.route-stats .is-wet { color: var(--d-road-4); }
.route-stats .is-dry { color: var(--c-ok); }
.route-stats span { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.route-links { display: flex; flex-wrap: wrap; gap: 6px; }
.route-links a { display: inline-flex; align-items: center; min-height: var(--touch-size); padding: 0 var(--s-3); border-radius: 8px; font-size: var(--t-small-size); text-decoration: none; border: 1px solid var(--c-line-strong); color: var(--c-ink); }
.route-rain { display: grid; gap: 6px; padding: var(--s-3); border-radius: 12px; background: var(--c-surface-alt); font-size: var(--t-small-size); }
.route-rain div { display: flex; justify-content: space-between; gap: var(--s-3); }

/* ── 4. Mapa: controles, leyenda, avisos ─────────────────── */
.map-controls {
  position: absolute; z-index: var(--z-map-controls); top: var(--s-4); right: var(--s-4);
  display: flex; flex-direction: column; align-items: flex-end; gap: var(--s-2);
}
.map-control-wrap { position: relative; }
.map-controls:has(#basemap-menu:not([hidden])) { z-index: var(--z-drawer); }
.map-popover {
  position: absolute; z-index: var(--z-map-controls); padding: var(--s-2);
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float);
  font-size: var(--t-small-size); line-height: var(--t-small-lh);
}
.basemap-menu { top: 0; right: calc(100% + var(--s-2)); display: grid; gap: var(--s-1); min-width: 168px; max-width: calc(100vw - 72px); max-height: calc(100dvh - 16px); overflow-y: auto; overscroll-behavior: contain; }
.basemap-menu[hidden], .sources-help[hidden] { display: none; }
.zone-card { display: grid; gap: var(--s-2); padding: var(--s-3); }
.zone-card p { margin: 0; }
.zone-card button { justify-self: start; }
.zone-dialog { width: min(920px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow-y: auto; border: 1px solid var(--c-line); border-radius: var(--r-md); padding: var(--s-4); color: var(--c-ink); background: var(--c-surface); }
.zone-dialog::backdrop { background: rgb(0 0 0 / .45); }
.zone-dialog-head { display: flex; justify-content: space-between; align-items: start; gap: var(--s-3); }
.zone-dialog-head h2, .zone-dialog-head p { margin: 0; }
.zone-legend { display: flex; flex-wrap: wrap; gap: var(--s-2) var(--s-4); list-style: none; padding: 0; font-size: var(--t-small-size); margin: var(--s-2) 0; }
.zone-legend li { display: inline-flex; align-items: center; gap: var(--s-2); }
.zone-sw { display: inline-block; width: 18px; height: 14px; border-radius: 3px; border: 1px solid var(--d-zone-border); }
.zone-sw-auto { background: var(--d-zone-auto); }
.zone-sw-extra { background: var(--d-zone-extra); }
.zone-sw-available { background: var(--d-zone-available); }
.zone-parts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); margin: 0 0 var(--s-2); font-size: var(--t-small-size); }
.zone-parts .btn-secondary { min-height: 32px; padding: 0 var(--s-3); }
.zone-summary { display: grid; gap: var(--s-2); justify-items: start; }
.zone-summary p { margin: 0; }
.zone-auto::before { background: var(--d-zone-auto); }.zone-extra::before { background: var(--d-zone-extra); }.zone-locked::before { background: var(--d-zone-locked); }.zone-available::before { background: var(--d-zone-available); }.zone-no-data::before { background: var(--d-zone-nodata); }
.zone-map { width: 100%; height: min(48dvh, 440px); min-height: 190px; border: 1px solid var(--c-line); }
.zone-action { display: flex; align-items: center; flex-wrap: wrap; justify-content: space-between; gap: var(--s-2); }
.zone-action p { margin: var(--s-2) 0; }
.basemap-menu .menu-title { padding: 0 var(--s-2); font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); }
.basemap-option {
  min-height: 36px; padding: 0 var(--s-3); text-align: left; background: transparent; color: var(--c-ink);
  border: 1px solid transparent; border-radius: var(--r-sm); font-size: var(--t-body-size);
}
.basemap-option:hover { background: var(--c-surface-alt); }
.basemap-option[aria-pressed="true"] { background: var(--c-brand); color: var(--c-on-brand); font-weight: 600; }
.basemap-option:focus-visible, .seg-btn:focus-visible, .sources-help-btn:focus-visible, .stepper-btn:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }
.basemap-menu .layer-status { padding: 0 var(--s-2); }
.map-btn {
  display: grid; place-items: center;
  width: var(--control-size); height: var(--control-size); padding: 0;
  background: var(--c-surface); color: var(--c-brand);
  border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float);
}
.map-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.map-btn:hover:not(:disabled) { background: var(--c-surface-alt); }
.map-btn-text { width: auto; padding: 0 var(--s-4); gap: var(--s-2); grid-auto-flow: column; font-weight: 600; font-size: var(--t-body-size); height: var(--touch-size); }
.map-tabs { position: absolute; z-index: var(--z-map-controls); right: var(--s-4); bottom: 44px; display: flex; gap: var(--s-2); }
.icon-button {
  display: grid; place-items: center; width: var(--touch-size); height: var(--touch-size);
  background: transparent; border: 1px solid transparent; border-radius: var(--r-md);
  font-size: 24px; line-height: 1; color: var(--c-ink-muted);
}
.icon-button:hover { background: var(--c-surface-alt); border-color: var(--c-line); }
.map-legend { position: absolute; z-index: var(--z-map-controls); left: var(--s-4); bottom: 36px; display: grid; gap: var(--s-1); justify-items: start; max-width: calc(100% - 2 * var(--s-4)); }
.legend-chip { display: inline-flex; align-items: center; min-height: 32px; padding: 0 var(--s-3); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line-strong); border-radius: var(--r-pill); box-shadow: var(--e-float); font: inherit; font-size: var(--t-small-size); font-weight: 600; cursor: pointer; }
.legend-chip[aria-expanded="true"] { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.legend-chip:focus-visible { outline: 3px solid var(--c-info); outline-offset: 2px; }
/* Una sola tarjeta «Referencias»: solo las capas activas, agrupadas; el resto de las leyendas son secciones de ella. */
.legend-body { box-sizing: border-box; display: grid; gap: var(--s-2); width: 232px; max-width: 100%; max-height: min(60vh, 480px); overflow-y: auto; padding: 10px 12px; background: var(--c-surface); border-radius: 10px; box-shadow: var(--e-float); }
.legend-body[hidden] { display: none; }
.legend-body .legend-map { gap: 4px; padding: 0; background: none; border-radius: 0; box-shadow: none; }
.legend-body .legend-map + .legend-map, .legend-body .legend-map + .jrc-legend { padding-top: var(--s-2); border-top: 1px solid var(--c-line); }
.legend-body .legend-title { font-weight: 600; color: var(--c-ink); }
.legend-body .legend-map li { gap: var(--s-2); }
.legend-body .scale-values { font-size: 11px; }
.legend-title-both { display: none; }   /* los caminos de una fecha ya no usan la escala de frecuencia: la del lote es solo del lote */
.sw-road-wet { background: var(--d-road-wet); height: 5px; }
.sw-road-day { background: var(--d-road-day); height: 2px; }
.sw-road-recent { background: var(--d-road-wet); height: 3px; opacity: .45; }
.legend-map { display: grid; gap: 6px; padding: 10px 12px; background: var(--c-surface); border-radius: 10px; box-shadow: var(--e-float); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); }
.legend-map li { display: flex; align-items: center; gap: var(--s-2); }
.legend-map li[hidden] { display: none; }
.legend-map[data-for-mode] { display: none; }
body[data-mode="ahora"] .legend-map[data-for-mode~="ahora"],
body[data-mode="campos"] .legend-map[data-for-mode~="campos"],
body[data-mode="historial"] .legend-map[data-for-mode~="historial"],
body[data-mode="viajes"] .legend-map[data-for-mode~="viajes"] { display: grid; }
.map-legend[hidden] { display: none; }

.toasts {
  position: absolute; z-index: var(--z-toast); bottom: calc(var(--s-8) + var(--s-8)); left: 50%; transform: translateX(-50%);
  display: grid; gap: var(--s-2); justify-items: center;
  width: max-content; max-width: calc(100% - 2 * var(--s-4));
  pointer-events: none;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-4); border-radius: var(--r-md); box-shadow: var(--e-float);
  font-size: var(--t-small-size); line-height: var(--t-small-lh);
}
.toast-warn { color: var(--c-warn); background: var(--c-warn-bg); }
.toast-error { color: var(--c-error); background: var(--c-error-bg); }
.toast button {
  min-height: 36px; padding: 0 var(--s-3); font-weight: 600; font-size: var(--t-small-size);
  background: var(--c-surface); border: 1px solid currentColor; border-radius: var(--r-sm); color: inherit;
}

/* Leaflet: la atribución y la escala no tocan el borde del mapa */
.leaflet-bottom { bottom: var(--s-2); }
.leaflet-bottom.leaflet-right { right: var(--s-2); max-width: calc(100% - 2 * var(--s-2) - 96px); }
.leaflet-bottom.leaflet-left { left: var(--s-2); }
.leaflet-control-attribution { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); white-space: normal; text-align: right; }
.basemap-muted { filter: var(--basemap-muted-filter); }

/* Marcadores de sitios y extremos de recorrido */
.site-marker, .route-end { background: none; border: 0; }
.site-marker .site-icon.is-dry, .site-marker .site-icon.is-no_data { box-shadow: var(--e-float); }
.site-marker .site-icon.is-water_near { box-shadow: inset 0 0 0 2px var(--c-surface), inset 0 0 0 3px var(--d-site-near), var(--e-float); }
.site-label { position: absolute; left: 38px; top: 6px; white-space: nowrap; padding: 0 var(--s-1); border-radius: var(--r-sm); background: var(--c-surface); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink); opacity: .94; }
.route-end span { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--c-brand); color: var(--c-on-brand); border: 2px solid var(--c-surface); font-size: 13px; font-weight: 700; }

/* ── 5. Línea temporal ───────────────────────────────────── */
/* P23: en el encabezado va un control sutil (▶, fecha, barra fina, ‹ ›, ⋯); todo lo demás (barra con meses, velocidad, fuentes, última imagen) está en un
   panel desplegable debajo del encabezado, flotando sobre el mapa. */
.tl-compact { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: var(--s-2); overflow: hidden; }
.tlc-btn { flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--c-ink-muted); font-size: 16px; line-height: 1; cursor: pointer; }
.tlc-btn:hover:not(:disabled) { background: var(--c-surface-alt); color: var(--c-brand); }
.tlc-btn:disabled { opacity: .4; cursor: default; }
.tlc-btn:focus-visible { outline: 3px solid var(--c-brand); outline-offset: 1px; }
.tlc-play { background: var(--c-surface-alt); color: var(--c-brand); font-size: 11px; }
.tlc-date { flex: none; min-width: 80px; padding-left: var(--s-1); font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tlc-slider { -webkit-appearance: none; appearance: none; flex: 1 1 420px; min-width: 200px; max-width: 420px; height: 18px; margin: 0; background: transparent; --f: 0; cursor: pointer; }
.tlc-slider::-webkit-slider-runnable-track { height: 3px; border-radius: var(--r-pill); background: linear-gradient(to right, var(--c-ink-subtle) calc(var(--f) * 100%), var(--c-line) 0); }
.tlc-slider::-moz-range-track { height: 3px; border-radius: var(--r-pill); background: var(--c-line); }
.tlc-slider::-moz-range-progress { height: 3px; border-radius: var(--r-pill); background: var(--c-ink-subtle); }
.tlc-slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 12px; height: 12px; margin-top: -4.5px; border-radius: 50%; background: var(--c-brand); border: 2px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-brand); }
.tlc-slider::-moz-range-thumb { box-sizing: border-box; width: 12px; height: 12px; border-radius: 50%; background: var(--c-brand); border: 2px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-brand); }
.tlc-slider:disabled { opacity: .5; }
@media (max-width: 1439px) { .tl-compact { gap: var(--s-1); } .tlc-date { min-width: 80px; } .tlc-slider { min-width: 130px; } }   /* con 4 pestañas a 1366 px la barra cede espacio: nunca una fila más */
.tlc-slider:focus { outline: none; }
.tlc-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--c-brand), 0 0 0 4px var(--c-accent); }
.timeline {
  display: none; position: fixed; z-index: var(--z-drawer);
  left: 50%; transform: translateX(-50%); top: calc(var(--header-h) + var(--s-1));
  width: min(560px, calc(100vw - 2 * var(--s-4))); max-height: calc(100dvh - var(--header-h) - 2 * var(--s-2)); overflow-y: auto;
  gap: var(--s-1);
  padding: var(--s-2) var(--s-3);
  background: var(--c-surface); border-radius: 12px; box-shadow: var(--e-float);
}
.timeline.is-open { display: grid; }
/* P25: aviso al ver una fecha que no es la última */
.day-notice { position: absolute; z-index: var(--z-map-controls); top: var(--s-2); left: 50%; transform: translateX(-50%); max-width: calc(100% - 2 * var(--control-size) - 4 * var(--s-4)); display: flex; align-items: center; gap: var(--s-3); padding: var(--s-1) var(--s-1) var(--s-1) var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-pill); box-shadow: var(--e-float); font-size: var(--t-small-size); line-height: var(--t-small-lh); white-space: nowrap; }
.day-notice[hidden] { display: none; }
.day-notice button { min-height: 28px; padding: 0 var(--s-3); border: 0; border-radius: var(--r-pill); background: var(--c-brand); color: var(--c-on-brand); font: inherit; font-weight: 600; cursor: pointer; }
.day-notice button:focus-visible { outline: 3px solid var(--c-accent); outline-offset: 1px; }
body[data-mode="viajes"] .timeline, body[data-mode="config"] .timeline, body[data-mode="viajes"] .tl-compact, body[data-mode="config"] .tl-compact { display: none; }
.timeline .service-chip { display: inline-flex; justify-self: start; }
.timeline-main { display: flex; align-items: center; gap: var(--s-3); min-width: 0; }
.timeline-current { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: auto auto; justify-content: start; align-items: baseline; column-gap: var(--s-2); }
#selected-day-label { font-size: 15px; line-height: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.date-availability { grid-column: 1 / -1; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.date-availability.is-warn { color: var(--c-warn); }
.timeline-group { display: flex; gap: 2px; }
.tl-btn.tl-speed { min-width: 32px; font-size: 12px; font-weight: 700; margin-left: calc(var(--s-3) * -0.5); }
.tl-btn.tl-speed[aria-pressed="true"] { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.tl-btn.tl-more { display: none; }
.timeline-extra { display: grid; gap: var(--s-1); }
.tl-btn {
  display: grid; place-items: center; min-width: 36px; height: 36px; padding: 0;
  background: var(--c-surface); color: var(--c-brand); font-size: 20px; line-height: 1;
  border: 1px solid var(--c-line); border-radius: 8px;
}
.tl-btn:hover:not(:disabled) { background: var(--c-surface-alt); }
.tl-btn:disabled { color: var(--c-ink-muted); opacity: .55; cursor: default; }
.tl-btn.play-button { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); font-size: 14px; }
.tl-btn.play-button:hover:not(:disabled) { background: var(--c-brand-strong); }
.tl-btn.play-button:disabled { background: var(--c-ink-muted); border-color: var(--c-ink-muted); color: var(--c-on-brand); }
.tl-btn:focus:not(:focus-visible) { outline: none; box-shadow: none; }
.tl-btn:focus-visible { outline: 3px solid var(--c-brand); outline-offset: -3px; box-shadow: none; }
.badge { display: inline-flex; align-items: center; padding: 0 var(--s-2); border-radius: var(--r-sm); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: var(--t-micro-weight); }
.badge-prelim { color: var(--c-warn); background: var(--c-warn-bg); border: 1px dashed var(--c-warn); }
.timeline-track { min-width: 0; display: grid; }
.slider-wrap { position: relative; height: 32px; }
.date-ticks { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.date-ticks i {
  position: absolute; top: calc(50% - 13px); height: 6px; width: 2px; margin-left: -1px;
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--f, 0));
  background: var(--d-water-optical); border-radius: 1px;
}
.date-ticks i.is-radar { background: var(--d-water-radar); }
.date-ticks i.is-empty { background: var(--c-line-strong); }
/* Etiquetas de mes (y del cambio de fuente) bajo la barra */
.date-months { position: relative; height: 12px; font-size: var(--t-micro-size); line-height: 12px; color: var(--c-ink-muted); pointer-events: none; }
.date-months span { position: absolute; top: 0; white-space: nowrap; transform: translateX(-50%); left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--f, 0)); }
.date-months span.is-start { transform: none; margin-left: calc(var(--thumb) / -2); }
.date-months span.is-end { transform: translateX(-100%); margin-left: calc(var(--thumb) / 2); }
.date-ticks i.is-prelim {
  top: calc(50% - 14px); width: 6px; height: 8px; margin-left: -3px; box-sizing: border-box;
  background: transparent; border: 1.5px solid var(--c-warn); border-radius: 1px;
}
/* Historial: la ventana de recurrencia hasta la fecha elegida */
.timeline-window {
  position: absolute; z-index: 0; top: calc(50% - 9px); height: 18px; border-radius: 4px; pointer-events: none;
  left: calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--fs, 0));
  right: calc(var(--thumb) / 2 + (100% - var(--thumb)) * (1 - var(--fe, 1)));
  background: var(--c-accent); opacity: .55;
}
#date-slider {
  -webkit-appearance: none; appearance: none;
  position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; background: transparent;
  --f: 0;
}
#date-slider::-webkit-slider-runnable-track {
  height: 4px; border-radius: var(--r-pill);
  background: linear-gradient(to right, var(--c-brand) calc(var(--thumb) / 2 + (100% - var(--thumb)) * var(--f)), var(--c-line) 0);
}
#date-slider::-moz-range-track { height: 4px; border-radius: var(--r-pill); background: var(--c-line); }
#date-slider::-moz-range-progress { height: 4px; border-radius: var(--r-pill); background: var(--c-brand); }
#date-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: var(--thumb); height: var(--thumb); margin-top: -8px;
  border-radius: 50%; background: var(--c-brand); border: 3px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-brand);
}
#date-slider::-moz-range-thumb {
  box-sizing: border-box; width: var(--thumb); height: var(--thumb);
  border-radius: 50%; background: var(--c-brand); border: 3px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-brand);
}
#date-slider:disabled { opacity: .5; }
/* Foco: el recuadro del control (ancho completo) nunca se dibuja; el foco de teclado va en la perilla. */
#date-slider:focus, #date-slider:focus-visible { outline: none; box-shadow: none; }
#date-slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--c-brand), 0 0 0 4px var(--c-accent); }
#date-slider:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 1px var(--c-brand), 0 0 0 4px var(--c-accent); }
.sources-control { position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); padding-top: var(--s-1); border-top: 1px solid var(--c-line); }
.sources-label { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink-muted); }
.seg { display: inline-flex; flex: 1 1 auto; min-width: 0; }
.seg-btn {
  flex: 1 1 0; min-height: 32px; padding: 0 var(--s-2); background: var(--c-surface); color: var(--c-ink);
  border: 1px solid var(--c-line-strong); font-size: var(--t-small-size); font-weight: 600; white-space: nowrap;
}
.seg-btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
.seg-btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; margin-left: -1px; }
.seg-btn:hover:not([aria-pressed="true"]) { background: var(--c-surface-alt); }
.seg-btn[aria-pressed="true"] { background: var(--c-brand); border-color: var(--c-brand); color: var(--c-on-brand); }
.seg-btn:focus-visible { position: relative; z-index: 1; }
.sources-help-btn { flex: none; width: 28px; height: 28px; padding: 0; background: var(--c-surface-alt); color: var(--c-brand); border: 1px solid var(--c-line-strong); border-radius: 50%; font-size: var(--t-small-size); font-weight: 700; }
.sources-help { position: static; flex: 1 0 100%; width: 100%; margin: 0; box-sizing: border-box; padding: var(--s-2) var(--s-3); }
.timeline-ends { display: flex; justify-content: space-between; gap: var(--s-2); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.timeline-window-label { flex: 1; text-align: center; }
body:not([data-mode="historial"]) .timeline-window-label { display: none; }

/* ── 6. Panel del tramo (Historial) ──────────────────────── */
.road-panel {
  display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-5); overflow-y: auto;
  background: var(--c-surface); border-left: 1px solid var(--c-line);
}
.road-panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.road-panel-head h2 { margin-top: 2px; font-size: var(--t-title-size); line-height: var(--t-title-lh); font-weight: 700; }
.road-detail { display: grid; gap: var(--s-4); }
.road-frequency { display: grid; gap: 2px; padding: var(--s-4); border-radius: 12px; background: var(--c-surface-alt); }
.road-recurrence-count { font-size: 24px; line-height: 30px; font-weight: 700; }
.road-frequency .meta { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.road-warning { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-warn); background: var(--c-warn-bg); }
.road-episodes { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--c-line-strong); background: var(--c-surface); }
.road-episodes h3 { font-size: var(--t-small-size); font-weight: 600; }
.road-flood { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--t-body-size); font-weight: 600; background: var(--c-surface-alt); color: var(--c-ink); }
.road-flood.is-flooded { border: 2px solid var(--d-road-outline); background: var(--c-surface); }
.episode-list { display: grid; gap: var(--s-1); }
.episode-list li { display: grid; }
.episode-list strong { font-size: var(--t-body-size); font-weight: 700; }
.episode-list span { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.road-permanent, .road-weak { padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); font-size: var(--t-small-size); line-height: var(--t-small-lh); background: var(--c-surface-alt); color: var(--c-ink); }
.road-permanent { border-left: 4px dashed var(--d-road-permanent); }
.road-longterm { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); border: 1px dashed var(--c-line-strong); background: var(--c-surface); }
.road-longterm h3 { font-size: var(--t-small-size); font-weight: 600; }
.road-longterm p { font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.road-longterm .meta, .road-longterm .source { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.date-strip-block { display: grid; gap: var(--s-2); }
.date-strip-block h3 { font-size: var(--t-small-size); font-weight: 600; }
.date-strip { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 3px; }
.date-strip i { display: block; height: 18px; border-radius: 3px; background: var(--c-line); }
.date-strip i.is-wet { background: var(--d-water-optical); }
.date-strip i.is-dry { background: var(--c-line); }
.date-strip i.is-weak { background: repeating-linear-gradient(135deg, var(--d-water-weak) 0 3px, var(--c-surface) 3px 5px); border: 1px solid var(--d-water-weak); }
.date-strip i.is-persistent { box-shadow: 0 0 0 2px var(--d-road-outline); position: relative; z-index: 1; }
.date-strip i.is-none { background: var(--c-surface); border: 1px dashed var(--c-ink-muted); }
.date-strip i.out-window { opacity: .4; }
.strip-legend { display: flex; flex-wrap: wrap; gap: var(--s-3); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.strip-legend span { display: inline-flex; align-items: center; gap: 6px; }
.strip-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.strip-legend i.is-wet { background: var(--d-water-optical); }
.strip-legend i.is-dry { background: var(--c-line); }
.strip-legend i.is-weak { background: repeating-linear-gradient(135deg, var(--d-water-weak) 0 2px, var(--c-surface) 2px 4px); border: 1px solid var(--d-water-weak); }
.strip-legend i.is-none { border: 1px dashed var(--c-ink-muted); }
.road-dates { max-height: 160px; overflow: auto; border-top: 1px solid var(--c-line); }
.road-dates li { display: flex; flex-wrap: wrap; gap: var(--s-1) var(--s-3); padding: var(--s-2) 0; border-bottom: 1px solid var(--c-line); font-size: var(--t-small-size); line-height: var(--t-small-lh); font-variant-numeric: tabular-nums; }
.road-dates .res { margin-left: auto; font-weight: 600; }
.road-dates .res.wet { color: var(--d-water-optical); }
.road-dates .res.weak { color: var(--c-info); }
.road-dates .res.none { color: var(--c-ink-muted); font-weight: 400; }
.road-dates li.out-window { opacity: .5; }
.road-panel-actions { display: grid; gap: var(--s-2); }
.dialog-note { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }

/* ── 7. Conversación ─────────────────────────────────────── */
.assistant-link {
  display: inline-flex; align-items: center; min-height: var(--touch-size); padding: 0 var(--s-2); background: transparent; border: 0; border-radius: var(--r-sm);
  font-size: var(--t-small-size); line-height: var(--t-small-lh); font-weight: 600;
  color: var(--c-brand);
}
.assistant-link:hover:not(:disabled) { color: var(--c-brand-strong); text-decoration: underline; }
.assistant-link.danger { color: var(--c-error); }
.assistant {
  display: flex; flex-direction: column; min-height: 0;
  background: var(--c-surface); border-left: 1px solid var(--c-line);
}
.assistant-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4); border-bottom: 1px solid var(--c-line); }
.assistant-title-block { flex: 1; min-width: 0; }
.assistant-head h2 { font-size: 15px; line-height: 20px; font-weight: 700; }
.assistant-close { display: none; }
.assistant-collapse { display: grid; place-items: center; }
.assistant-collapse svg, .chat-bubble svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.chat-bubble { display: none; position: fixed; z-index: var(--z-panel); right: var(--s-4); bottom: 48px; align-items: center; gap: var(--s-2); min-height: var(--touch-size); padding: 0 var(--s-4); background: var(--c-brand); color: var(--c-on-brand); border: 0; border-radius: var(--r-pill); box-shadow: var(--e-float); font: inherit; font-weight: 600; cursor: pointer; }
.chat-bubble:hover { background: var(--c-brand-strong); }
.chat-bubble-dot { position: absolute; top: 4px; right: 4px; width: 12px; height: 12px; border-radius: var(--r-pill); background: var(--c-accent); border: 2px solid var(--c-brand); }
body.chat-collapsed .chat-bubble { display: inline-flex; }
body.chat-collapsed .workspace { grid-template-columns: var(--panel-w) minmax(0, 1fr); }
body.chat-collapsed .assistant, body.chat-collapsed #open-assistant { display: none !important; }
@media (max-width: 767px) { .chat-bubble { bottom: 120px; } }
.assistant-disclaimer { padding: var(--s-2) var(--s-4); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); border-bottom: 1px solid var(--c-line); }
.assistant-empty {
  margin: var(--s-3) var(--s-4) 0; padding: var(--s-3);
  background: var(--c-surface-alt); border: 1px solid var(--c-line); border-radius: var(--r-md);
  font-size: var(--t-body-size); line-height: var(--t-body-lh);
}
.assistant-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-4); background: var(--c-surface-alt); }
.assistant-welcome { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.assistant-prompts { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
.assistant-prompts button { min-height: var(--touch-size); padding: 0 var(--s-3); border: 1px solid var(--c-line-strong); border-radius: var(--r-pill); background: var(--c-surface); color: var(--c-ink); font-size: var(--t-small-size); }
.assistant-prompts button:hover { background: var(--c-surface-alt); }
.assistant-tools-used { margin: var(--s-2) 0 0; color: var(--c-ink-muted); font-size: var(--t-micro-size); }
.assistant-messages { display: flex; flex-direction: column; gap: var(--s-3); }
.assistant-msg {
  max-width: 90%; padding: 10px 12px;
  font-size: var(--t-body-size); line-height: 1.45;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.assistant-msg.is-user { align-self: flex-end; background: var(--c-brand); color: var(--c-on-brand); border-radius: 12px 12px 2px 12px; }
.assistant-msg.is-assistant { align-self: flex-start; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 12px 12px 12px 2px; white-space: normal; }
.assistant-msg a { color: var(--c-brand); text-decoration: underline; }
.assistant-msg.is-user a { color: var(--c-on-brand); }
.assistant-text p { margin: 0 0 .5em; white-space: pre-wrap; }
.assistant-text ul, .assistant-text ol { margin: 0 0 .5em; padding-left: 1.2em; }
.assistant-text ul { list-style: disc; }
.assistant-text li { margin: .1em 0; }
.assistant-text code { font-family: var(--font-mono, monospace); font-size: .92em; }
.assistant-text > :last-child { margin-bottom: 0; }
.assistant-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-2); margin-top: var(--s-2); }
.assistant-action {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-line-strong); border-radius: var(--r-pill);
  font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink); text-decoration: none;
}
.assistant-msg a.assistant-action { text-decoration: none; color: var(--c-ink); }
.assistant-action:hover { border-color: var(--c-brand); }
.assistant-actions-note { flex-basis: 100%; margin: 0; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.assistant-chip { gap: var(--s-1); cursor: pointer; }
.assistant-pin, .assistant-secondary svg { width: 16px; height: 16px; flex: none; fill: none; stroke: var(--c-brand); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.assistant-confirm { margin-top: var(--s-2); }
.assistant-confirm-question { margin: 0; font-weight: 600; }
.assistant-action:disabled { color: var(--c-ink-muted); cursor: default; }
.assistant-action.is-chosen:disabled { color: var(--c-ink); border-color: var(--c-ink); }
.assistant-location-chip { display: inline-flex; align-items: center; gap: var(--s-1); align-self: start; max-width: 100%; min-height: 36px; padding: 0 var(--s-1) 0 var(--s-2); background: var(--c-surface-alt); border: 1px solid var(--c-line); border-radius: var(--r-sm); font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.assistant-chip-label { display: inline-flex; align-items: center; gap: var(--s-1); min-width: 0; }
.assistant-chip-remove { min-width: 32px; min-height: 32px; background: transparent; border: 0; border-radius: var(--r-sm); font-size: 18px; line-height: 1; color: var(--c-ink-muted); cursor: pointer; }
.assistant-chip-remove:hover { color: var(--c-ink); }
.assistant-share { position: relative; }
.assistant-secondary { display: inline-flex; align-items: center; gap: var(--s-2); min-height: 40px; padding: 0 var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 8px; font-size: var(--t-small-size); }
.assistant-share-menu { position: absolute; bottom: 100%; left: 0; z-index: 1; display: flex; flex-direction: column; gap: var(--s-1); margin-bottom: var(--s-1); padding: var(--s-2); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float); white-space: nowrap; }
.assistant-status { margin: 0 var(--s-4) var(--s-2); align-items: center; }
.assistant-status .assistant-link { margin-left: auto; flex: none; }
.assistant-form { display: grid; gap: var(--s-2); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--c-line); }
.assistant-input {
  display: block; width: 100%; min-height: 56px; max-height: var(--assistant-input-max); resize: none;
  padding: var(--s-2) var(--s-3); color: var(--c-ink);
  background: var(--c-surface); border: 1px solid var(--c-line-strong); border-radius: var(--r-md);
}
.assistant-input:disabled { background: var(--c-surface-alt); color: var(--c-ink-muted); cursor: not-allowed; }
.assistant-compose { display: flex; align-items: center; gap: var(--s-3); }
.assistant-counter { margin-left: auto; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.assistant-counter.is-limit { color: var(--c-warn); font-weight: 600; }
.assistant-send {
  min-height: 40px; padding: 0 var(--s-5);
  background: var(--c-brand); color: var(--c-on-brand); border: 1px solid var(--c-brand); border-radius: 8px;
  font-weight: 600;
}
.assistant-send:hover:not(:disabled) { background: var(--c-brand-strong); }
.assistant-send:disabled { background: var(--c-ink-muted); border-color: var(--c-ink-muted); cursor: default; }

/* ── 8. Configuración ────────────────────────────────────── */
.config-page { height: calc(100vh - var(--header-h)); height: calc(100dvh - var(--header-h)); overflow-y: auto; }
.config-inner { display: flex; flex-wrap: wrap; gap: var(--s-6); max-width: 1280px; margin: 0 auto; padding: var(--s-6); }
.config-nav { flex: 0 1 220px; min-width: 200px; display: flex; flex-direction: column; gap: var(--s-1); align-self: flex-start; }
.config-nav h1 { margin: 0 0 var(--s-3); font-size: 22px; line-height: 28px; font-weight: 700; }
.config-nav a { display: flex; align-items: center; min-height: var(--touch-size); padding: 0 var(--s-3); border-radius: 8px; color: var(--c-ink); text-decoration: none; font-size: var(--t-body-size); }
.config-nav a:hover, .config-nav a.is-active { background: var(--c-surface); font-weight: 600; }
.config-nav p { margin-top: var(--s-4); }
.config-sections { flex: 999 1 560px; min-width: 0; display: grid; gap: var(--s-5); align-content: start; }
.config-card { display: grid; gap: var(--s-3); align-content: start; padding: var(--s-5); background: var(--c-surface); border-radius: 14px; min-width: 0; }
.config-card h2 { font-size: 18px; line-height: 24px; font-weight: 700; }
.config-pair { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--s-5); }
.territory-list { display: grid; gap: var(--s-2); }
.territory-list li { display: flex; align-items: center; gap: var(--s-3); min-height: var(--touch-size); padding: 0 var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.territory-list li::before { content: ""; flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--c-brand); }
.territory-list li.is-pending::before { background: var(--c-accent); box-shadow: 0 0 0 1px var(--c-brand); }
.territory-list strong { flex: 1; font-size: var(--t-body-size); font-weight: 600; }
.territory-pill { padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ok); background: var(--c-surface-alt); }
.territory-pill.is-pending { color: var(--c-brand); background: var(--c-accent); }
.territory-remove { min-height: 32px; padding: 0 var(--s-3); color: var(--c-error); background: transparent; border: 1px solid var(--c-line-strong); border-radius: var(--r-sm); font-size: var(--t-small-size); }
.territory-remove:hover { background: var(--c-error-bg); }
.territory-search { position: relative; }
.territory-search input { width: 100%; min-height: var(--touch-size); padding: 0 var(--s-3); border: 1px solid var(--c-line-strong); border-radius: var(--r-sm); background: var(--c-surface); font-size: var(--t-body-size); }
.territory-suggest { position: absolute; z-index: var(--z-dialog); left: 0; right: 0; top: calc(100% + var(--s-1)); max-height: 280px; overflow-y: auto; background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float); }
.territory-suggest[hidden] { display: none; }
.territory-suggest li { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); min-height: var(--touch-size); padding: 0 var(--s-3); cursor: pointer; }
.territory-suggest li:hover, .territory-suggest li.is-active { background: var(--c-surface-alt); }
.territory-suggest .small { color: var(--c-ink-muted); }
.territory-map-wrap { display: grid; gap: var(--s-2); margin: 0; }
.territory-map { width: 100%; max-height: 460px; background: var(--c-surface-alt); border-radius: var(--r-md); }
.territory-map path { fill: var(--c-surface); stroke: var(--c-line-strong); stroke-width: .12; vector-effect: non-scaling-stroke; cursor: pointer; }
.territory-map path:hover { fill: var(--c-line); }
.territory-map path.is-selected { fill: var(--c-brand); stroke: var(--c-brand-strong); }
.territory-map path.is-selected.is-pending { fill: var(--c-accent); stroke: var(--c-brand); }
.territory-map path:focus-visible { outline: 3px solid var(--c-brand); outline-offset: 1px; stroke: var(--c-ink); stroke-width: 2; }
.legend-dot { display: inline-block; width: 10px; height: 10px; margin: 0 var(--s-1) 0 var(--s-3); border-radius: 50%; background: var(--c-surface); border: 1px solid var(--c-line-strong); }
.legend-dot.is-on { background: var(--c-brand); border-color: var(--c-brand); }
.legend-dot.is-wait { background: var(--c-accent); border-color: var(--c-brand); }
.site-form { display: grid; gap: var(--s-2); padding: var(--s-4); background: var(--c-surface-alt); border-radius: 12px; }
.site-form > label, .site-coordinates label { font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); }
.site-coordinates summary { min-height: 32px; color: var(--c-ink-muted); font-size: var(--t-micro-size); }
.site-coordinates > div { display: grid; grid-template-columns: auto minmax(0,1fr) auto minmax(0,1fr); gap: var(--s-2); align-items: center; }
.site-pick-button { min-height: var(--touch-size); padding: 0 var(--s-3); color: var(--c-brand); background: var(--c-surface); border: 1px dashed var(--c-brand); border-radius: var(--r-sm); text-align: left; font-weight: 600; }
.site-form-actions { display: flex; align-items: center; gap: var(--s-3); flex-wrap: wrap; }
.site-groups { display: grid; gap: var(--s-4); }
.site-group h3 { margin-bottom: var(--s-2); font-size: var(--t-small-size); font-weight: 600; color: var(--c-ink-muted); }
.site-group ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: var(--s-2); }
.site-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.site-row.is-picked { border-color: var(--c-brand); }
.site-row-copy { flex: 1 1 8ch; min-width: 8ch; overflow-wrap: anywhere; }
.site-row-name { display: block; font-weight: 600; }
.site-row-meta { display: block; margin-top: 2px; color: var(--c-ink-muted); font-size: var(--t-micro-size); }
.site-row-actions { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: 0; align-items: center; }
.site-empty { padding: var(--s-3); color: var(--c-ink-muted); background: var(--c-surface-alt); border: 1px dashed var(--c-line); border-radius: var(--r-sm); font-size: var(--t-small-size); }
.link-block { display: grid; gap: var(--s-2); }
.link-block > div { display: grid; gap: var(--s-2); justify-items: start; }
.link-code { font-size: 2rem; font-weight: 700; letter-spacing: .25em; font-variant-numeric: tabular-nums; color: var(--c-brand); }
.link-ok { font-weight: 600; }

/* ── 9. Responsive ───────────────────────────────────────── */
/* La conversación pasa a cajón lateral por debajo de 1280 px */
@media (max-width: 1279px) {
  .workspace { grid-template-columns: var(--panel-w) minmax(0, 1fr); }
  .side-panel {
    position: fixed; z-index: var(--z-drawer); top: var(--header-h); right: 0; bottom: 0;
    width: min(var(--conv-w), 100vw); box-shadow: var(--e-float);
  }
  .assistant-close { display: grid; }
}
@media (min-width: 1280px) {
  #open-assistant { display: none; }
  /* Fija a la derecha: se muestra aunque no se haya «abierto» */
  .assistant[hidden] { display: flex !important; }
  body.road-panel-open .assistant, body.trip-panel-open .assistant { display: none !important; }
}
@media (min-width: 768px) and (max-width: 1279px) {
}
@media (max-width: 767px) {
  :root { --control-size: var(--touch-size); }
  .topbar { padding: var(--s-2) var(--s-3); gap: var(--s-2); }
  .brand span:last-child { display: none; }
  .mode-nav a { padding: 0 var(--s-2); font-size: var(--t-small-size); }
  #territories-label { display: none; }
  .territories-chip { padding: 0 var(--s-3); }
  .service-chip { display: none; }
  .topbar-spacer { flex: 1 1 0; }
  .mobile-only { display: grid !important; }
  .sheet-head.mobile-only { display: flex !important; }

  .workspace { display: block; position: relative; }
  .map-shell { position: absolute; inset: 0; }
  .sidebar {
    position: fixed; z-index: var(--z-panel); top: var(--header-h); right: 0; bottom: 0; left: 0;
    border-right: 0;
    transform: translateY(100%); visibility: hidden;
    transition: transform .2s ease-out, visibility 0s linear .2s;
  }
  .sidebar.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }
  .mode-panel { padding: var(--s-4); }

  .map-controls { top: auto; bottom: 172px; right: var(--s-2); }
  .map-tabs { left: var(--s-2); right: var(--s-2); bottom: var(--s-2); }
  .map-tabs .map-btn-text { flex: 1; justify-content: center; }
  .map-legend { left: var(--s-2); bottom: 172px; }
  .toasts { bottom: 172px; }
  .leaflet-bottom { bottom: 64px; }
  .leaflet-bottom.leaflet-right { max-width: calc(100% - 2 * var(--s-2)); }
  .tl-btn { min-width: 40px; height: 40px; }
  .tl-btn.tl-speed { min-width: 36px; }
  .timeline { width: calc(100vw - 2 * var(--s-2)); }
  #tlc-prev, #tlc-next { display: none; }   /* en celular: ▶, fecha y barra (y ⋯) */
  .tlc-slider { min-width: 80px; }
  .date-months[data-many="2"] span:nth-child(even) { display: none; }
  .date-months[data-many="3"] span:not(:nth-child(3n+1)) { display: none; }
  .seg-btn { min-height: 40px; }
  .sources-help-btn { width: 40px; height: 40px; }
  .basemap-menu { min-width: 150px; }
  .side-panel { width: 100vw; }
  .assistant-input { font-size: var(--t-date-size); line-height: var(--t-date-lh); }
  .assistant-msg { max-width: 94%; }
  .config-inner { padding: var(--s-4); }
  .config-nav { flex-basis: 100%; flex-direction: row; flex-wrap: wrap; }
  .config-nav h1, .config-nav p { flex-basis: 100%; }
  .site-group ul { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; transition-delay: 0s !important; }
  .layer-status.is-loading::before { animation: none; border-top-color: var(--c-line); border-right-color: var(--c-brand); }
}

/* ── Alertas: campana, panel y alertas por sitio ─────────── */
.alerts { position: relative; }
.alerts-btn { position: relative; background: var(--c-surface); cursor: pointer; }
.alerts-btn[aria-expanded="true"] { background: var(--c-surface-alt); }
.alerts-badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 var(--s-1);
  display: inline-grid; place-items: center; border-radius: var(--r-pill);
  background: var(--c-error); color: var(--c-on-brand); font-size: var(--t-micro-size); line-height: 1; font-weight: 700;
}
.alerts-badge[hidden] { display: none; }
.alerts-panel { left: auto; right: 0; width: min(380px, calc(100vw - 2 * var(--s-3))); max-height: min(70vh, 560px); overflow-y: auto; }
.alerts-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); flex-wrap: wrap; }
.alerts-list { display: grid; gap: var(--s-2); }
.alert-item {
  display: grid; gap: var(--s-1); width: 100%; text-align: left; padding: var(--s-3);
  background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); cursor: pointer;
  font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink); font-weight: 400;
}
.alert-item:hover { background: var(--c-surface-alt); }
.alert-item.is-unread { background: var(--c-info-bg); border-color: var(--c-info); }
.alert-item .alert-title { font-weight: 400; }
.alert-item.is-unread .alert-title, .alert-item.is-unread .alert-text { font-weight: 700; }
.site-alerts { display: grid; gap: var(--s-2); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); padding: var(--s-3); }
.site-alerts[hidden] { display: none; }
.site-alerts legend { padding: 0 var(--s-1); font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); }
.site-alerts > label:not(.check-row) { font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); }
.check-row { display: flex; align-items: center; gap: var(--s-2); min-height: var(--touch-size); font-size: var(--t-body-size); }
.check-row input { width: 20px; height: 20px; flex: none; }
.site-alerts input[type="number"] { max-width: 120px; }
@media (max-width: 767px) {
  .alerts-panel { position: fixed; top: var(--header-h); left: var(--s-3); right: var(--s-3); width: auto; }
}

/* Etapa 2: organización, roles, tipos de lugar y destinos públicos */
.site-icon.is-catalog { --site-ring: var(--d-site-catalog); --site-fill: var(--d-site-catalog-bg); border-style: dashed; }
.catalog-marker .site-icon { box-shadow: var(--e-float); }
.catalog-detail { display: grid; gap: var(--s-2); padding: var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.catalog-detail p { overflow-wrap: anywhere; }
.site-filter { max-width: 280px; }
.role-badge { display: inline-flex; align-items: center; padding: 2px var(--s-2); border-radius: var(--r-pill); font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); background: var(--c-surface-alt); }
.role-badge.is-titular { color: var(--c-on-brand); background: var(--c-brand); }
.role-badge.is-planificador { color: var(--c-brand); background: var(--c-accent); }
.org-members { display: grid; gap: var(--s-2); }
.org-member { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2) var(--s-3); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.org-member-copy { flex: 1 1 12ch; min-width: 12ch; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); overflow-wrap: anywhere; }
.org-member-meta { flex: 1 0 100%; color: var(--c-ink-muted); font-size: var(--t-micro-size); font-variant-numeric: tabular-nums; }
.org-member-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.org-card { gap: var(--s-4); }
.org-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-3); padding-bottom: var(--s-3); border-bottom: 1px solid var(--c-line); }
.org-hero h2 { margin: 0; font-size: 24px; line-height: 1.2; }
.org-hero p { margin: var(--s-2) 0 0; }
.org-hero .eyebrow { color: var(--c-brand); font-size: var(--t-micro-size); font-weight: 700; letter-spacing: .08em; }
.org-summary { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4); border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface-alt); }
.org-summary-mark { color: var(--c-brand); font-size: 24px; }
.org-summary div { display: grid; gap: 3px; }
.org-summary strong { font-size: var(--t-date-size); }
.org-edit-form { max-width: 620px; }
.org-team { display: grid; gap: var(--s-3); padding-top: var(--s-3); border-top: 1px solid var(--c-line); }
.org-subhead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.org-subhead .section-title { margin: 0; }
.org-subhead > span { color: var(--c-ink-muted); font-size: var(--t-micro-size); white-space: nowrap; }
.org-member { align-items: flex-start; padding: var(--s-3); }
.org-member.is-pending { background: var(--c-surface-alt); border-style: dashed; }
.org-pending-block { display: grid; gap: var(--s-2); padding-top: var(--s-3); border-top: 1px solid var(--c-line); }
.org-invite-details, .org-join-details { padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.org-invite-details summary, .org-join-details summary { cursor: pointer; font-weight: 650; }
.org-invite-details > p, .org-join-details > p { margin: var(--s-2) 0; }
.org-role-guide { display: grid; gap: var(--s-2); }
.org-role-guide p { margin: 0; color: var(--c-ink-muted); line-height: 1.5; }
.org-copy-fallback { width: 100%; min-height: 100px; padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); resize: vertical; }
.org-copy-again { justify-self: start; }
.auth-pending > .topbar, .auth-pending > #workspace, .auth-pending > #config-page { display: none !important; }
.auth-gate { display: none; min-height: 100dvh; padding: clamp(20px, 6vh, 64px) var(--s-4); place-items: center; background: var(--c-canvas); overflow-y: auto; }
.auth-pending > .auth-gate { display: grid; }
.auth-card { width: min(100%, 460px); display: grid; gap: var(--s-4); padding: clamp(24px, 5vw, 40px); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: 18px; box-shadow: var(--e-float); }
.auth-brand { display: inline-flex; align-items: center; gap: var(--s-2); color: var(--c-brand); font-size: 20px; font-weight: 750; text-decoration: none; }
.auth-card h1 { font-size: clamp(24px, 5vw, 32px); line-height: 1.15; }
.auth-form { gap: var(--s-2); }
.auth-form button { margin-top: var(--s-2); }
.org-account-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); padding: var(--s-3); background: var(--c-surface-alt); border-radius: var(--r-md); }
.org-account-toolbar p { display: grid; gap: 2px; }
.org-password-details { padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.org-password-details summary { cursor: pointer; font-weight: 650; }
.org-password-details form { margin-top: var(--s-3); }
.org-account-form { max-width: 620px; }
.org-accounts-list { display: grid; gap: var(--s-2); }
.org-accounts-list li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.org-account-copy { display: grid; gap: 3px; overflow-wrap: anywhere; }
.org-account-reset { width: 100%; display: grid; justify-items: start; gap: var(--s-2); padding-top: var(--s-2); border-top: 1px solid var(--c-line); }
.org-account-reset summary { cursor: pointer; color: var(--c-brand); font-size: var(--t-small-size); font-weight: 650; }
.org-account-reset-form { display: flex; flex-wrap: wrap; align-items: end; gap: var(--s-2); width: 100%; }
.org-account-reset-form label { display: grid; flex: 1 1 220px; gap: var(--s-1); font-size: var(--t-small-size); }
.org-account-reset-form input { width: 100%; min-height: var(--touch-size); padding: 0 var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); }

/* Compartir un viaje: un botón primario; el resto, discreto */
.trip-share { display: grid; gap: var(--s-2); margin-top: var(--s-2); }
.trip-share-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.route-gpx { display: inline-block; margin-top: var(--s-2); text-decoration: underline; }
.assistant-trip-image { display: block; width: 100%; height: auto; border-radius: var(--r-md); border: 1px solid var(--c-line); margin-bottom: var(--s-2); }
.org-logout { display: flex; justify-content: flex-end; }

/* Mis viajes: lista en dos grupos, tarjetas con una acción principal y asistente de tres pasos */
.trip-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.trip-card { display: grid; gap: var(--s-2); padding: var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.trip-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-2); }
.trip-card-head h3 { font-size: var(--t-body-size); line-height: var(--t-body-lh); font-weight: 600; overflow-wrap: anywhere; }
.trip-card-meta, .trip-card-km, .trip-card-share { margin: 0; font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.trip-card-km { color: var(--c-ink); font-variant-numeric: tabular-nums; }
.trip-card-km.is-wet { color: var(--c-warn); font-weight: 600; }
.trip-share-main { width: 100%; min-height: var(--touch-size); }
.trip-menu { position: relative; flex: none; }
.trip-menu > summary { list-style: none; display: grid; place-items: center; width: var(--touch-size); height: var(--touch-size); margin: calc(-1 * var(--s-2)) calc(-1 * var(--s-2)) 0 0; border-radius: var(--r-md); font-size: 22px; line-height: 1; cursor: pointer; color: var(--c-ink); }
.trip-menu > summary::-webkit-details-marker { display: none; }
.trip-menu > summary:hover { background: var(--c-surface-alt); }
.trip-menu-list { position: absolute; z-index: var(--z-dialog); right: 0; top: 100%; display: grid; min-width: 200px; padding: var(--s-1); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float); }
.trip-menu-item { min-height: var(--touch-size); padding: 0 var(--s-3); text-align: left; background: none; border: 0; border-radius: var(--r-sm); font: inherit; font-size: var(--t-body-size); color: var(--c-ink); cursor: pointer; }
.trip-menu-item:hover { background: var(--c-surface-alt); }
.trip-menu-item.danger { color: var(--c-error); }
.trip-steps { display: flex; gap: var(--s-1); margin: 0; padding: 0; list-style: none; counter-reset: trip-step; }
.trip-steps li { flex: 1; counter-increment: trip-step; padding: var(--s-2) var(--s-1); border-bottom: 3px solid var(--c-line-strong); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); text-align: center; }
.trip-steps li::before { content: counter(trip-step) ". "; }
.trip-steps li[aria-current="step"] { border-bottom-color: var(--c-brand); color: var(--c-ink); font-weight: 700; }
.trip-step { display: grid; gap: var(--s-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.trip-wizard-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.trip-wizard-actions .btn-primary, .trip-wizard-actions .btn-secondary { flex: 1; }
.trip-preview { display: grid; gap: var(--s-3); }
.trip-preview h3 { font-size: var(--t-section-size); line-height: var(--t-section-lh); font-weight: var(--t-section-weight); }

/* Buscador de lugares */
.place-search { display: grid; gap: var(--s-2); }
.place-search input[type="search"] { width: 100%; min-height: var(--touch-size); }
.place-results { display: grid; gap: var(--s-2); max-height: 320px; overflow-y: auto; padding: var(--s-2); background: var(--c-surface); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); }
.place-group-title { margin: 0 0 var(--s-1); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 700; letter-spacing: var(--t-section-tracking); text-transform: uppercase; color: var(--c-ink-muted); }
.place-item { display: grid; width: 100%; min-height: var(--touch-size); padding: var(--s-1) var(--s-2); text-align: left; background: none; border: 0; border-radius: var(--r-sm); font: inherit; color: var(--c-ink); cursor: pointer; }
.place-item:hover, .place-item:focus-visible { background: var(--c-surface-alt); }
.place-item span { font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.place-attr { margin: var(--s-1) 0 0; }
.place-map { justify-self: start; }

/* Nuevo viaje en una pantalla: chips, camiones, «Más datos» plegado, estados por camión y tranquera del lugar */
.trip-quick { gap: var(--s-4); }
.trip-block { display: grid; gap: var(--s-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.trip-block > legend, .trip-stops-title { padding: 0; margin: 0 0 var(--s-1); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink-muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.chip { min-height: var(--touch-size); padding: 0 var(--s-4); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line-strong); border-radius: var(--r-pill); font: inherit; font-size: var(--t-body-size); cursor: pointer; }
.chip:hover { background: var(--c-surface-alt); }
.chip.is-on, .chip[aria-checked="true"], .chip[aria-pressed="true"] { background: var(--c-brand); color: var(--c-on-brand); border-color: var(--c-brand); font-weight: 600; }
.trip-chosen { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.trip-chosen strong { overflow-wrap: anywhere; }
.stepper { display: flex; align-items: center; gap: var(--s-3); }
.stepper output { min-width: 2ch; text-align: center; font-size: var(--t-date-size); line-height: var(--t-date-lh); font-weight: var(--t-date-weight); font-variant-numeric: tabular-nums; }
.stepper-btn { min-width: var(--touch-size); min-height: var(--touch-size); padding: 0; font-size: 20px; line-height: 1; }
.trip-more { border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); }
.trip-more > summary { min-height: var(--touch-size); display: flex; align-items: center; padding: 0 var(--s-3); font-weight: 600; cursor: pointer; }
.trip-more-body { display: grid; gap: var(--s-2); padding: 0 var(--s-3) var(--s-3); }
.trip-more-body > label { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink-muted); }
.trip-pair { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-2); }
.trip-stops { display: grid; gap: var(--s-2); }
.trip-stops-list { display: grid; gap: var(--s-2); margin: 0; padding: 0; list-style: none; }
.trip-stop-row { display: flex; align-items: center; gap: var(--s-2); }
.trip-stop-row > span { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.trip-preview-rain { margin: 0; font-size: var(--t-small-size); line-height: var(--t-small-lh); color: var(--c-ink-muted); }
.trip-notify { display: grid; gap: var(--s-2); }
.trip-notify:empty { display: none; }
.trip-trucks { display: grid; gap: var(--s-1); margin: 0; padding: 0; list-style: none; }
.trip-truck { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.trip-truck-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.trip-truck-state { padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--c-surface-alt); color: var(--c-ink-muted); font-weight: 600; }
.trip-truck[data-state="voy"] .trip-truck-state, .trip-truck[data-state="llego"] .trip-truck-state, .trip-truck[data-state="cargo"] .trip-truck-state, .trip-truck[data-state="en_camino"] .trip-truck-state { background: var(--c-info-bg); color: var(--c-info); }
.trip-truck[data-state="no_puedo"] .trip-truck-state { background: var(--c-warn-bg); color: var(--c-warn); }
.site-entrance { display: grid; gap: var(--s-2); }
.alert-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-2); }
@media (max-width: 480px) { .trip-pair { grid-template-columns: 1fr; } }
.trip-link-field { width: 100%; min-height: var(--touch-size); font: inherit; padding: 0 var(--s-2); }
.trip-share-main[aria-busy="true"], .trip-truck-share[aria-busy="true"] { opacity: .7; cursor: progress; }
.org-phone-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.org-phone-form input { min-height: var(--touch-size); font: inherit; padding: 0 var(--s-2); max-width: 15rem; }
.ingest-status { margin: 0; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.ingest-status[hidden] { display: none; }

/* ── Plegable «Tus sitios», interruptores del menú de capas, leyenda JRC, rótulo «Ocultar» ── */
.card h2:has(> .collapse-toggle) { margin: 0; }
.collapse-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); width: 100%; min-height: var(--touch-size);
  padding: 0; background: transparent; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.collapse-toggle:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }
.collapse-toggle .chevron { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--c-ink-subtle); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.collapse-toggle.is-collapsed .chevron { transform: rotate(-90deg); }
@media (prefers-reduced-motion: reduce) { .collapse-toggle .chevron { transition: none; } }
.sites-body[hidden] { display: none; }
.now-window { margin: 0; color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.menu-switch { min-height: 36px; padding: 0 var(--s-2); white-space: nowrap; font-size: var(--t-small-size); }
.jrc-legend[hidden] { display: none; }
.jrc-legend { max-width: 220px; }
.jrc-legend .legend-title { font-weight: 600; }
.jrc-legend .legend-source { color: var(--c-ink-muted); }
.jrc-ramp { display: block; height: 10px; border-radius: var(--r-sm); background: linear-gradient(to right, var(--d-jrc-low), var(--d-jrc-high)); }
.jrc-ramp-ends { display: flex; justify-content: space-between; color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.assistant-collapse { width: auto; grid-auto-flow: column; gap: var(--s-1); padding: 0 var(--s-2); }
.collapse-label { font-size: var(--t-small-size); font-weight: 600; color: var(--c-ink-muted); }

/* ── Control de capas único: grupos, hoja inferior en pantallas chicas, bloques del panel ── */
.layers-menu { min-width: 232px; max-height: calc(100vh - 2 * var(--s-4)); overflow-y: auto; }
.layer-group { display: grid; gap: 0; }
.layers-close { display: none; justify-self: stretch; }
.layer-name { margin: 0; font-size: var(--t-body-size); line-height: var(--t-body-lh); font-weight: 600; }
.layer-item[hidden] { display: none; }
.legend-map[hidden] { display: none; }
@media (max-width: 767px) {
  .layers-menu {
    position: fixed; top: calc(var(--header-h) + var(--s-2)); right: var(--s-2); bottom: auto; left: var(--s-2); z-index: var(--z-drawer); max-height: calc(100dvh - 2 * var(--s-2)); max-width: none; min-width: 0;
    padding: var(--s-3) var(--s-4) var(--s-4); border-radius: var(--r-md) var(--r-md) 0 0;
  }
  .layers-menu .menu-switch { min-height: var(--touch-size); }
  .layers-menu .basemap-option { min-height: var(--touch-size); }
  .layers-close { display: block; }
}

/* ── Lotes: lista, dibujo, importación y ficha ───────────── */
.sw-lot { width: 16px; height: 10px; border-radius: 2px; border: 2px solid var(--d-lot-line); background: none; box-sizing: border-box; }
.sw-lot-water { width: 16px; height: 10px; border-radius: 2px; background: var(--d-lot-water); opacity: .35; }
.sw-lot-off { width: 16px; height: 10px; border-radius: 2px; border: 2px dashed var(--d-lot-off); background: none; box-sizing: border-box; }
.lot-list { display: grid; gap: var(--s-2); }
.lot-list-mini { gap: var(--s-1); }
.lot-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-1) var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.lot-row.is-picked { border-color: var(--c-brand); }
.lot-row.is-off { border-style: dashed; border-color: var(--d-lot-off); }
.lot-row-main { flex: 1 1 8ch; min-width: 0; min-height: var(--touch-size); display: grid; gap: 2px; align-content: center; padding: var(--s-2) var(--s-3); background: transparent; border: 0; border-radius: var(--r-md); text-align: left; color: var(--c-ink); font: inherit; }
.lot-row-main:hover { background: var(--c-surface-alt); }
.lot-row-main strong { font-size: var(--t-body-size); font-weight: 600; overflow-wrap: anywhere; }
.lot-row-main span { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.lot-row-note { flex: 1 0 100%; padding: 0 var(--s-3); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.lot-list .site-row-actions { padding: 0 var(--s-2) var(--s-1); }
.lot-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.lot-usage { display: grid; gap: var(--s-1); }
.lot-usage strong { font-variant-numeric: tabular-nums; }
.lot-meter { height: 8px; border-radius: var(--r-pill); background: var(--c-line); overflow: hidden; }
.lot-meter i { display: block; height: 100%; width: 0; background: var(--c-brand); }
.lot-import { gap: var(--s-3); }
.lot-import-items { display: grid; gap: var(--s-1); max-height: 320px; overflow: auto; }
.lot-import-row label { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0 var(--s-3); min-height: var(--touch-size); padding: var(--s-1) var(--s-2); border-radius: var(--r-sm); background: var(--c-surface); font-weight: 400; color: var(--c-ink); }
.lot-import-row input[type="checkbox"] { width: 22px; height: 22px; margin: 0; }
.lot-import-row strong { font-size: var(--t-body-size); font-weight: 600; overflow-wrap: anywhere; }
.lot-import-meta { grid-column: 2; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.lot-import-row.is-invalid label { background: var(--c-error-bg); }
.lot-import-row.is-invalid .lot-import-meta { color: var(--c-error); }

.lot-draw-bar {
  position: absolute; z-index: var(--z-timeline); left: 50%; transform: translateX(-50%); bottom: var(--s-4);
  width: min(460px, calc(100% - 2 * var(--s-4))); box-sizing: border-box; display: grid; gap: var(--s-2);
  padding: var(--s-3) var(--s-4); background: var(--c-surface); border-radius: 12px; box-shadow: var(--e-float);
}
.lot-draw-bar[hidden] { display: none; }
.lot-draw-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-3); }
.lot-draw-head strong { font-size: var(--t-body-size); font-weight: 700; }
.lot-draw-area { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-brand); }
.lot-draw-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-2); }
.lot-draw-actions[hidden] { display: none; }
.lot-draw-form { display: grid; gap: var(--s-2); }
.lot-draw-form[hidden] { display: none; }
.lot-draw-form > label { font-size: var(--t-micro-size); font-weight: 600; color: var(--c-ink-muted); }
.lot-draw-form input { min-height: var(--touch-size); box-sizing: border-box; padding: 0 var(--s-3); font: inherit; border: 1px solid var(--c-line-strong); border-radius: var(--r-sm); background: var(--c-surface); color: var(--c-ink); }
.lot-draw-form.is-shape-only > label, .lot-draw-form.is-shape-only > input, .lot-draw-form.is-shape-only > select { display: none; }
body.lot-drawing .map-legend { display: none; }
body.lot-drawing .map-tabs { display: none; }
.lot-handle { background: transparent; border: 0; }
.lot-handle-dot { display: block; width: 18px; height: 18px; margin: 13px; box-sizing: border-box; border-radius: 50%; background: var(--c-surface); border: 3px solid var(--c-brand); box-shadow: var(--e-float); cursor: grab; }
.lot-handle.is-first .lot-handle-dot { width: 22px; height: 22px; margin: 11px; background: var(--c-accent); }
.lot-handle:focus-visible .lot-handle-dot { outline: 3px solid var(--c-info); outline-offset: 2px; }

.lot-detail { display: grid; gap: var(--s-4); }
.lot-now.is-off { background: var(--c-surface-alt); border: 1px dashed var(--d-lot-off); }
.lot-kinds, .lot-evolution, .lot-recurrence { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--c-line-strong); background: var(--c-surface); }
.lot-kinds h3, .lot-evolution h3, .lot-recurrence h3 { font-size: var(--t-small-size); font-weight: 600; }
.lot-kinds .meta, .lot-evolution .meta { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.lot-kinds-bar { display: flex; height: 12px; border-radius: var(--r-pill); overflow: hidden; background: var(--c-line); }
.lot-kinds-bar i { display: block; height: 100%; }
.lot-kinds-bar .is-new { background: var(--d-lot-water); }
.lot-kinds-bar .is-usual { background: var(--d-road-permanent); }
.lot-kinds-text { font-size: var(--t-small-size); font-variant-numeric: tabular-nums; }
.lot-spark svg { display: block; width: 100%; height: 64px; }
.lot-spark .spark-base { stroke: var(--c-line-strong); stroke-width: 1; }
.lot-spark .spark-line { fill: none; stroke: var(--d-lot-water); stroke-width: 2; stroke-linejoin: round; vector-effect: non-scaling-stroke; }
.lot-spark .spark-dot { fill: var(--d-lot-water); }
.lot-spark .spark-gap { stroke: var(--c-ink-muted); stroke-width: 1.5; stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }
.lot-spark .spark-now { stroke: var(--c-brand); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.lot-spark-ends { display: flex; justify-content: space-between; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.lot-frequency { display: grid; gap: var(--s-2); margin: 0; }
.lot-frequency img { display: block; width: 100%; max-height: 260px; object-fit: contain; border-radius: var(--r-sm); background: var(--c-surface-alt); }
.lot-frequency img[hidden] { display: none; }
.lot-frequency-legend { display: grid; gap: var(--s-1); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); }
.lot-edit-form { margin: 0; }
@media (min-width: 1280px) {
  body.lot-panel-open .assistant { display: none !important; }
  body.lot-panel-open .map-shell,
  body.road-panel-open .map-shell,
  body.trip-panel-open .map-shell { grid-column: 2 / -1; }
}
@media (max-width: 767px) {
  .lot-draw-bar { bottom: calc(64px + var(--s-2)); width: calc(100% - 2 * var(--s-2)); }
  .lot-draw-actions .btn-compact { min-height: var(--touch-size); }
}

/* ── Mis campos (campo → lotes) y bloques de la ficha del lote ─────────────── */
.mode-short { display: none; }
.btn-large { min-height: 52px; font-size: var(--t-body-size); font-weight: 600; flex: 1 1 0; }
.campos-actions { display: flex; gap: var(--s-2); margin-bottom: var(--s-3); }
.campos-filters { display: flex; flex-wrap: wrap; gap: var(--s-2); margin: var(--s-3) 0; }
.campos-list { display: grid; gap: var(--s-4); }
.campos-rows { display: grid; gap: var(--s-1); list-style: none; padding: 0; margin: 0; }
.campos-row { display: flex; align-items: center; gap: var(--s-2); min-height: var(--touch-size); padding: var(--s-2) var(--s-3); border-radius: var(--r-md); border: 1px solid var(--c-line-strong); background: var(--c-surface); text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.campos-row:hover { background: var(--c-surface-alt); }
.campos-row.is-picked { border-color: var(--c-brand); box-shadow: 0 0 0 2px var(--c-brand); }
.campos-row.is-off { border-style: dashed; color: var(--c-ink-muted); }
.campos-row-text { display: grid; gap: 2px; flex: 1 1 auto; min-width: 0; }
.campos-row-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campos-row-text span { font-size: var(--t-small-size); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.lot-block { display: grid; gap: var(--s-3); }
.lot-block-title { font-size: var(--t-small-size); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--c-ink-muted); padding-top: var(--s-2); border-top: 1px solid var(--c-line); }
.lot-history, .lot-rain { display: grid; gap: var(--s-2); padding: var(--s-3); border-radius: var(--r-md); border: 1px solid var(--c-line-strong); background: var(--c-surface); }
.lot-history h3, .lot-rain h3 { font-size: var(--t-small-size); font-weight: 600; }
.lot-history .meta, .lot-rain .meta { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.lot-menu summary { cursor: pointer; min-height: var(--touch-size); display: flex; align-items: center; font-weight: 600; }
.lot-menu-items { display: grid; gap: var(--s-2); padding-bottom: var(--s-2); }
@media (max-width: 767px) {
  .mode-full { display: none; }
  .mode-short { display: inline; }
  .campos-actions { flex-direction: column; }
}

/* Ficha del lote: en el panel izquierdo, en lugar de la lista, compacta y con scroll propio */
body.lot-panel-open #sidebar .mode-panel { display: none; }
.lot-panel { display: grid; gap: var(--s-3); align-content: start; padding: var(--s-2) var(--s-4) var(--s-6); }
.lot-panel[hidden] { display: none; }
.lot-panel-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; }
.btn-back { min-height: var(--touch-size); padding: 0 var(--s-2); background: none; border: 0; color: var(--c-brand); font: inherit; font-weight: 600; cursor: pointer; }
.btn-back:hover { text-decoration: underline; }
/* Teléfono: «Volver», «Compartir», «Planificar viaje» y «Ampliar» caben en una sola fila (menos aire a los costados, mismo alto táctil) */
@media (max-width: 480px) { .lot-panel-head .btn-back { padding: 0 var(--s-1); } }
.lot-panel-title h2 { font-size: var(--t-body-size); font-weight: 700; line-height: 1.25; }
.lot-panel .lot-block { gap: var(--s-2); }
.lot-panel .lot-block-title { font-size: var(--t-micro-size); }
.lot-panel p, .lot-panel .meta { font-size: var(--t-small-size); }
.lot-panel .road-recurrence-count { font-size: var(--t-body-size); }
.lot-bars svg { display: block; width: 100%; height: 72px; }
.lot-bars .bar { fill: var(--d-lot-water); }
.lot-bars .bar-new { fill: var(--d-lot-water); }
.lot-bars .bar-gap { fill: var(--c-line-strong); }
.lot-bars .bar-now { fill: none; stroke: var(--c-brand); stroke-width: 2; vector-effect: non-scaling-stroke; }
.lot-bars .bar-base { stroke: var(--c-line-strong); stroke-width: 1; }
.lot-bars .bar-point { cursor: pointer; outline: none; }
.lot-bars .bar-hit { fill: transparent; pointer-events: all; }
.lot-bars .bar-point:focus .bar-hit { fill: color-mix(in srgb, var(--c-brand) 14%, transparent); stroke: var(--c-brand); stroke-width: 1; vector-effect: non-scaling-stroke; }
.lot-bars .bar-tooltip { min-height: 1.25em; margin: 0; color: var(--c-ink-muted); font-size: var(--t-micro-size); font-variant-numeric: tabular-nums; }
.campo-pixel-card { display: grid; grid-template-columns: 1fr auto; gap: var(--s-1); padding: var(--s-2) 0; border-top: 1px solid var(--c-line); font-size: var(--t-small-size); }
.campo-pixel-card p, .campo-pixel-days { grid-column: 1 / -1; margin: 0; }
.campo-pixel-days { max-height: 12rem; overflow: auto; padding-inline-start: var(--s-4); font-variant-numeric: tabular-nums; }
.campo-curtain-control { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--s-1) var(--s-2); flex-basis: 100%; min-width: 0; }
.campo-curtain-control > label, .campo-curtain-control > button { grid-column: 1 / -1; }
.campo-curtain-control input { min-width: 5rem; width: 100%; min-height: var(--touch-size); }
.campo-curtain-dates { color: var(--c-ink-muted); font-size: var(--t-micro-size); font-variant-numeric: tabular-nums; white-space: nowrap; }
.lot-compare-control { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: var(--s-2); }
.lot-compare-control select { min-width: 0; width: 100%; min-height: var(--touch-size); }
.lot-switch { display: flex; align-items: center; gap: var(--s-2); min-height: var(--touch-size); cursor: pointer; font-size: var(--t-small-size); }
@media (max-width: 767px) {
  body.lot-panel-open .sidebar.open { top: auto; height: 52vh; border-top: 1px solid var(--c-line-strong); border-radius: var(--r-md) var(--r-md) 0 0; box-shadow: var(--e-float); }
  body.lot-panel-open .sidebar.open.is-expanded { top: var(--header-h); height: auto; border-radius: 0; }
}

/* ── Modelo integrado: zona en la cabecera, campos anidados, análisis del campo, agenda, Configuración por secciones ── */
.territories-chip.zone-line { text-decoration: none; color: var(--c-ink-muted); background: transparent; border-color: transparent; font-size: var(--t-small-size); }
.territories-chip.zone-line:hover { background: var(--c-surface); color: var(--c-ink); }
.territories-chip.zone-line svg { stroke: var(--c-ink-subtle); }
.campos-actions { flex-wrap: wrap; }
.campos-actions .btn-large { flex: 1 1 auto; min-width: 0; }
.campos-filters { flex-wrap: nowrap; gap: var(--s-1); }
.campos-filters .chip { flex: 1 1 0; min-width: 0; padding: 0 var(--s-2); font-size: var(--t-small-size); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.campo-form-slot:empty { display: none; }
.campo-open { flex: none; min-height: var(--touch-size); }
.campo-line { font-size: var(--t-small-size); color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.agenda-block { display: grid; gap: var(--s-3); margin-top: var(--s-4); padding-top: var(--s-4); border-top: 1px solid var(--c-line-strong); }
.agenda-form-slot:empty { display: none; }
.site-perimeter { display: grid; gap: var(--s-2); margin: 0; padding: 0; border: 0; }
.site-perimeter[hidden], .site-perimeter-block[hidden] { display: none; }
.org-type-line { margin: 0; }
.org-type-details summary { cursor: pointer; min-height: var(--touch-size); display: flex; align-items: center; font-weight: 600; }
.config-sections > [hidden] { display: none; }
.territory-list li.is-auto { flex-wrap: wrap; }
.territory-list li.is-auto .territory-why { flex: 1 0 100%; padding-bottom: var(--s-2); }
.territory-map path.is-selected.is-auto { fill: var(--c-brand-strong); }
/* Análisis del campo */
.campo-panel { gap: var(--s-3); }
.campo-tools { display: grid; gap: var(--s-2); }
.campo-tools .chip { min-height: 36px; padding: 0 var(--s-3); font-size: var(--t-small-size); }
.campo-actions-row { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.campo-compare { margin: 0; }
.campo-compare select { min-height: var(--touch-size); }
.campo-compare-result { display: grid; gap: var(--s-1); font-size: var(--t-small-size); }
.campo-compare-sentence { font-weight: 600; }
.campo-compare-lots { display: grid; gap: var(--s-1); list-style: none; padding: 0; margin: 0; }
.campo-compare-row { display: grid; gap: 2px; padding: var(--s-1) 0; border-bottom: 1px solid var(--c-line); }
.campo-compare-row span { color: var(--c-ink-muted); font-variant-numeric: tabular-nums; }
.campo-lots { display: grid; gap: var(--s-1); list-style: none; padding: 0; margin: 0; }
.campo-lot-main { width: 100%; min-height: var(--touch-size); display: grid; gap: 2px; text-align: left; padding: var(--s-2) var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); font: inherit; cursor: pointer; }
.campo-lot-main:hover { background: var(--c-surface-alt); }
.campo-lot-main span { font-size: var(--t-small-size); color: var(--c-ink-muted); }
.campo-access-line, .campo-frequency-line, .lot-sentence { font-size: var(--t-body-size); }
.campo-series { gap: var(--s-2); }
.campo-multiples { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--s-2); }
.campo-multiple { display: grid; gap: var(--s-1); padding: var(--s-2); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.campo-multiple h4 { font-size: var(--t-micro-size); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campo-multiple .lot-bars svg { height: 44px; }
.lot-bars .bar-usual { fill: var(--d-road-permanent); }
.lot-period { gap: var(--s-1); }
.lot-period .chip { min-height: 32px; padding: 0 var(--s-3); font-size: var(--t-small-size); }
.campo-export { margin-top: var(--s-2); }
/* Satellite pixels stay crisp when a tile is scaled past its native zoom (no blur between 10–30 m cells). */
.leaflet-evidence-pane img, .leaflet-jrc-pane img, .leaflet-campo-compare-pane img, .leaflet-lot-compare-pane img { image-rendering: pixelated; }

/* Hoy, Mis lugares: tarjetas de campo, «Agregar» y línea de zona (reordenamiento de la interfaz) */
.hoy-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.hoy-stat { display: grid; align-content: start; gap: 2px; padding: var(--s-3) var(--s-2); border: 1px solid var(--c-line); border-radius: 12px; background: var(--c-surface); text-align: center; }
.hoy-stat-num { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-ink); overflow-wrap: anywhere; }
.hoy-stat-num.is-empty { font-size: var(--t-small-size); line-height: 28px; font-weight: 500; color: var(--c-ink-muted); }
.hoy-stat-label { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); }
.hoy-km-link { justify-self: start; margin-top: calc(var(--s-1) * -1); font-size: var(--t-small-size); }
.hoy-list { display: grid; gap: var(--s-3); }
.hoy-card { display: grid; grid-template-columns: 84px minmax(0, 1fr); column-gap: var(--s-3); row-gap: var(--s-2); width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer; border-left-width: 4px; }
.hoy-card:hover { border-color: var(--c-line-strong); }
.hoy-card:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }
.hoy-card.is-new { border-left-color: var(--c-info); }
.hoy-card.is-dry { border-left-color: var(--c-ok); }
.hoy-card.is-stale { border-left-color: var(--c-ink-subtle); border-left-style: dashed; }
.hoy-shape { width: 84px; height: 84px; border-radius: var(--r-md); background: var(--c-surface-alt); }
.hoy-shape-perimeter { fill: none; stroke: var(--c-ink-subtle); stroke-width: 1; stroke-dasharray: 3 3; }
.hoy-shape-lot { fill: var(--d-water-optical); stroke: var(--c-brand); stroke-width: 1.5; stroke-linejoin: round; }
.hoy-shape-lot.is-nodata { fill: none; stroke: var(--c-ink-subtle); stroke-dasharray: 4 3; }
.hoy-shape-empty { fill: none; stroke: var(--c-line-strong); stroke-width: 2; stroke-dasharray: 4 4; }
.hoy-card-main { display: grid; align-content: start; gap: 2px; min-width: 0; }
.hoy-name { font-size: var(--t-body-size); line-height: var(--t-body-lh); font-weight: 650; overflow-wrap: anywhere; }
.hoy-badge { display: inline-flex; align-items: center; gap: 4px; font-size: var(--t-micro-size); line-height: var(--t-micro-lh); font-weight: 600; color: var(--c-ink-muted); }
.state-icon { width: 14px; height: 14px; flex: none; }
.hoy-card.is-new .hoy-badge { color: var(--c-info); }
.hoy-card.is-dry .hoy-badge { color: var(--c-ok); }
.hoy-num { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--s-2); min-width: 0; color: var(--c-ink-muted); font-size: var(--t-small-size); }
.hoy-num b { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-ink); }
.hoy-num small { font-size: var(--t-micro-size); }
.hoy-bars { width: 100%; height: 26px; margin-top: 2px; }
.hoy-bar { fill: var(--d-water-optical); opacity: .55; }
.hoy-bar.is-last { opacity: 1; }
.hoy-bar-gap { fill: var(--c-line-strong); }
.hoy-foot { grid-column: 1 / -1; padding-top: var(--s-2); border-top: 1px solid var(--c-line); font-size: var(--t-micro-size); line-height: var(--t-micro-lh); overflow-wrap: anywhere; }
.hoy-avisos { display: grid; gap: var(--s-2); list-style: none; margin: 0; padding: 0; font-size: var(--t-small-size); }
.hoy-aviso { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s-2); min-width: 0; }
.hoy-aviso strong { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hoy-aviso span { flex: none; }
.hoy-aviso.is-unread strong { font-weight: 650; color: var(--c-ink); }
.hoy-aviso.is-unread strong::before { content: ""; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: var(--c-info); vertical-align: 1px; }
.zone-row { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: baseline; margin: 0 0 var(--s-3); }
.lugares-add-wrap { display: grid; gap: var(--s-2); margin-bottom: var(--s-3); }
.lugares-add-menu { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-2); }
.lugares-add-menu[hidden], .lugares-add-menu > [hidden] { display: none; }
.layer-details { display: grid; gap: var(--s-3); padding: var(--s-2); border-top: 1px solid var(--c-line); }
.layer-details .helper { font-size: var(--t-micro-size); }

/* Mis lugares: una sola jerarquía (zona y «Agregar», secciones plegables, filas iguales con estado y menú «⋯») */
.lugares-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s-3); }
.lugares-head .lugares-add-wrap { margin: 0; }
.lugares-head .btn-primary { min-height: var(--touch-size); padding: 0 var(--s-5); }
.lugares-zona { display: grid; gap: var(--s-2); padding-bottom: var(--s-3); border-bottom: 1px solid var(--c-line); }
.lugares-zona .zone-row { margin: 0; }
.lugares-celdas-slot:empty { display: none; }
.lugares-sec { display: grid; gap: var(--s-2); }
.lugares-sec[hidden] { display: none; }
.lugares-sec-head { margin: 0; font-size: var(--t-section-size); line-height: var(--t-section-lh); }
.lugares-sec-toggle { display: flex; align-items: center; gap: var(--s-2); width: 100%; min-height: var(--touch-size); padding: 0; background: transparent; border: 0; font: inherit; font-weight: var(--t-section-weight); color: var(--c-ink); text-align: left; cursor: pointer; }
.lugares-sec-toggle:focus-visible, .row-menu-btn:focus-visible, .row-menu-item:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }
.lugares-sec-toggle .chevron { flex: none; width: 18px; height: 18px; fill: none; stroke: var(--c-ink-subtle); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .15s; }
.lugares-sec.is-collapsed .lugares-sec-toggle .chevron { transform: rotate(-90deg); }
.lugares-sec.is-collapsed .lugares-sec-body { display: none; }
.lugares-sec-body { display: grid; gap: var(--s-2); }
.lugares-count { min-width: 22px; padding: 0 var(--s-2); border-radius: var(--r-pill); background: var(--c-surface-alt); color: var(--c-ink-muted); font-size: var(--t-micro-size); line-height: 20px; text-align: center; font-variant-numeric: tabular-nums; }
.lugares-count:empty { display: none; }
#agenda-block { margin-top: 0; padding-top: 0; border-top: 0; }
.campos-filters { margin: 0; }
.campos-list { gap: var(--s-2); }
.campos-empty, .site-empty { padding: var(--s-3); border-radius: var(--r-md); border: 1px dashed var(--c-line-strong); background: transparent; font-size: var(--t-small-size); }
.campos-row, .site-row { min-height: 56px; }
.campos-row-text strong, .campos-row-text .campo-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.campos-row-text .campo-line { font-size: var(--t-small-size); color: var(--c-ink-muted); }
.state-pill { flex: none; display: inline-flex; align-items: center; gap: 4px; max-width: 46%; padding: 2px var(--s-2); border-radius: var(--r-pill); border: 1px solid var(--c-line-strong); background: var(--c-surface); color: var(--c-ink-muted); font-size: var(--t-micro-size); line-height: 16px; font-weight: 600; white-space: nowrap; }
.state-pill.is-new { background: var(--c-info-bg); color: var(--c-info); border-color: var(--c-info); }
.state-pill.is-dry { color: var(--c-ok); border-color: var(--c-ok); background: var(--c-surface); }
.state-pill.is-stale { border-style: dashed; }
.state-pill.is-off { border-style: dashed; color: var(--c-ink-subtle); }
.state-pill.is-wait { border-style: dashed; color: var(--c-ink-subtle); }
.campos-row.is-off .state-pill { color: var(--c-ink-subtle); }
.site-groups { gap: var(--s-2); }
.site-group ul { grid-template-columns: minmax(0, 1fr); }
.site-group h3[hidden] { display: none; }
.site-row { position: relative; flex-wrap: nowrap; gap: var(--s-2); padding: var(--s-2) var(--s-2) var(--s-2) var(--s-3); border-color: var(--c-line-strong); }
.site-row .site-icon { flex: none; }
.site-row-copy { flex: 1 1 0; min-width: 0; }
.site-row-name, .site-row-meta { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-menu-wrap { position: relative; flex: none; }
.row-menu-btn { min-width: var(--touch-size); min-height: var(--touch-size); background: transparent; border: 0; border-radius: var(--r-md); font: inherit; font-size: 20px; line-height: 1; color: var(--c-ink-muted); cursor: pointer; }
.row-menu-btn:hover, .row-menu-btn[aria-expanded="true"] { background: var(--c-surface-alt); color: var(--c-ink); }
.row-menu { position: absolute; right: 0; top: 100%; z-index: 5; display: grid; min-width: 150px; padding: var(--s-1); background: var(--c-surface); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); box-shadow: 0 6px 18px rgba(16, 40, 32, .16); }
.row-menu[hidden] { display: none; }
.row-menu-item { min-height: var(--touch-size); padding: 0 var(--s-3); background: transparent; border: 0; border-radius: var(--r-sm); font: inherit; color: var(--c-ink); text-align: left; cursor: pointer; }
.row-menu-item:hover { background: var(--c-surface-alt); }
.hoy-km-link { display: inline-block; }
.lugares-zona .zone-row { display: block; font-size: var(--t-small-size); line-height: var(--t-small-lh); }
.lugares-zona .zone-row a { display: inline; min-height: 0; margin-left: var(--s-1); }
.campos-row-text .campo-line { white-space: normal; overflow: visible; }
.state-pill { max-width: none; }
.campos-row-text strong { max-width: 100%; }
.campos-row-text strong { white-space: normal; overflow-wrap: anywhere; }
#rain-kind .chip { flex: 1 1 0; min-height: 36px; padding: 0 var(--s-2); font-size: var(--t-small-size); }
.hoy-stat.is-unusual { border-color: var(--c-warn); background: var(--c-warn-bg); }
.hoy-stat.is-unusual .hoy-stat-label { color: var(--c-warn); font-weight: 600; }
.hoy-foot .hoy-unusual { color: var(--c-warn); font-weight: 600; }
/* Al reproducir, la ficha del campo no se grisa: se queda como estaba hasta que llega la fecha nueva y solo un punto discreto, junto al título, indica que está actualizando (sin mover nada). */
#campo-detail.is-updating, #lot-detail.is-updating { cursor: progress; }
#campo-detail.is-updating .lot-block-title::after, #lot-detail.is-updating .lot-block-title::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: var(--s-2); border-radius: 50%; background: var(--c-brand); vertical-align: middle; animation: lot-updating-dot 1s ease-in-out infinite; }
@keyframes lot-updating-dot { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { #campo-detail.is-updating .lot-block-title::after, #lot-detail.is-updating .lot-block-title::after { animation: none; } }
.lotes-campo-filter select { min-height: var(--touch-size); }
.campos-row-text .row-name { font-weight: 650; }
.campos-row-text span { white-space: normal; }
.campos-rows { display: grid; gap: var(--s-2); list-style: none; padding: 0; margin: 0; }
.campos-row { width: 100%; text-align: left; }
.campos-row:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }
#trip-list-block { display: grid; gap: var(--s-4); }
#trip-list-block section { display: grid; gap: var(--s-2); }

/* P12: Hoy municipal */
.hoy-muni { display: grid; gap: var(--s-3); }
.hoy-muni[hidden] { display: none; }
.hoy-stats-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hoy-stats-3 .hoy-stat { padding-inline: var(--s-1); }
.muni-bars-card { display: grid; gap: var(--s-2); padding: var(--s-3); }
.muni-bars .muni-spark { width: 100%; height: 44px; display: block; }
.muni-top { display: grid; gap: var(--s-2); list-style: none; padding: 0; margin: 0; }
.muni-top-row { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); width: 100%; min-height: var(--touch-size); padding: var(--s-2) var(--s-3); border: 1px solid var(--c-line); border-radius: var(--r-md); background: var(--c-surface); text-align: left; font: inherit; cursor: pointer; }
.muni-top-row strong { font-weight: 650; overflow-wrap: anywhere; }
.muni-top-row span { font-variant-numeric: tabular-nums; color: var(--d-road-wet); font-weight: 650; white-space: nowrap; }
.muni-top-row:focus-visible { outline: 3px solid var(--c-info); outline-offset: 1px; }

/* P4: histórico y lluvia de las fichas, en cifras y barras */
.hist-card { display: grid; gap: var(--s-2); }
.hist-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-2); }
.hist-fig { display: grid; align-content: start; gap: 2px; text-align: center; }
.hist-num { font-size: 22px; line-height: 28px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--c-ink); }
.hist-label { font-size: var(--t-micro-size); line-height: var(--t-micro-lh); color: var(--c-ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }   /* una sola línea: las tres barras quedan a la misma altura */
.hist-bar, .rain-bar { display: block; height: 6px; border-radius: 3px; background: var(--c-line); overflow: hidden; }
.hist-bar b, .rain-bar b { display: block; height: 100%; border-radius: 3px; background: var(--d-water-optical); }
.rain-bar b { background: var(--d-rain-3); }
.rain-bars { display: grid; gap: var(--s-2); }
.rain-row { display: grid; grid-template-columns: 56px minmax(0, 1fr) 56px; align-items: center; gap: var(--s-2); font-size: var(--t-small-size); }
.rain-label { color: var(--c-ink-muted); }
.rain-mm { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* Hoy dice primero lo importante: la frase de arriba y, en el teléfono, una tira sobre el mapa que abre el panel */
.hoy-lead-box { display: grid; gap: var(--s-2); }
.hoy-lead-box[hidden] { display: none; }
.hoy-lead { margin: 0; font-size: var(--t-body-size); line-height: var(--t-body-lh); font-weight: 600; color: var(--c-ink); overflow-wrap: anywhere; }
.hoy-strip { display: none; }
@media (max-width: 767px) and (min-height: 480px) {
  .hoy-strip:not([hidden]) { position: absolute; z-index: var(--z-map-controls); top: var(--s-2); left: var(--s-2); right: var(--s-2); display: flex; align-items: center; gap: var(--s-2); min-height: var(--touch-size); padding: var(--s-1) var(--s-3); background: var(--c-surface); color: var(--c-ink); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); box-shadow: var(--e-float); font: inherit; font-size: var(--t-small-size); line-height: var(--t-small-lh); font-weight: 600; text-align: left; cursor: pointer; }
  .hoy-strip:focus-visible { outline: 3px solid var(--c-info); outline-offset: 2px; }
  .hoy-strip-text { flex: 1 1 auto; min-width: 0; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden; overflow-wrap: anywhere; }
  .hoy-strip svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
  #day-notice:not([hidden]) ~ .hoy-strip { top: 52px; }
  #sidebar.open ~ #mapa .hoy-strip, body.lot-panel-open .hoy-strip, body.road-panel-open .hoy-strip, body.trip-panel-open .hoy-strip, body.lot-drawing .hoy-strip { display: none; }
}

/* Hoy: «¿se puede entrar?» en cada tarjeta y «Compartir» */
/* «Compartir» va en la fila del título «Hoy»; la frase usa todo el ancho y, con agua en una entrada, esa parte va sola en su línea */
.panel-head-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.hoy-share[hidden] { display: none; }
.hoy-lead-entrance { display: flex; align-items: flex-start; gap: var(--s-2); margin: var(--s-1) 0; font-weight: 700; color: var(--c-warn); }
.hoy-lead-entrance .state-icon { flex: none; width: 16px; height: 18px; }
.hoy-lead-entrance.is-flooded { color: var(--c-error); }
.hoy-share { padding: 0 var(--s-3); white-space: nowrap; }
.hoy-share:disabled { color: var(--c-ink-muted); cursor: default; }
.muni-day-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.muni-day-row p { margin: 0; min-width: 0; }
.hoy-access { grid-column: 1 / -1; display: inline-flex; align-items: center; gap: var(--s-1); font-size: var(--t-small-size); line-height: var(--t-small-lh); font-weight: 600; color: var(--c-ink-muted); overflow-wrap: anywhere; }
.hoy-access .state-icon { margin-right: 2px; }
.hoy-access.is-water_near { color: var(--c-warn); }
.hoy-access.is-flooded { color: var(--c-error); }
.share-pop { position: fixed; z-index: var(--z-toast); display: grid; gap: var(--s-2); width: min(260px, calc(100vw - 16px)); padding: var(--s-3); background: var(--c-surface); border: 1px solid var(--c-line); border-radius: var(--r-md); box-shadow: var(--e-float); }
.share-pop-action { width: 100%; }
.share-pop-status { margin: 0; min-height: 0; }
.share-pop-status:empty { display: none; }
.share-pop-text { width: 100%; font: inherit; font-size: var(--t-small-size); border: 1px solid var(--c-line-strong); border-radius: var(--r-md); padding: var(--s-2); color: var(--c-ink); background: var(--c-surface); resize: none; }
