﻿:root {
    --bg: #06111f;
    --bg2: #071a2f;
    --panel: rgba(13, 31, 52, .92);
    --panel2: rgba(16, 39, 65, .95);
    --line: rgba(120, 180, 255, .18);
    --text: #e8f2ff;
    --muted: #90a6bf;
    --blue: #1e90ff;
    --cyan: #18d4d8;
    --green: #31d158;
    --yellow: #ffbd2e;
    --orange: #ff8a00;
    --red: #ff453a;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    background: radial-gradient(circle at top left, #0d2a48 0, #06111f 36%, #030914 100%);
    color: var(--text);
    font-family: "Segoe UI", "Microsoft JhengHei", Arial, sans-serif;
}

.syswatch-shell {
    display: flex;
    min-height: 100vh;
}

/* sidebar */
.syswatch-sidebar {
    width: 260px;
    flex: 0 0 260px;
    min-height: 100vh;
    padding: 22px 18px;
    background: linear-gradient(180deg, rgba(5, 19, 35, .98), rgba(6, 17, 31, .96));
    border-right: 1px solid var(--line);
    position: sticky;
    top: 0;
}

.brand-box {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 32px;
}

.brand-icon {
    width: 38px;
    height: 38px;
    border: 2px solid var(--blue);
    border-radius: 8px;
    display: grid;
    place-items: center;
    color: var(--blue);
    box-shadow: 0 0 18px rgba(30, 144, 255, .35);
}

.brand-title {
    font-size: 27px;
    font-weight: 800;
    line-height: 1;
}

.brand-subtitle {
    font-size: 12px;
    color: #c6d7e8;
    margin-top: 6px;
}

.side-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.side-link {
    height: 58px;
    border-radius: 8px;
    padding: 0 18px;
    display: flex;
    gap: 16px;
    align-items: center;
    color: #dce9f7;
    text-decoration: none;
    position: relative;
}

    .side-link span {
        font-size: 24px;
        color: #cbd8e9;
    }

    .side-link b {
        font-size: 18px;
        font-weight: 600;
    }

    .side-link.active {
        background: linear-gradient(90deg, rgba(0, 135, 255, .28), rgba(0, 135, 255, .08));
        color: #26a8ff;
        border-left: 3px solid var(--blue);
    }

        .side-link.active span {
            color: #26a8ff;
        }

    .side-link em {
        margin-left: auto;
        min-width: 26px;
        height: 26px;
        border-radius: 50%;
        background: var(--red);
        color: #fff;
        font-style: normal;
        display: grid;
        place-items: center;
        font-size: 14px;
        font-weight: 800;
    }

.sidebar-bottom {
    position: absolute;
    left: 18px;
    right: 18px;
    bottom: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.system-card,
.time-card {
    border: 1px solid var(--line);
    background: rgba(13, 31, 52, .72);
    border-radius: 14px;
    padding: 16px;
    display: flex;
    gap: 12px;
    color: #cbd8e9;
}

.green-dot {
    width: 14px;
    height: 14px;
    background: var(--green);
    border-radius: 50%;
    margin-top: 3px;
    box-shadow: 0 0 12px rgba(49, 209, 88, .55);
}

    .green-dot.small {
        display: inline-block;
        width: 11px;
        height: 11px;
        margin: 0 6px 0 0;
        vertical-align: middle;
    }

.system-title {
    font-size: 12px;
    color: #c7d6e9;
}

.system-ok {
    color: #62ff5f;
    font-size: 16px;
    font-weight: 700;
    margin-top: 8px;
}

.system-note {
    margin-top: 10px;
    color: #9dafc4;
}

/* main */
.syswatch-main {
    flex: 1;
    padding: 22px 26px 30px;
    overflow-x: hidden;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    align-items: flex-start;
    margin-bottom: 18px;
}

.page-title-row {
    display: flex;
    align-items: flex-start;
    gap: 18px;
}

.hamburger {
    background: transparent;
    border: 0;
    color: #fff;
    font-size: 26px;
    padding: 4px 0;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
}

.topbar p {
    margin: 6px 0 0;
    color: #b4c6dc;
}

.top-actions {
    display: flex;
    gap: 18px;
    align-items: center;
}

.search-box {
    width: 310px;
    height: 48px;
    border: 1px solid var(--line);
    background: rgba(6, 17, 31, .8);
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 0 14px;
}

    .search-box input,
    .device-tools input {
        flex: 1;
        min-width: 0;
        background: transparent;
        border: 0;
        outline: none;
        color: #fff;
    }

    .search-box span {
        color: #cfe4ff;
        font-size: 24px;
    }

.bell {
    position: relative;
    font-size: 24px;
}

    .bell em {
        position: absolute;
        right: -9px;
        top: -8px;
        min-width: 20px;
        height: 20px;
        border-radius: 50%;
        background: var(--red);
        color: #fff;
        font-size: 12px;
        font-style: normal;
        display: grid;
        place-items: center;
    }

.user-box {
    display: flex;
    gap: 10px;
    align-items: center;
}

.avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-weight: 800;
    background: linear-gradient(135deg, #fff, #8fc7ff);
    color: #06111f;
}

.user-box strong {
    display: block;
}

.user-box span {
    color: #b7c8dc;
    font-size: 13px;
}

/* KPI */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(150px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.kpi-card {
    min-height: 110px;
    padding: 18px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: var(--panel);
    display: flex;
    gap: 16px;
    align-items: center;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .22);
}

.kpi-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    font-size: 25px;
    font-weight: 800;
    color: #fff;
}

    .kpi-icon.blue {
        background: linear-gradient(135deg, #1152ff, #28a8ff);
    }

    .kpi-icon.red {
        background: linear-gradient(135deg, #ca1f2d, #ff5b5b);
    }

    .kpi-icon.cyan {
        background: linear-gradient(135deg, #079aa7, #28dbdf);
    }

    .kpi-icon.green {
        background: linear-gradient(135deg, #11893d, #35d36d);
    }

    .kpi-icon.orange {
        background: linear-gradient(135deg, #9f5400, #ff9d1a);
    }

.kpi-card span {
    display: block;
    color: #d1e0f0;
    font-weight: 700;
    font-size: 14px;
}

.kpi-card strong {
    display: block;
    font-size: 30px;
    line-height: 1.1;
    margin: 6px 0;
}

.kpi-card small,
.up {
    color: var(--green);
}

.down {
    color: var(--red);
}

.warn {
    color: var(--orange);
}

/* panels */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.4fr 1.15fr .9fr;
    gap: 16px;
}

.panel {
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .2);
}

    .panel h2 {
        margin: 0;
        font-size: 17px;
        font-weight: 800;
    }

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

    .panel-head select,
    .device-tools button {
        background: rgba(6, 17, 31, .7);
        border: 1px solid var(--line);
        color: #dbeaff;
        border-radius: 7px;
        height: 32px;
        padding: 0 10px;
    }

.panel canvas {
    width: 100% !important;
}

.chart-large canvas {
    height: 210px !important;
}

.chart-mid canvas {
    height: 210px !important;
}

.status-panel {
    grid-row: span 1;
}

.donut-wrap {
    display: flex;
    align-items: center;
    gap: 18px;
}

.status-panel canvas {
    width: 170px !important;
    height: 170px !important;
}

.status-legend {
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: #d8e6f7;
}

    .status-legend b {
        display: block;
        margin-left: 18px;
    }

.dot,
.status {
    display: inline-block;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    margin-right: 7px;
}

    .online,
    .status.online {
        background: var(--green);
    }

    .warning,
    .status.warning {
        background: var(--yellow);
    }

    .offline,
    .status.offline {
        background: var(--red);
    }

.alerts-panel {
    min-height: 245px;
}

.alert-row {
    display: grid;
    grid-template-columns: 24px 1fr 75px 72px;
    gap: 10px;
    align-items: center;
    padding: 9px 0;
    border-bottom: 1px solid rgba(120, 180, 255, .1);
}

    .alert-row strong {
        display: block;
        font-size: 14px;
    }

    .alert-row small {
        color: #a9bfd5;
    }

    .alert-row time {
        color: #cbd8e9;
        font-size: 13px;
    }

.alert-icon.critical {
    color: var(--red);
}

.alert-icon.warning {
    color: var(--orange);
}

.alert-icon.info {
    color: var(--blue);
}

.badge-critical,
.badge-warning,
.badge-info {
    font-style: normal;
    border-radius: 5px;
    text-align: center;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: 700;
}

.badge-critical {
    background: rgba(255, 69, 58, .18);
    color: var(--red);
}

.badge-warning {
    background: rgba(255, 189, 46, .18);
    color: var(--yellow);
}

.badge-info {
    background: rgba(30, 144, 255, .18);
    color: var(--blue);
}

.right-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.mini-panel {
    min-height: 114px;
    display: grid;
    grid-template-columns: 1fr 140px;
    align-items: center;
}

    .mini-panel strong {
        font-size: 30px;
        display: block;
        margin: 10px 0 3px;
    }

    .mini-panel canvas {
        height: 70px !important;
    }

/* device table */
.device-panel {
    margin-top: 16px;
}

.device-tools {
    display: flex;
    gap: 8px;
    align-items: center;
}

    .device-tools input {
        width: 260px;
        height: 34px;
        padding: 0 12px;
        border: 1px solid var(--line);
        background: rgba(6, 17, 31, .7);
        border-radius: 7px;
    }

.device-table {
    width: 100%;
    border-collapse: collapse;
    color: #dce9f7;
}

    .device-table th {
        color: #aebed2;
        font-size: 13px;
        font-weight: 700;
        padding: 10px 14px;
        border-bottom: 1px solid rgba(120, 180, 255, .14);
    }

    .device-table td {
        padding: 9px 14px;
        border-bottom: 1px solid rgba(120, 180, 255, .09);
        vertical-align: middle;
    }

.bar {
    display: inline-block;
    width: 110px;
    height: 6px;
    margin-left: 8px;
    background: rgba(150, 180, 220, .14);
    border-radius: 99px;
    overflow: hidden;
    vertical-align: middle;
}

    .bar span {
        display: block;
        height: 100%;
        border-radius: 99px;
    }

    .bar .danger {
        background: var(--red);
    }

    .bar .warning {
        background: var(--orange);
    }

    .bar .normal {
        background: var(--blue);
    }

    .bar .ok {
        background: var(--green);
    }

@media (max-width: 1400px) {
    .kpi-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
    }

    .right-stack {
        grid-column: span 2;
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 992px) {
    .syswatch-shell {
        display: block;
    }

    .syswatch-sidebar {
        position: relative;
        width: 100%;
        min-height: auto;
    }

    .sidebar-bottom {
        position: relative;
        left: auto;
        right: auto;
        bottom: auto;
        margin-top: 24px;
    }

    .topbar {
        flex-direction: column;
    }

    .kpi-grid,
    .dashboard-grid,
    .right-stack {
        grid-template-columns: 1fr;
    }

    .right-stack {
        grid-column: auto;
    }

    .top-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        width: 100%;
    }
}

.time-content {
    line-height: 1.45;
}

.time-date {
    font-size: 15px;
    color: #dce9f7;
    white-space: nowrap;
}

.time-clock {
    font-size: 24px;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: 1px;
    margin-top: 4px;
}

.time-zone {
    font-size: 13px;
    color: #93a9c2;
    margin-top: 2px;
    white-space: nowrap;
}

.system-dot-ok {
    background: var(--green);
    box-shadow: 0 0 12px rgba(49, 209, 88, .55);
}

.system-dot-warning {
    background: var(--yellow);
    box-shadow: 0 0 12px rgba(255, 189, 46, .55);
}

.system-dot-critical {
    background: var(--red);
    box-shadow: 0 0 12px rgba(255, 69, 58, .55);
}

.system-warning {
    color: var(--yellow);
    font-size: 16px;
    font-weight: 700;
    margin-top: 8px;
}

.system-critical {
    color: var(--red);
    font-size: 16px;
    font-weight: 700;
    margin-top: 8px;
}

/* ===== 第四刀 J：暫時隱藏未開放功能，保留 HTML 供日後啟用 ===== */

/* 上方搜尋、通知鈴鐺、使用者資訊先隱藏 */
.top-actions {
    display: none;
}

/* 側邊選單暫時只保留：儀表板 */
.side-menu .side-link:nth-child(2),
.side-menu .side-link:nth-child(3),
.side-menu .side-link:nth-child(4),
.side-menu .side-link:nth-child(5) {
    display: none;
}

/* =========================================================
   第六刀 A：手機版儀表板版面優化
   目標：
   1. 手機版卡片統一單欄
   2. 裝置清單不再被擠成直排
   3. 表格改為橫向捲動
   4. 圖表高度固定，避免手機版變形
   ========================================================= */

@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .syswatch-shell {
        display: block;
        width: 100%;
        min-width: 0;
    }

    .sidebar {
        position: relative;
        width: 100%;
        min-height: auto;
        padding: 26px 22px;
        border-right: none;
        border-bottom: 1px solid rgba(255, 255, 255, .08);
    }

    .brand {
        margin-bottom: 28px;
    }

    .side-menu {
        margin-bottom: 28px;
    }

    .side-link {
        height: 68px;
        padding: 0 22px;
        border-radius: 10px;
        font-size: 20px;
    }

    .sidebar-bottom {
        position: static;
        width: 100%;
        margin-top: 26px;
    }

    .system-card,
    .time-card {
        width: 100%;
        box-sizing: border-box;
        margin-top: 18px;
    }

    .main {
        width: 100%;
        padding: 28px 20px 36px;
        box-sizing: border-box;
    }

    .page-head {
        display: block;
        margin-bottom: 24px;
    }

    .page-title {
        display: flex;
        align-items: flex-start;
        gap: 16px;
    }

        .page-title h1 {
            font-size: 32px;
            line-height: 1.2;
            margin: 0;
        }

        .page-title p {
            font-size: 15px;
            margin-top: 8px;
        }

    .hamburger {
        flex: 0 0 auto;
        margin-top: 4px;
    }

    .top-actions {
        display: none !important;
    }

    .kpi-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .kpi-card {
        min-height: 142px;
        padding: 24px 22px;
        border-radius: 14px;
    }

        .kpi-card .icon-circle {
            width: 64px;
            height: 64px;
            flex: 0 0 64px;
        }

        .kpi-card strong {
            font-size: 34px;
            line-height: 1.1;
        }

        .kpi-card small {
            font-size: 15px;
            line-height: 1.5;
        }

    .dashboard-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 18px;
    }

    .panel {
        width: 100%;
        box-sizing: border-box;
        padding: 20px 18px;
        border-radius: 14px;
        overflow: hidden;
    }

    .panel-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        margin-bottom: 16px;
    }

        .panel-head h2,
        .panel h2 {
            font-size: 20px;
            line-height: 1.3;
            margin: 0;
            white-space: normal;
        }

        .panel-head select {
            max-width: 150px;
            height: 40px;
            font-size: 15px;
        }

    .chart-panel canvas {
        width: 100% !important;
        height: 250px !important;
    }

    .mini-panel {
        min-height: 150px;
    }

        .mini-panel strong {
            font-size: 34px;
        }

    .alerts-panel {
        min-height: 220px;
    }

    .alert-row {
        grid-template-columns: 18px 1fr;
        gap: 12px;
        align-items: flex-start;
    }

        .alert-row em,
        .alert-row time {
            margin-left: 30px;
        }

    /* 裝置清單手機版修正 */
    .device-panel {
        padding: 20px 18px;
        overflow: hidden;
    }

        .device-panel .panel-head {
            display: block;
            margin-bottom: 16px;
        }

            .device-panel .panel-head h2 {
                display: block;
                width: 100%;
                font-size: 20px;
                line-height: 1.3;
                white-space: nowrap;
                margin-bottom: 14px;
            }

    .device-tools {
        display: grid;
        grid-template-columns: 1fr auto auto;
        gap: 8px;
        width: 100%;
    }

        .device-tools input {
            width: 100%;
            min-width: 0;
            height: 42px;
            box-sizing: border-box;
        }

        .device-tools button {
            height: 42px;
            min-width: 54px;
            padding: 0 12px;
            white-space: nowrap;
        }

    .device-table-wrap {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
    }

    .device-table {
        min-width: 760px;
        width: 760px;
    }

        .device-table th,
        .device-table td {
            white-space: nowrap;
            font-size: 14px;
            padding: 12px 10px;
        }

            .device-table th:first-child,
            .device-table td:first-child {
                min-width: 150px;
            }

            .device-table th:nth-child(2),
            .device-table td:nth-child(2) {
                min-width: 90px;
                text-align: center;
            }

            .device-table th:nth-child(3),
            .device-table td:nth-child(3) {
                min-width: 70px;
                text-align: center;
            }

    .bar {
        min-width: 90px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        padding: 24px 18px;
    }

    .main {
        padding: 26px 16px 32px;
    }

    .brand h1 {
        font-size: 30px;
    }

    .side-link {
        font-size: 19px;
    }

    .page-title h1 {
        font-size: 30px;
    }

    .kpi-card {
        gap: 18px;
    }

    .panel {
        padding: 18px 16px;
    }

    .chart-panel canvas {
        height: 235px !important;
    }

    .device-tools {
        grid-template-columns: 1fr auto auto;
    }

        .device-tools input {
            font-size: 14px;
        }
}

/* =========================================================
   第六刀 C：CPU 溫度卡加入小折線圖
   ========================================================= */

.temperature-panel {
    grid-template-columns: 1fr 160px;
}

    .temperature-panel canvas {
        height: 76px !important;
    }

@media (max-width: 768px) {
    .temperature-panel {
        display: grid;
        grid-template-columns: 1fr 145px;
        align-items: center;
        gap: 12px;
        min-height: 150px;
    }

        .temperature-panel strong {
            font-size: 34px;
        }

        .temperature-panel canvas {
            width: 145px !important;
            height: 78px !important;
        }
}

@media (max-width: 420px) {
    .temperature-panel {
        grid-template-columns: 1fr;
    }

        .temperature-panel canvas {
            width: 100% !important;
            height: 82px !important;
            margin-top: 8px;
        }
}

/* =========================================================
   第六刀 C-1：溫度小圖加入最近 1 分鐘標示
   ========================================================= */

.temperature-chart-box {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: 4px;
    min-width: 0;
}

.temperature-trend-text {
    font-size: 12px;
    color: #90a6bf;
    text-align: right;
    line-height: 1.2;
    white-space: nowrap;
}

    .temperature-trend-text.trend-up {
        color: var(--orange);
    }

    .temperature-trend-text.trend-down {
        color: var(--green);
    }

@media (max-width: 768px) {
    .temperature-chart-box {
        width: 145px;
    }

    .temperature-trend-text {
        font-size: 12px;
        text-align: right;
    }
}

@media (max-width: 420px) {
    .temperature-chart-box {
        width: 100%;
    }

    .temperature-trend-text {
        text-align: left;
        margin-top: 2px;
    }
}

/* =========================================================
   第六刀 D：手機版裝置清單改成卡片式
   ========================================================= */

.mobile-device-cards {
    display: none;
}

.mobile-device-card {
    border: 1px solid rgba(120, 180, 255, .18);
    background: rgba(6, 17, 31, .42);
    border-radius: 14px;
    padding: 16px;
}

.mobile-device-head {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: flex-start;
    margin-bottom: 16px;
}

.mobile-device-name {
    font-size: 18px;
    font-weight: 800;
    color: #e8f2ff;
    line-height: 1.35;
}

.mobile-device-ip {
    margin-top: 4px;
    font-size: 13px;
    color: #90a6bf;
}

.mobile-device-status {
    flex: 0 0 auto;
    min-width: 54px;
    height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    font-size: 13px;
    font-weight: 800;
}

    .mobile-device-status.online {
        background: rgba(49, 209, 88, .15);
        color: var(--green);
    }

    .mobile-device-status.warning {
        background: rgba(255, 189, 46, .16);
        color: var(--yellow);
    }

    .mobile-device-status.offline {
        background: rgba(255, 69, 58, .16);
        color: var(--red);
    }

.mobile-device-metrics {
    display: grid;
    gap: 14px;
}

.mobile-metric {
    display: grid;
    grid-template-columns: 74px 54px 1fr;
    align-items: center;
    gap: 10px;
}

    .mobile-metric span {
        color: #aebed2;
        font-size: 14px;
        font-weight: 700;
    }

    .mobile-metric strong {
        color: #e8f2ff;
        font-size: 18px;
        font-weight: 800;
    }

.mobile-bar {
    width: 100%;
    margin-left: 0;
}

.mobile-device-foot {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(120, 180, 255, .12);
    display: flex;
    justify-content: space-between;
    color: #90a6bf;
    font-size: 13px;
}

    .mobile-device-foot b {
        color: #dce9f7;
    }

@media (max-width: 768px) {
    .device-table-wrap {
        display: none;
    }

    .mobile-device-cards {
        display: block;
    }

    .device-panel .panel-head {
        display: block;
        margin-bottom: 16px;
    }

        .device-panel .panel-head h2 {
            margin-bottom: 14px;
        }
}

/* =========================================================
   第六刀 D-1：修正桌機版同時出現表格與手機卡片
   ========================================================= */

/* 預設桌機版：只顯示表格，不顯示手機卡片 */
.mobile-device-cards {
    display: none !important;
}

/* 桌機 / 平板寬版：表格正常顯示 */
.device-table-wrap {
    display: block !important;
}

/* 手機版：隱藏表格，改顯示卡片 */
@media (max-width: 768px) {
    .device-table-wrap {
        display: none !important;
    }

    .mobile-device-cards {
        display: block !important;
    }
}

/* ===== 第六刀 D-1：手機版最近警示排版放寬 ===== */
@media (max-width: 768px) {
    .alert-item,
    .recent-alert-item,
    .alert-list-item {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .alert-main,
    .recent-alert-main,
    .alert-content {
        width: 100%;
    }

    .alert-meta,
    .recent-alert-meta,
    .alert-side {
        width: 100%;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 10px;
        flex-wrap: wrap;
        margin-top: 4px;
    }

    .alert-badge,
    .recent-alert-badge,
    .badge-warning,
    .status-badge {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 52px;
        height: 30px;
        padding: 0 10px;
        border-radius: 10px;
        white-space: nowrap;
        writing-mode: horizontal-tb;
        text-orientation: mixed;
        line-height: 1;
        flex: 0 0 auto;
    }

    .alert-time,
    .recent-alert-time {
        white-space: nowrap;
        font-size: 14px;
        line-height: 1.2;
        flex: 0 0 auto;
    }
}

/* =========================================================
   第六刀 D-1 修正版：手機版最近警示 badge / 時間不重疊
   ========================================================= */
@media (max-width: 768px) {
    .alerts-panel .alert-row {
        display: grid;
        grid-template-columns: 24px 1fr;
        grid-template-areas:
            "icon content"
            ". meta";
        gap: 10px 12px;
        align-items: start;
        padding: 12px 0;
    }

        .alerts-panel .alert-row .alert-icon {
            grid-area: icon;
            margin-top: 4px;
        }

        .alerts-panel .alert-row > div {
            grid-area: content;
            min-width: 0;
        }

        .alerts-panel .alert-row strong {
            display: block;
            font-size: 15px;
            line-height: 1.4;
            word-break: break-word;
        }

        .alerts-panel .alert-row small {
            display: block;
            margin-top: 4px;
            font-size: 14px;
            line-height: 1.5;
        }

        .alerts-panel .alert-row em {
            grid-area: meta;
            justify-self: start;
            margin-left: 0 !important;
            min-width: 56px;
            height: 28px;
            padding: 0 10px;
            display: inline-flex;
            align-items: center;
            justify-content: center;
            white-space: nowrap;
            writing-mode: horizontal-tb;
            line-height: 1;
        }

        .alerts-panel .alert-row time {
            grid-area: meta;
            justify-self: start;
            margin-left: 68px !important;
            align-self: center;
            white-space: nowrap;
            font-size: 14px;
            line-height: 28px;
        }
}

/* =========================================================
   Part2 第一刀 B：多裝置 Agent 清單顯示
   ========================================================= */

.device-key {
    display: block;
    margin-top: 4px;
    color: #7f93aa;
    font-size: 12px;
    font-weight: 500;
}

.device-row-offline {
    opacity: .62;
}

    .device-row-offline td {
        background: rgba(255, 69, 58, .035);
    }

.device-table td strong {
    color: #e8f2ff;
    font-weight: 800;
}

.mobile-device-card + .mobile-device-card {
    margin-top: 12px;
}

.mobile-device-card.is-offline {
    opacity: .72;
    border-color: rgba(255, 69, 58, .28);
    background: rgba(255, 69, 58, .045);
}

@media (max-width: 768px) {
    .mobile-device-cards {
        display: grid !important;
        gap: 12px;
    }
}

/* =========================================================
   Part2：溫度監測明細卡
   ========================================================= */

.temperature-detail-panel {
    min-height: 180px;
    display: block;
}

.temperature-detail-head {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.temperature-device-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.temperature-device-row {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 14px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid rgba(120, 180, 255, .10);
}

    .temperature-device-row:last-child {
        border-bottom: 0;
    }

.temperature-device-name {
    color: #e8f2ff;
    font-size: 16px;
    font-weight: 800;
    line-height: 1.35;
}

.temperature-device-values {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    color: #cfe0f5;
}

    .temperature-device-values em {
        color: #647b93;
        font-style: normal;
    }

.temperature-value {
    font-size: 15px;
    font-weight: 800;
    white-space: nowrap;
}

    .temperature-value.normal {
        color: var(--green);
    }

    .temperature-value.warning {
        color: var(--orange);
    }

    .temperature-value.danger {
        color: var(--red);
    }

.temperature-device-empty {
    color: #90a6bf;
    font-size: 15px;
    padding: 10px 0;
}

@media (max-width: 768px) {
    .temperature-device-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .temperature-device-values {
        gap: 6px;
    }
}

/* Part2：溫度監測數值加強 */
.temperature-device-values .temperature-value {
    font-size: 20px;
    font-weight: 900;
    letter-spacing: .2px;
}

.temperature-device-values {
    font-size: 20px;
}

.temperature-device-name {
    font-size: 18px;
}