/**
 * Estilos del Portal de Administración Integral
 * Proporciona maquetación de pantalla completa (Full-Screen) para los módulos:
 * 1. Monitor MQTT
 * 2. Heartbeat
 * 3. Data de Dispositivos
 * Diseñado bajo directrices ergonómicas de alta legibilidad, contraste y cero emojis.
 */

/* ==========================================================
   BARRA DE NAVEGACIÓN SUPERIOR DEL PORTAL
   ========================================================== */

.admin-portal-nav {
    display: flex;
    align-items: center;
    margin: 0 16px;
    flex: 1;
    justify-content: center;
}

.admin-portal-tabs-group {
    display: inline-flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-md, 8px);
    padding: 3px;
    gap: 4px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.admin-portal-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm, 6px);
    color: rgba(255, 255, 255, 0.85);
    font-size: var(--text-sm, 13px);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: var(--transition-fast, all 0.15s ease);
    white-space: nowrap;
}

.admin-portal-tab:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.admin-portal-tab.active {
    background: #ffffff;
    color: var(--color-brand-800, #1e3a8a);
    border-color: #ffffff;
    box-shadow: var(--shadow-sm, 0 1px 3px rgba(0, 0, 0, 0.2));
    font-weight: 700;
}

.admin-portal-tab .tab-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-portal-tab .tab-icon svg {
    width: 15px;
    height: 15px;
}

/* ==========================================================
   CONTENEDOR GLOBAL DE VISTAS (PANTALLA COMPLETA)
   ========================================================== */

.portal-main-container {
    width: 100%;
    min-height: calc(100vh - 72px);
    display: flex;
    flex-direction: column;
    position: relative;
    background: #f8fafc;
}

.portal-view {
    width: 100%;
    flex: 1;
}

.portal-view-activo {
    display: flex;
    flex-direction: column;
}

.portal-view-oculto {
    display: none !important;
}

/* ==========================================================
   VISTA COMPLETA: HEARTBEAT (PANTALLA COMPLETA)
   ========================================================== */

.hb-fullscreen-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

.hb-app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    flex-wrap: wrap;
    gap: 16px;
}

.hb-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.hb-heartbeat-pulse {
    position: relative;
    width: 14px;
    height: 14px;
}

.hb-pulse-dot {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #059669;
    border-radius: 50%;
    top: 2px;
    left: 2px;
}

.hb-pulse-ring {
    position: absolute;
    width: 14px;
    height: 14px;
    border: 2px solid #059669;
    border-radius: 50%;
    animation: hbPulseRing 1.8s infinite ease-out;
    opacity: 0;
}

@keyframes hbPulseRing {
    0% { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(2.2); opacity: 0; }
}

.hb-app-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #0f172a;
}

.hb-app-subtitle {
    margin: 2px 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
}

.hb-header-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.hb-stat-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 12px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
}

.hb-stat-label {
    color: #64748b;
    font-size: 11px;
    letter-spacing: 0.04em;
}

.hb-stat-num {
    color: #0f172a;
    font-weight: 700;
    font-size: 14px;
}

.hb-stat-pill-ok .hb-stat-num { color: #059669; }
.hb-stat-pill-err .hb-stat-num { color: #b91c1c; }
.hb-stat-pill-alert .hb-stat-num { color: #2563eb; }
.hb-stat-pill-bat .hb-stat-num { color: #d97706; }
.hb-stat-pill-foco .hb-stat-num { color: #0284c7; }

/* Toolbar Heartbeat */
.hb-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.hb-toolbar-left, .hb-toolbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.hb-filter-tabs {
    display: inline-flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 6px;
    gap: 4px;
}

.hb-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.hb-filter-btn:hover {
    color: #0f172a;
}

.hb-filter-btn.active {
    background: #ffffff;
    color: #0f172a;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.hb-filter-btn .btn-icono svg {
    width: 14px;
    height: 14px;
}

.hb-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.hb-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    display: flex;
    pointer-events: none;
}

.hb-search-box input {
    padding: 7px 30px 7px 32px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    width: 280px;
    outline: none;
    font-family: inherit;
    background: #ffffff;
}

.hb-search-box input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.hb-btn-clear {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.hb-auto-refresh-tag {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

/* Tabla Heartbeat */
.hb-table-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.hb-devices-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.hb-devices-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    letter-spacing: 0.02em;
    font-size: 11px;
}

.hb-devices-table tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #1e293b;
}

.hb-row:hover {
    background: #f8fafc;
}

.hb-row-disconnected {
    background: #fff5f5;
}

.hb-status-badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
}

.hb-status-ok { background: #dcfce7; color: #15803d; }
.hb-status-err { background: #fee2e2; color: #b91c1c; }

.hb-device-name {
    font-size: 13px;
    color: #0f172a;
    display: block;
}

.hb-device-topic {
    font-family: monospace;
    font-size: 11px;
    color: #64748b;
    margin-top: 2px;
}

.hb-bat-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.battery-meter-body {
    width: 38px;
    height: 12px;
    border: 1px solid #94a3b8;
    border-radius: 2px;
    padding: 1px;
    position: relative;
}

.battery-meter-body::after {
    content: '';
    position: absolute;
    right: -3px;
    top: 2px;
    width: 2px;
    height: 6px;
    background: #94a3b8;
    border-radius: 0 1px 1px 0;
}

.battery-meter-fill {
    height: 100%;
    border-radius: 1px;
}

.bat-ok .battery-meter-fill { background: #059669; }
.bat-warning .battery-meter-fill { background: #d97706; }
.bat-danger .battery-meter-fill { background: #b91c1c; }
.bat-unknown .battery-meter-fill { background: #cbd5e1; }

.hb-bat-val {
    font-weight: 600;
    font-size: 12px;
}

/* Celda de Monitoreo de Batería */
.battery-cell-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.battery-control-row {
    font-size: 11px;
}

.battery-chk-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #475569;
    cursor: pointer;
}

.battery-chk-label input {
    margin: 0;
}

/* ==========================================================
   COLUMNA DE DISPONIBILIDAD OPERATIVA Y CONTINUIDAD COMPLETA
   ========================================================== */

.continuity-cell-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 270px;
}

.continuity-field-row {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.continuity-field-label {
    font-size: 11px;
    font-weight: 600;
    color: #64748b;
    width: 38px;
    flex-shrink: 0;
}

.continuity-date-input {
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    flex: 1;
    min-width: 115px;
}

.continuity-date-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.continuity-target-input {
    width: 54px;
    padding: 3px 6px;
    font-size: 12px;
    font-family: inherit;
    font-weight: 600;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    text-align: center;
    background: #ffffff;
    color: #1e293b;
    outline: none;
}

.continuity-target-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.continuity-unit {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
}

.btn-continuity-today {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-continuity-today:hover {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

.btn-continuity-clear {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 15px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.btn-continuity-clear:hover {
    color: #b91c1c;
}

/* Barra de progreso y badges de estado */
.continuity-progress-row {
    margin-top: 2px;
}

.continuity-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    width: 100%;
    box-sizing: border-box;
}

.continuity-status-badge .btn-icono svg {
    width: 13px;
    height: 13px;
}

.status-pruebas {
    background: #f8fafc;
    border: 1px dashed #cbd5e1;
    color: #64748b;
}

.status-cumplida {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-weight: 700;
}

.continuity-avail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.avail-badge {
    font-size: 11px;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.avail-badge strong {
    font-weight: 700;
}

.avail-high {
    background: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.avail-med {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.avail-low {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.packets-counter {
    font-size: 11px;
    color: #64748b;
    font-variant-numeric: tabular-nums;
}

.packets-actual {
    font-weight: 600;
    color: #1e293b;
}

.packets-expected {
    font-weight: 500;
    color: #64748b;
}

.continuity-bar-track {
    width: 100%;
    height: 7px;
    background: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
    margin-top: 3px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.continuity-bar-fill {
    height: 100%;
    border-radius: 999px;
    transition: width 0.35s ease, background 0.35s ease;
}

.fill-avail-high, .fill-cumplida {
    background: linear-gradient(90deg, #10b981, #059669);
}

.fill-avail-med {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.fill-avail-low {
    background: linear-gradient(90deg, #f87171, #dc2626);
}

.continuity-meta-sub {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    color: #64748b;
    margin-top: 3px;
}

.continuity-period-info {
    font-size: 11px;
    color: #64748b;
}

.badge-cumplida-sub {
    color: #065f46;
    font-weight: 700;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-cumplida-sub svg {
    width: 13px;
    height: 13px;
}

.warn-low-avail {
    color: #92400e;
    font-weight: 600;
    font-size: 11px;
}

.warn-offline {
    color: #991b1b;
    font-weight: 600;
    font-size: 11px;
}

.continuity-hint-sub {
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
    margin-top: 2px;
}

.hb-badge-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.hb-badge-meta svg {
    width: 12px;
    height: 12px;
}

.hb-continuity-tag {
    font-size: 11px;
    color: #64748b;
    font-family: monospace;
}

.hb-email-cell-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.hb-email-chips-list {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 100%;
}

.hb-chip-email {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-size: 11px;
    font-family: monospace;
    color: #1e293b;
    margin: 1px 0;
    max-width: 100%;
    word-break: break-all;
    transition: all 0.15s;
}

.hb-chip-email:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.hb-btn-chip-del {
    border: none;
    background: transparent;
    cursor: pointer;
    color: #64748b;
    font-size: 13px;
    line-height: 1;
    padding: 0 2px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
    transition: color 0.15s;
}

.hb-btn-chip-del:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.1);
}

.hb-chip-add-row {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.hb-input-chip-add {
    flex: 1;
    min-width: 120px;
    border: 1px dashed #cbd5e1;
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 11px;
    background: #ffffff;
    color: #1e293b;
    outline: none;
    transition: all 0.15s;
}

.hb-input-chip-add:focus {
    border: 1px solid #0284c7;
    box-shadow: 0 0 0 1px #0284c7;
}

.hb-btn-chip-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: #0284c7;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.hb-btn-chip-add:hover {
    background: #0369a1;
}

.hb-modal-chip-add-row {
    display: flex;
    gap: 6px;
    align-items: center;
    width: 100%;
    margin-top: 4px;
}

.hb-modal-chip-add-row input {
    flex: 1;
}

.hb-email-feedback-hint {
    font-size: 10px;
    line-height: 1.2;
}

.hb-email-badge-count {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    background: #f0f9ff;
    color: #0284c7;
    border: 1px solid #bae6fd;
    border-radius: 3px;
    padding: 1px 4px;
    font-size: 10px;
    font-weight: 600;
}

.hb-email-hint-single {
    color: #0284c7;
    font-size: 10px;
    font-weight: 500;
}

.hb-email-hint-none {
    color: #94a3b8;
    font-size: 10px;
    font-style: italic;
}

.hb-no-email {
    font-size: 11px;
    color: #94a3b8;
    font-style: italic;
}

.check-on { color: #16a34a; font-weight: bold; }
.check-off { color: #cbd5e1; }

.btn-table-action {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    color: #475569;
    transition: all 0.2s;
}

.btn-table-action:hover {
    background: #0284c7;
    color: #ffffff;
    border-color: #0284c7;
}

.btn-del-device:hover {
    background: #dc2626 !important;
    border-color: #dc2626 !important;
}

/* Bottom Grid Heartbeat */
.hb-bottom-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 16px;
    margin-top: 8px;
}

@media (max-width: 1024px) {
    .hb-bottom-grid {
        grid-template-columns: 1fr;
    }
}

.hb-info-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 16px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.hb-info-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 8px;
}

.hb-info-card-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: #0f172a;
}

.hb-badge-tag {
    font-size: 11px;
    background: #f1f5f9;
    color: #475569;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.hb-strategy-desc {
    font-size: 12px;
    color: #475569;
    margin-bottom: 8px;
    line-height: 1.5;
}

.hb-strategy-desc code {
    background: #f1f5f9;
    padding: 1px 4px;
    border-radius: 3px;
    color: #0f172a;
}

.hb-logs-container {
    max-height: 220px;
    overflow-y: auto;
    font-size: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.hb-log-entry {
    padding: 6px 10px;
    background: #f8fafc;
    border-left: 3px solid #0284c7;
    border-radius: 0 4px 4px 0;
    display: flex;
    gap: 8px;
    font-size: 11px;
}

.hb-log-date {
    color: #64748b;
    font-family: monospace;
}

.hb-log-device {
    color: #0f172a;
}

.hb-log-msg {
    color: #334155;
    flex: 1;
}

.hb-btn-link {
    background: none;
    border: none;
    color: #0284c7;
    font-size: 12px;
    cursor: pointer;
    font-weight: 600;
    padding: 0;
}

.hb-btn-link:hover {
    text-decoration: underline;
}

/* Toast Heartbeat */
.hb-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    z-index: 10000;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    transition: opacity 0.3s;
}

.hb-toast.hidden { opacity: 0; pointer-events: none; }
.hb-toast.show { opacity: 1; }
.hb-toast-ok { background: #16a34a; color: #ffffff; }
.hb-toast-error { background: #dc2626; color: #ffffff; }
.hb-toast-info { background: #0f172a; color: #ffffff; }

/* Modal Heartbeat */
.hb-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 20px;
    box-sizing: border-box;
}

.hb-modal-backdrop.hidden {
    display: none;
}

.hb-modal-card {
    background: #ffffff;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.2);
}

.hb-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 10px;
}

.hb-modal-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
}

.hb-btn-close {
    background: transparent;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #64748b;
}

.hb-form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.hb-form-group label {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.hb-form-group input[type="text"],
.hb-form-group input[type="number"],
.hb-form-group input[type="date"] {
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    outline: none;
    font-family: inherit;
}

.hb-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.hb-form-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 12px;
    color: #334155;
}

.hb-form-help {
    font-size: 11px;
    color: #64748b;
}

.hb-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
}

/* ==========================================================
   VISTA COMPLETA: MONITOR MQTT (PANTALLA COMPLETA)
   ========================================================== */

.mqtt-fullscreen-wrapper {
    width: 100%;
    max-width: 100%;
    padding: 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-sizing: border-box;
}

.mqtt-app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    flex-wrap: wrap;
    gap: 16px;
}

.mqtt-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.mqtt-header-icon-box {
    width: 38px;
    height: 38px;
    background: #e0f2fe;
    color: #0284c7;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mqtt-app-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #0f172a;
}

.mqtt-app-subtitle {
    margin: 2px 0 0 0;
    font-size: 0.8rem;
    color: #64748b;
}

.mqtt-header-right {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.mqtt-stat-pill {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    padding: 6px 14px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
}

.mqtt-stat-label {
    color: #64748b;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
}

.mqtt-stat-num {
    font-weight: 700;
    font-size: 14px;
    color: #0f172a;
}

.mqtt-stat-fecha {
    font-size: 12px;
    color: #334155;
}

.status-online { color: #059669; font-weight: 700; }
.status-offline { color: #b91c1c; font-weight: 700; }

/* Toolbar MQTT */
.mqtt-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 12px;
}

.mqtt-toolbar-left, .mqtt-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.mqtt-search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.mqtt-search-icon {
    position: absolute;
    left: 10px;
    color: #94a3b8;
    display: flex;
    pointer-events: none;
}

.mqtt-search-box input {
    padding: 7px 12px 7px 32px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    width: 240px;
    outline: none;
    font-family: inherit;
    background: #ffffff;
}

.mqtt-search-box input:focus {
    border-color: #0284c7;
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.mqtt-select-limit {
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12px;
    background: #ffffff;
    outline: none;
    font-family: inherit;
}

.mqtt-toggle-autorefresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    cursor: pointer;
    user-select: none;
}

.mqtt-pulse-dot {
    width: 8px;
    height: 8px;
    background: #059669;
    border-radius: 50%;
    animation: mqttPulseDot 1.6s infinite ease-out;
}

@keyframes mqttPulseDot {
    0% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.7); }
    70% { box-shadow: 0 0 0 6px rgba(5, 150, 105, 0); }
    100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0); }
}

/* Tabla MQTT */
.mqtt-table-card {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow-x: auto;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.mqtt-data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    text-align: left;
}

.mqtt-data-table thead th {
    background: #f8fafc;
    color: #475569;
    font-weight: 700;
    padding: 12px 14px;
    border-bottom: 1px solid #e2e8f0;
    font-size: 11px;
    letter-spacing: 0.02em;
    position: sticky;
    top: 0;
    z-index: 5;
}

.mqtt-data-table tbody td {
    padding: 10px 14px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    color: #1e293b;
}

.mqtt-row:hover {
    background: #f8fafc;
}

.mqtt-topic-tag {
    font-family: monospace;
    font-size: 11px;
    background: #e2e8f0;
    color: #1e293b;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mqtt-qos-tag {
    font-size: 10px;
    color: #64748b;
    background: #f1f5f9;
    padding: 2px 5px;
    border-radius: 3px;
}

.col-payload {
    font-family: monospace;
    font-size: 11px;
    color: #0284c7;
    max-width: 380px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.mqtt-empty-state, .hb-empty-state {
    text-align: center;
    padding: 40px !important;
    color: #94a3b8;
    font-style: italic;
}

/* Slide Drawer Inspector MQTT */
.mqtt-drawer-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: flex-end;
    z-index: 9999;
}

.mqtt-drawer-backdrop.hidden {
    display: none;
}

.mqtt-drawer-card {
    background: #0f172a;
    color: #f8fafc;
    width: 100%;
    max-width: 580px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 24px rgba(0, 0, 0, 0.3);
    animation: drawerSlide 0.25s ease-out;
}

@keyframes drawerSlide {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.mqtt-drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #1e293b;
}

.mqtt-drawer-title-box {
    display: flex;
    align-items: center;
    gap: 10px;
}

.drawer-icon {
    color: #38bdf8;
    display: flex;
}

.mqtt-drawer-title-box h3 {
    margin: 0;
    font-size: 15px;
    color: #ffffff;
}

.mqtt-btn-close {
    background: transparent;
    border: none;
    font-size: 22px;
    color: #94a3b8;
    cursor: pointer;
}

.mqtt-drawer-meta {
    padding: 14px 20px;
    background: #1e293b;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    font-size: 12px;
    border-bottom: 1px solid #334155;
}

.meta-label {
    color: #94a3b8;
}

.meta-val {
    color: #f8fafc;
    font-weight: 600;
}

.meta-code {
    color: #38bdf8;
    font-family: monospace;
}

.mqtt-drawer-code-wrap {
    padding: 16px 20px;
    flex: 1;
    overflow-y: auto;
}

.mqtt-code-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    font-size: 11px;
    color: #94a3b8;
    text-transform: uppercase;
}

.mqtt-code-pre {
    margin: 0;
    padding: 14px;
    background: #090d16;
    border: 1px solid #1e293b;
    border-radius: 8px;
    font-family: 'Fira Code', monospace;
    font-size: 12px;
    color: #7dd3fc;
    overflow-x: auto;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 480px;
}

/* ==========================================================
   DIRECTRICES ERGONÓMICAS ISO 9241-151
   ========================================================== */

/* Foco de alto contraste accesible (§10.1) */
.admin-portal-tab:focus-visible {
    outline: 2px solid #ffffff !important;
    outline-offset: 2px !important;
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 2px solid #0284c7 !important;
    outline-offset: 2px !important;
}

/* Tipografía tabular para lecturas numéricas estables (§7.3) */
.hb-stat-num,
.mqtt-stat-num,
.col-fecha,
.col-lastseen,
.hb-bat-val,
.mqtt-qos-tag,
.hb-continuity-tag,
.hb-chip-email {
    font-variant-numeric: tabular-nums;
}

/* Estados Vacíos Informativos con Acción de Restablecimiento (§8.4) */
.mqtt-empty-state-cell,
.hb-empty-state-cell {
    padding: 48px 24px !important;
    text-align: center;
    background: #f8fafc;
}

.mqtt-empty-state-box {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 440px;
    margin: 0 auto;
}

.mqtt-empty-state-box .empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0284c7;
}

.mqtt-empty-state-box .empty-icon svg {
    width: 24px;
    height: 24px;
}

.mqtt-empty-state-box .empty-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: #0f172a;
}

.mqtt-empty-state-box .empty-desc {
    margin: 0;
    font-size: 13px;
    color: #64748b;
    line-height: 1.5;
}

/* Retroalimentación de Copiado Exitoso (§9.1) */
.btn-copiado-exito {
    border-color: #16a34a !important;
    background: #f0fdf4 !important;
    color: #15803d !important;
}

/* Botón de borrado rápido en campos de búsqueda (§8.2) */
.hb-btn-clear {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    transition: color 0.15s ease;
}

.hb-btn-clear:hover {
    color: #ef4444;
}

/* ==========================================================
   BARRA DE COMANDOS UNIFICADA Y ESTANDARIZACIÓN DE MENÚS
   ========================================================== */

/* Barra superior de Data de Dispositivos */
.portal-command-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 18px;
    background: var(--surface-card, #ffffff);
    border: 1px solid var(--border-subtle, #e2e8f0);
    border-radius: var(--radius-md, 8px);
    margin: 0 16px 8px 16px;
    box-shadow: var(--shadow-xs, 0 1px 3px rgba(0, 0, 0, 0.03));
    flex-wrap: wrap;
    gap: 8px;
    min-height: 42px;
    box-sizing: border-box;
}

.command-bar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.command-bar-title {
    font-size: var(--text-base, 14px);
    font-weight: var(--fw-bold, 700);
    color: var(--color-neutral-900, #0f172a);
    letter-spacing: 0.01em;
}

.command-bar-desc {
    font-size: var(--text-xs, 12px);
    color: var(--color-neutral-600, #475569);
}

.command-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.command-group-admin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Normalización de botones en todas las barras de herramientas (Data, Heartbeat, MQTT) */
.portal-command-bar .btn-base,
.hb-toolbar .btn-base,
.mqtt-toolbar .btn-base,
.hb-modal-card .btn-base {
    margin-top: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    line-height: 1.2;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
}

/* Triada ergonómica de botones institucionales (sin colores chillones ni gradientes estridentes) */

/* 1. Actualizar / Recargar / Acciones secundarias */
.btn-base.btn-secundario {
    background: #ffffff !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

.btn-base.btn-secundario:hover {
    background: #f8fafc !important;
    color: #0f172a !important;
    border-color: #94a3b8 !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08) !important;
}

.btn-base.btn-secundario:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04) !important;
}

/* 2. Descargar / Exportar / Acciones principales (Navy institucional SGC) */
.btn-base.btn-primario {
    background: #1e3a8a !important;
    color: #ffffff !important;
    border: 1px solid #172554 !important;
    box-shadow: 0 1px 3px rgba(30, 58, 138, 0.25) !important;
}

.btn-base.btn-primario:hover {
    background: #1e40af !important;
    border-color: #1e3a8a !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(30, 58, 138, 0.35) !important;
}

.btn-base.btn-primario:active {
    background: #172554 !important;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(30, 58, 138, 0.2) !important;
}

/* 3. Registrar / Agregar Dispositivo (Éxito Institucional sobrio) */
.btn-base.btn-exito {
    background: #065f46 !important;
    color: #ffffff !important;
    border: 1px solid #047857 !important;
    box-shadow: 0 1px 2px rgba(6, 95, 70, 0.25) !important;
}

.btn-base.btn-exito:hover {
    background: #047857 !important;
    border-color: #064e3b !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 6px rgba(6, 95, 70, 0.35) !important;
}

.btn-base.btn-exito:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(6, 95, 70, 0.2) !important;
}

/* 4. Peligro / Cancelar / Eliminar (Garnet sobrio) */
.btn-base.btn-peligro {
    background: #991b1b !important;
    color: #ffffff !important;
    border: 1px solid #7f1d1d !important;
    box-shadow: 0 1px 2px rgba(153, 27, 27, 0.2) !important;
}

.btn-base.btn-peligro:hover {
    background: #7f1d1d !important;
    border-color: #581c1c !important;
    transform: translateY(-1px);
}

/* 5. Editar - Neutro sin naranja estridente */
.btn-base.btn-editar {
    background: #ffffff !important;
    color: #334155 !important;
    border: 1px solid #cbd5e1 !important;
}

.btn-base.btn-editar:hover {
    background: #f8fafc !important;
    color: #1e3a8a !important;
    border-color: #93c5fd !important;
}

.btn-con-icono .icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-con-icono .icono svg,
.btn-con-icono svg.svg-icon {
    width: 14px;
    height: 14px;
}

@media (max-width: 768px) {
    .portal-command-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .command-bar-right {
        width: 100%;
        justify-content: flex-start;
    }
}

