/* Telemetry Portal · apariencia persistente dark/light */
html { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

html[data-theme="light"] {
  --bg: #eaf2f5;
  --card: rgba(255, 255, 255, .92);
  --card-soft: rgba(246, 250, 252, .94);
  --line: rgba(0, 112, 143, .22);
  --line-strong: rgba(0, 122, 155, .46);
  --text: #102a37;
  --muted: #5f7885;
  --cyan: #007f9e;
  --green: #087a52;
  --yellow: #9b7200;
  --orange: #a95600;
  --red: #c63e4d;
  --purple: #7c3ca0;
  --blue: #176a9b;
}

html[data-theme="light"] body { color: var(--text); background: #eaf2f5; }
html[data-theme="light"] body::before {
  background: #eef5f7 url("/static/portal-bg-light-v2.png?v=2") center center / cover no-repeat;
}
html[data-theme="light"] body::after {
  background:
    linear-gradient(90deg, rgba(246,250,252,.84), rgba(239,247,249,.72) 48%, rgba(245,249,251,.84)),
    linear-gradient(180deg, rgba(255,255,255,.18), rgba(226,239,243,.48));
}

html[data-theme="light"] :is(h1,h2,h3,h4,strong,th,legend) { color: #102a37; }
html[data-theme="light"] :is(p,small,.helper,.section-description) { color: #607986; }
html[data-theme="light"] .eyebrow { color: #087a68; }
html[data-theme="light"] a { color: inherit; }

html[data-theme="light"] :is(input,select,textarea) {
  color: #102a37;
  border-color: rgba(0,112,143,.25);
  background: rgba(255,255,255,.84);
  box-shadow: inset 0 1px 1px rgba(16,42,55,.04);
}
html[data-theme="light"] select option { color: #102a37; background: #fff; }
html[data-theme="light"] :is(input,select,textarea):focus {
  border-color: rgba(0,127,158,.56);
  box-shadow: 0 0 0 3px rgba(0,127,158,.10);
}
html[data-theme="light"] label { color: #365968; }

html[data-theme="light"] button.secondary,
html[data-theme="light"] .secondary {
  color: #123946;
  background: rgba(0,127,158,.08);
  border-color: rgba(0,127,158,.25);
}
html[data-theme="light"] button.ghost,
html[data-theme="light"] .ghost { color: #007b99; border-color: rgba(0,127,158,.25); }

html[data-theme="light"] :is(
  .panel,.login-card,.portal-session-stack,.environment-status,.monitoring-profile-strip,
  .kpi,.wind-panel,.gps-card,.charts-card,.history-hero,.history-overview-card,
  .history-workspace,.alerts-summary-card,.alert-events-panel,.alert-config-panel,
  .pilot-status-card,.config-device-action-card,.config-equipment-head,.passport-hero,
  .passport-section,.operations-summary-card,.operations-filter-panel,.operations-priority-panel,
  .operations-distribution-panel,.operations-map-panel,.operations-fleet-panel,
  .lora-device-card,.lora-detail-panel,.coverage-controls,.coverage-results,
  .client-card,.client-device-card,.client-permission-card
) {
  color: #102a37;
  border-color: rgba(0,112,143,.23);
  background: linear-gradient(155deg, rgba(255,255,255,.96), rgba(241,248,250,.95));
  box-shadow: 0 14px 34px rgba(28,67,82,.10);
}

html[data-theme="light"] :is(.portal-header,.tabs) { border-color: rgba(0,112,143,.16); }
html[data-theme="light"] .portal-session-stack { background: rgba(255,255,255,.76); }
html[data-theme="light"] .portal-session-divider { background: rgba(28,82,101,.22); }
html[data-theme="light"] .user-pill { color: #153b49; }
html[data-theme="light"] .user-pill:hover,
html[data-theme="light"] .user-pill:focus-visible { color: #007f9e; background: rgba(0,127,158,.06); }
html[data-theme="light"] .tab-button { color: #55717e; }
html[data-theme="light"] .tab-button.active { color: #007f9e; border-bottom-color: #007f9e; }

html[data-theme="light"] :is(.operations-summary-card,.alerts-summary-card,.pilot-status-card,.history-overview-card) span { color: #637f8b; }
html[data-theme="light"] :is(.operations-summary-card,.alerts-summary-card,.pilot-status-card,.history-overview-card) strong { color: #123443; }
html[data-theme="light"] :is(.operations-summary-card,.alerts-summary-card,.pilot-status-card,.history-overview-card) small { color: #6d8792; }

html[data-theme="light"] :is(
  .operations-device-card,.operations-priority-item,.operations-product-row,.operations-activity-item,
  .passport-profile-item,.passport-capability,.passport-diagnostic-item,.history-metric-card,
  .alert-v14-protections,.alert-v14-protections-grid article,.energy-metric,.energy-system-item,
  .energy-battery-item,.lora-definition-grid>div,.lora-device-metric,.lora-detail-block,
  .coverage-section,.coverage-result-card
) {
  border-color: rgba(0,112,143,.17);
  background: rgba(248,252,253,.88);
}

html[data-theme="light"] :is(.table-wrap,.alert-events-table-wrap,.devices-table-wrap) { border-color: rgba(0,112,143,.18); background: rgba(255,255,255,.76); }
html[data-theme="light"] :is(table th,.alert-events-table th,.alerts-table th,.pilot-audit-table th,.devices-table th) {
  color: #4c6977;
  background: #e8f2f5;
  border-color: rgba(0,112,143,.14);
}
html[data-theme="light"] :is(table td,.alert-events-table td,.alerts-table td,.pilot-audit-table td,.devices-table td) {
  color: #183846;
  border-color: rgba(0,112,143,.11);
}
html[data-theme="light"] :is(table td strong,.alert-events-table td strong) { color: #102a37; }
html[data-theme="light"] code { color: #315a69; background: rgba(0,99,128,.07); }

html[data-theme="light"] .alert-events-table tr,
html[data-theme="light"] .pilot-audit-table tr { background: rgba(255,255,255,.68); }
html[data-theme="light"] .alert-event-row:hover,
html[data-theme="light"] .pilot-audit-table tbody tr:hover { background: rgba(0,127,158,.045); }

html[data-theme="light"] :is(.alert-event-dialog,.alert-event-dialog::backdrop) { color: #102a37; }
html[data-theme="light"] .alert-event-dialog { background: #f8fcfd; border-color: rgba(0,112,143,.3); }
html[data-theme="light"] .alert-detail-section { background: #fff; border-color: rgba(0,112,143,.16); }

html[data-theme="light"] .lora-portal-link,
html[data-theme="light"] .portal-lora-entry { color: #214c5b; background: rgba(255,255,255,.56); border-color: rgba(0,112,143,.22); }
html[data-theme="light"] .lora-global-message { color: #9e2837; background: rgba(198,62,77,.08); }
html[data-theme="light"] .lora-device-card { background: linear-gradient(155deg,#fff,#edf6f8); }
html[data-theme="light"] .lora-device-meta { color: #466978; }
html[data-theme="light"] .lora-detail-overlay { background: rgba(57,81,91,.36); }
html[data-theme="light"] .lora-detail-panel { background: #f7fbfc; }
html[data-theme="light"] .lora-detail-list dd { color: #183846; }

html[data-theme="light"] .history-analysis-strip,
html[data-theme="light"] .history-comparison-strip,
html[data-theme="light"] .history-status-line { background: rgba(255,255,255,.72); border-color: rgba(0,112,143,.14); }
html[data-theme="light"] input[type="date"]::-webkit-calendar-picker-indicator {
  filter: invert(29%) sepia(24%) saturate(1150%) hue-rotate(151deg) brightness(82%);
  opacity: .95;
  cursor: pointer;
}

html[data-theme="light"] :is(.config-info-banner,.pilot-status-message,.monitoring-profile-action-status) {
  color: #4c6977;
  background: rgba(255,255,255,.68);
  border-color: rgba(0,112,143,.18);
}

/* El mapa 3D selecciona automáticamente basemap claro/oscuro desde telemetry-map.js. */
html[data-theme="light"] .telemetry-map-summary article { background: rgba(255,255,255,.92); }
html[data-theme="light"] .telemetry-map-summary :is(span,small) { color: #5f7885; }
html[data-theme="light"] .telemetry-map-summary strong { color: #102a37; }

/* Mapas Leaflet: controles y herramientas legibles en ambos temas. */
html[data-theme="light"] :is(.operations-map-tool,.map-tool-button,.wind-map-tool,.geo-map-tool) {
  color: #1b4655;
  background: rgba(255,255,255,.9);
  border-color: rgba(0,112,143,.24);
}
html[data-theme="light"] :is(.operations-map-tool.active,.map-tool-button.active,.wind-map-tool.active,.geo-map-tool.active) {
  color: #fff;
  background: #007f9e;
}

html[data-theme="light"] .leaflet-popup-content-wrapper,
html[data-theme="light"] .leaflet-popup-tip { color: #173846; background: #fff; }
html[data-theme="light"] .leaflet-control { color: #173846; }

html[data-theme="light"] .client-theme-option.is-selected { border-color: #007f9e; background: rgba(0,127,158,.07); }

@media (prefers-reduced-motion: reduce) {
  html[data-theme="light"] * { scroll-behavior: auto; }
}

/* El usuario de cabecera es el acceso a Mi cuenta. */
.user-pill-link { display:block; width:100%; color:inherit; text-decoration:none; cursor:pointer; border-radius:9px; transition:color .16s ease,background .16s ease; }
.user-pill-link:hover,.user-pill-link:focus-visible { color:var(--cyan); background:rgba(49,215,255,.055); outline:none; }

/* BEGIN DASHBOARD VISUAL RC1 */

html[data-theme="light"]
.operations-summary-card,
html[data-theme="light"]
.operations-filter-panel,
html[data-theme="light"]
.operations-map-panel {
  background: transparent;
  box-shadow: none;
}

/* END DASHBOARD VISUAL RC1 */

/* BEGIN MONITORING AMBIENT VISUAL RC1 */

html[data-theme="light"]
#environmentKpiGrid .kpi {
  border: 0;

  background: rgba(240, 247, 249, .62);

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.65);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

html[data-theme="light"]
#environmentKpiGrid .kpi-label {
  color: #3e5e6b;
}

html[data-theme="light"]
#environmentKpiGrid .sensor-state-detail {
  color: #617985;
}

/* END MONITORING AMBIENT VISUAL RC1 */

/* BEGIN MONITORING WIND CLEAN RC1 */

html[data-theme="light"]
#windGrid {
  border-color:
    rgba(0,112,143,.14);

  background:
    linear-gradient(
      180deg,
      rgba(244,249,251,.76),
      rgba(235,244,247,.65)
    );

  box-shadow:
    inset 0 1px 0
    rgba(255,255,255,.72);
}

html[data-theme="light"]
.wind-clean-title {
  color: #173846;
}

html[data-theme="light"]
.wind-clean-unit {
  color: #607b87;
}

html[data-theme="light"]
.wind-clean-speed-value {
  color: #173846;
}

html[data-theme="light"]
.wind-clean-speed-state {
  color: #16836f;
}

html[data-theme="light"]
.wind-clean-direction-main {
  color: #007f9e;
}

html[data-theme="light"]
.wind-clean-direction-long {
  color: #365561;
}

html[data-theme="light"]
.wind-clean-summary {
  border-top-color:
    rgba(0,112,143,.09);
}

html[data-theme="light"]
.wind-clean-summary-item {
  border-color:
    rgba(0,112,143,.09);

  background:
    rgba(245,249,251,.56);
}

html[data-theme="light"]
.wind-clean-summary-label {
  color: #66808b;
}

html[data-theme="light"]
.wind-clean-summary-value {
  color: #173846;
}

/* END MONITORING WIND CLEAN RC1 */

/* BEGIN MONITORING POWER SYSTEM VISUAL RC1 */

html[data-theme="light"]
#powerKpiGrid .kpi,

html[data-theme="light"]
#systemKpiGrid .kpi {
  border: 0;

  background:
    rgba(240, 247, 249, .62);

  box-shadow:
    inset 0 1px 0
    rgba(255,255,255,.65);

  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

html[data-theme="light"]
#powerKpiGrid .kpi-label,

html[data-theme="light"]
#systemKpiGrid .kpi-label {
  color: #3e5e6b;
}

html[data-theme="light"]
#powerKpiGrid .sensor-state-detail,

html[data-theme="light"]
#systemKpiGrid .sensor-state-detail {
  color: #617985;
}

/* END MONITORING POWER SYSTEM VISUAL RC1 */

/* BEGIN GPS VISUAL RC1 */

html[data-theme="light"] .gps-manual-summary {
  border: 0;
  background: transparent;
}

html[data-theme="light"] .gps-manual-summary-mode {
  color: #397f70;
}

html[data-theme="light"] .gps-manual-summary-geo strong {
  color: #173846;
}

html[data-theme="light"] .gps-location-map-card {
  border: 0;
  background: transparent;
  box-shadow: none;
}

html[data-theme="light"] .gps-location-coordinate-actions small {
  color: #006f8b;
}

html[data-theme="light"] .gps-location-copy-btn {
  color: #07596e;

  background: rgba(238,248,250,.72);

  border-color: rgba(0,112,143,.24);
}

html[data-theme="light"] .gps-location-map-status {
  color: #5b7480;
}

/* END GPS VISUAL RC1 */


/* ==========================================================================
   TELEMETRY · LIGHT MODE PURE BACKGROUND
   Mostrar portal-bg-light-v2.png sin overlays ni capas extra
   ========================================================================== */

html[data-theme="light"] body {
  background: transparent !important;
}

html[data-theme="light"] body::before {
  content: "" !important;

  position: fixed !important;
  inset: 0 !important;
  z-index: -2 !important;

  width: 100% !important;
  height: 100% !important;

  background:
    url("/static/portal-bg-light-v2.png")
    center center / cover
    no-repeat
    fixed !important;

  opacity: 1 !important;

  filter: none !important;

  pointer-events: none !important;
}

html[data-theme="light"] body::after {
  content: none !important;
  display: none !important;

  background: none !important;
  opacity: 0 !important;

  filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

/* Eliminar overlays globales que pudieran alterar visualmente el fondo */
html[data-theme="light"] .page-background,
html[data-theme="light"] .background-overlay,
html[data-theme="light"] .portal-background-overlay {
  display: none !important;
}

/* ==========================================================================
   END TELEMETRY · LIGHT MODE PURE BACKGROUND
   ========================================================================== */


/* ==========================================================================
   TELEMETRY · LIGHT CONTRAST RC1
   BG2 permanece puro. Sólo se refuerza contraste tipográfico.
   ========================================================================== */

html[data-theme="light"] {
  --text: #102c39;
  --muted: #496976;
  --cyan: #006f8d;
  --green: #08745f;
  --yellow: #856500;
  --red: #a72e3d;
}


/* Texto principal */

html[data-theme="light"] body {
  color: #102c39;
}

html[data-theme="light"] :is(
  h1,h2,h3,h4,h5,h6,
  strong,
  th,
  legend
) {
  color: #102c39 !important;
}

html[data-theme="light"] :is(
  p,
  small,
  .muted,
  .helper,
  .section-description,
  .secondary-text
) {
  color: #496976 !important;
}


/* Eyebrows / etiquetas */

html[data-theme="light"] .eyebrow {
  color: #076f62 !important;
}

html[data-theme="light"] :is(
  .operations-summary-card span,
  .alerts-summary-card span,
  .pilot-status-card span,
  .history-overview-card span,
  .client-card span
) {
  color: #4c6975 !important;
}


/* Navegación */

html[data-theme="light"] .tab-button {
  color: #365965 !important;
}

html[data-theme="light"] .tab-button:hover {
  color: #005f79 !important;
}

html[data-theme="light"] .tab-button.active {
  color: #005f79 !important;
  border-bottom-color: #005f79 !important;
}


/* Header */

html[data-theme="light"] .portal-header :is(
  .portal-brand-title,
  .portal-branding h1,
  .portal-logo-text
) {
  color: #0a2937 !important;
}

html[data-theme="light"] :is(
  .portal-brand-slogan,
  .portal-brand-slogan strong,
  .portal-brand-slogan span
) {
  color: #365965 !important;
}


/* Account dropdown */

html[data-theme="light"] :is(
  .user-pill,
  .user-pill strong,
  .portal-account-identity
) {
  color: #173d4b !important;
}

html[data-theme="light"] :is(
  .user-pill small,
  .portal-account-card small
) {
  color: #55727d !important;
}


/* Dashboard KPIs */

html[data-theme="light"] .operations-summary-card strong {
  color: #102c39 !important;
}

html[data-theme="light"] .operations-summary-card small {
  color: #496976 !important;
}


/* Filtros */

html[data-theme="light"] label {
  color: #294f5e !important;
}

html[data-theme="light"] :is(
  input,
  select,
  textarea
) {
  color: #102c39 !important;
}

html[data-theme="light"] ::placeholder {
  color: #69828c !important;
  opacity: 1;
}


/* Tablas */

html[data-theme="light"] :is(
  table th,
  .inventory-table th,
  .devices-table th,
  .alerts-table th,
  .alert-events-table th,
  .pilot-audit-table th
) {
  color: #294f5e !important;
}

html[data-theme="light"] :is(
  table td,
  .devices-table td,
  .alerts-table td,
  .alert-events-table td,
  .pilot-audit-table td
) {
  color: #173946 !important;
}

html[data-theme="light"] code,
html[data-theme="light"] .mono {
  color: #315968 !important;
}


/* Botones secundarios */

html[data-theme="light"] :is(
  button.secondary,
  button.ghost,
  .secondary,
  .ghost
) {
  color: #174c60 !important;
}


/* Cliente */

html[data-theme="light"] .client-header h1 {
  color: #102c39 !important;
}

html[data-theme="light"] .client-card strong {
  color: #163946 !important;
}

html[data-theme="light"] .client-device-card strong {
  color: #173946 !important;
}

html[data-theme="light"] .client-permission-card span {
  color: #294f5e !important;
}

html[data-theme="light"] .client-footer {
  color: #526f7a !important;
}


/* ==========================================================================
   END TELEMETRY · LIGHT CONTRAST RC1
   ========================================================================== */
