:root {
    --primary: #1a73e8;
    --primary-dark: #1558b0;
    --success: #34a853;
    --danger: #ea4335;
    --warning: #fbbc04;
    --muted: #6c757d;
    --bg: #f0f2f5;
    --card: #ffffff;
    --border: #e0e0e0;
    --text: #202124;
    --text-light: #5f6368;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.10);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.13);
    --nav-h: 60px;
    --bottom-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    min-height: 100vh;
}

/* ── TOP NAV ── */
.topnav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--nav-h);
    background: var(--primary);
    display: flex;
    align-items: center;
    padding: 0 16px;
    z-index: 100;
    gap: 12px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}
.topnav .logo {
    color: #fff;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: .5px;
    flex: 1;
}
.topnav .nav-icon {
    color: rgba(255,255,255,0.85);
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    text-decoration: none;
    display: flex;
    align-items: center;
    transition: background .2s;
}
.topnav .nav-icon:hover { background: rgba(255,255,255,0.15); }

/* ── BOTTOM NAV ── */
.bottomnav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-h);
    background: #fff;
    border-top: 1px solid var(--border);
    display: flex;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.07);
}
.bottomnav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    text-decoration: none;
    font-size: 10px;
    gap: 3px;
    padding: 6px 0 8px;
    border-top: 3px solid transparent;
    transition: all .2s;
}
.bottomnav a .icon { font-size: 22px; }
.bottomnav a.active {
    color: var(--primary);
    border-top-color: var(--primary);
}

/* ── PAGE WRAP ── */
.page {
    padding: calc(var(--nav-h) + 16px) 16px calc(var(--bottom-h) + 16px);
    max-width: 600px;
    margin: 0 auto;
}

/* ── CARDS ── */
.card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 14px;
}
.card-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 10px;
}

/* ── STAT GRID ── */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 14px;
}
.stat-box {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-box .num {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
}
.stat-box .lbl {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}
.stat-box.online .num { color: var(--success); }
.stat-box.offline .num { color: var(--danger); }
.stat-box.total .num { color: var(--primary); }

/* ── DEVICE LIST ITEM ── */
.device-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
}
.device-item:last-child { border-bottom: none; }
.device-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}
.device-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(52,168,83,.2); }
.device-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(234,67,53,.2); }
.device-dot.disabled { background: var(--muted); }
.device-info { flex: 1; min-width: 0; }
.device-name {
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-addr {
    font-size: 12px;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.device-meta {
    font-size: 12px;
    color: var(--text-light);
    text-align: right;
    flex-shrink: 0;
}
.device-chevron { color: var(--border); font-size: 18px; flex-shrink: 0; }

/* ── STATUS BADGE ── */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-online { background: #e6f4ea; color: var(--success); }
.badge-offline { background: #fce8e6; color: var(--danger); }
.badge-disabled { background: #fdecea; color: #c62828; }
.badge-running { background: #e8f0fe; color: var(--primary); }
.badge-stopped { background: #f1f3f4; color: var(--muted); }
.badge-inicio { background: #fff8e1; color: #f57f17; }

/* Grid de estados (dashboard) */
.state-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    padding: 4px 0;
}
.state-cell {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
}
.state-cell .state-icon { font-size: 18px; line-height: 1; margin-bottom: 4px; }
.state-cell .state-num  { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--text); }
.state-cell .state-lbl  { font-size: 11px; color: var(--text-light); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.state-cell[data-state="running"]  .state-num { color: var(--primary); }
.state-cell[data-state="inicio"]   .state-num { color: #f57f17; }
.state-cell[data-state="stopped"]  .state-num { color: var(--muted); }
.state-cell[data-state="disabled"] .state-num { color: #c62828; }

/* Senha com botão de mostrar/ocultar */
.pwd-wrap { position: relative; }
.pwd-wrap input { padding-right: 42px; }
.pwd-toggle {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: var(--text-light);
    padding: 6px 8px;
    line-height: 1;
    border-radius: 6px;
}
.pwd-toggle:hover { color: var(--primary); background: rgba(26,115,232,0.08); }
.pwd-toggle:active { transform: translateY(-50%) scale(0.95); }

/* ── FORMS ── */
.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    margin-bottom: 5px;
}
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    background: #fafafa;
    color: var(--text);
    transition: border .2s;
    outline: none;
}
.form-control:focus { border-color: var(--primary); background: #fff; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ── BUTTONS ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all .2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--text);
}
.btn-block { width: 100%; }
.btn-sm { padding: 7px 14px; font-size: 13px; }

/* ── TOGGLE SWITCH ── */
.toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 0;
}
.toggle-label { font-size: 16px; font-weight: 600; }
.toggle-sublabel { font-size: 13px; color: var(--text-light); }
.toggle {
    position: relative;
    width: 60px;
    height: 32px;
    flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 32px;
    cursor: pointer;
    transition: background .3s;
}
.toggle-slider:before {
    content: '';
    position: absolute;
    width: 26px; height: 26px;
    left: 3px; top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider:before { transform: translateX(28px); }
.toggle input:disabled + .toggle-slider { opacity: .5; cursor: not-allowed; }

/* ── COMMAND STATUS ── */
.cmd-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 20px;
    background: #f1f3f4;
    color: var(--text-light);
}
.cmd-status.requested { background: #fff3cd; color: #856404; }
.cmd-status.processing { background: #cfe2ff; color: #084298; }
.cmd-status.done { background: #d1e7dd; color: #0f5132; }

/* ── INFO ROWS ── */
.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.info-row:last-child { border-bottom: none; }
.info-row .key { color: var(--text-light); font-size: 13px; }
.info-row .val { font-weight: 600; }

/* ── SEARCH ── */
.search-wrap {
    position: relative;
    margin-bottom: 14px;
}
.search-wrap .search-icon {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 18px;
}
.search-wrap .form-control { padding-left: 40px; }

/* ── LOGIN PAGE ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    background: linear-gradient(135deg, #1a73e8 0%, #0d47a1 100%);
}
.login-box {
    background: #fff;
    border-radius: 18px;
    padding: 32px 24px;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 28px;
}
.login-logo h1 { font-size: 28px; color: var(--primary); font-weight: 800; }
.login-logo p { color: var(--text-light); font-size: 14px; margin-top: 4px; }

/* ── ALERT ── */
.alert {
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 14px;
}
.alert-danger { background: #fce8e6; color: var(--danger); border: 1px solid #f5c2c0; }
.alert-success { background: #e6f4ea; color: var(--success); border: 1px solid #b7dfbf; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #fde68a; }

/* ── WIFI SIGNAL ── */
.wifi-bar { display: flex; gap: 3px; align-items: flex-end; }
.wifi-bar span {
    width: 6px;
    background: var(--border);
    border-radius: 2px;
    display: block;
}
.wifi-bar span:nth-child(1) { height: 6px; }
.wifi-bar span:nth-child(2) { height: 10px; }
.wifi-bar span:nth-child(3) { height: 14px; }
.wifi-bar span:nth-child(4) { height: 18px; }
.wifi-bar.s4 span { background: var(--success); }
.wifi-bar.s3 span:not(:last-child) { background: var(--success); }
.wifi-bar.s2 span:not(:nth-child(n+3)) { background: var(--warning); }
.wifi-bar.s1 span:first-child { background: var(--danger); }
.wifi-bar.s0 span { background: var(--border); }

/* ── OFFLINE ALERT ITEM ── */
.offline-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}
.offline-item:last-child { border-bottom: none; }
.offline-time { font-size: 12px; color: var(--danger); font-weight: 600; }

/* ── EMPTY STATE ── */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-light);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── PULSE DOT ANIMATION ── */
@keyframes pulse-anim {
    0% { box-shadow: 0 0 0 0 rgba(52,168,83,.4); }
    70% { box-shadow: 0 0 0 8px rgba(52,168,83,0); }
    100% { box-shadow: 0 0 0 0 rgba(52,168,83,0); }
}
.device-dot.online { animation: pulse-anim 2s infinite; }

/* ── LOADING SPINNER ── */
.spinner {
    width: 20px; height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DEVICE HEADER ── */
.device-header {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 4px 0 16px;
}
.device-header .dot-lg {
    width: 18px; height: 18px;
    border-radius: 50%;
    flex-shrink: 0;
}
.device-header .dot-lg.online { background: var(--success); animation: pulse-anim 2s infinite; }
.device-header .dot-lg.offline { background: var(--danger); }
.device-header .dot-lg.disabled { background: var(--muted); }
.device-header h2 { font-size: 20px; font-weight: 700; line-height: 1.2; }
.device-header .city { font-size: 13px; color: var(--text-light); }

/* ── FAB ── */
.fab {
    position: fixed;
    right: 20px;
    bottom: calc(var(--bottom-h) + 16px);
    width: 54px; height: 54px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    text-decoration: none;
    border: none;
    cursor: pointer;
    z-index: 90;
    transition: background .2s, transform .2s;
}
.fab:hover { background: var(--primary-dark); transform: scale(1.06); }

/* ── SECTION TITLE ── */
.section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .7px;
    margin-bottom: 8px;
    margin-top: 18px;
}
.section-title:first-child { margin-top: 0; }

/* ── CU TAG ── */
.cu-tag {
    font-family: monospace;
    background: #f1f3f4;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 13px;
}

@media (max-width: 400px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-grid .stat-box:last-child { grid-column: 1 / -1; }
}

/* ── FILTER CHIPS ── */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px;
    -webkit-overflow-scrolling: touch;
}
.filter-chips .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: var(--card);
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    text-decoration: none;
    white-space: nowrap;
    transition: all .15s;
}
.filter-chips .chip:hover { border-color: var(--primary); color: var(--primary); }
.filter-chips .chip.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.filter-chips .chip-cnt {
    background: rgba(0,0,0,0.08);
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    font-weight: 700;
}
.filter-chips .chip.active .chip-cnt { background: rgba(255,255,255,0.25); }

/* ── ALERT/MINI-ITEM (dashboard widgets) ── */
.alert-block { border-left: 3px solid var(--warning); }
.alert-block .kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-light);
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
}
.alert-block .kv-row:last-of-type { border-bottom: none; }
.alert-block .mini-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px dashed var(--border);
    font-size: 13px;
}
.alert-block .mini-item:last-child { border-bottom: none; }
.alert-block .mini-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-right: 8px;
}
.alert-block .mini-tag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 600;
    white-space: nowrap;
}

/* ── FW PILL (badge "atualização disponível" no nome do device) ── */
.fw-pill {
    display: inline-block;
    margin-left: 6px;
    font-size: 10px;
    background: #fff3cd;
    color: #856404;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 700;
    vertical-align: middle;
}

/* ── WHATSAPP RECIPIENT ROW (settings) ── */
.wa-recipient {
    border: 1.5px solid var(--border);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 12px;
    background: #fafafa;
    position: relative;
}
.wa-recipient.wa-disabled { opacity: .6; }
.wa-recipient .wa-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}
.wa-recipient .wa-label-input {
    font-weight: 700;
    font-size: 14px;
    background: transparent;
    border: none;
    padding: 4px 0;
    flex: 1;
    color: var(--text);
    outline: none;
    border-bottom: 1.5px dashed transparent;
}
.wa-recipient .wa-label-input:focus { border-bottom-color: var(--primary); }
.wa-recipient .wa-actions { display: flex; gap: 6px; }
.wa-recipient .wa-actions button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 18px;
    padding: 4px 6px;
    border-radius: 6px;
    color: var(--text-light);
}
.wa-recipient .wa-actions button:hover { background: rgba(0,0,0,0.06); color: var(--danger); }
.wa-alerts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.wa-alerts-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
}
.wa-alerts-grid label input[type=checkbox] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: var(--primary);
}
.wa-add-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 2px dashed var(--border);
    border-radius: 12px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 12px;
    transition: all .15s;
}
.wa-add-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ── FIRMWARE SUGGESTION BOX (device_edit) ── */
.fw-suggest-box {
    background: linear-gradient(135deg, #e3f2fd 0%, #f1f8ff 100%);
    border: 1.5px solid #1a73e8;
    border-radius: 12px;
    padding: 14px 16px;
    margin-bottom: 14px;
    position: relative;
    overflow: hidden;
}
.fw-suggest-box::before {
    content: "";
    position: absolute;
    top: -20px; right: -20px;
    width: 80px; height: 80px;
    background: radial-gradient(circle, rgba(26,115,232,0.18), transparent);
    border-radius: 50%;
}
.fw-suggest-box h4 {
    font-size: 14px;
    font-weight: 700;
    color: #1558b0;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.fw-suggest-box .ver-flow {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    margin: 6px 0 10px;
}
.fw-suggest-box .ver-pill {
    font-family: monospace;
    background: #fff;
    border: 1px solid #c8d7e8;
    border-radius: 6px;
    padding: 2px 8px;
    font-weight: 600;
}
.fw-suggest-box .ver-flow .arrow { color: var(--primary); font-weight: 700; }
.fw-suggest-box .ver-pill.new { background: #1a73e8; color: #fff; border-color: #1558b0; }
.fw-suggest-box .filename {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-light);
    background: rgba(255,255,255,0.6);
    padding: 4px 8px;
    border-radius: 6px;
    margin-bottom: 10px;
    display: inline-block;
    word-break: break-all;
}
.fw-suggest-box .fw-apply-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    font-size: 13px;
}
.fw-suggest-box .fw-apply-btn:hover { background: var(--primary-dark); }

/* version badge (settings/info) */
.version-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 12px;
    letter-spacing: .3px;
}

/* ═══════════════════════════════════════════════════════════════════
   DASHBOARD v1.6 — Rich device cards, fleet metrics, time bar
   ═══════════════════════════════════════════════════════════════════ */

/* Métricas agregadas da frota */
.fleet-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}
.fleet-metrics .fm-cell {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 8px;
    text-align: center;
}
.fleet-metrics .fm-label {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 4px;
}
.fleet-metrics .fm-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}
@media (max-width: 480px) {
    .fleet-metrics { grid-template-columns: 1fr 1fr; }
}

/* Card detalhado de dispositivo (usado no painel de status do device_edit) */
.device-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow);
    border-left: 4px solid var(--border);
    transition: transform .15s, box-shadow .15s;
}
.device-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); }
.device-card.online  { border-left-color: var(--success); }
.device-card.offline { border-left-color: var(--danger); }
.device-card[data-state="running"]  { border-left-color: var(--success); }
.device-card[data-state="inicio"]   { border-left-color: var(--warning); }
.device-card[data-state="stopped"]  { border-left-color: var(--muted); }
.device-card[data-state="disabled"] { border-left-color: #c62828; }

.device-card .dc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 6px;
}
.device-card .dc-id {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.device-card .dc-dot {
    width: 12px; height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 5px;
}
.device-card .dc-dot.online  { background: var(--success); box-shadow: 0 0 0 3px rgba(52,168,83,.2); animation: pulse-anim 2s infinite; }
.device-card .dc-dot.offline { background: var(--danger); box-shadow: 0 0 0 3px rgba(234,67,53,.2); }
.device-card .dc-titles { flex: 1; min-width: 0; }
.device-card .dc-name {
    display: block;
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.device-card .dc-name:hover { color: var(--primary); }
.device-card .dc-sub {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
}
.device-card .dc-status { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.device-card .dc-status-row {
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-end;
}
.device-card .dc-status-row .toggle {
    width: 44px;
    height: 24px;
}
.device-card .dc-status-row .toggle-slider:before {
    width: 18px; height: 18px;
    left: 3px; top: 3px;
}
.device-card .dc-status-row input:checked + .toggle-slider:before {
    transform: translateX(20px);
}
.device-card .dc-status-time {
    font-size: 11px;
    color: var(--text-light);
}
.device-card .dc-cmd-pill { margin-top: 2px; }
.device-card .dc-cmd-pill .cmd-status { font-size: 11px; padding: 3px 8px; }
.device-card .dc-addr {
    font-size: 12px;
    color: var(--text-light);
    padding: 4px 0 10px;
    border-bottom: 1px dashed var(--border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Grade de métricas dentro do card */
.dc-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin: 10px 0;
}
.dc-metric {
    background: #fafafa;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
}
.dc-m-label {
    font-size: 9px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
    margin-bottom: 4px;
}
.dc-m-value {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dc-m-value.on  { color: var(--success); }
.dc-m-value.off { color: var(--danger); }
.dc-m-sub {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Barra de tempo segmentada */
.dc-timebar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg);
    margin-top: 10px;
}
.dc-timebar .seg { display: block; height: 100%; }
.dc-timebar .seg-running  { background: var(--success); }
.dc-timebar .seg-inicio   { background: var(--warning); }
.dc-timebar .seg-stopped  { background: var(--muted); }
.dc-timebar .seg-disabled { background: #c62828; }

.dc-timebar-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 10px;
    color: var(--text-light);
    flex-wrap: wrap;
    gap: 4px;
}
.dc-timebar-legend span { display: inline-flex; align-items: center; gap: 4px; }
.dc-timebar-legend i {
    display: inline-block;
    width: 8px; height: 8px;
    border-radius: 2px;
}
.dc-timebar-legend i.lg-running  { background: var(--success); }
.dc-timebar-legend i.lg-inicio   { background: var(--warning); }
.dc-timebar-legend i.lg-stopped  { background: var(--muted); }
.dc-timebar-legend i.lg-disabled { background: #c62828; }

/* ── Firmware OTA compacto (meta 3 colunas + action row) ── */
.fw-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 8px;
}
.fw-meta-cell {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 6px;
    text-align: center;
    min-height: 56px;
}
.fw-meta-label {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 3px;
}
.fw-meta-value {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.1;
}
.fw-meta-sub {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.fw-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 8px;
}
.fw-action-row .cfg-cell:only-child { grid-column: 1 / -1; }
@media (max-width: 420px) {
    .fw-meta { grid-template-columns: 1fr; }
}

/* Tabela "Pulsos acumulados por estado" no painel de status */
.state-pulses-table {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
}
.state-pulses-table .spt-head {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .5px;
    font-weight: 600;
    margin-bottom: 6px;
}
.state-pulses-table .spt-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
}
.state-pulses-table .spt-cell {
    background: #fafafa;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 4px;
    text-align: center;
}
.state-pulses-table .spt-icon { font-size: 14px; line-height: 1; }
.state-pulses-table .spt-label {
    font-size: 10px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-top: 2px;
}
.state-pulses-table .spt-num {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-top: 4px;
    line-height: 1.1;
}
.state-pulses-table .spt-sub {
    font-size: 10px;
    color: var(--text-light);
    margin-top: 2px;
}
.state-pulses-table .spt-cell[data-state="running"]  .spt-num { color: var(--success); }
.state-pulses-table .spt-cell[data-state="inicio"]   .spt-num { color: #f57f17; }
.state-pulses-table .spt-cell[data-state="stopped"]  .spt-num { color: var(--muted); }
.state-pulses-table .spt-cell[data-state="disabled"] .spt-num { color: #c62828; }
@media (max-width: 420px) {
    .state-pulses-table .spt-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Ações no rodapé do card */
.dc-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}
.dc-actions .dc-btn {
    flex: 1;
    text-align: center;
    padding: 7px;
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all .15s;
}
.dc-actions .dc-btn:hover {
    background: var(--card);
    border-color: var(--primary);
    color: var(--primary);
}

