/* Telemetry Portal 1.9.2 · cabecera minimalista y encabezados de sección unificados */
:root {
  --telemetry-operational-teal: #0f6b6e;
  --telemetry-operational-teal-border: #69c7c8;
  --telemetry-operational-teal-soft: rgba(15, 107, 110, 0.22);
  --portal-header-control-width: 286px;
}

/* Cabecera: marca a la izquierda, selector centrado y sesión apilada a la derecha. */
.portal-header {
  display: grid;
  grid-template-columns: minmax(250px, 1fr) minmax(340px, 1.15fr) minmax(250px, 1fr);
  align-items: start;
  gap: 28px;
  min-height: 184px;
  padding: 20px 8px 14px;
}

.portal-branding {
  min-width: 0;
  align-self: start;
  padding-top: 20px;
}

.portal-branding h1 {
  margin: 0;
  font-size: clamp(48px, 5vw, 66px);
  line-height: .95;
  letter-spacing: -.035em;
}

.portal-header-actions.portal-header-center {
  display: grid;
  align-self: end;
  justify-self: center;
  width: min(100%, 450px);
  min-width: 0;
  max-width: none;
  margin: 0;
  padding-bottom: 2px;
}

.portal-global-device {
  display: grid;
  gap: 7px;
  width: 100%;
  min-width: 0;
  margin: 0;
}

.portal-global-device > span {
  justify-self: center;
  padding: 0;
  border: 0;
  color: #b8c9d8;
  background: transparent;
  text-align: center;
  font-size: 13px;
  font-weight: 650;
  line-height: 1.2;
}

.portal-global-device select {
  width: 100%;
  min-height: 46px;
  margin: 0;
  font-size: 13px;
  font-weight: 700;
}

.portal-session-stack {
  display: grid;
  grid-template-rows: repeat(3, auto);
  justify-self: end;
  align-items: stretch;
  gap: 7px;
  width: min(100%, var(--portal-header-control-width));
  min-width: 0;
}

.portal-session-stack .user-pill,
.portal-session-stack #logoutBtn,
.portal-session-stack #presentationModeBtn {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  box-sizing: border-box;
  margin: 0;
  padding: 7px 11px;
  justify-content: center;
  text-align: center;
  font-size: 12px;
  line-height: 1.2;
}

.portal-session-stack .user-pill {
  display: flex;
  max-width: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-session-stack #presentationModeBtn {
  white-space: nowrap;
}

/* Navegación únicamente textual, sin cajas alrededor de la pestaña activa. */
.tabs {
  justify-content: space-between;
  gap: 4px;
  margin-bottom: 24px;
}

.tabs .tab-button,
.tabs .tab-button[aria-selected="true"] {
  min-height: 46px;
  margin: 0 0 -1px;
  padding: 12px 10px;
  color: var(--muted);
  background: transparent !important;
  border: 0 !important;
  border-bottom: 2px solid transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.tabs .tab-button.active,
.tabs .tab-button[aria-selected="true"] {
  color: var(--cyan);
  border-bottom-color: var(--cyan) !important;
  text-shadow: 0 0 16px rgba(49, 215, 255, .28);
}

.portal-hidden-tab,
.tab-button[hidden] {
  display: none !important;
}

/* Encabezados superiores minimalistas, tomando Administración como referencia. */
.operations-hero,
.telemetry-map-hero,
.history-hero,
.passport-hero,
.alerts-operations-head,
.config-equipment-head,
.monitoring-device-panel {
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.operations-hero,
.telemetry-map-hero,
.history-hero,
.passport-hero,
.alerts-operations-head,
.config-equipment-head {
  margin: 0 0 20px !important;
  padding: 12px 4px 18px !important;
}

.operations-hero::before {
  display: none !important;
}

.monitoring-device-panel {
  padding: 12px 4px 20px !important;
}

.monitoring-device-panel h2 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

/* Dashboard y mapa: acciones centradas respecto del bloque completo de texto. */
.operations-hero,
.telemetry-map-hero {
  align-items: center !important;
}

.operations-hero-actions,
.telemetry-map-hero-actions {
  align-self: center;
}

.history-hero-actions {
  align-self: center;
  min-width: 300px;
}

.history-hero-button-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.passport-hero {
  align-items: center !important;
}

.passport-hero-actions {
  align-self: center;
}

.passport-hero-actions > div {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.alerts-operations-head {
  align-items: center !important;
}

.alerts-worker-box {
  align-self: center;
  min-width: min(280px, 100%);
}

.alerts-config-context {
  margin: 10px 0 0;
  color: var(--cyan);
  font-size: 13px;
}

.config-equipment-head {
  display: block;
}

/* Estado operativo sólido y consistente en mapas Leaflet. */
.operations-map-legend .legend-healthy,
.operations-map-legend .legend-online,
.legend-healthy,
.legend-online {
  color: var(--telemetry-operational-teal) !important;
  background: var(--telemetry-operational-teal) !important;
}

@media (max-width: 1120px) {
  .portal-header {
    grid-template-columns: minmax(220px, .9fr) minmax(320px, 1.15fr) minmax(230px, .9fr);
    gap: 18px;
  }

  .portal-branding h1 {
    font-size: clamp(40px, 5vw, 54px);
  }

  .tabs .tab-button {
    padding-inline: 7px;
    font-size: 13px;
  }
}

@media (max-width: 900px) {
  .portal-header {
    grid-template-columns: minmax(0, 1fr) minmax(220px, .8fr);
    min-height: 0;
    align-items: center;
  }

  .portal-branding {
    padding-top: 0;
  }

  .portal-header-actions.portal-header-center {
    grid-column: 1 / -1;
    grid-row: 2;
    width: min(100%, 540px);
    padding-top: 8px;
  }

  .portal-session-stack {
    grid-column: 2;
    grid-row: 1;
  }

  .operations-hero,
  .telemetry-map-hero,
  .history-hero,
  .passport-hero,
  .alerts-operations-head {
    gap: 18px;
  }
}

@media (max-width: 760px) {
  .portal-header {
    position: sticky;
    top: 0;
    z-index: 1350;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 9px;
    padding: 10px 0;
    background: rgba(3, 11, 21, .96);
    backdrop-filter: blur(16px);
  }

  .portal-branding h1 {
    font-size: 30px;
  }

  .portal-header-actions.portal-header-center {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: end;
    gap: 8px;
    width: 100%;
    margin: 0;
    padding: 0;
  }

  .portal-nav-toggle {
    display: inline-flex;
    min-height: 42px;
  }

  .portal-global-device > span {
    font-size: 11px;
  }

  .portal-global-device select,
  .portal-session-stack #logoutBtn,
  .portal-session-stack #presentationModeBtn {
    min-height: 42px;
  }

  .portal-session-stack {
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    width: auto;
    min-width: 208px;
  }

  .portal-session-stack .user-pill {
    display: none;
  }

  .portal-session-stack #logoutBtn,
  .portal-session-stack #presentationModeBtn {
    font-size: 0;
    padding-inline: 11px;
  }

  .portal-session-stack #logoutBtn::after {
    content: "Salir";
    font-size: .78rem;
  }

  .portal-session-stack #presentationModeBtn::after {
    content: "Presentar";
    font-size: .78rem;
  }

  .operations-hero,
  .telemetry-map-hero,
  .history-hero,
  .passport-hero,
  .alerts-operations-head,
  .config-equipment-head {
    padding-inline: 0 !important;
  }

  .history-hero-actions {
    width: 100%;
    min-width: 0;
  }

  .history-hero-button-row,
  .passport-hero-actions > div {
    justify-content: stretch;
  }

  .history-hero-button-row > button,
  .passport-hero-actions button {
    flex: 1 1 150px;
  }
}

@media (max-width: 520px) {
  .portal-header-actions.portal-header-center {
    grid-template-columns: 1fr;
  }

  .portal-nav-toggle {
    justify-self: start;
  }

  .portal-session-stack {
    min-width: 174px;
  }
}

/* BEGIN TELEMETRY HEADER LEFT 1.9.2-H1 */
/*
 * Cabecera:
 * - marca arriba a la izquierda;
 * - selector bien alineado a la izquierda debajo de la marca;
 * - bloque de sesión a la derecha.
 */
@media (min-width: 901px) {
  .portal-header {
    grid-template-columns: minmax(420px, 1fr) minmax(286px, auto);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 42px;
    row-gap: 8px;
    min-height: 184px;
    padding: 8px 8px 14px;
  }

  .portal-branding {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    align-self: start;
    padding-top: 0;
    margin: 0;
  }

  .portal-branding h1 {
    margin: 0;
    font-size: clamp(48px, 5vw, 66px);
    line-height: .94;
    text-align: left;
  }

  .portal-header-actions.portal-header-center {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    justify-self: start;
    width: 430px;
    max-width: 430px;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    justify-content: flex-start !important;
  }

  .portal-header-actions.portal-header-center .portal-global-device {
    width: 430px;
    max-width: 430px;
    margin: 0 !important;
    padding: 0 !important;
    justify-items: start !important;
  }

  .portal-header-actions.portal-header-center .portal-global-device > span {
    display: block;
    width: 100%;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    text-align: left !important;
    justify-self: start !important;
  }

  .portal-header-actions.portal-header-center .portal-global-device select,
  .portal-header-actions.portal-header-center .portal-global-device .portal-select,
  .portal-header-actions.portal-header-center .portal-global-device .portal-control {
    width: 100%;
    margin-left: 0 !important;
  }

  .portal-session-stack {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    justify-self: end;
    width: min(100%, var(--portal-header-control-width));
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .portal-header {
    grid-template-columns: minmax(360px, 1fr) minmax(230px, 286px);
    grid-template-rows: auto auto;
    align-items: start;
    column-gap: 22px;
    row-gap: 8px;
    min-height: 168px;
    padding: 8px 4px 14px;
  }

  .portal-branding {
    grid-column: 1;
    grid-row: 1;
    align-self: start;
    justify-self: start;
    padding-top: 0;
  }

  .portal-branding h1 {
    font-size: clamp(40px, 6vw, 52px);
    text-align: left;
  }

  .portal-header-actions.portal-header-center {
    grid-column: 1;
    grid-row: 2;
    align-self: start;
    justify-self: start;
    width: 400px;
    max-width: 400px;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    justify-content: flex-start !important;
  }

  .portal-header-actions.portal-header-center .portal-global-device {
    width: 400px;
    max-width: 400px;
    margin: 0 !important;
    padding: 0 !important;
    justify-items: start !important;
  }

  .portal-header-actions.portal-header-center .portal-global-device > span {
    display: block;
    width: 100%;
    margin: 0 0 8px 0 !important;
    padding: 0 !important;
    text-align: left !important;
    justify-self: start !important;
  }

  .portal-session-stack {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: start;
    justify-self: end;
    width: 100%;
  }
}
/* END TELEMETRY HEADER LEFT 1.9.2-H1 */

/* BEGIN TELEMETRY DESKTOP WIDE 1.9.2-W1 */
/*
 * Aprovechamiento horizontal exclusivo para PC.
 * Tablet y móvil conservan sus reglas actuales.
 */
@media (min-width: 1280px) {
  .portal-shell {
    width: min(1600px, calc(100vw - 64px));
    max-width: none;
    margin-inline: auto;
  }

  /*
   * Evita que textos descriptivos se vuelvan demasiado largos,
   * mientras mapas, tablas, tarjetas y filtros usan todo el ancho.
   */
  .operations-hero-copy,
  .telemetry-map-hero-copy,
  .history-hero-copy,
  .passport-hero-copy,
  .alerts-operations-copy,
  .config-equipment-head > div:first-child {
    max-width: 960px;
  }
}

/* Full HD grande y ultrawide: crecimiento controlado. */
@media (min-width: 2000px) {
  .portal-shell {
    width: min(1760px, calc(100vw - 96px));
  }
}

/* El modo presentación también aprovecha el ancho disponible. */
@media (min-width: 1280px) {
  .presentation-mode .portal-shell {
    width: min(1680px, calc(100vw - 48px));
  }
}
/* END TELEMETRY DESKTOP WIDE 1.9.2-W1 */

/* BEGIN TELEMETRY PORTAL UNIFIED SESSION PANEL */
.portal-session-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0 !important;
  width: 100%;
  min-width: 220px;
  box-sizing: border-box;
  overflow: hidden;

  border: 1px solid rgba(180, 200, 210, 0.24);
  border-radius: 16px;
  background:
    linear-gradient(
      180deg,
      rgba(17, 31, 42, 0.78),
      rgba(9, 21, 31, 0.72)
    );
  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(7px);
}

.portal-session-stack > .user-pill,
.portal-session-stack > button,
.portal-session-stack > .portal-lora-entry {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;

  width: 100% !important;
  min-width: 0 !important;
  min-height: 40px;
  box-sizing: border-box;

  margin: 0 !important;
  padding: 8px 14px !important;

  border: 0 !important;
  border-radius: 0 !important;
  outline: 0;
  background: transparent !important;
  box-shadow: none !important;

  font-size: 12px;
  line-height: 1.2;
  text-align: center;
  text-decoration: none !important;
  transform: none !important;
}

.portal-session-stack > * + * {
  border-top: 1px solid rgba(190, 205, 215, 0.18) !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.025);
}

.portal-session-stack > .user-pill {
  min-height: 42px;
  color: rgba(214, 224, 230, 0.82);
  font-weight: 500;
  cursor: default;
}

.portal-session-stack > #logoutBtn,
.portal-session-stack > #presentationModeBtn,
.portal-session-stack > .portal-lora-entry {
  color: rgba(236, 242, 245, 0.96) !important;
  font-weight: 700;
}

.portal-session-stack > #logoutBtn:hover,
.portal-session-stack > #presentationModeBtn:hover,
.portal-session-stack > .portal-lora-entry:hover {
  background: rgba(255, 255, 255, 0.035) !important;
}

.portal-session-stack > #logoutBtn:focus-visible,
.portal-session-stack > #presentationModeBtn:focus-visible,
.portal-session-stack > .portal-lora-entry:focus-visible {
  background: rgba(255, 255, 255, 0.05) !important;
  box-shadow: inset 0 0 0 2px rgba(215, 225, 230, 0.22) !important;
}

@media (max-width: 760px) {
  .portal-session-stack {
    min-width: 0;
    border-radius: 14px;
  }
}
/* END TELEMETRY PORTAL UNIFIED SESSION PANEL */

/* BEGIN TELEMETRY PORTAL REAL SESSION SEPARATORS */

/* Anula separadores anteriores creados por bordes o pseudo-elementos. */
.portal-session-stack > * + * {
  border-top: 0 !important;
}

.portal-session-stack > * + *::before {
  content: none !important;
  display: none !important;
}

/* Separador físico entre cada fila. */
.portal-session-stack > .portal-session-divider {
  display: block;
  width: auto;
  height: 1px;
  min-height: 1px;
  margin: 0 14px;
  padding: 0;

  border: 0 !important;
  background: rgba(205, 218, 226, 0.32) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.025) !important;

  pointer-events: none;
}

/* Mantiene todas las acciones en blanco/gris. */
.portal-session-stack > #logoutBtn,
.portal-session-stack > #presentationModeBtn,
.portal-session-stack > .portal-lora-entry {
  color: rgba(232, 238, 242, 0.94) !important;
}

/* END TELEMETRY PORTAL REAL SESSION SEPARATORS */

