/* ============================================
   RESET & VARIABLES
   ============================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #0f172a;
    --bg-2: #1e293b;
    --bg-3: #334155;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --purple: #8b5cf6;
    --radius: 10px;
    --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

[data-theme="light"] {
    --bg: #f1f5f9;
    --bg-2: #ffffff;
    --bg-3: #e2e8f0;
    --border: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --shadow: 0 4px 12px rgba(0,0,0,0.08);
}

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    min-height: 100vh;
}

button { cursor: pointer; font-family: inherit; }
a { color: inherit; text-decoration: none; }
code {
    background: var(--bg-3);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    color: var(--text);
}

/* ============================================
   LAYOUT
   ============================================ */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 240px;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transition: transform 0.25s;
}

.sidebar-brand {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 16px;
    font-weight: 700;
}
.brand-icon { font-size: 22px; }

.sidebar-brand .brand-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;   /* biar gambar tidak gepeng */
    flex-shrink: 0;        /* biar tidak mengecil saat text panjang */
}

.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.15s;
}
.nav-item:hover {
    background: var(--bg-3);
    color: var(--text);
}
.nav-item.active {
    background: var(--primary);
    color: white;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: 10px;
}
.user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 15px;
    overflow: hidden;   /* ← tambah */
    padding: 0;         /* ← tambah */
}
.user-meta { overflow: hidden; }
.user-name { font-weight: 600; font-size: 13px; }
.user-role { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

.btn-logout {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
}
.btn-logout:hover { opacity: 0.9; }

/* ============ MAIN ============ */
.main {
    flex: 1;
    margin-left: 240px;
    padding: 0 24px 32px;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 0;
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 10;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.page-title { font-size: 20px; font-weight: 700; flex: 1; }

.hamburger {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 6px;
}

.theme-toggle {
    background: var(--bg-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 16px;
    padding: 8px 12px;
    border-radius: 8px;
}
.theme-toggle:hover { background: var(--bg-3); }

/* ============ PAGES ============ */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.15s; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ============ STATS ============ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.15s;
}
.stat-card:hover { transform: translateY(-2px); }
.stat-icon {
    font-size: 28px;
    width: 52px; height: 52px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-3);
    border-radius: 12px;
}
.stat-value { font-size: 26px; font-weight: 700; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ============ PANELS ============ */
.row-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}
.panel {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.panel-header {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.panel-header h2 { font-size: 14px; font-weight: 700; }
.panel-body { padding: 12px; max-height: 400px; overflow-y: auto; }

.badge-muted {
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-3);
    padding: 3px 8px;
    border-radius: 12px;
}

/* ============ TOOLBAR ============ */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}
.search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
}
.search-input:focus {
    outline: none;
    border-color: var(--primary);
}
.filter-select {
    padding: 10px 14px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}

/* ============ MASTER-DETAIL ============ */
.master-detail {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 16px;
    height: calc(100vh - 180px);
}
.master {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    padding: 8px;
}
.detail {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-y: auto;
    padding: 20px;
}

.device-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 4px;
    border: 1px solid transparent;
    transition: all 0.15s;
}
.device-item:hover { background: var(--bg-3); }
.device-item.active {
    background: var(--bg-3);
    border-color: var(--primary);
}
.device-item-id {
    font-family: 'Consolas', monospace;
    font-size: 12px;
    font-weight: 600;
    word-break: break-all;
}
.device-item-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ============ CARDS LIST ============ */
.cards-list { display: flex; flex-direction: column; gap: 10px; }

.card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

/* ============ BADGES ============ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-active    { background: rgba(16,185,129,0.15); color: #10b981; }
.badge-inactive  { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-expired   { background: rgba(245,158,11,0.15); color: #f59e0b; }
.badge-lifetime  { background: rgba(139,92,246,0.15); color: #8b5cf6; }
.badge-none      { background: var(--bg-3); color: var(--text-muted); }

/* ============ TABLE ============ */
.table-wrap {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th {
    text-align: left;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-3);
    white-space: nowrap;
}
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover { background: var(--bg-3); }
.text-right { text-align: right; }

/* ============ BUTTONS ============ */
.btn {
    padding: 8px 14px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--bg-3); color: var(--text); }
.btn-secondary:hover { opacity: 0.85; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-success { background: var(--success); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============ EMPTY STATE ============ */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 13px;
}
.empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ============ MODAL ============ */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal.show { display: flex; }
.modal-content {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 460px;
    max-width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s;
}
@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    padding: 4px 8px;
    border-radius: 6px;
}
.modal-close:hover { background: var(--bg-3); color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ============ FORMS ============ */
.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    margin-top: 12px;
}
.form-label:first-child { margin-top: 0; }
.form-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 14px;
}
.form-input:focus {
    outline: none;
    border-color: var(--primary);
}
.form-static {
    padding: 10px 12px;
    background: var(--bg-3);
    border-radius: 8px;
    font-family: 'Consolas', monospace;
    font-size: 12px;
    word-break: break-all;
}

.duration-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.result-box {
    margin-top: 14px;
    font-size: 13px;
    word-break: break-all;
}
.result-box code {
    display: block;
    padding: 12px;
    background: var(--bg);
    border: 1px dashed var(--border);
    text-align: center;
    font-size: 16px;
    letter-spacing: 2px;
    font-weight: 700;
    margin-top: 8px;
}

/* ============ STATUS COLORS ============ */
.status-active   { color: var(--success); font-weight: 600; }
.status-inactive { color: var(--danger); font-weight: 600; }
.status-expired  { color: var(--warning); font-weight: 600; }

/* ============ ACTIVITY ITEM ============ */
.activity-item {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: var(--bg);
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}
.activity-action {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}
.activity-target {
    font-size: 12px;
    font-family: 'Consolas', monospace;
    color: var(--text);
    margin-top: 4px;
}
.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

/* ============ LICENSE ROW (expiring) ============ */
.expiring-row {
    padding: 12px;
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    border-left: 3px solid var(--warning);
}
.expiring-key {
    font-family: 'Consolas', monospace;
    font-size: 12px;
    font-weight: 600;
}
.expiring-time {
    font-size: 11px;
    color: var(--warning);
    font-weight: 700;
    white-space: nowrap;
}

/* ============ DETAIL HEADER ============ */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}
.detail-device-id {
    font-family: 'Consolas', monospace;
    font-size: 16px;
    font-weight: 700;
    word-break: break-all;
}
.detail-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.detail-section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 20px 0 10px;
}

.license-card {
    padding: 14px;
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    border-left: 3px solid var(--border);
}
.license-card.active   { border-left-color: var(--success); }
.license-card.inactive { border-left-color: var(--danger); }
.license-card.expired  { border-left-color: var(--warning); }

.license-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.license-card-key {
    font-family: 'Consolas', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 1px;
}
.license-card-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 8px;
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
}
.license-card-actions {
    margin-top: 10px;
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
    }
    .main { margin-left: 0; }
    .hamburger { display: block; }
    .row-2col { grid-template-columns: 1fr; }
    .master-detail {
        grid-template-columns: 1fr;
        height: auto;
    }
    .master { max-height: 300px; }
    .detail { min-height: 300px; }
}

@media (max-width: 600px) {
    .main { padding: 0 14px 24px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 20px; }
    .data-table { font-size: 12px; }
    .data-table th, .data-table td { padding: 10px 8px; }
}

/* ============================================
   MAP TRACKER PAGE
   ============================================ */

/* ============ MAIN layout untuk maptracker ============ */
/* Saat page maptracker aktif, .main jadi flex column dan tidak scroll */
.main.maptracker-active {
    overflow: hidden;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* Topbar tetap proporsional */
.main.maptracker-active .topbar {
    flex-shrink: 0;
    margin-bottom: 16px;      /* ← JARAK topbar ke peta */
    padding: 16px 24px;
}

/* Section page maptracker aktif */
#page-maptracker.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    margin: 0;
}


/* ============ CONTAINER MAP ============ */
.maptracker-container {
    position: relative;
    flex: 1;
    min-height: 0;
    width: calc(100% - 48px);   /* ← kurangi 48px (24px kiri + 24px kanan) */
    background: #111;
    overflow: hidden;
    border-radius: 16px;
    box-shadow: 0 6px 24px rgba(0,0,0,0.35);
    border: 1px solid var(--border);
    margin: 0 24px 24px 24px;   /* ← margin kiri-kanan-bawah */
}

#page-maptracker #map {
    width: 100%;
    height: 100%;
    background: #111;
    position: relative;
    z-index: 1;
    border-radius: 16px;                        /* ← TAMBAH INI */
    overflow: hidden;                           /* ← TAMBAH INI */
}

/* ============ LEAFLET CONTROL CUSTOM ============ */
.leaflet-control-custom {
    background-color: white;
    width: 36px;
    height: 36px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    border-radius: 4px;
    box-shadow: 0 1px 5px rgba(0,0,0,0.4);
    transition: all 0.2s;
}
.leaflet-control-custom:hover {
    background-color: #f0f0f0;
    transform: scale(1.05);
}

/* ============ DROPDOWN LAYER ============ */
.dropdown-container {
    position: relative;
    display: inline-block;
}
.dropdown-menu {
    display: none;
    position: absolute;
    top: 38px;
    right: 0;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    min-width: 150px;
    border-radius: 4px;
    overflow: hidden;
}
.dropdown-menu div {
    padding: 8px 15px;
    cursor: pointer;
    white-space: nowrap;
    font-size: 14px;
    color: #333;
}
.dropdown-menu div:hover {
    background: #f0f0f0;
}

/* ============ SIDEBAR USER ============ */
.user-sidebar {
    position: absolute;
    top: 0;
    left: -320px;
    width: 300px;
    height: 100%;
    background: white;
    box-shadow: 2px 0 12px rgba(0,0,0,0.15);
    z-index: 1500;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', sans-serif;
}
.user-sidebar.open {
    left: 0;
}

.sidebar-header {
    padding: 16px;
    background: #2196F3;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    font-size: 18px;
}
.sidebar-header button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-header button:hover {
    background: rgba(255,255,255,0.2);
}

.user-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}
.user-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}
.user-item:hover {
    background: #f5f5f5;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
    font-size: 18px;
    margin-right: 12px;
    flex-shrink: 0;
}
.user-info {
    flex: 1;
}
.user-name {
    font-weight: 600;
    font-size: 14px;
    color: #868585;
}
.user-detail {
    font-size: 11px;
    color: #777;
    margin-top: 2px;
}
.user-time {
    font-size: 10px;
    color: #999;
}
.empty-users {
    text-align: center;
    padding: 32px;
    color: #999;
    font-style: italic;
}

/* ============ OVERLAY SIDEBAR ============ */
.sidebar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.3);
    z-index: 1400;
    display: none;
}
.sidebar-overlay.open {
    display: block;
}

/* ============ POPUP MQTT ============ */
.mqtt-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.mqtt-popup-content {
    background: white;
    padding: 25px 30px;
    border-radius: 12px;
    text-align: center;
    min-width: 320px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.mqtt-popup-content h3 {
    margin-bottom: 15px;
    color: #333;
}
.mqtt-popup-content input {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.mqtt-popup-content button {
    padding: 10px 20px;
    margin: 5px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
}
.btn-connect {
    background-color: #28a745;
    color: white;
}
.btn-connect:hover {
    background-color: #1e7e34;
}
.btn-cancel {
    background-color: #6c757d;
    color: white;
}
.btn-cancel:hover {
    background-color: #5a6268;
}

.close-btn {
    float: right;
    font-size: 24px;
    cursor: pointer;
    background: none;
    border: none;
    color: #999;
}
.close-btn:hover {
    color: #333;
}

/* ============ TOAST MAP ============ */
.map-toast-container {
    position: fixed;
    top: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}
.map-toast {
    background: rgba(0,0,0,0.85);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    min-width: 250px;
    text-align: center;
    font-size: 14px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-20px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}
.map-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.map-toast-success { background: rgba(40, 167, 69, 0.95); }
.map-toast-error   { background: rgba(220, 53, 69, 0.95); }
.map-toast-info    { background: rgba(0, 123, 255, 0.95); }

/* ============ STATUS PANEL ============ */
.status-panel {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0,0,0,0.75);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 12px;
    z-index: 1000;
    font-family: monospace;
    pointer-events: none;
}
.status-panel span {
    color: #4CAF50;
}

/* ============ BUTTON ROUTE DI POPUP MARKER ============ */
.btn-route {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 8px;
    font-size: 12px;
    width: 100%;
}
.btn-route:hover {
    background-color: #0056b3;
}

/* ============ DARK TILES MODE ============ */
.dark-tiles .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.85) contrast(0.95);
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .maptracker-container {
        height: calc(100vh - 80px);
    }
    .user-sidebar {
        width: 260px;
        left: -280px;
    }
}

/* ============================================
   NAV BADGE (notifikasi jumlah pending)
   ============================================ */
.nav-badge {
    margin-left: auto;
    background: var(--danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
    line-height: 1.4;
    animation: pulseBadge 1.5s ease-in-out infinite;
}

@keyframes pulseBadge {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.75; transform: scale(1.08); }
}

/* Saat menu aktif, badge jadi putih biar kontras */
.nav-item.active .nav-badge {
    background: white;
    color: var(--primary);
    animation: none;
}

/* ============================================
   FIX HAMBURGER — paksa sidebar terbuka
   ============================================ */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 999;
    }
    .sidebar.open {
        transform: translateX(0) !important;
        box-shadow: 4px 0 20px rgba(0,0,0,0.5);
        z-index: 999;
    }
    .hamburger {
        display: block !important;
        position: relative;
        z-index: 1000;
        pointer-events: auto !important;
    }
}

/* ============================================
   FIX: Hamburger di atas topbar
   ============================================ */
@media (max-width: 900px) {
    .topbar {
        position: relative;   /* biar z-index bekerja */
        z-index: 1;
    }
    .hamburger {
        display: block !important;
        position: relative;
        z-index: 9999;
        pointer-events: auto !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }
    /* Kalau tombol hamburger ada di dalam topbar */
    .topbar .hamburger {
        position: relative;
        z-index: 9999;
    }
    /* Pastikan sidebar di bawah hamburger */
    .sidebar {
        z-index: 100 !important;
    }
    .sidebar.open {
        z-index: 100 !important;
    }
}

/* ============================================
   GEMPA MARKER — Animasi Pulse
   ============================================ */
@keyframes gempaPulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 12px rgba(239,68,68,0.8);
    }
    50% {
        transform: scale(1.15);
        box-shadow: 0 0 24px rgba(239,68,68,1);
    }
}

.gempa-marker {
    background: transparent !important;
    border: none !important;
}

/* Leaflet popup styling untuk gempa */
.leaflet-popup-content {
    margin: 12px 14px !important;
    font-size: 13px;
}

.leaflet-popup-content img {
    max-width: 100%;
}

/* ============ PREFIX INPUT (ID1- ...) ============ */
.prefix-wrapper {
    display: flex;
    align-items: stretch;
    width: 100%;
}

.prefix-label {
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: var(--bg-3);
    border: 1px solid var(--border);
    border-right: none;
    border-radius: 8px 0 0 8px;
    font-family: 'Consolas', monospace;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    user-select: none;
}

.prefix-wrapper .form-input {
    border-radius: 0 8px 8px 0;
    flex: 1;
    min-width: 0;   /* biar flex tidak overflow */
}