/* NexaCore Industrial V50.9.8
   Capa final de geometría, densidad, accesibilidad y respuesta entre viewports.
   Se carga después del CSS de cada módulo para resolver la cascada histórica sin
   alterar identificadores, eventos ni contratos con JavaScript. */

:root {
  --nexa-content-max: 1840px;
  --nexa-page-gutter: clamp(14px, 1.8vw, 30px);
  --nexa-focus: #1976d2;
  --nexa-surface-line: #d6e2ec;
  --nexa-radius-panel: 20px;
}

html {
  max-width: 100%;
  overflow-x: hidden;
  scrollbar-gutter: stable;
}

body {
  max-width: 100%;
  overflow-x: hidden;
}

@supports (overflow: clip) {
  html,
  body {
    overflow-x: clip;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

img,
video,
canvas,
svg,
iframe {
  max-width: 100%;
}

:where(.app-shell, .app-content, .app-page, .app-page > *, .container-fluid,
  .row, .row > *, [class*="-grid"], [class*="-layout"], [class*="-panel"],
  [class*="-card"], [class*="-copy"], [class*="-head"], [class*="-body"]) {
  min-width: 0;
}

:where(h1, h2, h3, h4, p, li, dd, dt, strong, small, span, a, button, label) {
  overflow-wrap: break-word;
}

:where(input, select, textarea, button) {
  max-width: 100%;
}

textarea {
  resize: vertical;
}

:where(a, button, input, select, textarea, summary, [role="button"], [tabindex="0"]):focus-visible {
  outline: 3px solid var(--nexa-focus);
  outline: 3px solid color-mix(in srgb, var(--nexa-focus) 72%, white);
  outline-offset: 3px;
}

:where(section, article, [id]) {
  scroll-margin-top: 92px;
}

/* Armazón principal centrado y sin anchos accidentales. */
body:not(.monitor-page-v510) .app-content {
  width: 100%;
  max-width: 100%;
}

body:not(.monitor-page-v510) .app-page {
  width: min(100%, var(--nexa-content-max));
  max-width: var(--nexa-content-max);
  margin-inline: auto;
  padding: 20px var(--nexa-page-gutter) 38px;
}

.app-header.v22-header {
  min-width: 0;
  min-height: 72px;
  padding: 13px var(--nexa-page-gutter);
  gap: 14px;
}

.app-header.v22-header > :first-child {
  min-width: 0;
  flex: 1 1 auto;
}

.app-header.v22-header > :last-child {
  min-width: 0;
  flex: 0 1 auto;
}

.app-header .header-kicker,
.app-header .header-title {
  max-width: min(54vw, 760px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-header .header-title {
  line-height: 1.18;
}

.page-title-bar,
.premium-page-heading {
  width: 100%;
  min-width: 0;
  margin-bottom: 16px;
  align-items: center !important;
}

.page-title-bar > :first-child,
.premium-page-heading > :first-child {
  min-width: min(100%, 260px);
  flex: 1 1 420px;
}

.page-title-bar > :last-child,
.premium-page-heading > :last-child {
  flex: 0 1 auto;
  justify-content: flex-end;
}

.section-title {
  margin-bottom: 4px;
  font-size: clamp(1.55rem, 2.4vw, 2.25rem);
  line-height: 1.08;
}

.section-subtitle {
  max-width: 820px;
  line-height: 1.5;
}

.card,
.panel-card,
.module-control-board,
.premium-history-card {
  max-width: 100%;
}

.table-responsive {
  width: 100%;
  max-width: 100%;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}

.table-responsive > .table {
  margin-bottom: 0;
}

.form-control,
.form-select {
  max-width: 100%;
  border-radius: 11px;
}

.form-label {
  line-height: 1.28;
}

/* Bloques de estado: compactos, uniformes y sin tarjetas alargadas. */
body .module-control-board {
  padding: 10px !important;
  border-radius: var(--nexa-radius-panel) !important;
}

body .module-stat-grid,
body .maintenance-board-shell .module-stat-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)) !important;
  gap: 9px !important;
}

body .module-stat-card,
body .maintenance-board-shell .module-stat-card {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 84px !important;
  padding: 11px 13px !important;
  gap: 10px !important;
  border-radius: 15px !important;
}

body .module-stat-icon,
body .maintenance-board-shell .module-stat-icon {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
}

body .module-stat-card strong,
body .maintenance-board-shell .module-stat-card strong {
  font-size: 1.38rem !important;
}

/* Modales: centrados, con scroll interior y cierre siempre alcanzable. */
.modal {
  max-width: 100vw;
  overflow-x: hidden;
}

.modal-dialog {
  max-width: min(var(--bs-modal-width, 900px), calc(100vw - 24px));
  margin-inline: auto;
}

.modal-content {
  min-width: 0;
  max-height: calc(100dvh - 24px);
  overflow: hidden;
}

.modal-content > form,
.modal-content > form > .modal-body {
  min-height: 0;
}

.modal-body {
  max-width: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal-header,
.modal-footer,
.ops-modal-header,
.ops-modal-footer,
.inventory-detail-head-v503,
.inventory-detail-actions-final {
  min-width: 0;
  flex: 0 0 auto;
}

.modal .btn-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid rgba(124, 180, 238, .34);
  border-radius: 14px;
  opacity: 1;
  background-color: #0b2038;
  box-shadow: 0 10px 24px rgba(2, 10, 24, .2);
}

/* Inicio: centro de control industrial firme, sin un bloque desproporcionado. */
.home-dashboard-v505 {
  width: 100%;
  max-width: 1740px;
}

.hd507-command-hero {
  min-height: 0;
  gap: clamp(20px, 2.6vw, 42px);
  padding: clamp(24px, 2.6vw, 40px);
}

.hd507-command-hero .hd505-hero h1,
.hd507-command-hero h1 {
  font-size: clamp(2.2rem, 3.1vw, 3.7rem);
  line-height: 1;
}

.hd507-command-stage {
  height: clamp(350px, 26vw, 410px);
}

.hd505-area {
  gap: 14px;
  padding: clamp(15px, 1.7vw, 23px);
}

.hd505-area-head h2 {
  font-size: clamp(1.45rem, 2.1vw, 2rem);
}

.hd505-kpi {
  min-height: 96px;
  padding: 12px;
}

.hd505-kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 13px;
}

.hd505-module {
  min-height: 88px;
  padding: 11px;
}

.hd505-recent-row {
  min-height: 62px;
}

/* Inventario y activos: más información por pantalla, alineación estable. */
body.inventory-page-v506 .ops-hero,
body.assets-page-v506 .ops-hero {
  min-height: clamp(300px, 23vw, 350px) !important;
  grid-template-columns: minmax(0, 1fr) minmax(235px, 305px) !important;
  gap: clamp(18px, 2.4vw, 34px) !important;
  padding: clamp(25px, 2.6vw, 38px) !important;
}

body.inventory-page-v506 .ops-hero h1,
body.assets-page-v506 .ops-hero h1 {
  font-size: clamp(2rem, 3.25vw, 3.25rem) !important;
  line-height: 1 !important;
}

body.inventory-page-v506 .ops-hero-actions,
body.assets-page-v506 .ops-hero-actions {
  margin-top: 18px !important;
}

body.inventory-page-v506 .ops-command-grid,
body.assets-page-v506 .ops-command-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 235px), 1fr)) !important;
  gap: 10px !important;
  margin-bottom: 14px !important;
}

body.inventory-page-v506 .ops-command-card,
body.assets-page-v506 .ops-command-card {
  min-height: 104px !important;
  padding: 13px 14px !important;
}

body.inventory-page-v506 .ops-kpi-grid,
body.assets-page-v506 .ops-kpi-grid {
  gap: 10px !important;
  margin-bottom: 14px !important;
}

body.inventory-page-v506 .ops-kpi,
body.assets-page-v506 .ops-kpi {
  min-height: 98px !important;
  padding: 14px 16px !important;
  border-radius: 17px !important;
}

body.inventory-page-v506 .ops-kpi > strong,
body.assets-page-v506 .ops-kpi > strong {
  margin-top: 6px !important;
  font-size: clamp(1.5rem, 2vw, 1.82rem) !important;
}

body.inventory-page-v506 .ops-panel,
body.assets-page-v506 .ops-panel {
  border-radius: 20px !important;
}

body.inventory-page-v506 .ops-panel-head,
body.assets-page-v506 .ops-panel-head {
  padding: 16px 18px !important;
}

body.inventory-page-v506 .ops-panel-head.compact,
body.assets-page-v506 .ops-panel-head.compact {
  min-height: 68px;
  padding: 13px 16px !important;
}

body.inventory-page-v506 .inventory-filter-console-v506,
body.assets-page-v506 .inventory-filter-console-v506 {
  width: 100% !important;
  max-width: 1460px !important;
  margin-inline: auto !important;
}

body.inventory-page-v506 .ops-side-stack,
body.assets-page-v506 .ops-side-stack {
  min-width: 0;
  align-items: stretch;
}

body.inventory-page-v506 .ops-side-stack > .ops-panel,
body.assets-page-v506 .ops-side-stack > .ops-panel {
  min-width: 0;
  height: 100%;
}

body.inventory-page-v506 .ops-alert-list,
body.inventory-page-v506 .ops-timeline,
body.assets-page-v506 .ops-alert-list,
body.assets-page-v506 .ops-timeline {
  width: 100%;
  min-width: 0;
  padding-inline: 14px;
}

body.inventory-page-v506 .ops-alert-item,
body.inventory-page-v506 .ops-timeline-item,
body.assets-page-v506 .ops-alert-item,
body.assets-page-v506 .ops-timeline-item {
  min-width: 0;
  text-align: left;
}

body.inventory-page-v506 .ops-material-cell {
  grid-template-columns: 40px minmax(0, 1fr) !important;
}

body.inventory-page-v506 .ops-material-cell img,
body.inventory-page-v506 .ops-material-cell > span {
  width: 40px;
  height: 40px;
}

body.assets-page-v506 .ops-asset-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr)) !important;
  gap: 12px !important;
  padding: 14px !important;
}

body.assets-page-v506 .ops-asset-card {
  border-radius: 18px !important;
}

body.assets-page-v506 .ops-asset-visual {
  min-height: 155px !important;
  height: clamp(155px, 13vw, 205px) !important;
}

body.assets-page-v506 .ops-asset-body {
  padding: 14px !important;
}

body.assets-page-v506 .ops-asset-metrics {
  margin-top: 10px !important;
}

body.assets-page-v506 .ops-asset-actions {
  padding-top: 10px !important;
}

.inventory-detail-data-v503 > div {
  min-height: 70px;
  padding: 10px 12px;
}

/* Monitor: QR geométrico y responsable unido visualmente a la lectura. */
body.monitor-page-v510 .wm510-qr-rail {
  align-items: center;
  justify-items: center;
}

body.monitor-page-v510 .wm510-qr-frame,
body.monitor-page-v510 .wm510-assignee,
body.monitor-page-v510 .wm510-qr-code {
  margin-inline: auto;
}

body.monitor-page-v510 .wm510-qr-code {
  width: 100%;
  text-align: center;
}

/* Centro de impresión: los tres sectores permanecen centrados y contenidos. */
.printing-center-nav,
.zebra-hero,
.zebra-studio,
.zebra-action-dock,
.pdf-branding-shell {
  width: 100%;
  max-width: 1720px;
  margin-right: auto;
  margin-left: auto;
}

.zebra-hero {
  min-height: 280px;
  margin-bottom: 16px;
  padding: clamp(28px, 3vw, 40px);
}

.zebra-studio {
  gap: 14px;
}

.zebra-panel-head {
  min-height: 68px;
  padding: 14px 16px;
}

.zebra-action-dock {
  min-height: 72px;
}

.pdf-branding-shell {
  padding-bottom: 36px;
}

.pdf-branding-hero {
  padding: 22px 26px;
}

.pdf-catalog {
  padding: 17px;
}

.pdf-catalog-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 225px), 1fr));
}

.pdf-profile-card {
  min-height: 64px;
}

.pdf-branding-layout {
  grid-template-columns: minmax(285px, 330px) minmax(0, 1fr);
  gap: 16px;
}

.pdf-branding-workbench,
.pdf-paper-stage,
.pdf-real-pages,
.pdf-real-page {
  min-width: 0;
  max-width: 100%;
}

.pdf-paper-stage {
  justify-content: center;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
}

.pdf-real-page.is-portrait {
  width: min(100%, 590px);
}

.pdf-real-page.is-landscape {
  width: min(100%, 860px);
}

.pdf-branding-real-preview iframe {
  height: clamp(440px, 58vh, 650px);
}

/* Tablet. */
@media (max-width: 1180px) {
  body:not(.monitor-page-v510) .app-page {
    padding-top: 17px;
  }

  .app-header.v22-header {
    min-height: 66px;
  }

  .hd507-command-stage {
    height: clamp(350px, 46vw, 420px);
  }

  .pdf-branding-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .pdf-branding-sidebar {
    position: static;
  }
}

@media (max-width: 900px) {
  .app-header.v22-header {
    flex-wrap: wrap;
  }

  .app-header.v22-header > :last-child {
    width: 100%;
    justify-content: flex-start !important;
  }

  .app-header .header-kicker,
  .app-header .header-title {
    max-width: calc(100vw - 105px);
  }

  body.inventory-page-v506 .ops-hero,
  body.assets-page-v506 .ops-hero {
    min-height: 0 !important;
    grid-template-columns: minmax(0, 1fr) !important;
    background-position: 62% center !important;
  }

  body.inventory-page-v506 .ops-hero-status,
  body.assets-page-v506 .ops-hero-status {
    width: min(100%, 420px);
  }

  .zebra-hero {
    min-height: 330px;
  }
}

/* Teléfono y colector. */
@media (max-width: 767px) {
  :root {
    --nexa-page-gutter: 11px;
  }

  html {
    scrollbar-gutter: auto;
  }

  body:not(.monitor-page-v510) .app-page,
  body.mobile-interface .app-page {
    width: 100%;
    padding: 11px var(--nexa-page-gutter) 26px !important;
  }

  .app-header.v22-header {
    padding: 10px 11px;
  }

  .app-header.v22-header > :last-child {
    gap: 6px !important;
    overflow-x: auto;
    flex-wrap: nowrap !important;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .app-header.v22-header > :last-child::-webkit-scrollbar {
    display: none;
  }

  .app-header.v22-header .nav-menu-btn,
  .app-header.v22-header .pdf-brand-context-launch {
    flex: 0 0 auto;
    min-height: 40px;
  }

  .page-title-bar > :last-child,
  .premium-page-heading > :last-child {
    width: 100%;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
  }

  .page-title-bar > :last-child > *,
  .premium-page-heading > :last-child > * {
    width: 100%;
  }

  body .module-control-board {
    padding: 8px !important;
  }

  body .module-stat-grid,
  body .maintenance-board-shell .module-stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 7px !important;
  }

  body .module-stat-card,
  body .maintenance-board-shell .module-stat-card {
    min-height: 78px !important;
    padding: 9px !important;
  }

  .modal-dialog {
    width: calc(100vw - 10px) !important;
    max-width: calc(100vw - 10px) !important;
    margin: 5px auto !important;
  }

  .modal-content {
    max-height: calc(100dvh - 10px);
    border-radius: 18px !important;
  }

  .hd507-command-hero {
    padding: 19px 14px 14px;
  }

  .hd507-command-stage {
    height: clamp(410px, 118vw, 470px);
  }

  .hd505-area-nav,
  .hd505-kpi-grid,
  .hd505-module-grid,
  .hd505-message-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.inventory-page-v506 .ops-hero,
  body.assets-page-v506 .ops-hero {
    padding: 21px 18px !important;
    border-radius: 21px !important;
  }

  body.inventory-page-v506 .ops-command-grid,
  body.assets-page-v506 .ops-command-grid,
  body.inventory-page-v506 .ops-kpi-grid,
  body.assets-page-v506 .ops-kpi-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body.inventory-page-v506 .ops-kpi,
  body.assets-page-v506 .ops-kpi {
    min-height: 88px !important;
  }

  body.inventory-page-v506 .inventory-filter-console-v506,
  body.assets-page-v506 .inventory-filter-console-v506 {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  body.assets-page-v506 .ops-asset-grid {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 10px !important;
  }

  body.assets-page-v506 .ops-asset-visual {
    min-height: 165px !important;
    height: clamp(165px, 52vw, 230px) !important;
  }

  body.monitor-page-v510 .wm510-qr-rail {
    grid-template-columns: minmax(0, 1fr) !important;
    justify-items: center !important;
    gap: 10px !important;
    text-align: center !important;
  }

  body.monitor-page-v510 .wm510-qr-frame {
    grid-row: auto !important;
    width: min(64vw, 190px) !important;
  }

  body.monitor-page-v510 .wm510-qr-heading {
    justify-content: center !important;
  }

  body.monitor-page-v510 .wm510-assignee {
    width: min(100%, 290px) !important;
    text-align: left !important;
  }

  body.monitor-page-v510 .wm510-qr-rail > p {
    max-width: 290px !important;
    display: block !important;
  }

  .printing-center-nav {
    margin-bottom: 12px;
  }

  .zebra-hero {
    min-height: 330px;
    padding: 24px 18px;
  }

  .zebra-action-dock {
    padding: 11px;
  }

  .pdf-branding-hero,
  .pdf-catalog,
  .pdf-branding-sidebar,
  .pdf-branding-workbench {
    border-radius: 18px;
  }

  .pdf-branding-hero,
  .pdf-catalog {
    padding: 15px;
  }

  .pdf-branding-state {
    flex-basis: auto;
    width: 100%;
  }

  .pdf-catalog-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .pdf-paper-stage {
    padding: 10px;
  }

  .pdf-branding-real-preview iframe {
    height: 440px;
  }
}

@media (max-width: 480px) {
  body .module-stat-grid,
  body .maintenance-board-shell .module-stat-grid,
  body.inventory-page-v506 .inventory-filter-console-v506,
  body.assets-page-v506 .inventory-filter-console-v506 {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .hd507-command-stage {
    height: 430px;
  }

  .hd507-showcase-controls button {
    min-width: 40px;
  }

  .zebra-coordinate-readout {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .zebra-coordinate-readout span {
    min-width: 0;
  }
}

/* Pantallas bajas del taller: preserva la descripción y el QR completos. */
@media (min-width: 721px) and (max-height: 720px) {
  body.monitor-page-v510 .workshop-monitor-v510 {
    padding: 8px;
    gap: 7px;
  }

  body.monitor-page-v510 .wm510-header {
    padding: 10px 14px;
    border-radius: 18px;
  }

  body.monitor-page-v510 .wm510-brand p,
  body.monitor-page-v510 .wm510-clockbox span,
  body.monitor-page-v510 .wm510-guidance,
  body.monitor-page-v510 .wm510-qr-rail > p {
    display: none;
  }

  body.monitor-page-v510 .wm510-summary > div {
    min-height: 52px;
    padding: 7px 9px;
  }

  body.monitor-page-v510 .wm510-task-main,
  body.monitor-page-v510 .wm510-qr-rail {
    padding: 11px;
    gap: 7px;
  }

  body.monitor-page-v510 .wm510-description {
    min-height: 92px;
    padding: 13px 17px;
  }

  body.monitor-page-v510 .wm510-qr-frame {
    width: min(100%, 165px);
  }

  body.monitor-page-v510 .wm510-assignee {
    min-height: 54px;
  }
}

@media (hover: hover) and (pointer: fine) {
  :where(.card, .panel-card, .ops-panel, .hd505-chart-card, .hd505-recent-card,
    .pdf-profile-card, .printing-center-tabs > a) {
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
  }
}

@media (pointer: coarse) {
  :where(button, .btn, [role="button"], a.sidebar-link, a.sidebar-sublink,
    input:not([type="hidden"]):not([type="checkbox"]):not([type="radio"]), select) {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hd507-orbit-ring,
  .hd507-orbit-core,
  .hd507-core-energy,
  .hd507-orbit-badge,
  .hd507-orbit-badge b,
  .hd507-stage-scan,
  .zebra-btn.is-busy::after,
  .zebra-toast.tone-busy > span {
    animation: none !important;
  }

  :where(.hd505-kpi, .hd505-module, .ops-command-card, .ops-asset-card,
    .printing-center-tabs > a, .pdf-profile-card, .zebra-label-item):hover {
    transform: none !important;
  }
}

@media print {
  html,
  body {
    overflow: visible !important;
  }

  .app-page {
    width: 100% !important;
    max-width: none !important;
  }
}
