:root {
    --background: #f4f7fb;
    --surface: #ffffff;
    --text-primary: #172033;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --primary: #2563eb;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --unknown: #64748b;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--background);
    color: var(--text-primary);
    font-family: Arial, Helvetica, sans-serif;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 24px 5%;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 26px;
}

.topbar p {
    margin: 0;
    color: var(--text-secondary);
}

.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.live-dot {
    width: 10px;
    height: 10px;
    background: var(--success);
    border-radius: 50%;
    box-shadow: 0 0 0 5px rgba(21, 128, 61, 0.12);
}

.container {
    width: min(1400px, 92%);
    margin: 30px auto;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.summary-card,
.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.summary-card {
    padding: 24px;
}

.card-label {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.summary-card h2 {
    margin: 16px 0 10px;
    font-size: 32px;
}

.summary-card small {
    font-size: 16px;
    color: var(--text-secondary);
}

.card-description {
    margin: 0;
    color: var(--text-secondary);
    font-size: 13px;
}

.information-grid {
    display: grid;
    grid-template-columns: minmax(280px, 0.8fr) minmax(500px, 2fr);
    gap: 20px;
    margin-top: 20px;
}

.panel {
    margin-top: 20px;
    padding: 24px;
}

.information-grid .panel {
    margin-top: 0;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.panel-header h2 {
    margin: 0 0 6px;
    font-size: 19px;
}

.panel-header p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.device-information {
    margin: 0;
}

.device-information div {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    padding: 13px 0;
    border-bottom: 1px solid var(--border);
}

.device-information div:last-child {
    border-bottom: 0;
}

.device-information dt {
    color: var(--text-secondary);
}

.device-information dd {
    margin: 0;
    text-align: right;
    font-weight: 600;
}

.chart-container {
    position: relative;
    height: 330px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 110px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
}

.status-normal {
    color: var(--success);
    background: rgba(21, 128, 61, 0.12);
}

.status-warning {
    color: var(--warning);
    background: rgba(180, 83, 9, 0.12);
}

.status-danger {
    color: var(--danger);
    background: rgba(185, 28, 28, 0.12);
}

.status-unknown {
    color: var(--unknown);
    background: rgba(100, 116, 139, 0.12);
}

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    white-space: nowrap;
}

th {
    background: #f8fafc;
    font-size: 13px;
}

td {
    font-size: 14px;
}

.empty-cell {
    padding: 35px;
    color: var(--text-secondary);
    text-align: center;
}

.error-box {
    margin-bottom: 20px;
    padding: 15px 18px;
    color: var(--danger);
    background: rgba(185, 28, 28, 0.08);
    border: 1px solid rgba(185, 28, 28, 0.25);
    border-radius: 12px;
}

.hidden {
    display: none;
}

footer {
    padding: 24px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 13px;
}

@media (max-width: 1000px) {
    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .information-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 600px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .summary-grid {
        grid-template-columns: 1fr;
    }

    .container {
        width: 94%;
    }

    .summary-card,
    .panel {
        padding: 18px;
    }
}

/* ==================================================
   Logo dan judul header
   ================================================== */

.header-brand {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-logo {
    width: 56px;
    height: 56px;
    object-fit: contain;
    flex-shrink: 0;
}

.header-title {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.header-title h1 {
    margin: 0;
}

.header-title p {
    margin: 4px 0 0;
}

@media (max-width: 768px) {
    .header-brand {
        gap: 12px;
    }

    .header-logo {
        width: 46px;
        height: 46px;
    }

    .header-title h1 {
        font-size: 20px;
    }

    .header-title p {
        font-size: 13px;
    }
}

/* ==================================================
   Perbaikan tampilan responsif
   ================================================== */

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

.container,
.summary-grid,
.information-grid,
.panel,
.summary-card {
    min-width: 0;
}

/* Mencegah teks panjang keluar dari kartu */
.device-information > div {
    min-width: 0;
}

.device-information dt,
.device-information dd {
    min-width: 0;
}

.device-information dd {
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Container grafik mengikuti lebar layar */
.chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
}

.chart-container canvas {
    display: block;
    max-width: 100% !important;
}

/* Tabel dapat digeser pada layar kecil */
.table-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ==================================================
   Tampilan tablet dan HP
   ================================================== */

@media (max-width: 768px) {
    .topbar {
        padding: 16px;
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .header-brand {
        width: 100%;
        min-width: 0;
        align-items: center;
    }

    .header-logo {
        width: 48px;
        height: 48px;
        flex-shrink: 0;
    }

    .header-title {
        min-width: 0;
    }

    .header-title h1 {
        font-size: 20px;
        line-height: 1.25;
        overflow-wrap: anywhere;
    }

    .header-title p {
        font-size: 13px;
        line-height: 1.4;
    }

    .live-indicator {
        margin-left: 0;
    }

    .container {
        width: 100%;
        padding: 16px 12px;
    }

    .summary-grid,
    .information-grid {
        grid-template-columns: minmax(0, 1fr);
        gap: 16px;
    }

    .summary-card,
    .panel {
        width: 100%;
        max-width: 100%;
        padding: 20px;
    }

    /*
     * Label di kiri dan nilai di kanan.
     * Kedua kolom dapat mengecil tanpa keluar dari kartu.
     */
    .device-information > div {
        display: grid;
        grid-template-columns:
            minmax(0, 38%)
            minmax(0, 62%);
        gap: 12px;
        align-items: start;
    }

    .device-information dt {
        line-height: 1.4;
    }

    .device-information dd {
        margin: 0;
        text-align: right;
        line-height: 1.4;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .chart-container {
        height: 300px;
    }

    .panel-header h2 {
        font-size: 21px;
    }
}

/* ==================================================
   Tampilan HP kecil
   ================================================== */

@media (max-width: 480px) {
    .container {
        padding: 12px 10px;
    }

    .summary-card,
    .panel {
        padding: 18px 16px;
        border-radius: 18px;
    }

    /*
     * Pada HP kecil, label dan nilai dibuat bertumpuk
     * agar nama perangkat dan lokasi tidak terpotong.
     */
    .device-information > div {
        display: block;
    }

    .device-information dt {
        margin-bottom: 6px;
    }

    .device-information dd {
        width: 100%;
        margin: 0;
        text-align: left;
        white-space: normal;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .chart-container {
        height: 280px;
    }

    .header-logo {
        width: 42px;
        height: 42px;
    }

    .header-title h1 {
        font-size: 18px;
    }
}