/* ==========================================================================
   Dashboard Termografia — OMRON K6PM-TH
   Tema: Dark (padrão OMRON industrial)
   © SetSystem Automação e Robótica — 2026
   ========================================================================== */

/* ---------- Design Tokens ---------- */
:root {
    /* Cores base */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2332;
    --bg-card: #151d2e;
    --bg-hover: #1e2a3e;

    /* Bordas e divisores */
    --border-color: #1e293b;
    --border-active: #334155;

    /* Textos */
    --text-primary: #e5e7eb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-accent: #60a5fa;

    /* Acentos OMRON */
    --accent-primary: #0066cc;
    --accent-secondary: #00bcd4;
    --accent-gradient: linear-gradient(135deg, #0066cc, #00bcd4);

    /* Torre luminosa */
    --color-normal: #22c55e;
    --color-warning: #f59e0b;
    --color-critical: #ef4444;

    /* Escala de calor (termografia) */
    --heat-cold: #1e3a5f;
    --heat-cool: #2196f3;
    --heat-warm: #4caf50;
    --heat-hot: #ff9800;
    --heat-extreme: #f44336;

    /* Dimensões */
    --header-height: 64px;
    --nav-height: 48px;
    --footer-height: 40px;
    --panel-radius: 12px;
    --card-radius: 10px;

    /* Fontes */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-glow-green: 0 0 16px rgba(34, 197, 94, 0.3);
    --shadow-glow-orange: 0 0 16px rgba(245, 158, 11, 0.4);
    --shadow-glow-red: 0 0 20px rgba(239, 68, 68, 0.5);
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ---------- HEADER ---------- */
.app-header {
    height: var(--header-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    height: 40px;
    width: auto;
    object-fit: contain;
    filter: brightness(1.1);
    background: linear-gradient(135deg, #ffffff, #f0f0f0, #e8e8e8);
    padding: 4px 10px;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(255, 255, 255, 0.1);
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.02em;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 400;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 500;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-warning);
    animation: pulse 1.5s infinite;
}

.status-dot.connected {
    background: var(--color-normal);
    box-shadow: var(--shadow-glow-green);
}

.status-dot.disconnected {
    background: var(--color-critical);
    animation: pulse-fast 0.8s infinite;
}

.header-clock {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 70px;
    text-align: right;
}

/* ---------- NAVIGATION ---------- */
.app-nav {
    height: var(--nav-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 8px;
    overflow-x: auto;
    overflow-y: visible;
    /* Fixa logo abaixo do header (que ja e sticky em top:0). Sem isso a barra
       sumia ao rolar telas longas e obrigava a voltar ao topo para navegar.
       z-index 99 = um abaixo do header, para o header cobrir a nav ao rolar. */
    position: sticky;
    top: var(--header-height);
    z-index: 99;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-decoration: none;
}

.nav-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
    color: var(--text-accent);
}

.nav-btn .nav-alarm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-left: 4px;
}

.nav-btn .nav-alarm-dot.warning {
    background: var(--color-warning);
    box-shadow: var(--shadow-glow-orange);
    animation: pulse 1.2s infinite;
}

.nav-btn .nav-alarm-dot.critical {
    background: var(--color-critical);
    box-shadow: var(--shadow-glow-red);
    animation: pulse-fast 0.6s infinite;
}

.nav-separator {
    width: 1px;
    height: 28px;
    background: var(--border-color);
    margin: 0 8px;
}

.nav-equipment-list {
    display: flex;
    gap: 6px;
}

/* ---------- MAIN CONTENT ---------- */
.app-main {
    flex: 1;
    padding: 20px 24px;
    min-height: calc(100vh - var(--header-height) - var(--nav-height) - var(--footer-height));
}

.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    gap: 16px;
}

.view-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
}

.view-stats {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.view-stats .stat {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.view-stats .stat-value {
    font-weight: 700;
    color: var(--text-primary);
    font-family: var(--font-mono);
}

/* Linha de acoes do cabecalho: chips e botao na MESMA altura. Antes o botao
   (padding 8px) ficava visivelmente mais alto que os chips (padding 4px).
   Escopado em .view-actions para nao alterar .btn-primary das outras telas. */
.view-actions .view-stats .stat,
.view-actions .btn-primary {
    height: 32px;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
}

.view-actions .view-stats .stat { padding: 0 12px; }

.view-actions .btn-primary {
    padding: 0 14px;
    font-size: 0.82rem;
}

/* ---------- EQUIPMENT GRID (Overview) ---------- */
.equipment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(480px, 1fr));
    gap: 20px;
}

.equipment-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    /* overflow: hidden removido — necessário para o overlay de alarme crítico (position:absolute) */
    cursor: pointer;
    transition: all 0.4s ease;
    position: relative;
}

.equipment-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

/* ---- ALARME CRÍTICO NO CARD ---- */
.equipment-card.alarm-warning {
    border: 1px solid var(--color-warning);
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.18);
}

.equipment-card.alarm-warning .equipment-card-header {
    background: rgba(245, 158, 11, 0.10);
    border-bottom-color: rgba(245, 158, 11, 0.28);
}

.equipment-card.alarm-critical {
    background: linear-gradient(135deg, #5c1111, #7a1a1a, #5c1111);
    border: 2px solid var(--color-critical);
    box-shadow: 0 0 30px rgba(239, 68, 68, 0.4), 0 0 60px rgba(239, 68, 68, 0.15);
    animation: card-critical-pulse 1.2s infinite;
}

.equipment-card.alarm-critical .equipment-card-header {
    background: rgba(239, 68, 68, 0.15);
    border-bottom-color: rgba(239, 68, 68, 0.3);
}

.equipment-card.alarm-critical .eq-name {
    color: #fca5a5;
}

.equipment-card.alarm-critical .eq-meta {
    color: #fca5a5;
}

.equipment-card.alarm-critical .eq-stat-item .label {
    color: #fca5a5;
}

.equipment-card.alarm-critical .eq-stat-item .value {
    color: #fff;
}

@keyframes card-critical-pulse {

    0%,
    100% {
        box-shadow: 0 0 30px rgba(239, 68, 68, 0.4), 0 0 60px rgba(239, 68, 68, 0.15);
    }

    50% {
        box-shadow: 0 0 50px rgba(239, 68, 68, 0.6), 0 0 100px rgba(239, 68, 68, 0.25);
        border-color: #ff6b6b;
    }
}

.equipment-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 11;
}

.eq-info-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.eq-tower-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    transform: scale(0.6);
    transform-origin: center left;
    margin-right: -10px;
}

.equipment-card-header .eq-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.equipment-card-header .eq-name {
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.equipment-card-header .eq-name .color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.equipment-card-header .eq-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
}

.equipment-card-body {
    display: flex;
    flex-direction: column;
    padding: 12px 16px;
}

.equipment-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-color);
}

.view-toggle {
    display: flex;
    gap: 6px;
}

.btn-toggle {
    padding: 4px 8px;
    background: transparent;
    border: 1px solid var(--border-active);
    border-radius: 4px;
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-toggle.active {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.card-view-content {
    min-height: 200px;
    width: 100%;
}

.eq-heatmap-mini {
    width: 100%;
    height: 200px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-secondary);
}

.eq-heatmap-mini canvas {
    width: 100%;
    height: 100%;
    display: block;
    image-rendering: auto;
}

.eq-sensors-list {
    display: flex;
    flex-wrap: wrap;
    /* essencial para o wrap do novo grid em vez de esticar para os lados do flex */
    gap: 16px;
    max-height: 400px;
    /* Expansão um pouco pra caber os 16 se a tela for pequena */
    overflow-y: auto;
    justify-content: center;
    padding: 10px 0;
    width: 100%;
}

.mini-sensor-item {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border-radius: 6px;
}

.mini-sensor-item .s-name {
    font-size: 0.8rem;
    font-weight: 500;
}

.mini-sensor-item .s-temp {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 700;
    text-align: right;
}

/* Gauges Radiais Industriais */
.industrial-radial-gauge {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.radial-gauge-container {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: -15px;
    /* Compensa o espaço vazio na base do círculo */
}

.radial-gauge-svg {
    width: 100%;
    height: 100%;
    transform: rotate(135deg);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.radial-gauge-track {
    fill: none;
    stroke: #1e293b;
    stroke-width: 12;
    stroke-linecap: round;
    stroke-dasharray: 235.6 314.159;
}

.radial-gauge-fill {
    fill: none;
    stroke-width: 12;
    stroke-linecap: round;
    transition: stroke-dasharray 0.8s cubic-bezier(0.4, 0.0, 0.2, 1), stroke 0.3s;
}

.radial-gauge-center {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.radial-gauge-temp {
    font-size: 1.3rem;
    font-weight: 800;
    font-family: var(--font-mono);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.radial-gauge-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.gauge-machinery {
    position: relative;
    padding-bottom: 5px;
}

.gm-track {
    width: 100%;
    height: 10px;
    background: #0f1623;
    border-radius: 4px;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.gm-fill {
    height: 100%;
    border-radius: 4px;
    position: absolute;
    left: 0;
    top: 0;
    transition: width 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.gm-marker {
    position: absolute;
    width: 4px;
    height: 18px;
    background: #fff;
    top: -4px;
    transform: translateX(-50%);
    border-radius: 2px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
    transition: left 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
    z-index: 2;
}

.gm-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-weight: 600;
}

.disconnected-overlay {
    position: absolute;
    top: 50px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(10, 14, 23, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-muted);
    backdrop-filter: blur(2px);
    border-radius: 0 0 var(--panel-radius) var(--panel-radius);
    text-transform: uppercase;
    letter-spacing: 2px;
}

/* ---------- TOWER LIGHT INDICATORS ---------- */
.tower-light {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
}

.tower-light-lamp {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: all 0.3s ease;
}

.tower-light-lamp.red {
    background: #3a1111;
}

.tower-light-lamp.orange {
    background: #3a2a11;
}

.tower-light-lamp.green {
    background: #113a17;
}

/* Estados ativos */
.tower-light.normal .tower-light-lamp.green {
    background: var(--color-normal);
    box-shadow: var(--shadow-glow-green);
    animation: pulse-soft 2s infinite;
}

.tower-light.warning .tower-light-lamp.orange {
    background: var(--color-warning);
    box-shadow: var(--shadow-glow-orange);
    animation: pulse 1.2s infinite;
}

.tower-light.warning .tower-light-lamp.green {
    background: var(--color-normal);
    box-shadow: var(--shadow-glow-green);
}

.tower-light.critical .tower-light-lamp.red {
    background: var(--color-critical);
    box-shadow: var(--shadow-glow-red);
    animation: pulse-fast 0.6s infinite;
}

.tower-light.critical .tower-light-lamp.orange {
    background: var(--color-warning);
    box-shadow: var(--shadow-glow-orange);
}

.tower-light.critical .tower-light-lamp.green {
    background: var(--color-normal);
    box-shadow: var(--shadow-glow-green);
}

.tower-light-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* Torre luminosa inline (para lista de sensores) */
.tower-inline {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tower-inline .lamp {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.tower-inline .lamp.green {
    background: #113a17;
}

.tower-inline .lamp.orange {
    background: #3a2a11;
}

.tower-inline .lamp.red {
    background: #3a1111;
}

.tower-inline.normal .lamp.green {
    background: var(--color-normal);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.tower-inline.warning .lamp.orange {
    background: var(--color-warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
    animation: pulse 1.2s infinite;
}

.tower-inline.warning .lamp.green {
    background: var(--color-normal);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

.tower-inline.critical .lamp.red {
    background: var(--color-critical);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
    animation: pulse-fast 0.6s infinite;
}

.tower-inline.critical .lamp.orange {
    background: var(--color-warning);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
}

.tower-inline.critical .lamp.green {
    background: var(--color-normal);
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.4);
}

/* ---------- DETAIL VIEW ---------- */
.btn-back {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: 0.82rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-back:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

/* ---------- Botoes Padronizados ---------- */
.btn-primary {
    padding: 8px 16px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary:hover {
    filter: brightness(1.2);
}

.btn-secondary {
    padding: 8px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-active);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.btn-danger {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid var(--color-critical);
    border-radius: 6px;
    color: var(--color-critical);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
}


.detail-alarm-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-layout {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 20px;
    align-items: start;
}

/* ---------- PANELS ---------- */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    overflow: hidden;
    margin-bottom: 16px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.panel-header h3 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* ---------- HEATMAP ---------- */
.heatmap-container {
    padding: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.heatmap-container canvas {
    max-width: 100%;
    border-radius: 8px;
    image-rendering: pixelated;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.heatmap-legend .legend-bar {
    width: 120px;
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(90deg, #1e3a5f, #2196f3, #4caf50, #ff9800, #f44336);
}

.heatmap-legend .legend-label {
    font-family: var(--font-mono);
    font-size: 0.65rem;
}

/* ---------- THERMAL VIDEO ---------- */
.video-container {
    position: relative;
    padding: 16px;
}

.video-container canvas {
    width: 100%;
    border-radius: 8px;
    background: #000;
}

.video-overlay {
    position: absolute;
    top: 24px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.video-badge {
    padding: 3px 10px;
    background: var(--color-critical);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    animation: pulse 1.5s infinite;
}

.video-info {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.5);
    padding: 3px 8px;
    border-radius: 4px;
}

/* ---------- SENSOR LIST ---------- */
.sensor-list {
    max-height: 500px;
    overflow-y: auto;
}

.sensor-item {
    display: grid;
    grid-template-columns: auto 1fr auto auto auto;
    align-items: center;
    gap: 12px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.sensor-item:hover {
    background: var(--bg-hover);
}

.sensor-item:last-child {
    border-bottom: none;
}

.sensor-item .sensor-name {
    font-weight: 600;
    font-size: 0.82rem;
}

.sensor-item .sensor-temps {
    display: flex;
    gap: 12px;
    font-size: 0.78rem;
    font-family: var(--font-mono);
}

.sensor-item .sensor-temps .temp-label {
    color: var(--text-muted);
    font-family: var(--font-family);
    font-size: 0.68rem;
}

.sensor-item .sensor-avg {
    font-family: var(--font-mono);
    font-size: 1rem;
    font-weight: 700;
    min-width: 65px;
    text-align: right;
}

.sensor-item .btn-config {
    padding: 5px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    color: var(--text-muted);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}

.sensor-item .btn-config:hover {
    border-color: var(--accent-primary);
    color: var(--text-accent);
    background: var(--bg-hover);
}

.sensor-summary {
    display: flex;
    gap: 12px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.sensor-summary span {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ---------- CONFIG FORM ---------- */
.config-form {
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.form-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.form-group input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: 0.85rem;
    transition: border-color 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.15);
}

.form-group input[readonly] {
    opacity: 0.6;
    cursor: not-allowed;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.btn-save {
    padding: 10px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: var(--font-family);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 4px;
}

.btn-save:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-close-config {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-close-config:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── Config: separador de seção de thresholds ── */
.cfg-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0 4px;
    border-top: 1px solid var(--border-color);
    margin-top: 4px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.cfg-source-badge {
    font-size: 0.66rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    transition: all 0.3s;
}

.cfg-source-badge.hardware {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.cfg-source-badge.local {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.cfg-source-badge.loading {
    animation: pulse-soft 1s infinite;
}

/* ---------- FOOTER ---------- */
.app-footer {
    height: var(--footer-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.72rem;
    color: var(--text-muted);
}

.footer-separator {
    color: var(--border-color);
}

/* ---------- CARD ALARM OVERLAY (sobre o card) ---------- */
.card-alarm-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to bottom,
            rgba(120, 15, 15, 0.12) 0%,
            rgba(120, 15, 15, 0.30) 22%,
            rgba(120, 15, 15, 0.85) 42%,
            rgba(120, 15, 15, 0.95) 100%);
    backdrop-filter: blur(1px);
    z-index: 50;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    border-radius: var(--panel-radius);
    animation: overlay-appear 0.3s ease;
    padding: 16px 20px;
}

.card-alarm-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-end;
    width: 100%;
    gap: 8px;
}

.card-alarm-left {
    display: flex;
    align-items: center;
    gap: 14px;
    flex: 1;
}

.card-alarm-icon {
    font-size: 2.4rem;
    animation: pulse-fast 0.6s infinite;
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.6));
    flex-shrink: 0;
}

.card-alarm-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.card-alarm-title {
    font-size: 0.78rem;
    font-weight: 800;
    color: #fca5a5;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.3;
}

.card-alarm-temp {
    font-size: 1.6rem;
    font-weight: 800;
    font-family: var(--font-mono);
    color: #fff;
    text-shadow: 0 0 16px rgba(255, 255, 255, 0.3);
    line-height: 1;
}

.card-alarm-info {
    font-size: 0.68rem;
    color: rgba(252, 165, 165, 0.8);
    font-weight: 500;
}

/* Dica discreta: instrução para reset físico no K6PM */
.card-alarm-hint {
    font-size: 0.68rem;
    color: rgba(252, 165, 165, 0.75);
    font-weight: 500;
    font-style: italic;
    text-align: center;
    border-top: 1px solid rgba(252, 165, 165, 0.2);
    padding-top: 6px;
    margin-top: 4px;
    letter-spacing: 0.02em;
}

@keyframes overlay-appear {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes btn-glow {

    0%,
    100% {
        box-shadow: 0 4px 16px rgba(239, 68, 68, 0.4);
    }

    50% {
        box-shadow: 0 4px 24px rgba(239, 68, 68, 0.7), 0 0 40px rgba(239, 68, 68, 0.2);
    }
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-active);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ---------- ANIMATIONS ---------- */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-soft {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(0.92);
    }
}

@keyframes pulse-fast {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.85);
    }
}

/* ---------- USER AREA (Header) ---------- */
.header-user {
    margin-left: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-name {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.2);
    color: #fca5a5;
    font-size: 0.9rem;
    border-radius: 6px;
    padding: 4px 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.25);
    color: #fff;
}

.btn-login-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 6px 14px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    transition: all 0.2s;
}

.btn-login-link:hover {
    background: var(--accent);
    color: #fff;
}

/* ---------- LOG VIEW ---------- */
.log-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.log-filters {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.log-filter-btn {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.log-filter-btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.log-filter-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.log-actions {
    display: flex;
    gap: 8px;
}

.btn-log-export {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 6px 14px;
    border-radius: 6px;
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-log-export:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.log-event-list {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.log-event-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    animation: fadeIn 0.2s ease;
}

.log-event-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.log-event-item:last-child {
    border-bottom: none;
}

.log-event-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', 'Consolas', monospace;
    min-width: 56px;
    padding-top: 2px;
}

.log-event-icon {
    font-size: 0.85rem;
    min-width: 22px;
    text-align: center;
}

.log-event-content {
    flex: 1;
}

.log-event-message {
    font-size: 0.8rem;
    color: var(--text-primary);
    line-height: 1.4;
}

.log-event-meta {
    display: flex;
    gap: 8px;
    margin-top: 2px;
    font-size: 0.68rem;
}

.log-event-eq {
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 1px 6px;
    border-radius: 3px;
}

.log-event-type {
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.log-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.log-empty-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* ---------- REPORTS VIEW ---------- */
.reports-container {
    max-width: 600px;
}

.report-panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--panel-radius);
}

.report-body {
    padding: 20px;
}

.report-body p {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}

.report-options {
    margin-bottom: 20px;
}

.report-format-group .form-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.report-format-btns {
    display: flex;
    gap: 8px;
}

.report-format-btn {
    flex: 1;
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-secondary);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.report-format-btn:hover {
    border-color: var(--border-active);
    color: var(--text-primary);
}

.report-format-btn.active {
    background: rgba(0, 102, 204, 0.12);
    border-color: var(--accent);
    color: var(--accent);
}

.btn-generate-report {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #0066cc, #0052a3);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-family: 'Inter', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.btn-generate-report:hover {
    background: linear-gradient(135deg, #0077ee, #0060bb);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 102, 204, 0.3);
}

.btn-generate-report:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1200px) {
    .detail-layout {
        grid-template-columns: 1fr;
    }

    .equipment-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 0 12px;
    }

    .header-title h1 {
        font-size: 1rem;
    }

    .header-subtitle {
        display: none;
    }

    .app-main {
        padding: 12px;
    }

    .equipment-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================ */
/* K6PM CONFIG VIEW                                             */
/* ============================================================ */

.k6pm-config-layout {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    align-items: start;
    padding: 0 0 30px;
}

.k6pm-config-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.k6pm-sensors-col {
    min-width: 0;
}

/* Status badge no header */
.k6pm-status-badge {
    padding: 4px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(75, 85, 99, 0.4);
    border: 1px solid rgba(107, 114, 128, 0.4);
    color: #9ca3af;
    transition: all 0.3s;
}
.k6pm-status-online {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #4ade80;
}
.k6pm-status-offline {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

/* Widget Saídas Físicas */
.k6pm-outputs-widget .panel-header {
    justify-content: space-between;
}
.k6pm-live-badge {
    padding: 2px 10px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 20px;
    font-size: 0.68rem;
    font-weight: 800;
    color: #f87171;
    letter-spacing: 0.08em;
    animation: pulse-fast 1.2s infinite;
}
.k6pm-outputs-row {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    justify-content: space-around;
}
.k6pm-output-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex: 1;
    padding: 12px 8px;
    border-radius: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    text-align: center;
}
.k6pm-output-led {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    transition: all 0.3s;
}
.k6pm-led-on {
    background: #4ade80;
    box-shadow: 0 0 12px rgba(74, 222, 128, 0.6);
}
.k6pm-led-off {
    background: #374151;
    border: 1px solid #4b5563;
}
.k6pm-led-unknown {
    background: #4b5563;
    border: 1px dashed #6b7280;
    animation: pulse-fast 2s infinite;
}
.k6pm-output-label {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-primary);
}
.k6pm-output-label small {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 400;
    margin-top: 1px;
}
.k6pm-output-state {
    font-size: 0.72rem;
    font-weight: 600;
    color: #9ca3af;
    font-family: var(--font-mono);
}

/* Botões de ação */
.k6pm-action-btns {
    display: flex;
    gap: 10px;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-color);
}
.k6pm-action-btns .btn-secondary,
.k6pm-action-btns .btn-save {
    flex: 1;
    justify-content: center;
}

/* Mensagens */
.k6pm-msg {
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 0.84rem;
    margin: 8px 20px;
    font-weight: 500;
}
.k6pm-msg-info {
    background: rgba(99, 102, 241, 0.12);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
}
.k6pm-msg-error {
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}
.k6pm-msg-success {
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #6ee7b7;
}

/* Fieldsets */
.k6pm-fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 14px 20px;
    margin: 12px 20px 8px;
}
.k6pm-fieldset legend {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 0 8px;
}
.k6pm-fieldset:disabled {
    opacity: 0.45;
    pointer-events: none;
}

/* Rows de campo */
.k6pm-field-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px solid rgba(75, 85, 99, 0.25);
}
.k6pm-field-row:last-child {
    border-bottom: none;
}
.k6pm-field-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Badge de registrador */
.k6pm-reg-badge {
    padding: 1px 8px;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    font-size: 0.62rem;
    font-weight: 700;
    color: #a5b4fc;
    font-family: var(--font-mono);
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

/* Toggle groups (radio buttons estilizados) */
.k6pm-toggle-group {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.k6pm-toggle-opt {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0;
}
.k6pm-toggle-opt input[type="radio"] {
    display: none;
}
.k6pm-toggle-opt span {
    padding: 5px 14px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    transition: all 0.15s;
    cursor: pointer;
}
.k6pm-toggle-opt input[type="radio"]:checked + span {
    background: rgba(99, 102, 241, 0.2);
    border-color: rgba(99, 102, 241, 0.6);
    color: #a5b4fc;
    box-shadow: 0 0 8px rgba(99, 102, 241, 0.2);
}

/* Dicas */
.k6pm-help {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-style: italic;
}
.k6pm-help-warning {
    color: rgba(251, 191, 36, 0.8);
    font-style: normal;
    font-weight: 600;
}

/* Sensores */
.k6pm-sensors-desc {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
    line-height: 1.5;
}
.k6pm-sensors-list {
    padding: 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.k6pm-empty-sensors {
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.84rem;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}

/* Sensor details/summary */
.k6pm-sensor-details {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.k6pm-sensor-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    background: var(--bg-tertiary);
    list-style: none;
    flex-wrap: wrap;
}
.k6pm-sensor-summary:hover {
    background: rgba(99, 102, 241, 0.08);
}
.k6pm-sensor-num {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
    min-width: 70px;
}
.k6pm-sensor-addr {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-muted);
}
.k6pm-sensor-int-thresholds {
    display: flex;
    gap: 16px;
    margin-left: auto;
    font-size: 0.76rem;
    color: var(--text-secondary);
}
.k6pm-int-th {
    width: 70px;
    padding: 2px 6px;
    font-size: 0.76rem !important;
    border-radius: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    font-family: var(--font-mono);
    text-align: right;
}

/* Tabela de segmentos */
.k6pm-seg-table-wrapper {
    overflow-x: auto;
    padding: 12px 16px;
}
.k6pm-seg-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
}
.k6pm-seg-table th {
    padding: 6px 8px;
    text-align: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.k6pm-seg-table td {
    padding: 4px 6px;
    text-align: center;
    border-bottom: 1px solid rgba(75, 85, 99, 0.15);
}
.k6pm-seg-table tr:hover td {
    background: rgba(99, 102, 241, 0.05);
}
.k6pm-seg-num {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-muted);
    width: 40px;
}
.k6pm-temp-input {
    width: 80px;
    padding: 3px 6px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 0.76rem;
    text-align: right;
    transition: border-color 0.15s;
}
.k6pm-temp-input:focus {
    outline: none;
    border-color: rgba(99, 102, 241, 0.5);
    background: rgba(99, 102, 241, 0.06);
}
.k6pm-temp-input:disabled {
    opacity: 0.4;
}

/* Responsivo */
@media (max-width: 1100px) {
    .k6pm-config-layout {
        grid-template-columns: 1fr;
    }
}

/* ================================================================
   PAINEL DE NOTIFICAÇÕES
   ================================================================ */

/* Abas internas */
.notif-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 16px;
}
.notif-tab {
    padding: 8px 18px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-family);
}
.notif-tab:hover  { color: var(--text-primary); }
.notif-tab.active { color: var(--accent-primary); border-bottom-color: var(--accent-primary); }

/* Layout split destinatários/regras */
.notif-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    align-items: start;
}
@media (max-width: 900px) { .notif-split { grid-template-columns: 1fr; } }
.notif-col { min-width: 0; }

/* Tabela */
.notif-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}
.notif-table th {
    padding: 8px 12px;
    text-align: left;
    color: var(--text-muted);
    font-size: 0.71rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}
.notif-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(30,41,59,.4);
}
.notif-table tr:hover td { background: var(--bg-hover); }
.notif-td-empty {
    color: var(--text-muted);
    font-size: .8rem;
    padding: 24px 12px;
    text-align: center;
}

/* Badges */
.notif-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 700;
}
.notif-badge-ok  { background: rgba(34,197,94,.15);  color: #22c55e; }
.notif-badge-off { background: rgba(107,114,128,.12); color: #6b7280; }
.notif-badge-err { background: rgba(239,68,68,.15);  color: #ef4444; }

/* Botões de ação na tabela */
.notif-actions { display: flex; gap: 4px; }
.notif-btn-sm {
    padding: 3px 7px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-muted);
    font-size: .78rem;
    cursor: pointer;
    transition: all .15s;
}
.notif-btn-sm:hover { border-color: var(--accent-primary); color: var(--text-primary); }
.notif-btn-rules:hover { border-color: #a78bfa; color: #a78bfa; }
.notif-btn-danger:hover { border-color: #ef4444; color: #ef4444; }

/* Painel de regras */
.notif-rules-wrap { padding: 12px 16px; }
.notif-rules-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    font-size: .82rem;
    color: var(--text-secondary);
}
.notif-rule-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 7px;
    padding: 11px 14px;
    margin-bottom: 10px;
    transition: border-color .2s;
}
.notif-rule-card:hover { border-color: var(--accent-primary); }
.notif-rule-off { opacity: .55; }
.notif-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 7px;
}
.notif-rule-scope {
    font-size: .8rem;
    font-weight: 600;
    color: var(--text-primary);
}
.notif-rule-actions { display: flex; gap: 4px; }
.notif-rule-flags { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 7px; }
.notif-flag {
    padding: 2px 7px;
    border-radius: 4px;
    font-size: .68rem;
    font-weight: 700;
}
.notif-flag-on  { background: rgba(96,165,250,.15); color: #60a5fa; }
.notif-flag-off { background: rgba(107,114,128,.08); color: rgba(107,114,128,.6); text-decoration: line-through; }
.notif-rule-meta { font-size: .73rem; color: var(--text-muted); }

/* Worker status */
.notif-worker {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: .78rem;
    padding: 4px 10px;
    border-radius: 5px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}
.notif-worker-ok  { border-color: rgba(34,197,94,.3); }
.notif-worker-err { border-color: rgba(239,68,68,.3); }
.notif-worker-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
}
.notif-worker-ok  .notif-worker-dot { background: #22c55e; box-shadow: 0 0 6px #22c55e; }
.notif-worker-err .notif-worker-dot { background: #ef4444; }

/* Toast */
.notif-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 100000;
    padding: 10px 20px;
    border-radius: 7px;
    font-size: .83rem;
    font-weight: 600;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,.4);
    animation: fadeIn .2s ease;
}
.notif-toast-ok  { background: #14532d; color: #86efac; border: 1px solid rgba(34,197,94,.3); }
.notif-toast-err { background: #450a0a; color: #fca5a5; border: 1px solid rgba(239,68,68,.3); }

/* Formulários */
.notif-form { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.notif-form-row { display: flex; flex-direction: column; gap: 5px; }
.notif-form-row label {
    font-size: .74rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}
.notif-input {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-family: var(--font-family);
    font-size: .85rem;
    transition: border-color .2s;
    width: 100%;
}
.notif-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(0,102,204,.15);
}
.notif-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: .85rem;
    color: var(--text-primary);
    text-transform: none;
    font-weight: 400;
    letter-spacing: 0;
}
.notif-chk {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    font-size: .78rem;
    padding: 5px 9px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    transition: all .15s;
}
.notif-chk:has(input:checked) {
    border-color: var(--accent-primary);
    color: var(--text-accent);
    background: rgba(0,102,204,.08);
}
.notif-hint {
    color: var(--text-muted);
    font-size: .8rem;
    padding: 8px 0;
}
.notif-row-selected td { background: rgba(96,165,250,.07) !important; }

/* ================================================================
   ABA RELAT�RIOS � classes rpt-*
   ================================================================ */

.rpt-row {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.rpt-label {
    font-size: .74rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.rpt-label small {
    text-transform: none;
    font-weight: 400;
    letter-spacing: 0;
    color: var(--text-muted);
}

.rpt-period-btn {
    padding: 5px 14px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: .78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}

.rpt-period-btn:hover {
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.rpt-period-btn.active {
    background: rgba(0, 102, 204, .12);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

@media (max-width: 860px) {
    #viewReports > div {
        grid-template-columns: 1fr !important;
    }
}

/* ================================================================
   PAINEL DE ALARMES � classes alm-*
   ================================================================ */

/* Filtros */
.alm-filters {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    padding: 14px 16px;
    margin-bottom: 12px;
}
.alm-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-end;
}
@media (max-width: 860px) { .alm-filter-row { flex-direction: column; } }

/* Per�odo (reutiliza rpt-period-btn, alias) */
.alm-period-btn {
    padding: 5px 12px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-size: .76rem;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
}
.alm-period-btn:hover  { border-color: var(--accent-primary); color: var(--text-primary); }
.alm-period-btn.active { background: rgba(0,102,204,.12); border-color: var(--accent-primary); color: var(--accent-primary); }

/* Tabela */
.alm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .78rem;
    min-width: 840px;
}
.alm-table th {
    padding: 8px 12px;
    text-align: left;
    color: var(--text-muted);
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    background: var(--bg-tertiary);
}
.alm-th-cb { width: 32px; }
.alm-table td {
    padding: 8px 12px;
    border-bottom: 1px solid rgba(30,41,59,.35);
    vertical-align: middle;
}
.alm-table tr:hover td { background: var(--bg-hover); }
.alm-row-active td     { background: rgba(239,68,68,.04); }
.alm-td-cb  { width: 32px; }
.alm-td-empty { color: var(--text-muted); font-size: .8rem; padding: 24px 12px; text-align: center; }
.alm-mono   { font-family: var(--font-mono); font-size: .75rem; }

/* Badges de estado */
.alm-badge {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .04em;
    text-transform: uppercase;
}
.alm-state-atencao  { background: rgba(245,158,11,.15); color: #fbbf24; }
.alm-state-pre      { background: rgba(251,146,60,.15);  color: #fb923c; }
.alm-state-alarme   { background: rgba(239,68,68,.15);   color: #f87171; }
.alm-state-critico  { background: rgba(220,38,38,.25);   color: #fca5a5; border: 1px solid rgba(220,38,38,.4); }
.alm-state-falha    { background: rgba(124,58,237,.2);   color: #c4b5fd; }
.alm-state-normal   { background: rgba(34,197,94,.1);    color: #4ade80; }

/* Badges de status */
.alm-status-active { background: rgba(239,68,68,.15); color: #f87171; animation: pulse-soft 2s infinite; }
.alm-status-norm   { background: rgba(34,197,94,.1);  color: #4ade80; }
.alm-status-ack    { background: rgba(107,114,128,.1); color: #9ca3af; }

/* Indicador "em curso" */
.alm-pulse { color: #f87171; animation: pulse-fast .8s infinite; font-size: .75rem; }

/* Bot�o ACK individual */
.alm-btn-ack {
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid rgba(34,197,94,.35);
    background: rgba(34,197,94,.08);
    color: #4ade80;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
}
.alm-btn-ack:hover { background: rgba(34,197,94,.18); border-color: #4ade80; }

/* Bot�o ACK em lote */
.alm-btn-batch {
    padding: 7px 16px;
    border-radius: 6px;
    border: 1px solid rgba(34,197,94,.3);
    background: rgba(34,197,94,.1);
    color: #4ade80;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .2s;
}
.alm-btn-batch:hover:not(:disabled) { background: rgba(34,197,94,.2); }
.alm-btn-batch:disabled { opacity: .35; cursor: not-allowed; }

/* Badge contagem de alarmes no bot�o nav */
.alm-nav-badge {
    position: absolute;
    top: 4px; right: 4px;
    background: #ef4444;
    color: #fff;
    font-size: .58rem;
    font-weight: 800;
    padding: 1px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
    line-height: 14px;
    pointer-events: none;
}
.alm-actions { white-space: nowrap; }

/* === Card de Calculo Automatico de Thresholds === */

.k6pm-config-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px 24px;
    margin-top: 20px;
}

.k6pm-card-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 10px;
}

.k6pm-card-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.k6pm-card-hint {
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-style: italic;
}

.auto-calc-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auto-calc-params {
    display: flex;
    gap: 24px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.auto-calc-param-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auto-calc-param-group label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.auto-calc-param-group #acAmbientTemp {
    width: 90px;
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center;
}

.auto-calc-margins {
    flex: 1;
    min-width: 260px;
}

.auto-calc-margins-grid {
    display: grid;
    grid-template-columns: auto 70px auto 70px;
    gap: 6px 10px;
    align-items: center;
}

.auto-calc-margins-grid span {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.k6pm-margin-input {
    width: 64px !important;
    text-align: center;
    font-size: 0.88rem !important;
}

.auto-calc-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.k6pm-btn {
    padding: 9px 20px;
    border: none;
    border-radius: 7px;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.k6pm-btn:hover:not(:disabled) { opacity: 0.85; transform: translateY(-1px); }
.k6pm-btn:active:not(:disabled) { transform: translateY(0); }
.k6pm-btn:disabled { opacity: 0.45; cursor: not-allowed; }

.k6pm-btn-reset {
    background: #374151;
    color: #f9fafb;
    border: 1px solid #4b5563;
}

.k6pm-btn-calc {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.k6pm-temp-input.calc-suggested {
    background: rgba(234, 179, 8, 0.15) !important;
    border-color: #eab308 !important;
    color: #fbbf24 !important;
    font-weight: 600;
    transition: background 0.3s, border-color 0.3s;
}

.auto-calc-msg {
    padding: 9px 14px;
    border-radius: 6px;
    font-size: 0.83rem;
    line-height: 1.5;
}

.auto-calc-msg-loading {
    background: rgba(59, 130, 246, 0.12);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.25);
}

.auto-calc-msg-error {
    background: rgba(239, 68, 68, 0.12);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.25);
}

.auto-calc-msg-success {
    background: rgba(34, 197, 94, 0.12);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.25);
}

.auto-calc-legend {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.auto-calc-legend-badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.auto-calc-legend-badge.suggested {
    background: rgba(234, 179, 8, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(234, 179, 8, 0.4);
}

/* Hint do fluxo de uso do calculo automatico */
.auto-calc-flow-hint {
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 0.8rem;
    color: #93c5fd;
    line-height: 1.6;
}

/* Secao de selecao de sensores para calculo */
.auto-calc-sensor-select {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 14px;
}

.auto-calc-sensor-select-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.auto-calc-sensor-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.auto-calc-sensor-check {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.auto-calc-sensor-check:hover {
    border-color: rgba(99, 102, 241, 0.5);
    color: var(--text-primary);
}

.auto-calc-sensor-check:has(input:checked) {
    background: rgba(99, 102, 241, 0.12);
    border-color: rgba(99, 102, 241, 0.6);
    color: #a5b4fc;
}

.auto-calc-sensor-check input[type="checkbox"] {
    width: 13px;
    height: 13px;
    cursor: pointer;
    accent-color: #6366f1;
}

/* Botao link (selecionar todos / desmarcar todos) */
.k6pm-btn-link {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.76rem;
    color: var(--text-secondary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.15s;
}

.k6pm-btn-link:hover { color: #a5b4fc; }

/* ============================================================
   Insights K6Dash Thermal — Badge nos Cards + Painel Lateral
   © SetSystem Automação e Robótica — 2026
   ============================================================ */

/* ── Badge no card de equipamento ── */
.insight-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    border: 1.5px solid transparent;
    transition: transform 0.15s, box-shadow 0.15s;
    white-space: nowrap;
    user-select: none;
}
.insight-badge:hover {
    transform: scale(1.06);
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}
.insight-badge--hidden        { display: none !important; }
.insight-badge--info          { background: rgba(59,130,246,0.18);  color: #93c5fd; border-color: rgba(59,130,246,0.4); }
.insight-badge--attention     { background: rgba(234,179,8,0.18);   color: #fde047; border-color: rgba(234,179,8,0.4); }
.insight-badge--pre-critical  { background: rgba(245,158,11,0.18);  color: #fbbf24; border-color: rgba(245,158,11,0.4);
    animation: badge-pulse-orange 2s ease-in-out infinite; }
.insight-badge--critical      { background: rgba(239,68,68,0.18);   color: #fca5a5; border-color: rgba(239,68,68,0.4);
    animation: badge-pulse-red 1.4s ease-in-out infinite; }

@keyframes badge-pulse-orange {
    0%,100% { box-shadow: 0 0 0 0 rgba(245,158,11,0); }
    50%      { box-shadow: 0 0 0 6px rgba(245,158,11,0.25); }
}
@keyframes badge-pulse-red {
    0%,100% { box-shadow: 0 0 0 0 rgba(239,68,68,0); }
    50%      { box-shadow: 0 0 0 6px rgba(239,68,68,0.3); }
}
.insight-badge__icon { font-size: 0.85em; }
.insight-badge__count { font-size: 0.85em; }

/* ── Painel lateral de insights ── */
.insights-sidebar {
    position: fixed;
    top: 0;
    right: -440px;
    width: 420px;
    max-width: 96vw;
    height: 100vh;
    background: var(--bg-secondary, #1a1d23);
    border-left: 1px solid var(--border-color, #2d3748);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: right 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -8px 0 32px rgba(0,0,0,0.5);
}
.insights-sidebar--open { right: 0; }

.insights-sidebar__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color, #2d3748);
    background: var(--bg-tertiary, #161921);
    flex-shrink: 0;
}
.insights-sidebar__title {
    display: flex;
    align-items: center;
    gap: 12px;
}
.insights-sidebar__icon { font-size: 1.4rem; }
.insights-sidebar__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-normal, #e2e8f0);
}
.insights-sidebar__subtitle {
    font-size: 0.78rem;
    color: var(--text-muted, #718096);
}
.insights-sidebar__close {
    background: none;
    border: none;
    color: var(--text-muted, #718096);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
}
.insights-sidebar__close:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }

/* Filtros */
.insights-sidebar__filters {
    display: flex;
    gap: 6px;
    padding: 12px 16px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border-color, #2d3748);
    flex-shrink: 0;
}
.insights-filter-btn {
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color, #2d3748);
    background: var(--bg-tertiary, #161921);
    color: var(--text-muted, #718096);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
}
.insights-filter-btn:hover,
.insights-filter-btn.active {
    background: rgba(59,130,246,0.15);
    border-color: #3b82f6;
    color: #93c5fd;
}

/* Lista de insights */
.insights-sidebar__body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.insights-sidebar__body::-webkit-scrollbar { width: 4px; }
.insights-sidebar__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.insights-loading,
.insights-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: var(--text-muted, #718096);
    font-size: 0.9rem;
    padding: 40px 20px;
    text-align: center;
}
.insights-empty__icon { font-size: 2rem; }

/* ── Sumário Visual de Insights ──────────────────────────────────────────── */
.insights-summary {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color, #2d3748);
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.insights-summary__title {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--text-secondary, #9ca3af);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 6px;
}
.insights-summary__row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}
.insights-summary__row.clickable { cursor: pointer; }
.insights-summary__row.clickable:hover { background: rgba(255,255,255,0.05); }
.insights-summary__row.active { background: rgba(255,255,255,0.08); }
.insights-summary__icon { font-size: 0.9rem; flex-shrink: 0; width: 20px; text-align: center; }
.insights-summary__label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-normal, #e2e8f0);
    width: 85px;
    flex-shrink: 0;
}
.insights-summary__bar {
    flex: 1;
    height: 6px;
    background: rgba(255,255,255,0.06);
    border-radius: 3px;
    overflow: hidden;
}
.insights-summary__bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.5s ease;
    opacity: 0.8;
}
.insights-summary__count {
    font-size: 0.82rem;
    font-weight: 700;
    width: 30px;
    text-align: right;
    flex-shrink: 0;
}
.insights-summary__dq {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin-top: 4px;
    font-size: 0.72rem;
    color: var(--text-muted, #718096);
    border-top: 1px solid rgba(255,255,255,0.05);
}

/* ── Drill-down de Insights ─────────────────────────────────────────────── */
.insights-drilldown {
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.insights-drilldown__title {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-normal, #e2e8f0);
    margin-bottom: 2px;
}
.insights-drilldown__count {
    font-weight: 400;
    color: var(--text-muted, #718096);
    font-size: 0.72rem;
}

/* ── Grupo de Insight (card agrupado) ───────────────────────────────────── */
.insight-group {
    background: var(--bg-tertiary, #161921);
    border: 1px solid var(--border-color, #2d3748);
    border-left: 3px solid #3b82f6;
    border-radius: 8px;
    padding: 10px 12px;
    transition: border-color 0.2s, transform 0.1s;
}
.insight-group:hover { border-color: rgba(255,255,255,0.15); }
.insight-group__header { margin-bottom: 6px; }
.insight-group__title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 3px;
}
.insight-group__cat-icon { font-size: 0.9rem; }
.insight-group__cat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-normal, #e2e8f0);
    flex: 1;
}
.insight-group__severity {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 1px 8px;
    border-radius: 12px;
    font-size: 0.68rem;
    font-weight: 700;
    border: 1px solid;
    flex-shrink: 0;
}
.insight-group__sensor {
    font-size: 0.76rem;
    color: var(--text-secondary, #9ca3af);
    font-weight: 500;
}
.insight-group__segments {
    font-size: 0.7rem;
    color: var(--text-muted, #718096);
    margin-top: 1px;
}
.insight-group__headline {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-normal, #e2e8f0);
    line-height: 1.45;
    padding: 4px 0;
}
.insight-group__actions {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}
.insight-group__expand-btn,
.insight-group__ack-btn {
    padding: 3px 10px;
    border-radius: 5px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid;
}
.insight-group__expand-btn {
    background: rgba(255,255,255,0.04);
    border-color: rgba(255,255,255,0.1);
    color: var(--text-muted, #718096);
}
.insight-group__expand-btn:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-normal, #e2e8f0);
}
.insight-group__ack-btn {
    background: rgba(34,197,94,0.1);
    border-color: rgba(34,197,94,0.3);
    color: #4ade80;
}
.insight-group__ack-btn:hover {
    background: rgba(34,197,94,0.2);
    border-color: #4ade80;
}

/* ── Detalhe expandido do grupo ──────────────────────────────────────────── */
.insight-group__detail {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255,255,255,0.06);
    animation: insightDetailIn 0.2s ease;
}
@keyframes insightDetailIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.insight-group__interpretation {
    font-size: 0.8rem;
    color: var(--text-normal, #e2e8f0);
    line-height: 1.55;
    margin-bottom: 6px;
}
.insight-group__recommendation {
    font-size: 0.78rem;
    color: #86efac;
    line-height: 1.5;
    padding: 6px 10px;
    background: rgba(34,197,94,0.07);
    border-radius: 6px;
    border-left: 2px solid #4ade80;
    margin-bottom: 6px;
}
.insight-group__limitation {
    font-size: 0.72rem;
    color: var(--text-muted, #718096);
}
.insight-group__limitation summary {
    cursor: pointer;
    color: #94a3b8;
    font-style: italic;
}
.insight-group__limitation p { margin: 4px 0 0; line-height: 1.5; }
.insight-group__recurrence {
    font-size: 0.7rem;
    color: #c084fc;
    margin-top: 4px;
}

/* ── Evidências ──────────────────────────────────────────────────────────── */
.insight-evidence {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 4px;
    margin-bottom: 4px;
}
.insight-evidence__pair {
    font-size: 0.7rem;
    color: var(--text-muted, #718096);
    background: rgba(255,255,255,0.04);
    padding: 2px 7px;
    border-radius: 4px;
    border: 1px solid rgba(255,255,255,0.07);
}
.insight-evidence__pair b {
    font-weight: 600;
    color: var(--text-secondary, #9ca3af);
}

/* ── Botão de limpar insights Info ───────────────────────────────────────── */
.insights-clear-info-btn {
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid rgba(239,68,68,0.35);
    background: rgba(239,68,68,0.08);
    color: #f87171;
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.15s;
    display: none;
    align-items: center;
}
.insights-clear-info-btn:hover {
    background: rgba(239,68,68,0.2);
    border-color: #ef4444;
    color: #fca5a5;
}

/* ── Toast de Alerta de Insights ─────────────────────────────────────────── */
.insight-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: var(--bg-secondary, #1e2a35);
    border: 1px solid rgba(239,68,68,0.4);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    padding: 14px 16px;
    z-index: 9999;
    animation: toastSlideIn 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.insight-toast--pre_critical { border-color: rgba(245,158,11,0.55); }
.insight-toast--critical      { border-color: rgba(239,68,68,0.65); }
.insight-toast--dismissed     { animation: toastSlideOut 0.3s ease forwards; }
@keyframes toastSlideIn {
    from { transform: translateX(360px); opacity: 0; }
    to   { transform: translateX(0);     opacity: 1; }
}
@keyframes toastSlideOut {
    from { transform: translateX(0);     opacity: 1; }
    to   { transform: translateX(360px); opacity: 0; }
}
.insight-toast__header {
    display: flex;
    align-items: center;
    gap: 8px;
}
.insight-toast__icon  { font-size: 16px; }
.insight-toast__title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    flex: 1;
}
.insight-toast__close {
    background: none;
    border: none;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 14px;
    padding: 0;
    line-height: 1;
}
.insight-toast__close:hover { color: var(--text-primary, #e2e8f0); }
.insight-toast__body {
    font-size: 12px;
    color: var(--text-secondary, #94a3b8);
    line-height: 1.4;
}
.insight-toast__btn {
    background: rgba(99,102,241,0.15);
    border: 1px solid rgba(99,102,241,0.4);
    color: #a5b4fc;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
}
.insight-toast__btn:hover { background: rgba(99,102,241,0.28); }

/* ── Badge pulsante no botão Insights ───────────────────────────────────── */
.insights-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    background: #ef4444;
    color: #fff;
    border-radius: 9px;
    margin-left: 5px;
    vertical-align: middle;
    animation: insightBadgePulse 1.8s ease-in-out infinite;
}
@keyframes insightBadgePulse {
    0%, 100% { box-shadow: 0 0 0 0   rgba(239,68,68,0.6); }
    50%       { box-shadow: 0 0 0 5px rgba(239,68,68,0);   }
}

/* ============================================================
   DETAIL V2 — Layout 3 Colunas (Sensor Focado)
   © SetSystem Automação e Robótica — 2026
   ============================================================ */

/* Section header */
.detail-v2-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-tertiary, #161921);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
/* Versão compacta: linha fina de badges sem título volumoso */
.detail-v2-badges-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0 8px;
    flex-wrap: wrap;
}
.detail-v2-section-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-v2-hint {
    font-size: 0.75rem;
    color: var(--text-muted, #718096);
    font-style: italic;
}
.detail-v2-badges { margin-left: auto; display: flex; gap: 8px; }
.detail-v2-badge {
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(34,197,94,0.12);
    color: #4ade80;
    border: 1px solid rgba(34,197,94,0.3);
}
.detail-v2-badge.accent {
    background: rgba(96,165,250,0.12);
    color: #60a5fa;
    border-color: rgba(96,165,250,0.3);
}
.detail-v2-badge.warning {
    background: rgba(245,158,11,0.12);
    color: #fbbf24;
    border-color: rgba(245,158,11,0.3);
}
.detail-v2-badge.critical {
    background: rgba(239,68,68,0.12);
    color: #f87171;
    border-color: rgba(239,68,68,0.3);
}

/* Grid 3 colunas */
.detail-layout-v2 {
    display: grid;
    grid-template-columns: 220px 1fr 340px;
    gap: 12px;
    min-height: 480px;
}

/* ── Sidebar Esquerda: Sensores ── */
.detail-sidebar {
    background: var(--bg-card, #1a1d23);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.detail-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 4px;
}
.detail-sidebar-title {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-sidebar-count {
    background: rgba(96,165,250,0.15);
    color: #60a5fa;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}
.detail-sidebar-hint {
    font-size: 0.68rem;
    color: var(--text-muted, #718096);
    padding: 0 14px 6px;
    font-style: italic;
}
/* Lista de segmentos que expande abaixo do card (duplo clique) */
.sensor-seg-list {
    animation: slideDown 0.15s ease;
}
@keyframes slideDown {
    from { opacity:0; transform:translateY(-6px); }
    to   { opacity:1; transform:translateY(0); }
}
.detail-sidebar-filters {
    display: flex;
    gap: 4px;
    padding: 0 10px 8px;
}
.dsf-btn {
    padding: 3px 10px;
    border-radius: 14px;
    border: 1px solid var(--border-color, #2d3748);
    background: var(--bg-tertiary, #161921);
    color: var(--text-muted, #718096);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.dsf-btn:hover, .dsf-btn.active {
    background: rgba(96,165,250,0.12);
    border-color: rgba(96,165,250,0.4);
    color: #93c5fd;
}
.detail-sidebar-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.detail-sidebar-list::-webkit-scrollbar { width: 3px; }
.detail-sidebar-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* Card de sensor na sidebar */
.sensor-card-v2 {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid transparent;
    background: rgba(255,255,255,0.02);
    cursor: pointer;
    transition: all 0.15s;
}
.sensor-card-v2:hover {
    background: rgba(96,165,250,0.06);
    border-color: rgba(96,165,250,0.2);
}
.sensor-card-v2.active {
    background: rgba(96,165,250,0.1);
    border-color: rgba(96,165,250,0.4);
    box-shadow: inset 3px 0 0 #60a5fa;
}
.sensor-card-v2__led {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.sensor-card-v2__led.normal { background: #22c55e; box-shadow: 0 0 4px rgba(34,197,94,0.4); }
.sensor-card-v2__led.warning { background: #f59e0b; box-shadow: 0 0 4px rgba(245,158,11,0.4); }
.sensor-card-v2__led.critical { background: #ef4444; box-shadow: 0 0 4px rgba(239,68,68,0.4); animation: ledPulse 1.2s infinite; }
@keyframes ledPulse { 0%,100%{opacity:1} 50%{opacity:0.4} }

.sensor-card-v2__info {
    flex: 1;
    min-width: 0;
}
.sensor-card-v2__name {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-primary, #e2e8f0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sensor-card-v2__sub {
    font-size: 0.65rem;
    color: var(--text-muted, #718096);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sensor-card-v2__temp {
    font-size: 1rem;
    font-weight: 700;
    flex-shrink: 0;
}
.sensor-card-v2__temp.normal { color: #22c55e; }
.sensor-card-v2__temp.warning { color: #f59e0b; }
.sensor-card-v2__temp.critical { color: #ef4444; }

/* ── Centro: Heatmap + Tabs ── */
.detail-center {
    background: var(--bg-card, #1a1d23);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.detail-center-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #2d3748);
}
.dct-tab {
    padding: 8px 16px;
    border: none;
    background: none;
    color: var(--text-muted, #718096);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.dct-tab:hover { color: var(--text-primary, #e2e8f0); }
.dct-tab.active {
    color: #60a5fa;
    border-bottom-color: #60a5fa;
    background: rgba(96,165,250,0.05);
}
.dct-tab.accent {
    color: #4ade80;
    margin-left: auto;
}
.dct-tab.accent:hover { background: rgba(74,222,128,0.08); }

/* Stats bar */
.detail-center-stats {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color, #2d3748);
}
.dcs-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px 6px;
    border-right: 1px solid var(--border-color, #2d3748);
}
.dcs-item:last-child { border-right: none; }
.dcs-label { font-size: 0.65rem; color: var(--text-muted, #718096); text-transform: uppercase; letter-spacing: 0.04em; }
.dcs-value { font-size: 0.9rem; font-weight: 700; color: var(--text-primary, #e2e8f0); }

/* Escala de cores compacta */
.detail-center-scale {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-top: 1px solid var(--border-color, #2d3748);
    justify-content: center;
}
.dcs-scale-label { font-size: 0.72rem; color: var(--text-muted, #718096); }
.dcs-scale-input {
    width: 52px;
    padding: 2px 4px;
    background: var(--bg-tertiary, #161921);
    border: 1px solid var(--border-color, #2d3748);
    color: white;
    text-align: center;
    border-radius: 4px;
    font-size: 0.78rem;
}
.dcs-gradient-bar {
    width: 120px;
    height: 12px;
    border-radius: 3px;
    box-shadow: inset 0 0 3px rgba(0,0,0,0.6);
    background: linear-gradient(to right, rgb(30,58,95), rgb(33,150,243), rgb(76,175,80), rgb(255,235,59), rgb(255,152,0), rgb(244,67,54));
    border: 1px solid rgba(255,255,255,0.1);
}
.dcs-auto-btn {
    padding: 2px 10px;
    background: var(--color-normal, #22c55e);
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

/* ── Sidebar Direita: Contexto do Segmento ── */
.detail-context {
    background: var(--bg-card, #1a1d23);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    gap: 0;
}
.detail-context::-webkit-scrollbar { width: 3px; }
.detail-context::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

.detail-ctx-sensor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #2d3748);
}
.detail-ctx-sensor-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-ctx-btn {
    padding: 3px 10px;
    border-radius: 4px;
    border: 1px solid var(--border-color, #2d3748);
    background: none;
    color: var(--text-muted, #718096);
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.15s;
}
.detail-ctx-btn:hover { background: rgba(255,255,255,0.06); color: var(--text-primary, #e2e8f0); }

/* Segmento info */
.detail-ctx-segment {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color, #2d3748);
}
.detail-ctx-seg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}
.detail-ctx-seg-name {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-ctx-seg-status {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.detail-ctx-seg-status.normal { background: rgba(34,197,94,0.12); color: #4ade80; }
.detail-ctx-seg-status.warning { background: rgba(245,158,11,0.12); color: #fbbf24; }
.detail-ctx-seg-status.critical { background: rgba(239,68,68,0.12); color: #f87171; }

.detail-ctx-seg-sub {
    font-size: 0.72rem;
    color: var(--text-muted, #718096);
    margin-bottom: 8px;
}
.detail-ctx-seg-temps {
    display: flex;
    gap: 16px;
}
.dct-temp {
    display: flex;
    flex-direction: column;
}
.dct-temp-label { font-size: 0.65rem; color: var(--text-muted, #718096); text-transform: uppercase; }
.dct-temp-value { font-size: 1.1rem; font-weight: 700; color: var(--text-primary, #e2e8f0); }

/* Mini tendência */
.detail-ctx-trend {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #2d3748);
}
.detail-ctx-trend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary, #9ca3af);
}
.detail-ctx-trend-link {
    font-size: 0.68rem;
    color: #60a5fa;
    text-decoration: none;
    cursor: pointer;
}
.detail-ctx-trend-link:hover { text-decoration: underline; }
.detail-ctx-trend-canvas-wrap {
    position: relative;
    background: var(--bg-tertiary, #161921);
    border-radius: 6px;
    overflow: hidden;
    min-height: 80px;
}
.detail-ctx-trend-canvas-wrap canvas {
    display: block;
    width: 100%;
    height: 80px;
}
.detail-ctx-trend-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    color: var(--text-muted, #718096);
    font-style: italic;
}

/* Config segmento na sidebar */
.detail-ctx-config {
    padding: 10px 14px;
}
.detail-ctx-config-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-ctx-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted, #718096);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
}
.detail-ctx-close:hover { color: var(--text-primary, #e2e8f0); }

.detail-ctx-config .config-form .form-group label { font-size: 0.72rem; }
.detail-ctx-config .config-form input { font-size: 0.8rem; padding: 5px 8px; }
.detail-ctx-config .btn-save { width: 100%; padding: 8px; font-size: 0.82rem; }

/* ── Seção Inferior: Todos os mini-heatmaps ── */
.detail-v2-allsensors {
    margin-top: 16px;
    background: var(--bg-card, #1a1d23);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    padding: 14px 16px;
}
.detail-v2-allsensors-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.detail-v2-allsensors-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-v2-allsensors-filters {
    display: flex;
    gap: 6px;
}
.detail-v2-allsensors-grid {
    display: flex;
    justify-content: center;
    overflow-x: auto;
    padding: 4px 0;
}

/* ── Seção Comparação Controlada ── */
.detail-v2-compare {
    margin-top: 16px;
    background: var(--bg-card, #1a1d23);
    border: 1px solid var(--border-color, #2d3748);
    border-radius: 8px;
    padding: 14px 16px;
}
.detail-v2-compare-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}
.detail-v2-compare-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary, #e2e8f0);
}
.detail-v2-compare-body {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 16px;
    align-items: start;
}
.detail-v2-compare-chips {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 160px;
}
.detail-v2-compare-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color, #2d3748);
    background: var(--bg-tertiary, #161921);
    font-size: 0.75rem;
    color: var(--text-primary, #e2e8f0);
}
.detail-v2-compare-chip__color {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.detail-v2-compare-chip__remove {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted, #718096);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0 2px;
}
.detail-v2-compare-chip__remove:hover { color: #ef4444; }
.detail-v2-compare-add {
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px dashed rgba(96,165,250,0.3);
    background: none;
    color: #60a5fa;
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.15s;
}
.detail-v2-compare-add:hover { background: rgba(96,165,250,0.06); border-color: #60a5fa; }
.detail-v2-compare-chart-wrap {
    position: relative;
    background: var(--bg-tertiary, #161921);
    border-radius: 6px;
    min-height: 180px;
    overflow: hidden;
}
.detail-v2-compare-chart-wrap canvas { display: block; width: 100%; height: 180px; }
.detail-v2-compare-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    color: var(--text-muted, #718096);
    font-style: italic;
}

/* ── Responsividade ── */
@media (max-width: 1200px) {
    .detail-layout-v2 {
        grid-template-columns: 200px 1fr;
    }
    .detail-context {
        grid-column: 1 / -1;
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
    }
    .detail-ctx-segment,
    .detail-ctx-trend,
    .detail-ctx-config { flex: 1; min-width: 240px; }
    .detail-v2-compare-body { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
    .detail-layout-v2 {
        grid-template-columns: 1fr;
    }
    .detail-sidebar {
        max-height: 200px;
    }
    .detail-sidebar-list {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .sensor-card-v2 { min-width: 140px; }
}

/* ============================================================
   Mapa do Painel (Detalhe → aba "Mapa do Painel")
   ============================================================ */
.detail-tabs {
    display: flex;
    gap: 4px;
    margin: 0 0 16px;
    border-bottom: 1px solid var(--border-color);
}
.detail-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 10px 20px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.12s ease;
}
.detail-tab:hover { color: #e2e8f0; }
.detail-tab.active {
    color: #fff;
    border-bottom-color: var(--accent-secondary);
}

.pm-loading,
.pm-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 60px 20px;
}
.pm-empty-icon { font-size: 2.4rem; margin-bottom: 10px; }
.pm-empty p { margin: 4px 0; }
.pm-empty-sub { font-size: 0.85rem; opacity: 0.7; }

.pm-imgtabs {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.pm-imgtab {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
}
.pm-imgtab.active {
    color: #fff;
    border-color: var(--accent-secondary);
    background: rgba(0, 188, 212, 0.12);
}

.pm-stage-wrap {
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin: 0 auto;
}
.pm-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    line-height: 0;
    overflow: hidden;          /* recorta a foto ampliada/deslocada */
    border-radius: 8px;
}
.pm-stage.pm-zoomed { cursor: grab; }
.pm-stage.pm-grabbing { cursor: grabbing; }
.pm-zoom {
    position: relative;
    display: inline-block;
    transform-origin: 0 0;
    will-change: transform;
}
.pm-photo {
    display: block;
    max-width: 100%;
    max-height: 72vh;
    width: auto;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}
.pm-markers {
    position: absolute;
    inset: 0;
}
.pm-marker {
    position: absolute;
    /* Contra-escala pelo nível de zoom → o marcador mantém ~30px na tela */
    transform: translate(-50%, -50%) scale(calc(1 / var(--pmz, 1)));
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid #fff;
    background: var(--accent-primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.5);
    transition: transform 0.08s ease;
}
.pm-marker:hover {
    transform: translate(-50%, -50%) scale(calc(1.18 / var(--pmz, 1)));
    z-index: 5;
}

/* Controles de zoom (canto inferior direito) */
.pm-zoomctl {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 20;
}
.pm-zbtn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(15, 20, 30, 0.85);
    color: #e2e8f0;
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.pm-zbtn:hover { border-color: var(--accent-secondary); color: #fff; }
/* Cor do marcador por nível de alarme (ao vivo) */
.pm-marker.ok   { background: var(--color-normal); }
.pm-marker.warn { background: var(--color-warning); }
.pm-marker.crit { background: var(--color-critical); }
.pm-marker.off  { background: #6b7280; }
/* Crítico pulsa suavemente */
.pm-marker.crit { animation: pmPulse 1.2s ease-in-out infinite; }
@keyframes pmPulse {
    0%, 100% { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 0 0 0 rgba(239, 68, 68, 0.6); }
    50%      { box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.45), 0 0 0 8px rgba(239, 68, 68, 0); }
}

.pm-tooltip {
    position: absolute;
    transform: translate(-50%, -100%);
    background: rgba(15, 20, 30, 0.95);
    border: 1px solid rgba(0, 188, 212, 0.4);
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.8rem;
    line-height: 1.3;
    color: #e2e8f0;
    white-space: nowrap;
    pointer-events: none;
    z-index: 50;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.pm-legend {
    margin-top: 12px;
    display: flex;
    gap: 16px;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.82rem;
}
.pm-leg-item { display: inline-flex; align-items: center; gap: 5px; }
.pm-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.pm-dot.ok   { background: var(--color-normal); }
.pm-dot.warn { background: var(--color-warning); }
.pm-dot.crit { background: var(--color-critical); }
.pm-dot.off  { background: #6b7280; }
.pm-leg-count { opacity: 0.7; }

.pm-tt-sub { color: #94a3b8; font-size: 0.74rem; }

/* ── Editor do Mapa do Painel (admin) ───────────────────────── */
.pm-editbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.pm-ebtn {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    padding: 7px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.pm-ebtn:hover { border-color: var(--accent-secondary); color: #fff; }
.pm-ebtn.primary {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: #fff;
}
.pm-ebtn.primary:hover { filter: brightness(1.1); }
.pm-edit-hint { color: var(--text-muted); font-size: 0.8rem; margin-right: auto; }
.pm-dirty { color: var(--color-warning); font-size: 0.8rem; font-weight: 600; }

.pm-imgtab-wrap { display: inline-flex; align-items: center; }
.pm-imgtab-del {
    background: transparent;
    border: none;
    color: var(--color-critical);
    font-size: 1.1rem;
    line-height: 1;
    cursor: pointer;
    padding: 0 6px;
}
.pm-imgtab-del:hover { color: #fff; }

.pm-label-edit {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.pm-label-edit label { color: var(--text-muted); font-size: 0.82rem; }
.pm-label-edit input {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: 0.85rem;
    min-width: 220px;
}

.pm-editing .pm-marker { cursor: grab; }

.pm-tray {
    margin-top: 14px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.pm-tray-title { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 8px; }
.pm-tray-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.pm-tray-empty { color: var(--text-muted); font-size: 0.82rem; }
.pm-chip {
    min-width: 30px;
    height: 30px;
    border-radius: 15px;
    border: 1px solid var(--accent-secondary);
    background: rgba(0, 188, 212, 0.12);
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: grab;
    padding: 0 8px;
}
.pm-chip:hover { background: rgba(0, 188, 212, 0.25); color: #fff; }
.pm-chip-ghost {
    position: fixed;
    transform: translate(-50%, -50%);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--accent-secondary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

/* Popover de posicionar/editar marcador */
.pm-menu {
    position: fixed;
    transform: translate(-50%, 8px);
    background: #1a2332;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    z-index: 9999;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.6);
    min-width: 180px;
}
.pm-menu-title { color: var(--text-muted); font-size: 0.78rem; margin-bottom: 8px; }
.pm-menu-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 260px; max-height: 180px; overflow-y: auto; }
.pm-menu-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.pm-menu-row label { color: var(--text-muted); font-size: 0.82rem; }
.pm-menu-row select {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.82rem;
    flex: 1;
}
.pm-menu-del {
    width: 100%;
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid var(--color-critical);
    color: #f87171;
    border-radius: 6px;
    padding: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
}
.pm-menu-del:hover { background: rgba(239, 68, 68, 0.25); color: #fff; }

/* Coluna lateral de nomes (consulta rápida) */
.pm-main {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    flex-wrap: wrap;
}
.pm-main .pm-stage-wrap { margin: 0; }
.pm-sidelist {
    flex: 0 0 210px;
    max-width: 240px;
    min-width: 170px;
}
.pm-sidelist-title {
    color: var(--text-muted);
    font-size: 0.8rem;
    margin-bottom: 8px;
}
.pm-sidelist-items {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 72vh;
    overflow-y: auto;
}
.pm-side-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0.85rem;
}
.pm-side-item.clickable { cursor: pointer; }
.pm-side-item.clickable:hover { background: var(--bg-tertiary); }
.pm-side-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    background: #6b7280;
}
.pm-side-dot.ok   { background: var(--color-normal); }
.pm-side-dot.warn { background: var(--color-warning); }
.pm-side-dot.crit { background: var(--color-critical); }
.pm-side-dot.off  { background: #6b7280; }
.pm-side-num { font-weight: 700; color: #e2e8f0; min-width: 18px; }
.pm-side-name {
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pm-side-empty { color: var(--text-muted); font-size: 0.82rem; padding: 6px 8px; }

/* ── Modal "Detalhe do Alarme" ─────────────────────────────── */
.alarmdetail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    padding: 20px;
}
.alarmdetail-modal {
    background: #1a2332;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 760px;
    max-width: 96vw;
    max-height: 92vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
}
.ad-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 700;
    color: #fff;
    background: rgba(239, 68, 68, 0.10);
}
.ad-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
}
.ad-close:hover { color: #fff; }
.ad-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 18px;
}
.ad-imgcol { display: flex; flex-direction: column; gap: 6px; }
.ad-img-title { font-size: 0.82rem; color: var(--text-muted); }
.ad-heatmap {
    width: 100%;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: #fff;
}
#adPanelCrop {
    width: 100%;
    height: auto;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}
.ad-img-missing {
    color: var(--text-muted);
    font-size: 0.82rem;
    padding: 18px;
    text-align: center;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
}
.ad-data {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 8px 18px;
}
.ad-row {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 0.88rem;
}
.ad-row span { color: var(--text-muted); }
.ad-row b { color: #e2e8f0; }
.ad-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--border-color);
}
.ad-msg { color: var(--color-warning); font-size: 0.82rem; margin-right: auto; }
.ad-reset {
    padding: 7px 18px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid var(--color-critical);
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}
.ad-reset:hover:not([disabled]) { background: rgba(239, 68, 68, 0.30); color: #fff; }
.ad-reset[disabled] {
    cursor: not-allowed;
    opacity: 0.55;
    border-color: var(--border-color);
    background: transparent;
    color: var(--text-muted);
}
.alm-btn-detail {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: #e2e8f0;
    padding: 3px 9px;
    border-radius: 5px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    margin-right: 6px;
}
.alm-btn-detail:hover { border-color: var(--accent-secondary); color: #fff; }

@media (max-width: 640px) {
    .ad-body { grid-template-columns: 1fr; }
}


/* ==================================================================
   MODO ORGANIZAR — arrasto dos cards na Visão Geral (card_order.js)
   Ativo apenas enquanto o botão "Organizar" está ligado.
   ================================================================== */
.equipment-grid.organizing .equipment-card {
    cursor: grab;
    border-style: dashed;
    border-color: var(--accent-primary);
    user-select: none;
}

.equipment-grid.organizing .equipment-card:hover {
    transform: none;              /* sem "pulo" no hover durante o arrasto */
}

.equipment-grid.organizing .equipment-card:active {
    cursor: grabbing;
}

.equipment-grid.organizing .equipment-card.dragging {
    opacity: 0.45;
    box-shadow: var(--shadow-lg);
}
