:root {
  --bg: #0b0b0c;
  --card: #141417;
  --muted: #888;
  --text: #e9e9ee;
  --accent: #4da3ff;
  /* fallbacks si no existen ya en tu tema */
  --sc-surface: var(--surface, #121a25);
  --sc-line: var(--line, #1e2a42);
  --sc-text: var(--text, #eaf0f6);
  --sc-accent: var(--accent, #7dd3fc);
  --sc-backdrop: rgba(0, 0, 0, .40);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, Segoe UI, Roboto;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.container {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 12px;
}

/* Header / navegación */
.topbar {
  background: #101014;
  border-bottom: 1px solid #23232a;
}

.topbar .container {
  max-width: 1600px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: nowrap;

}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
  white-space: nowrap;
}

.app-title {
  margin: 0;
  white-space: nowrap;
  flex-shrink: 0;
}


.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
  color: #e6e8eb;
  font-weight: 600;
  background: transparent;
}

.nav-link:hover {
  background: #1a1b20;
  border-color: #2f2f36;
}

.nav-link.active {
  border-color: #2563eb;
  background: #0f2236;
  color: #bcd8ff;
}

html[data-ui-mode="basic"] .nav-link--registro[data-requires-mode="advanced"] {
  opacity: .55;
  pointer-events: none;
  cursor: not-allowed;
}



/* Layout utilidades */
.row {
  display: flex;
  align-items: center;
}

.row.between {
  justify-content: space-between;
}

.row.end {
  justify-content: flex-end;
}

.row.gap {
  gap: 12px;
  align-items: center;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}


h2 {
  margin: 12px 0;
}

h3 {
  margin: 8px 0 6px;
}

.card {
  background: var(--card);
  border: 1px solid #23232a;
  border-radius: 10px;
  padding: 12px;
  margin: 10px 0;
  overflow: visible;
}

/* Tabla */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 8px;
  border-bottom: 1px solid #23232a;
  vertical-align: middle;
}

.table th {
  text-align: left;
  color: #cfd3d9;
}

.table td.right,
.table th.right {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
}

.table-responsive {
  overflow: auto;
}

.table td:first-child,
.table th:first-child {
  white-space: nowrap;
  min-width: 9ch;
}

/* Botones */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  background: #23232a;
  color: #fff;
  border: 1px solid #2f2f36;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.06);
}

.btn.primary {
  background: #2563eb;
  border-color: #1e40af;
}

.btn.small {
  font-size: 12px;
  padding: 8px 14px;
  min-height: 29px;
}

.btn.danger {
  background: #3a1c1c;
  border-color: #c24141;
}

.btn.ghost {
  background: transparent;
  border: 1px solid #2f2f36;
  color: #ddd;
}

.btn.ghost:hover {
  background: #2e2e2e;
}

.btn.success {
  background: #1c3c1f;
  border-color: #2c7a35;
  color: #9ae6b4;
}

.btn.info {
  background: #0f2236;
  border-color: #2a4a75;
  color: #9dcbff;
}

.btn.info::after,
.btn.success::after {
  content: none !important;
}

/* evita pseudo "?" de estilos base */

/* Formularios */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: #cfd3d9;
}

input,
select,
textarea,
input[type="date"],
input[type="number"],
input[type="text"] {
  background: #0e0f13;
  border: 1px solid #2f2f36;
  color: #fff;
  border-radius: 8px;
  padding: 8px;
}

select[multiple] {
  min-height: 144px;
}

/* Chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 999px;
  font-size: .85rem;
  line-height: 1;
  background: #2a2b33;
  border: 1px solid #3a3a46;
}

.chip.muted {
  background: #2a2a2a;
  color: #bbb;
}

.chip.ok,
.chip.true,
.chip.green {
  background: #1c3c1f;
  border-color: #2c7a35;
  color: #8de28d;
}

.chip.warn,
.chip.yellow {
  background: #3f3a1a;
  border-color: #b59f22;
}

.chip.alert,
.chip.red,
.chip.false,
.chip.danger {
  background: #3a1c1c;
  border-color: #c24141;
}

/* Key-Value lists */
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 16px;
}

.kv dt {
  color: #b7bac2;
}

.kv dd {
  margin: 0;
}

.kv dt .info {
  margin-left: 6px;
  font-weight: 600;
  cursor: help;
}

.info::after {
  content: "?";
  display: inline-flex;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
  font-size: 12px;
  color: #bbb;
}

/* Mensajes / estados */
.messages {
  margin: 6px 0 0;
  padding-left: 16px;
}

.error {
  color: #ff8a8a;
}

.muted {
  color: var(--muted);
  font-size: 12px;
}

/* Footer */
.footer {
  color: #9aa0a6;
  border-top: 1px solid #23232a;
  margin-top: 24px;
  padding: 10px 0;
}

.footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
}

.footer__institutional {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid #23232a;
}

.footer__institutional-label {
  color: #9aa0a6;
  font-size: 12px;
}

.footer__institutional-logos {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer__logo-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background: #f8fafc;
  border: 1px solid #d7dbe2;
  border-radius: 10px;
  padding: 6px 10px;
}

.footer__logo {
  display: block;
  width: auto;
  max-width: 100%;
  object-fit: contain;
}

.footer__logo--eu {
  height: 28px;
}

.footer__logo--dipu {
  height: 28px;
}

.footer__logo--ruractive {
  height: 32px;
}


/* Mapas */
.map {
  width: 100%;
  height: 360px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #23232a;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #0b0b0c;
}

.legend-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle
}

/* Preformateado */
.pre {
  white-space: pre-wrap;
  font-family: ui-monospace, Consolas, Menlo, monospace;
  background: #0d0f14;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid #23232a;
}

.pre.small {
  font-size: 12px;
  max-height: 220px;
  overflow: auto;
}

/* Sparklines / tendencias */
.sparkline {
  width: 100%;
  height: 48px;
}

.sparkline path {
  stroke: var(--accent);
}

.trend-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.trend-block {
  background: var(--card);
  border: 1px solid #23232a;
  border-radius: 10px;
  padding: 8px;
}

.trend-block h4 {
  margin: 0 0 6px;
  font-size: 13px;
  color: #cfd3d9;
}

.debug {
  margin-top: 8px;
}

.debug summary {
  cursor: pointer;
  color: #cfd3d9;
  margin-bottom: 6px;
}

.debug-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.debug .hints {
  margin: 0;
  padding-left: 16px;
}


/* Semáforos (puntos) */
.dots {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  vertical-align: middle;
}

.dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 1px solid #2a2a2e;
  background: #2a2a2e;
  position: static;
}

.dot.green {
  background: #1c5e31;
  border-color: #2b7a45;
}

.dot.amber {
  background: #7a6a1f;
  border-color: #9b8530;
}

.dot.red {
  background: #7a2a2a;
  border-color: #a33a3a;
}

.dot.neutral {
  background: #303038;
  border-color: #3a3a42;
}

/* ——— TOASTS ——— */
#toast-stack {
  position: fixed;
  top: 12px;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 240px;
  max-width: min(420px, 92vw);
  background: #101014;
  color: var(--text);
  border: 1px solid #23232a;
  border-left: 4px solid var(--accent);
  padding: 10px 12px;
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .35);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(-6px);
  animation: toast-in .18s ease-out forwards;
  margin-top: 65px;
}

@keyframes toast-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast.hide {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .18s ease, transform .18s ease;
}

.toast .toast-msg {
  flex: 1;
}

.toast .toast-close {
  border: none;
  background: transparent;
  color: #bbb;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.toast .toast-close:hover {
  color: #fff;
}

.toast-info {
  border-left-color: #4da3ff;
}

.toast-warning {
  border-left-color: #f1c40f;
}

.toast-error,
.toast-danger {
  border-left-color: #e74c3c;
}

.toast-success {
  border-left-color: #27ae60;
}

/* ==== Modal (dialog) ==== */

dialog:focus,
dialog:focus-visible {
  outline: none !important;
}

.modal {
  padding: 0;
  border: none;
  background: transparent;
  border-radius: 16px;
  overflow: hidden;
}

.modal::backdrop {
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(2px);
}


/* contenedor: soporta .modal-body (clásico) y .modal-contents (nuevo) */
.modal-body,
.modal-contents {
  width: min(900px, 96vw);
  max-height: min(92vh, 1000px);
  background: var(--card);
  color: var(--text);
  border: 1px solid #23232a;
  border-radius: 16px;
  padding: 16px;
  overflow: auto;
}

.modal-body h3 {
  margin-top: 0;
}

.map-card {
  background: #0f0f14;
  border: 1px solid #23232a;
  border-radius: 12px;
  padding: 12px;
}





#map-picker {
  height: 420px;
  border-radius: 10px;
  overflow: hidden;
}

.leaflet-draw-toolbar a {
  background: #16161b;
  border-color: #2a2a30;
}

.leaflet-draw-toolbar a:hover {
  background: #1d1d24;
}

.leaflet-bar a,
.leaflet-bar a:hover {
  color: var(--text);
  border-color: #2a2a30;
}

.leaflet-control-attribution {
  background: transparent;
  color: var(--muted);
}

/* === KPIs ====================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 12px 0 16px 0;
}

@media (max-width: 980px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.kpi {
  background: var(--card);
  border: 1px solid #23232a;
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}

.kpi .kpi-label {
  color: var(--muted);
  font-size: .95rem;
  margin-bottom: 4px;
}

.kpi .kpi-value {
  font-size: 1.9rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: .2px;
}

/* === Semáforos explicativos =================================== */
.sem-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.sem-card {
  border: 1px solid #24242a;
  background: #121216;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
  position: relative;
}

.sem-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  border-radius: 14px 0 0 14px;
  background: #2a2a2e;
}

.sem-card.green::before {
  background: #1c5e31;
}

.sem-card.amber::before {
  background: #7a6a1f;
}

.sem-card.red::before,
.sem-card.danger::before {
  background: #7a2a2a;
}

.sem-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.sem-card-header h4 {
  margin: 0;
  font-size: 15px;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid #2a2a2e;
  background: #15151a;
  color: #ccc;
}

.badge.green {
  background: #15361e;
  color: #b7f2c9;
  border-color: #1f4a2a;
}

.badge.amber {
  background: #352f12;
  color: #f2e6b7;
  border-color: #4a411f;
}

.badge.red,
.badge.danger {
  background: #3a1313;
  color: #f2b7b7;
  border-color: #4a1f1f;
}

.sem-card-body h5 {
  margin: 8px 0 6px;
  font-size: 13px;
  opacity: .85;
}

.sem-actions {
  margin: 0;
  padding-left: 18px;
}

.sem-actions li {
  margin: 3px 0;
}

/* === Secciones comunes ======================================== */
.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0 0 10px 0;
}

.card-muted {
  color: var(--muted);
  font-size: .92rem;
}

/* === Ayuda ===================================================== */
.help-btn {
  position: fixed;
  right: 16px;
  bottom: 16px;
  border: 1px solid #2a2a2e;
  background: #141417;
  color: #e9e9ee;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .25);
}

.help-btn:hover {
  background: #18181c;
}

.help-modal[aria-hidden="true"] {
  display: none;
}

.help-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.help-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .55);
}

.help-dialog {
  position: absolute;
  right: 4%;
  top: 6%;
  bottom: 6%;
  width: min(720px, 92vw);
  background: #101014;
  border: 1px solid #2a2a2e;
  border-radius: 16px;
  overflow: auto;
  box-shadow: 0 16px 40px rgba(0, 0, 0, .35);
  padding: 16px 18px 24px;
}

.help-close {
  position: sticky;
  top: 0;
  margin-left: auto;
  display: block;
  background: transparent;
  color: #aaa;
  border: 0;
  font-size: 22px;
  cursor: pointer;
}

.help-content h2 {
  margin: 4px 0 8px;
}

.help-content h3 {
  margin: 18px 0 8px;
}

.help-content p,
.help-content li,
.help-content dd {
  color: #d6d6dc;
}

.help-content code,
.help-tip code {
  background: #15151a;
  padding: 1px 4px;
  border-radius: 4px;
}

.help-tip {
  position: fixed;
  max-width: 340px;
  line-height: 1.25;
  background: #101014;
  border: 1px solid #2a2a2e;
  color: #e9e9ee;
  padding: 10px 12px;
  border-radius: 10px;
  z-index: 1100;
  pointer-events: none;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
}

/* === UI Mode Switch =========================================== */
.ui-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 0;
  border: 1px solid #2f2f36;
  border-radius: 10px;
  overflow: hidden;
  background: #1a1b20;
  margin-right: 4px;
}

.ui-mode-switch .seg {
  appearance: none;
  border: 0;
  background: transparent;
  color: #e6e8eb;
  padding: 7px 10px;
  min-width: 80px;
  min-height: 40px;
  font-size: 13px;
  cursor: pointer;
}

.ui-mode-switch .seg:hover {
  background: #23232a;
}

.ui-mode-switch .seg:focus {
  outline: 2px solid #2a4a75;
  outline-offset: -2px;
}

html[data-theme="noche"][data-ui-mode="basic"] .ui-mode-switch [data-mode="basic"],
html[data-theme="noche"][data-ui-mode="advanced"] .ui-mode-switch [data-mode="advanced"],
html[data-theme="noche"] .ui-mode-switch .seg.active {
  background: #2563eb;
  color: #fff;
}

html[data-theme="dia"][data-ui-mode="basic"] .ui-mode-switch [data-mode="basic"],
html[data-theme="dia"][data-ui-mode="advanced"] .ui-mode-switch [data-mode="advanced"],
html[data-theme="dia"] .ui-mode-switch .seg.active {
  background: #FF7B00;
  color: #fff;
}



/* === Grid de tarjetas (Index) ================================= */
.parcel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.parcel-card {
  background: var(--card);
  border: 1px solid #23232a;
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.parcel-card .title {
  font-size: 1.05rem;
  font-weight: 700;
  margin: 0;
}

.parcel-card .actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.parcel-card .actions .btn.info {
  background: #0f2236;
  border-color: #2a4a75;
  color: #9dcbff;
}

.parcel-card .actions .btn.edit {
  background: #23232a;
  border-color: #2f2f36;
}

.parcel-card .actions .btn.delete {
  background: #3a1c1c;
  border-color: #c24141;
  color: #f5bdbd;
}

.sem-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sem-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sem-line .label {
  color: #cfd3d9;
  font-size: .92rem;
}

.sem-line .dot {
  width: 12px;
  height: 12px;
  border: 1px solid #2a2a2e;
  border-radius: 999px;
}

/* === Index table fallback / acciones ========================== */
.name-cell .name-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  position: relative;
}

.name-cell .action-group {
  display: inline-flex;
  justify-content: center;
  gap: 8px;
}

.name-cell .action-group .btn {
  min-width: 92px;
}

.name-cell .action-group .btn::after {
  content: none !important;
}

/* === Histórico: layout & controles ============================ */
.form-grid {
  display: grid;
  grid-template-columns: 1.2fr 2fr 1fr 1fr;
  gap: 12px 16px;
}

.form-grid .range-mode {
  border: 1px solid #23232a;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-grid .range-fields {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
}

.field-label {
  font-size: 12px;
  color: #cfd3d9;
  margin-bottom: 6px;
}

.help-text {
  font-size: 11px;
  color: #9aa0a6;
  margin-top: 6px;
}

.chips.selectable .chip.toggle {
  cursor: pointer;
  user-select: none;
}

.chips.selectable .chip.toggle.active {
  background: #1c3c1f;
  border-color: #2c7a35;
  color: #8de28d;
}

#history-root .chart-canvas {
  background: radial-gradient(circle at top, rgba(36, 68, 112, 0.22), rgba(13, 15, 20, 0.96) 45%);
  border: 1px solid #243149;
  border-radius: 12px;
  padding: 14px;
}

#history-root .chart-canvas canvas {
  width: 100% !important;
}

#history-root #hist-chart {
  min-height: 300px;
}



/* Branding */
.site-badge {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 900;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #0f1115;
  border: 1px solid #2a2a2e;
  color: #e9e9ee;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
  text-decoration: none;
}

.site-badge:hover {
  background: #14141a;
  border-color: #3a3a42;
}

.site-badge .tag {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: #1a1a20;
  border: 1px solid #2a2a2e;
  color: #93f5bc;
  letter-spacing: .2px;
}

.site-badge img {
  height: 50px;
  display: block;
}

.site-badge .label {
  font-weight: 600;
  opacity: .9;
}



.brand-logo {
  height: 18px;
  width: auto;
  display: block;
}

/* Hitbox grande para los "?" de ayuda */
.help-q,
.info[data-help-key] {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 12px;
  /* desktop: 24px mínimo táctil aceptable */
  height: 34px;
  min-width: 24px;
  min-height: 24px;
  margin-left: 4px;
  /* separa del elemento anterior */
  border-radius: 9999px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  z-index: 3;
  /* por encima de inputs cercanos */
}

@media(pointer: coarse) {

  .help-q,
  .info[data-help-key] {
    /* móvil: sube a 32px */
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
  }
}

/* el glifo interno no debe robar eventos */
.help-q>svg,
.help-q>i,
.help-q>span,
.info[data-help-key]>svg,
.info[data-help-key]>i,
.info[data-help-key]>span {
  pointer-events: none;
}

/* ==========================================================================
   Loader reutilizable SmartCrop (overlay + spinner)
   Depende de variables CSS si existen; si no, usa fallbacks.
   ------------------------------------------------------------------------ */


.kpi-grid.env-kpis {
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.env-metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

.env-metric-card {
  background: var(--card, #121216);
  border: 1px solid #23232a;
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .22);
}

.env-metric-label {
  font-size: 0.9rem;
  color: var(--muted, #9aa0ab);
}

.env-metric-value {
  font-size: 1.4rem;
  font-weight: 700;
  margin-top: 4px;
}

.env-status-good {
  border-color: #22c55e55;
  box-shadow: 0 8px 24px rgba(34, 197, 94, 0.18);
}

.env-status-ok {
  border-color: #10b98155;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.16);
}

.env-status-warn {
  border-color: #f59e0b55;
  box-shadow: 0 8px 24px rgba(245, 158, 11, 0.18);
}

.env-status-bad {
  border-color: #f8717155;
  box-shadow: 0 8px 24px rgba(248, 113, 113, 0.20);
}

.env-empty {
  color: #9aa0ab;
  opacity: 0.7;
}

/* Cuando anclamos el overlay a un contenedor sin posicionamiento */
.sc-overlay-anchor {
  position: relative;
}

/* Contenedor del overlay */
.sc-overlay {
  position: absolute;
  inset: 0;
  display: none;
  /* visible sólo con .is-active */
  align-items: center;
  justify-content: center;
  z-index: 20;
  /* suficientemente alto para cubrir contenido local */
  pointer-events: all;
}

.sc-overlay--page {
  position: fixed;
  z-index: 9999;
  /* pantalla completa por encima de todo */
}

.sc-overlay.is-active {
  display: flex;
}

.sc-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: var(--sc-backdrop);
  backdrop-filter: saturate(1.1) blur(2px);
}

.sc-overlay__panel {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--sc-surface);
  color: var(--sc-text);
  border: 1px solid var(--sc-line);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  max-width: 85vw;
}

/* Spinner */
.sc-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--sc-line);
  border-top-color: var(--sc-accent);
  animation: scSpin .9s linear infinite;
}

@keyframes scSpin {
  to {
    transform: rotate(360deg);
  }
}

/* Texto */
.sc-overlay__text {
  font: 600 14px/1.2 system-ui, Segoe UI, Inter, Roboto, Arial, sans-serif;
  letter-spacing: .2px;
  white-space: nowrap;
}

/* Bloqueo de scroll cuando se muestra overlay de página */
body.sc-lock {
  overflow: hidden;
}


#modo-dia-noche {
  display: inline-block !important;
  visibility: visible !important;
}

.ui-mode-switch .seg.active {
  background: #2563eb;
  color: #fff;
}

.ui-mode-switch .btn {
  min-width: 85px;
}

.placeholder-noche::placeholder {
  color: #FFF;
}

.placeholder-dia::placeholder {
  color: #111;
}

/* Quitar el borde blanco boton Nueva Parcela */
#btn-open-modal:focus,
#btn-open-modal:active {
  outline: none;
  box-shadow: none;
}

#modo-dia-noche {
  margin-left: 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}


/* RESPONSIVE */
@media (max-width: 600px) {
  .ui-mode-switch .seg {
    min-width: 80px;
    padding: 8px 10px;
  }

  .site-badge .label {
    display: none;
  }
}

@media (max-width: 640px) {
  .main-nav {
    flex-wrap: nowrap;
  }
}

@media (max-width: 760px) {

  .topbar .container {
    max-width: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .topbar-left {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  #parcels-map {
    height: 300px;
  }

  .main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
  }

  .main-nav .nav-link {
    flex: 0 0 auto;
    min-width: 0;
    padding: 6px 6px;
    font-size: 13px;
  }

  .ui-mode-switch {
    overflow: visible;
    width: auto;
    justify-content: center;
  }

  .ui-mode-switch .seg {
    flex: 1;
    min-width: 0;
  }

  .topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
  }

  .topbar-right .btn {
    flex: 1;
    min-width: 0;
  }

  #modo-dia-noche {
    margin-left: auto;
    flex-shrink: 0;
  }

  .app-title {
    width: 100%;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }

  .debug-grid {
    grid-template-columns: 1fr;
  }

  .trend-grid {
    grid-template-columns: 1fr;
  }

  .footer__institutional {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .footer__institutional-logos {
    justify-content: center;
  }

  .footer__logo-wrap {
    width: 100%;
    max-width: 320px;
  }

  #history-root #hist-chart {
    min-height: 230px;
  }

}

@media (max-width: 980px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .form-grid .range-fields {
    grid-template-columns: 1fr;
  }

  .sem-grid {
    grid-template-columns: 1fr;
  }
}

#btn-open-modal {
  order: -1;
}

#parcels-map {
  width: 100%;
  height: 360px;
}

#form-create .btn {
  margin-top: 8px;
}


/* Tema noche (defecto) */
html[data-theme="noche"] {
  --bg: #0b0b0c;
  --card: #141417;
  --text: #e9e9ee;
  --muted: #888;
  --accent: #4da3ff;
}

.row.between {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.row.between{
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.row.gap .stack-label{
  display:flex;
  flex-direction:row;
  align-items:center;
  gap:6px;
}
.row.gap.end{
  margin-top: 10px;
}
