:root { 
    --brand:#1e326c; 
    --brand-700:#162650; 
    --brand-50:#eef2ff; 
}

* { 
    box-sizing:border-box; 
}

body { 
    margin:0; 
    font-family:system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; 
    color:#111827; 
    background:#f8fafc; 
}

/* Desktop: Prevent body scroll (content area handles scrolling) */
@media (min-width: 992px) {
    body {
        overflow: hidden;
    }
}

/* Mobile/Tablet: Enable full page scrolling */
@media (max-width: 991px) {
    body {
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
}

a { 
    color:inherit; 
    text-decoration:none; 
}

.navbar { 
    display:flex; 
    align-items:center; 
    justify-content:flex-start; 
    gap:4px; /* Reduced gap for compact layout */
    padding:12px 16px; /* Increased padding for better height */
    background:var(--brand); 
    color:#fff; 
    position:sticky; 
    top:0; 
    z-index:9999; /* Increased z-index to ensure navbar is on top */
    min-height:50px; /* Minimum height instead of fixed height */ 
}

.nav-left { 
    display:flex; 
    align-items:center; 
    gap:8px; /* Reduced gap for compact layout */
    margin-right:8px; /* Reduced margin */
    position:relative; /* Ensure proper stacking */
    z-index:10001; /* Ensure elements are clickable */
}

.sidebar-toggle { 
    background:none; 
    border:none; 
    color:#fff; 
    font-size:18px; 
    cursor:pointer; 
    padding:4px; 
    margin-right:8px; 
    position:relative; /* Ensure proper stacking */
    z-index:10001; /* Ensure button is clickable */
    pointer-events:auto; /* Explicitly enable clicking */
}

.sidebar-toggle:hover { 
    background:rgba(255,255,255,0.1); 
    border-radius:4px; 
}

.logo { 
    width:140px; 
    height:34px; 
    display:block; 
    object-fit:contain; 
}

.nav-links { 
    display:flex; 
    gap:2px; /* Reduced gap for compact layout */
    position:relative; /* Ensure proper stacking */
    z-index:10000; /* Ensure links are clickable */
}

.nav-right { 
    margin-left:auto; 
    position:relative; 
    display:flex; 
    align-items:center; 
    gap:4px; /* Reduced gap for compact layout */
    z-index:10000; /* Ensure nav-right is clickable */
}

.nav-icons { 
    display:flex; 
    align-items:center; 
    gap:8px; 
}

.nav-icon { 
    background:none; 
    border:none; 
    color:#fff; 
    font-size:16px; 
    cursor:pointer; 
    padding:6px; 
    border-radius:4px; 
}

.nav-icon:hover { 
    background:rgba(255,255,255,0.1); 
}

.admin-only { 
    display:none; 
}

.admin-only.show { 
    display:inline-block; 
}

.avatar-btn { 
    display:flex; 
    align-items:center; 
    gap:8px; 
    background:#ffffff22; 
    border:1px solid #ffffff33; 
    color:#fff; 
    padding:6px 10px; 
    border-radius:999px; 
    cursor:pointer; 
    position:relative; /* Ensure proper stacking */
    z-index:10001; /* Ensure button is clickable */
    pointer-events:auto; /* Explicitly enable clicking */
}

.avatar { 
    width:17px; 
    height:14px; 
    border-radius:50%; 
    background:#fff; 
    color:var(--brand); 
    display:grid; 
    place-items:center; 
    font-weight:700; 
}

.dropdown { 
    position:fixed; 
    right:16px; 
    top:50px; /* Updated for new navbar height */ 
    background:#fff; 
    color:#111827; 
    border:1px solid #e5e7eb; 
    border-radius:8px; 
    min-width:240px; 
    box-shadow:0 10px 20px rgba(0,0,0,.2); 
    display:none; 
    z-index:10001; /* Ensure dropdown appears above nav-right */
}

.dropdown.open { 
    display:block; 
}

.dropdown .item { 
    padding:10px 12px; 
    border-bottom:1px solid #f3f4f6; 
}

.dropdown .item:last-child { 
    border-bottom:none; 
}

.dropdown .muted { 
    color:#6b7280; 
    font-size:12px; 
}

.dropdown .btn-inline { 
    display:inline-block; 
    background:var(--brand); 
    color:#fff; 
    border:none; 
    padding:6px 10px; 
    border-radius:6px; 
    cursor:pointer; 
}

.nav-link { 
    padding:6px 10px; /* Reduced horizontal padding for compact layout */
    border-radius:6px; 
    color:#fff; 
    font-size:14px; 
    position:relative; /* Ensure proper stacking */
    z-index:10001; /* Ensure links are clickable */
    pointer-events:auto; /* Explicitly enable clicking */
}

.nav-link.active, .nav-link:hover { 
    background:var(--brand-700); 
}

.layout { 
    display:flex; 
    min-height:calc(100vh - 50px); /* Updated for new navbar height */ 
}

/* Mobile/Tablet: Allow layout to grow beyond viewport */
@media (max-width: 991px) {
    .layout {
        min-height: 100vh;
        height: auto;
    }
}

.sidebar { 
    width:315px; 
    background:#fff; 
    border-right:1px solid #e5e7eb; 
    padding:12px; 
    overflow:auto; 
    max-height:calc(100vh - 50px); /* Updated for new navbar height */ 
    transition: transform 0.3s ease; 
}

.sidebar.collapsed { 
    transform: translateX(-100%); 
    width: 0; 
    min-width: 0; 
    overflow: hidden; 
}

/* Sidebar lines and spacing */
.country {
    border-bottom: 1px solid #d1d5db;
    margin-bottom: 8px;
    padding-bottom: 8px;
}

.country:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.location-list li {
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 4px;
    padding-bottom: 4px;
}

.location-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.block-list li {
    border-bottom: 1px solid #f3f4f6;
    margin-bottom: 2px;
    padding-bottom: 2px;
}

.block-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.cab-list li {
    border-bottom: 1px solid #f9fafb;
    margin-bottom: 2px;
    padding-bottom: 2px;
}

.cab-list li:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.sidebar h3 { 
    margin:4px 0 8px; 
    font-size:14px; 
    color:#374151; 
}

.country { 
    margin-bottom:18px; 
    padding-bottom:10px; 
    border-bottom:1px dashed #e5e7eb; 
}

.country-title { 
    font-weight:600; 
    margin-bottom:6px; 
    color:#111827; 
    display:flex; 
    align-items:center; 
    gap:8px; 
    cursor:pointer; 
}

.country-title .count { 
    font-size:12px; 
}

.city-title { 
    font-weight:500; 
    margin-bottom:6px; 
    color:#111827; 
    cursor:pointer; 
}

.block-title { 
    font-weight:500; 
    margin-bottom:6px; 
    color:#111827; 
    cursor:pointer; 
}

.location-list, .block-list, .cab-list { 
    list-style:none; 
    padding:0; 
    margin:0; 
    display:grid; 
    gap:6px; 
}

.location-btn { 
    width:100%; 
    text-align:left; 
    padding:8px 10px; 
    border:1px solid #e5e7eb; 
    border-radius:6px; 
    background:#fff; 
    cursor:pointer; 
}

.location-btn:hover { 
    border-color:var(--brand); 
    box-shadow:0 0 0 2px var(--brand-50); 
}

.content { 
    flex:1; 
    display:flex; 
    flex-direction:column; 
    overflow-y: auto;
    overflow-x: hidden;
}

/* Mobile/Tablet: Enable full page scrolling */
@media (max-width: 991px) {
    .content {
        overflow-y: visible;
        min-height: 100%;
    }
}

.content.full-width { 
    width:100%; 
}

.toolbar { 
    padding:10px 12px; 
    background:#fff; 
    border-bottom:1px solid #e5e7eb; 
    display:flex; 
    justify-content:space-between; 
    align-items:center; 
}

.btn { 
    background:var(--brand); 
    color:#fff; 
    border:none; 
    padding:8px 12px; 
    border-radius:6px; 
    cursor:pointer; 
}

.btn.secondary { 
    background:#fff; 
    color:var(--brand); 
    border:1px solid var(--brand); 
}

.btn:disabled { 
    opacity:.6; 
    cursor:not-allowed; 
}

#map { 
    width:100%; 
    height:600px; 
    z-index:50; 
}

.panel { 
    background:#fff; 
    border:1px solid #e5e7eb; 
    border-radius:8px; 
    padding:12px; 
}

.grid { 
    display:grid; 
    gap:12px; 
}

.log-area { 
    width:100%; 
    min-height:160px; 
    resize:vertical; 
    font-family:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; 
    background:#0b1220; 
    color:#e5e7eb; 
    border:1px solid #1f2937; 
    border-radius:6px; 
    line-height:1.4; 
    padding:10px; 
}

.container { 
    padding:12px; 
    display:grid; 
    gap:12px; 
}

.tag { 
    display:inline-flex; 
    align-items:center; 
    gap:6px; 
    background:var(--brand-50); 
    color:var(--brand); 
    border-radius:999px; 
    padding:4px 10px; 
    font-size:12px; 
}

.form-row { 
    display:grid; 
    gap:8px; 
    margin:8px 0; 
}

.switch { 
    position:relative; 
    width:44px; 
    height:24px; 
    background:#e5e7eb; 
    border-radius:999px; 
    cursor:pointer; 
    display:inline-block; 
    vertical-align:middle; 
}

.switch::after { 
    content:""; 
    position:absolute; 
    top:3px; 
    left:3px; 
    width:18px; 
    height:18px; 
    background:#fff; 
    border-radius:50%; 
    transition:all .2s; 
    box-shadow:0 1px 2px rgba(0,0,0,.2); 
}

.switch.on { 
    background:var(--brand); 
}

.switch.on::after { 
    left:23px; 
}

.modal-backdrop { 
    position:fixed; 
    inset:0; 
    background:rgba(0,0,0,.35); 
    display:none; 
    align-items:center; 
    justify-content:center; 
    z-index:10000; 
    padding:16px; 
}

.modal { 
    width:100%; 
    max-width:520px; 
    background:#fff; 
    border-radius:12px; 
    border:1px solid #e5e7eb; 
    box-shadow:0 10px 20px rgba(0,0,0,.2); 
    position: relative;
    z-index: 10001;
}

.modal-header { 
    padding:12px; 
    border-bottom:1px solid #e5e7eb; 
    display:flex; 
    align-items:center; 
    justify-content:space-between; 
}

.modal-body { 
    padding:12px; 
    display:grid; 
    gap:10px; 
}

.modal-footer { 
    padding:12px; 
    border-top:1px solid #e5e7eb; 
    display:flex; 
    gap:8px; 
    justify-content:flex-end; 
}

.row { 
    display:flex; 
    gap:10px; 
    align-items:center; 
}

.row label { 
    width:140px; 
    color:#374151; 
    font-size:14px; 
}

.input { 
    padding:8px; 
    border:1px solid #e5e7eb; 
    border-radius:6px; 
}

.range { 
    width:160px; 
}

/* New main layout */
.main-layout {
    display: flex;
    gap: 12px;
    height: calc(100vh - 100px); /* Full height minus navbar and toolbar */
}

.left-column {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.right-column {
    width: 300px;
    min-width: 250px;
}

.map-row {
    flex: 1;
    min-height: 0;
}

.activity-row {
    height: 300px;
    min-height: 300px;
}

.quick-summary { 
    border-radius:8px; 
    padding:10px; 
    height: auto; /* Allow content to flow naturally */
    display: flex;
    flex-direction: column;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: 1fr 1fr;
    gap: 12px;
    height: calc(100vh - 73px);
    align-items: start;
}

.panel-1 {
    grid-column: 1;
    grid-row: 1;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-2 {
    grid-column: 1;
    grid-row: 2;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: 100%;
}

.panel-3 {
    grid-column: 2;
    grid-row: 1 / 3;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-1 .map-container {
    width: 100%;
    height: 100%;
    border-radius: 8px;
    padding: 0;
    margin: 0;
}

.panel-1 {
    padding: 0;
    overflow: hidden;
}

.panel-1 #map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* Legacy map-container styles for other pages */
.map-container { 
    display:flex; 
    gap:12px; 
    margin-bottom:12px; 
}

.map-main { 
    flex:1; 
}

.map-sidebar { 
    width:calc(100% / 7); 
    min-width:200px; 
    height: 100%;
    display: flex;
    flex-direction: column;
}

.quick-summary h3 { 
    margin:0 0 20px; 
    font-size:16px; 
    color:#1f2937; 
    display:flex; 
    align-items:center; 
    gap:10px; 
    font-weight: 600;
    padding-bottom: 12px;
    border-bottom: 2px solid #e5e7eb;
}

.quick-summary h3 i { 
    color:var(--brand); 
    font-size: 20px;
}

.summary-stats { 
    display:grid; 
    grid-template-columns: 1fr 1fr;
    gap: 16px; 
    flex: 1;
    justify-content: space-between;
}

.stat-item { 
    text-align:center; 
   /* padding:20px 16px; */
	padding: 4px 16px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-700) 100%);
    border-radius:16px; 
    display:flex; 
    flex-direction: column;
    align-items:center; 
   /* gap:8px; */
	    gap: 0px;
    border: none;
    margin: 0;
    box-shadow: 0 8px 25px rgba(30, 50, 108, 0.15);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.stat-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border-radius: 16px;
}

.stat-item:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 35px rgba(30, 50, 108, 0.25);
}

.stat-item.countries {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.stat-item.cities {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.15);
}

.stat-item.online {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    box-shadow: 0 8px 25px rgba(245, 158, 11, 0.15);
}

.stat-item.blocks {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15);
}

.stat-item.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.15);
}

.stat-item.offline {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 8px 25px rgba(239, 68, 68, 0.15);
}

.stat-item.alarm {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%);
    box-shadow: 0 8px 25px rgba(249, 115, 22, 0.15);
}

.stat-item.globe {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    box-shadow: 0 8px 25px rgba(59, 130, 246, 0.15);
}

.stat-item.city {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    box-shadow: 0 8px 25px rgba(139, 92, 246, 0.15);
}

.stat-item.block {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.15);
}

.stat-item.cab {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.15);
}

.stat-item.status {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    box-shadow: 0 8px 25px rgba(34, 197, 94, 0.15);
}

.stat-item.serial {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 8px 25px rgba(107, 114, 128, 0.15);
}

.stat-item:last-child {
    border-bottom: none;
}

.stat-icon { 
    width:45px; 
    height:45px; 
    border-radius:50%; 
    display:flex; 
    align-items:center; 
    justify-content:center; 
    color:#fff; 
    font-size:20px; 
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

.stat-icon.active { 
    background: rgba(255, 255, 255, 0.2);
}

.stat-icon.countries { 
    background: rgba(255, 255, 255, 0.2);
}

.stat-icon.cities { 
    background: rgba(255, 255, 255, 0.2);
}

.stat-icon.online { 
    background: rgba(255, 255, 255, 0.2);
}

.stat-content { 
    flex:1; 
    position: relative;
    z-index: 1;
}

.stat-number { 
    font-size:25px; 
    font-weight:800; 
    color:#fff; 
    margin:0; 
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    line-height: 1;
}

.stat-label { 
    font-size:13px; 
    color:rgba(255, 255, 255, 0.9); 
    margin:0; 
    font-weight:600; 
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sidebar-icons { 
    margin-top:16px; 
    padding-top:16px; 
    border-top:1px solid #e5e7eb; 
}

.sidebar-icon { 
    display:flex; 
    align-items:center; 
    gap:8px; 
    padding:8px 12px; 
    margin-bottom:4px; 
    border-radius:6px; 
    cursor:pointer; 
    color:#374151; 
    text-decoration:none; 
    transition:background-color 0.2s; 
}

.sidebar-icon:hover { 
    background:#f3f4f6; 
}

.sidebar-icon i { 
    width:16px; 
    text-align:center; 
}

/* Dashboard Layout Styles */
.dashboard-layout {
    background: #ffffff; /* White background */
    min-height: calc(100vh - 50px); /* Updated for new navbar height */
    padding: 0;
}

.panels-container {
    position: relative;
    height: calc(100vh - 73px); /* Full height minus navbar and toolbar */
    padding: 12px;
    display: grid;
    grid-template-columns: 1fr 300px;
    grid-template-rows: 1fr 300px;
    gap: 12px;
}

.panel {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 12px;
}

.panel-1 {
    grid-column: 1;
    grid-row: 1;
    min-height: 583px;
    padding: 0;
    height: 100%;
}

.panel-2 {
    grid-column: 2;
    grid-row: 1 / 3; /* Spans both rows */
    min-width: 250px;
}

.panel-3 {
    grid-column: 1;
    grid-row: 2;
    min-height: 250px;
}


/* Map container within panel */
.panel .map-container {
    width: 100%;
    height: 100%;
    min-height: 250px;
}

/* Map panel specific - full size */
.panel-1 .map-container {
    width: 100%;
    height: 100%;
    min-height: 300px;
    border-radius: 8px;
}

/* Ensure map takes full height in index */
.dashboard-layout #map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* Summary panel specific styles */
.panel-2 .quick-summary {
    height: auto; /* Allow content to flow naturally for scrolling */
    display: flex;
    flex-direction: column;
    min-height: 100%; /* Take full height when content is small */
}

.panel-2 .summary-stats {
    flex: 1 1 auto; /* Allow expansion to fill space */
    display: flex;
    flex-direction: column;
    gap: 12px; /* Space between cards */
    justify-content: space-evenly; /* Distribute cards evenly with space */
    padding: 4px 0; /* Add vertical padding */
}

.panel-2 .stat-item {
    margin-bottom: 0;
}

/* Activity panel specific styles */
.panel-3 {
    display: flex;
    flex-direction: column;
}

.panel-3 > div:last-child {
    flex: 1;
    overflow: auto;
}

/* CabMap Layout Styles */
/* 
 * CABMAP LAYOUT RESPONSIVE STRATEGY:
 * - Base: Side-by-side layout with left panel (map + activity) and right panel (status)
 * - Desktop (≥992px): Full-height layout, horizontal scroll if DevTools open
 * - Tablet (768-991px with touch): Stack vertically ONLY on touch devices  
 * - Mobile (<768px): Always stack vertically
 * - DevTools open: Horizontal scroll, maintain side-by-side layout
 */

.cabmap-layout {
    background: #ffffff;
    min-height: calc(100vh - 50px); /* Updated for new navbar height */
    padding: 0;
}

.cabmap-container {
    display: flex !important;
    flex-direction: row !important;
    height: calc(100vh - 98px); /* Full height minus navbar (50px) + toolbar (48px) */
    gap: 12px;
    padding: 12px;
    overflow-x: auto; /* Allow horizontal scroll if content is too wide */
    min-width: 0; /* Allow flexbox to shrink */
}

.left-panel {
    flex: 1 1 60% !important;
    display: flex !important;
    flex-direction: column;
    gap: 12px;
    min-width: 400px !important; /* Minimum width to ensure visibility */
    max-width: none !important;
    height: 100%; /* Ensure it takes full height */
}

.right-panel {
    width: 320px !important;
    min-width: 280px !important;
    max-width: 400px !important;
    flex: 0 0 320px !important; /* Fixed width, no grow/shrink */
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%; /* Ensure it takes full height */
    overflow-y: auto; /* Enable scrolling for status panel */
}

.map-and-status {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.map-panel {
    flex: 1;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    min-height: 300px;
    padding: 0; /* Remove padding to prevent white space around map */
    display: flex; /* Make it a flex container */
    flex-direction: column;
}

/* Ensure map fills the panel completely */
.map-panel #map {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
}

.cabinet-status-panel {
    width: 200px;
    min-width: 180px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.cabinet-status-panel h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cabinet-status-panel h3 i {
    color: var(--brand);
}

.status-icons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    justify-content: center;
}

.status-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s ease;
}

.status-icon-item:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.status-icon {
    font-size: 24px;
    width: auto;
    text-align: center;
}

.status-text {
    font-size: 16px;
    font-weight: 600;
    color: #374151;
}

.status-icon.active {
    color: #22c55e;
}

.status-icon.inactive {
    color: #ef4444;
}

.status-icon.open {
    color: #22c55e;
}

.status-icon.closed {
    color: #6b7280;
}


.status-icon.normal {
    color: #22c55e;
}

.status-icon.alert {
    color: #f59e0b;
}

.status-text {
    font-size: 13px;
    font-weight: 500;
    color: #374151;
}

.activity-panel {
    height: 250px;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.control-box, .response-box {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
}

.status-panel {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    height: 100%;
    overflow-y: auto;
}

/* SweetAlert z-index override to ensure popups appear above everything */
.swal2-container {
    z-index: 99999 !important;
}

.swal2-popup {
    z-index: 100000 !important;
}

/* Ensure all buttons that trigger popups have proper z-index */
.btn, .btn-icon, button {
    position: relative;
    z-index: 10;
}

/* Modal z-index - ensure modals appear above everything except SweetAlert */
.modal, [id*="Modal"], [id*="modal"], [class*="modal"] {
    z-index: 10000 !important;
}

.modal-backdrop, [class*="backdrop"] {
    z-index: 9999 !important;
}

/* Scrollbar styling for table containers */
.report-table-container,
.user-table-container,
.settings-table-container,
.cabinets-list {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.report-table-container::-webkit-scrollbar,
.user-table-container::-webkit-scrollbar,
.settings-table-container::-webkit-scrollbar,
.cabinets-list::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.report-table-container::-webkit-scrollbar-track,
.user-table-container::-webkit-scrollbar-track,
.settings-table-container::-webkit-scrollbar-track,
.cabinets-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.report-table-container::-webkit-scrollbar-thumb,
.user-table-container::-webkit-scrollbar-thumb,
.settings-table-container::-webkit-scrollbar-thumb,
.cabinets-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.report-table-container::-webkit-scrollbar-thumb:hover,
.user-table-container::-webkit-scrollbar-thumb:hover,
.settings-table-container::-webkit-scrollbar-thumb:hover,
.cabinets-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Leaflet map container - remove any default padding/margin */
.leaflet-container {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
}

.status-panel h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-panel h3 i {
    color: var(--brand);
}

.status-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.status-label {
    font-weight: 500;
    color: #374151;
    font-size: 13px;
}

.status-value {
    font-weight: 600;
    color: #111827;
    font-size: 13px;
}

.control-box h3, .response-box h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.control-box h3 i {
    color: var(--brand);
}

.response-box h3 i {
    color: #059669;
}

.control-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.control-btn {
    padding: 12px 16px;
    border-radius: 6px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer; /* Ensure cursor shows as pointer */
    font-size: 14px;
    border: none; /* Remove default border */
}

.open-btn {
    background: #22c55e !important; /* Green background for Open button */
    color: white !important;
    border: none !important;
}

.open-btn:hover:not(:disabled) {
    background: #16a34a !important; /* Darker green on hover */
}

.open-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.close-btn {
    background: #ef4444;
    color: white;
    border: none;
}

.close-btn:hover {
    background: #dc2626;
}

.control-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.status-label {
    font-weight: 500;
    color: #374151;
}

.status-value {
    font-weight: 600;
    color: var(--brand);
}

/* Status panel status coloring */
.status-value.active {
    color: #16a34a;
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-value.normal {
    color: #16a34a;
    background: #dcfce7;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #bbf7d0;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-value.inactive {
    color: #dc2626;
    background: #fef2f2;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #fecaca;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

.status-value.unknown {
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid #d1d5db;
    font-size: 12px;
    font-weight: 600;
    display: inline-block;
}

/* Status item spacing */
.status-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-label {
    margin-right: 12px;
    font-weight: 500;
    color: #6b7280;
    flex-shrink: 0;
    text-align: right;
    min-width: 120px;
}

.status-value {
    margin-left: 12px;
    text-align: left;
    flex: 1;
}


/* User Management Badges */
.permission-badge, .type-badge, .status-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.permission-badge.admin, .type-badge.admin {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.permission-badge.user, .type-badge.user {
    background: #eff6ff;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.status-badge.enabled {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-badge.disabled {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

/* Breadcrumb Navigation */
.breadcrumb-container {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    padding: 12px 20px;
    margin-bottom: 0;
}

.breadcrumb {
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #64748b;
    margin: 0;
    padding: 0;
    list-style: none;
    flex-wrap: wrap;
    gap: 2px;
}

.breadcrumb-item {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #64748b;
    transition: color 0.2s ease;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.breadcrumb-item:hover {
    color: #1e326c;
    background: #f1f5f9;
}

.breadcrumb-item.current {
    color: #1e326c;
    font-weight: 600;
    background: #e0e7ff;
}

.breadcrumb-separator {
    color: #94a3b8;
    margin: 0 2px;
        font-size: 10px;
    flex-shrink: 0;
    }
    
.breadcrumb i {
    margin-right: 4px;
        font-size: 11px;
    flex-shrink: 0;
}

/* Header breadcrumb specific styles */
.toolbar .breadcrumb {
    font-size: 12px;
    max-width: 100%;
    overflow: hidden;
}

.toolbar .breadcrumb-item {
    padding: 1px 4px;
    font-size: 12px;
}

.toolbar .breadcrumb i {
    margin-right: 3px;
    font-size: 10px;
}

.toolbar .breadcrumb-separator {
    margin: 0 1px;
    font-size: 9px;
}

/* Responsive breadcrumb for mobile */
@media (max-width: 768px) {
    .toolbar .breadcrumb {
        font-size: 11px;
        flex-wrap: wrap;
        max-height: 40px;
        overflow: hidden;
    }
    
    .toolbar .breadcrumb-item {
        padding: 1px 3px;
        font-size: 11px;
    }
    
    .toolbar .breadcrumb i {
        margin-right: 2px;
        font-size: 9px;
    }
    
    .toolbar .breadcrumb-separator {
        margin: 0 1px;
        font-size: 8px;
    }
    
    /* Hide some breadcrumb items on very small screens */
    .toolbar .breadcrumb-item:nth-child(n+8) {
        display: none;
    }
}

/* User Management Action Buttons */
.btn-icon {
    background: #f3f4f6;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px;
    margin: 0 2px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.btn-icon:hover {
    background: #e5e7eb;
    border-color: #9ca3af;
}

.btn-icon i {
    font-size: 14px;
    color: #374151;
}

.btn-icon:hover i {
    color: #111827;
}

/* Specific action button colors */
.btn-icon[title*="Enable"],
.btn-icon[title*="Disable"] {
    background: #dcfce7;
    border-color: #bbf7d0;
}

.btn-icon[title*="Enable"]:hover,
.btn-icon[title*="Disable"]:hover {
    background: #bbf7d0;
}

.btn-icon[title="Edit"] {
    background: #eff6ff;
    border-color: #bfdbfe;
}

.btn-icon[title="Edit"]:hover {
    background: #bfdbfe;
}

.btn-icon[title="Delete"] {
    background: #fef2f2;
    border-color: #fecaca;
}

.btn-icon[title="Delete"]:hover {
    background: #fecaca;
}

.response-content {
    background: #0f172a;
    border-radius: 6px;
    padding: 12px;
    overflow: auto;
}

.json-display {
    color: #e5e7eb;
    font-family: 'Courier New', monospace;
        font-size: 12px;
    line-height: 1.4;
    margin: 0;
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Map specific styles for cabmap */
.cabmap-layout #map {
    width: 100% !important;
    height: 100% !important;
    border-radius: 8px;
}

/* Ensure map panel container has no padding that creates white space */
.cabmap-layout .map-panel {
    padding: 0 !important;
    display: flex;
    flex-direction: column;
}

/* Make map fill the entire panel */
.map-panel #map {
    width: 100% !important;
    height: 100% !important;
    flex: 1;
}

/* Settings Layout Styles */
.settings-layout {
    background: #ffffff;
    min-height: calc(100vh - 50px); /* Updated for new navbar height */
    padding: 0;
}

.settings-container {
    height: calc(100vh - 73px); /* Full height minus navbar and toolbar */
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.settings-grid {
    display: flex;
        gap: 12px;
    flex: 1;
    min-height: 0;
}

.right-side {
    display: flex;
    flex-direction: row;
    gap: 12px;
    height: 100%;
    width: 48%;
    min-width: 0;
}

.left-side {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 53%;
    min-width: 0;
}

.settings-row-1 {
    display: flex;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.map-panel {
    width: 66.67%; /* 40% of total / 60% of left side */
    min-width: 0;
}

.controls-column {
    width: 33.33%; /* 20% of total / 60% of left side */
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.controllers-panel, .users-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.activity-panel {
    flex: 1;
    min-height: 0;
}

.settings-panel {
    width: 40%;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.map-panel, .controllers-panel, .users-panel, .settings-panel, .activity-panel {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Override padding for map panel in cabmap layout */
.cabmap-layout .map-panel {
    padding: 0 !important;
}

.map-panel {
    flex: 1;
    min-width: 0;
}

.activity-panel {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.controllers-panel, .users-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.settings-panel {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
}

.map-panel h3, .controllers-panel h3, .users-panel h3, .settings-panel h3, .activity-panel h3, .door-controls-panel-full h3, .user-management-panel-full h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
        display: flex;
        align-items: center;
    gap: 8px;
}

.map-panel h3 i {
        color: var(--brand);
    }
    
.controllers-panel h3 i {
    color: #8b5cf6;
}

.users-panel h3 i {
    color: #f59e0b;
}

.settings-panel h3 i {
    color: #059669;
}

.activity-panel h3 i {
        color: var(--brand);
}

.door-controls-panel-full h3 i {
    color: #8b5cf6;
}

.user-management-panel-full h3 i {
    color: #f59e0b;
}

.map-container {
    flex: 1;
    border-radius: 8px;
        overflow: hidden;
    }
    
.controllers-section, .users-section {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.controllers-section h4, .users-section h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
    display: flex;
    align-items: center;
    gap: 6px;
}

.control-buttons, .user-buttons {
    display: flex;
        flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.control-btn, .user-btn {
    padding: 10px 14px;
    border-radius: 6px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all 0.2s ease;
    cursor: pointer; /* Ensure cursor shows as pointer */
    font-size: 13px;
    border: none; /* Remove default border */
}

.open-btn {
    background: #22c55e !important; /* Green background for Open button */
    color: white !important;
    border: none !important;
}

.open-btn:hover:not(:disabled) {
    background: #16a34a !important; /* Darker green on hover */
}

.open-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed !important;
}

.close-btn {
    background: #ef4444;
    color: white;
    border: none;
}

.close-btn:hover {
    background: #dc2626;
}

.user-btn {
    background: var(--brand);
    color: white;
    border: none;
}

.user-btn.secondary {
    background: #6b7280;
    color: white;
}

.user-btn:hover {
    opacity: 0.9;
}

.user-btn.secondary:hover {
    background: #4b5563;
}

.user-table-container {
        flex: 1;
    overflow: auto;
    max-height: 200px;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
    flex: 1;
}

.form-section {
    border: 1px solid #e5e7eb;
        border-radius: 8px;
    padding: 16px;
    background: #f8f9fa;
}

.form-section h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--brand);
        border-bottom: 1px solid #e5e7eb;
    padding-bottom: 8px;
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.form-row label {
    font-weight: 500;
    color: #374151;
    font-size: 14px;
}

.form-row .input {
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
}

.form-row .input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(30, 50, 108, 0.1);
}

.form-row-inline {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    gap: 12px;
}

.form-row-inline label {
    text-align: right;
    min-width: 102px; 
    margin-bottom: 0;
    font-weight: 500;
    color: #374151;
    flex-shrink: 0;
    font-size: 13px;
}

.form-row-inline .input {
    flex: 1;
    margin-bottom: 0;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 13px;
}

.form-row-inline .input:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(30, 50, 108, 0.1);
}

.save-btn {
    background: var(--brand);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    display: flex;
    align-items: center;
        gap: 8px;
    justify-content: center;
    margin-top: 20px;
    align-self: flex-start;
}

.save-btn:hover {
    background: var(--brand-700);
}

/* Settings layout specific map styles */
.settings-layout #map {
    width: 100%;
    height: 100%;
    border-radius: 8px;
}

/* No data state for sidebar */
.no-data {
    padding: 20px;
    text-align: center;
    color: #6b7280;
}

.no-data i {
    font-size: 24px;
    margin-bottom: 8px;
    display: block;
}

.no-data p {
    margin: 0;
        font-size: 14px;
    }
    
/* Enhanced status badges for activity logs */
.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    border: 1px solid;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.active {
    background: #dcfce7;
    color: #166534;
    border-color: #bbf7d0;
}

.status-badge.inactive {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

.status-badge.maintenance {
    background: #fffbeb;
    color: #d97706;
    border-color: #fed7aa;
}

.status-badge.alert {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.status-badge.standby {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.status-badge.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #f87171;
}

.status-badge.default {
    background: #f9fafb;
    color: #6b7280;
    border-color: #d1d5db;
}

/* Cabinet Status Panel Dynamic Styles */
.status-icon.active {
    color: #22c55e;
}

.status-icon.inactive {
    color: #ef4444;
}

.status-icon.open {
    color: #f59e0b;
}

.status-icon.closed {
    color: #6b7280;
}

.status-icon.alert {
    color: #dc2626;
}

.status-icon.normal {
    color: #22c55e;
}

.status-icon.on {
    color: #22c55e;
}

.status-icon.off {
    color: #ef4444;
}

/* Desktop Cabmap Layout (>= 992px) */
@media (min-width: 992px) {
    /* Desktop cabmap layout - full viewport height */
    .cabmap-container {
        height: calc(100vh - 98px) !important; /* navbar (50px) + toolbar (48px) */
        overflow-x: auto !important; /* Allow horizontal scroll if viewport too narrow */
        overflow-y: hidden;
        max-height: calc(100vh - 98px);
    }
    
    .left-panel {
        height: 100% !important;
        max-height: 100%;
        overflow: hidden;
        min-width: 400px; /* Minimum width to prevent excessive shrinking */
    }
    
    .right-panel {
        height: 100% !important;
        max-height: 100%;
        overflow-y: auto !important;
        flex-shrink: 0; /* Prevent shrinking */
    }
    
    /* Map and status section takes ~60% of left panel */
    .map-and-status {
        flex: 0 0 calc(60% - 6px);
        max-height: calc(60% - 6px);
        min-height: 0;
    }
    
    /* Activity panel takes ~40% of left panel */
    .activity-panel {
        flex: 1 1 calc(40% - 6px);
        min-height: 0;
        overflow-y: auto !important;
    }
    
    .map-panel {
        height: 100%;
        min-height: 400px;
    }
    
    .status-panel {
        height: 100%;
        max-height: 100%;
    }
}

/* Handle narrow desktop viewports (e.g., with DevTools open) */
@media (min-width: 992px) and (max-width: 1400px) {
    .cabmap-container {
        overflow-x: auto !important; /* Enable horizontal scroll */
    }
    
    .right-panel {
        width: 300px; /* Slightly narrower on smaller desktop screens */
        min-width: 280px;
    }
}

/* Very narrow desktop (e.g., DevTools open on 1080p screen) */
@media (min-width: 992px) and (max-width: 1200px) {
    .cabmap-container {
        overflow-x: auto !important;
        padding: 8px;
    }
    
    .left-panel {
        min-width: 350px; /* Allow more shrinking */
    }
    
    .right-panel {
        width: 280px;
        min-width: 260px;
    }
}

@media (max-width: 767px) {
    /* Mobile: Enable scrolling and stack layout */
    body {
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    
    /* Force mobile layout for cabmap */
    [data-page="cabmap"] .cabmap-container {
        flex-direction: column !important;
        height: auto !important;
        overflow-y: visible !important;
        padding: 8px;
    }
    
    [data-page="cabmap"] .left-panel,
    [data-page="cabmap"] .right-panel {
        width: 100% !important;
        min-width: auto !important;
        max-width: none !important;
        flex: 1 1 auto !important;
        height: auto !important;
    }
    
    [data-page="cabmap"] .right-panel {
        margin-bottom: 20px;
    }
    
    [data-page="cabmap"] .map-and-status {
        flex-direction: column;
        gap: 8px;
    }
    
    [data-page="cabmap"] .map-panel {
        height: 400px !important;
        min-height: 400px;
    }
}

@media (max-width: 900px){ 
    .layout { 
        flex-direction:column; 
    } 
    .sidebar { 
        width:100%; 
        border-right:none; 
        border-bottom:1px solid #e5e7eb; 
    }
    
    .panels-container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
        height: auto;
    }
    
    .panel-1 {
        grid-column: 1;
        grid-row: 1;
    }
    
    .panel-2 {
        grid-column: 1;
        grid-row: 2;
    }
    
    .panel-3 {
        grid-column: 1;
        grid-row: 3;
    }
    
    /* NOTE: Cabmap responsive layout is now handled in dedicated media queries below */
    
    .map-and-status {
        flex-direction: column;
        height: auto !important;
        gap: 12px;
    }
    
    .map-panel {
        height: 450px !important;
        min-height: 450px;
    }
    
    .activity-panel {
        height: auto !important;
        min-height: 350px;
        max-height: 500px;
        overflow-y: auto;
    }
    
    .status-panel {
        height: auto !important;
        min-height: 400px;
    }
    
    .cabinet-status-panel {
        width: 100%;
        min-width: auto;
        height: auto;
        min-height: 200px;
        padding: 12px;
    }
    
    .cabinet-status-panel h3 {
        font-size: 14px;
        margin: 0 0 12px 0;
    }
    
    .cabinet-status-panel h3 i {
        font-size: 15px;
    }
    
    .status-icons {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 8px;
        justify-content: center;
    }
    
    .status-icon-item {
        flex: 1;
        min-width: calc(50% - 4px);
        max-width: calc(50% - 4px);
        padding: 10px 8px;
        flex-direction: column;
        align-items: center;
        gap: 6px;
    }
    
    .status-icon-item .status-icon {
        font-size: 20px;
    }
    
    .status-icon-item .status-text {
        font-size: 12px;
    }
    
    .right-panel {
        width: 100%;
        min-width: auto;
    }
}

@media (max-width: 1200px) {
    .right-side {
        width: 55%;
    }
    
    .left-side {
        width: 42%;
    }
}

@media (max-width: 900px) {
    /* NOTE: .right-panel width is now handled in page-specific or cabmap-specific queries */
    
    .settings-container {
        height: auto !important;
        min-height: calc(100vh - 37px) !important;
        padding: 8px !important;
        gap: 8px !important;
    }
    
    .settings-grid {
        flex-direction: column !important;
        gap: 8px !important;
    }
    
    .left-side, .settings-panel, .right-side {
        width: 100% !important;
        min-width: auto !important;
        gap: 8px !important;
    }
    
    .right-side {
        flex-direction: column !important;
    }
    
    .settings-row-1 {
        flex-direction: column;
    }
    
    .status-panel, .settings-panel {
        height: auto !important;
        min-height: 250px !important;
        width: 100% !important;
    }
    
    .map-panel, .controls-column {
        width: 100%;
        min-width: auto;
    }
    
    .activity-panel {
        flex: 1;
        min-height: 200px;
    }
    
    .map-panel {
        height: 300px;
        min-height: 300px;
    }
    
    .controllers-panel, .users-panel, .settings-panel {
        height: 250px;
        min-height: 250px;
    }
    
    /* Door Controls Responsive */
    .door-controls-panel-full {
        padding: 10px;
    }
    
    .door-controls-content {
        flex-direction: column;
        gap: 8px;
    }
    
    .cabinet-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .cabinet-info .status-tag {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* User Management Responsive */
    .user-management-panel-full {
        padding: 10px;
    }
    
    .user-table-container {
        height: 200px;
    }
    
    /* Activity Panel Responsive */
    .activity-panel {
        padding: 10px;
        min-height: 200px;
    }
    
    /* Settings Panel Form Responsive - More Specific Selectors */
    .settings-panel .form-row-inline {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 4px !important;
        margin-bottom: 8px !important;
        background-color: #f0f0f0 !important; /* Test color to verify CSS is loading */
    }
    
    .settings-panel .form-row-inline label {
        font-size: 12px !important;
        font-weight: 600 !important;
        text-align: left !important;
        min-width: auto !important;
        margin-bottom: 0 !important;
        width: 100% !important;
    }
    
    .settings-panel .form-row-inline .input, 
    .settings-panel .form-row-inline select {
        font-size: 12px !important;
        padding: 6px 8px !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Status Panel Responsive */
    .status-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 6px 0;
    }
    
    .status-label {
        font-size: 11px;
        font-weight: 600;
    }
    
    .status-value {
        font-size: 11px;
    }
}

/* User Management Layout Styles */
.user-management-layout {
    background: #ffffff;
    height: calc(100vh - 50px); /* Updated for new navbar height */
    padding: 0;
    display: flex;
    flex-direction: column;
}

.user-management-container {
    flex: 1;
    padding: 12px;
    display: flex;
    flex-direction: column;
    min-height: 0;
        overflow: hidden;
    }
    
.user-table-panel {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
}

.user-table-panel h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-table-panel h3 i {
    color: var(--brand);
}

.user-table-container {
    flex: 1;
    overflow: auto;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    min-height: 0;
    height: 100%;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.user-table th {
    background: #f3f4f6;
    color: #374151;
    text-align: left;
    padding: 16px 12px;
    border-bottom: 1px solid #d1d5db;
    font-size: 14px;
    font-weight: 600;
    position: sticky;
    top: 0;
    white-space: nowrap;
}

.user-table td {
    padding: 16px 12px;
        border-bottom: 1px solid #e5e7eb;
    font-size: 14px;
    vertical-align: middle;
    white-space: nowrap;
}

.user-table tr:hover {
    background: #f8f9fa;
}

.user-table .actions {
    white-space: nowrap;
}

.user-table .actions button {
    margin-right: 6px;
    padding: 6px 10px;
    font-size: 12px;
}

/* User Management Panel Styles */
.user-management-panel {
    width: 60%;
    min-width: 0;
}

/* Responsive adjustments for User Management */
@media (max-width: 900px) {
    .user-management-container {
        height: auto;
        min-height: calc(100vh - 73px);
    }
    
    .user-table-panel {
        height: auto;
        min-height: 400px;
    }
    
    .user-table-container {
        height: auto;
        min-height: 300px;
    }
}

.door-controls-panel {
    width: 40%;
    min-width: 0;
}

.user-table-container {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    overflow: auto;
}

.user-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.user-btn {
    padding: 8px 12px;
    font-size: 12px;
    white-space: nowrap;
}

/* Full Width Panel Styles */
.door-controls-panel-full {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    margin-bottom: 4px;
}

.door-controls-content {
    /* display: flex !important; */
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.door-controls-buttons{
    display: flex !important;
    gap: 6px;
}

.cabinet-info {
        display: flex;
        align-items: center;
    gap: 8px;
}

.cabinet-label {
    font-weight: 500;
    color: #6b7280;
    font-size: 14px;
}

.cabinet-name {
    font-weight: 600;
    color: #111827;
        font-size: 14px;
}

.status-tag {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
        font-weight: 600;
    text-transform: uppercase;
}

.status-tag.active {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.status-tag.inactive {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.user-management-panel-full {
    background: #fff;
    border: 1px solid #d1d5db;
        border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding: 16px;
    margin-bottom: 12px;
}

.user-buttons-inline {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.user-buttons-inline .user-btn {
    flex: 1;
    min-width: 0;
}

/* Modern Sidebar Design */
    .sidebar {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border-right: 1px solid #cbd5e1;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
   /* max-height: calc(100vh - 60px); */
    overflow-y: auto;
    overflow-x: hidden;
}

.sidebar-header {
    padding: 16px 12px 12px;
    border-bottom: 1px solid #e2e8f0;
    background: #fff;
    margin: -12px -12px 12px -12px;
    border-radius: 6px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.sidebar-title i {
    color: var(--brand);
    font-size: 20px;
}

.select-all-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    font-size: 12px;
    font-weight: 500;
    color: #64748b;
}

.select-all-label:hover {
    background: #f1f5f9;
}

.select-all-checkbox {
    display: none;
}

.checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    background: #fff;
}

.select-all-checkbox:checked + .checkmark {
    background: var(--brand);
    border-color: var(--brand);
}

.select-all-checkbox:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* Country Styles */
.country {
    margin-bottom: 8px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.country-title {
    list-style: none;
    cursor: pointer;
    padding: 12px;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-bottom: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    min-height: 40px;
}

.country-title:hover {
    background: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
}

.country-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.country-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.arrow {
    color: #64748b;
    font-size: 14px;
    transition: transform 0.2s ease;
}

/* Arrow rotation removed - handled by JavaScript icon changes */

.flag {
    font-size: 18px;
}

.country-name {
    font-weight: 600;
    color: #1e293b;
    font-size: 15px;
}

.count {
    background: var(--brand);
    color: white;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 600;
    min-width: 16px;
    text-align: center;
    flex-shrink: 0;
}

/* City Styles */
.city {
    margin: 0;
    border-bottom: 1px solid #f1f5f9;
}

.city:last-child {
    border-bottom: none;
}

.city-title {
    list-style: none;
    cursor: pointer;
    padding: 8px 12px 8px 24px;
    background: #fafbfc;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    min-height: 28px;
}

.city-title:hover {
    background: #f1f5f9;
    border-left-color: #cbd5e1;
}

.city-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.city-icon {
    color: #64748b;
    font-size: 14px;
    width: 16px;
}

.city-name {
    font-weight: 500;
    color: #374151;
    font-size: 13px;
}

/* Block Styles */
.block {
    margin: 0;
    border-bottom: 1px solid #f8fafc;
}

.block:last-child {
    border-bottom: none;
}

.block-title {
    list-style: none;
    cursor: pointer;
    padding: 6px 12px 6px 36px;
    background: #fefefe;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    min-height: 26px;
}

.block-title:hover {
    background: #f8fafc;
    border-left-color: #e2e8f0;
}

.block-content {
    display: flex;
    align-items: center;
        gap: 10px;
    }
    
.block-icon {
    color: #94a3b8;
    font-size: 13px;
    width: 16px;
}

.block-name {
    font-weight: 500;
    color: #475569;
    font-size: 12px;
}

/* Cabinet Styles */
.cabinet-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px 6px 48px;
    background: #fff;
    border-bottom: 1px solid #f8fafc;
    transition: all 0.2s ease;
    min-height: 32px;
}

.cabinet-item:hover {
    background: #f8fafc;
}

.cabinet-item:last-child {
    border-bottom: none;
}

.cabinet-checkbox {
    display: flex;
    align-items: center;
        gap: 10px;
    cursor: pointer;
    flex: 1;
}

.cabinet-checkbox input[type="checkbox"] {
    display: none;
}

.cabinet-checkbox .checkmark {
    width: 16px;
    height: 16px;
    border: 2px solid #cbd5e1;
    border-radius: 4px;
    position: relative;
    transition: all 0.2s ease;
    background: #fff;
    flex-shrink: 0;
}

.cabinet-checkbox input[type="checkbox"]:checked + .checkmark {
    background: var(--brand);
    border-color: var(--brand);
}

.cabinet-checkbox input[type="checkbox"]:checked + .checkmark::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cabinet-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cabinet-icon {
    color: var(--brand);
    font-size: 14px;
    width: 16px;
}

.cabinet-name {
    font-weight: 500;
    color: #374151;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.cabinet-actions {
    display: flex;
    gap: 3px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.cabinet-item:hover .cabinet-actions {
    opacity: 1;
}

.action-btn {
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 4px;
    background: #f1f5f9;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 11px;
}

.action-btn:hover {
    background: var(--brand);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* List Styles */
.location-list, .block-list, .cab-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.location-list li, .block-list li, .cab-list li {
    margin: 0;
    padding: 0;
}

/* Responsive Design */
@media (max-width: 900px) {
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .cabinet-actions {
        opacity: 1;
    }
}

/* ===== CABSETTINGS RESPONSIVE STYLES ===== */

/* Tablet and smaller screens (max-width: 1024px) */
@media (max-width: 1024px) {
    .settings-container {
        padding: 8px;
    gap: 8px;
}

    .settings-grid {
        gap: 8px;
}

    .left-side, .right-side {
    gap: 8px;
}

    .door-controls-panel-full, .user-management-panel-full, .activity-panel,
    .settings-panel, .status-panel {
        padding: 12px;
    }
}

/* Mobile landscape and small tablets (max-width: 768px) */
@media (max-width: 768px) {
    .settings-container {
        height: auto !important;
        min-height: calc(100vh - 37px) !important;
        padding: 6px !important;
        gap: 6px !important;
    }
    
    .settings-grid {
        flex-direction: column !important;
        gap: 6px !important;
    }
    
    .left-side, .right-side {
        width: 100% !important;
        gap: 6px !important;
    }
    
    .right-side {
        flex-direction: column !important;
    }
    
    .settings-panel, .status-panel {
        width: 100% !important;
        height: auto !important;
        min-height: 250px !important;
    }
    
    .door-controls-panel-full {
        padding: 10px;
    }
    
    .door-controls-content {
        flex-direction: column;
        gap: 8px;
    }
    
    .cabinet-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .cabinet-info .status-tag {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    .user-management-panel-full {
        padding: 10px;
    }
    
    .user-table-container {
        height: 200px;
    }
    
    .activity-panel {
        padding: 10px;
        min-height: 200px;
    }
    
    .form-section h4 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form-row-inline {
        flex-direction: column;
        gap: 4px;
        margin-bottom: 8px;
    }
    
    .form-row-inline label {
        font-size: 12px;
    font-weight: 600;
    }
    
    .form-row-inline .input, .form-row-inline select {
        font-size: 12px;
        padding: 6px 8px;
    }
    
    .status-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
        padding: 6px 0;
    }
    
    .status-label {
        font-size: 11px;
        font-weight: 600;
    }
    
    .status-value {
        font-size: 11px;
    }
}

/* Small mobile devices (max-width: 480px) */
@media (max-width: 480px) {
    /* Door Status Panel */
    .cabinet-status-panel {
        padding: 10px;
        min-height: 180px;
    }
    
    .cabinet-status-panel h3 {
        font-size: 13px;
        margin: 0 0 10px 0;
    }
    
    .cabinet-status-panel h3 i {
        font-size: 14px;
    }
    
    .status-icons {
        gap: 6px;
    }
    
    .status-icon-item {
        min-width: calc(50% - 3px);
        max-width: calc(50% - 3px);
        padding: 8px 6px;
        gap: 4px;
    }
    
    .status-icon-item .status-icon {
        font-size: 18px;
    }
    
    .status-icon-item .status-text {
        font-size: 11px;
    }
    
    .map-and-status {
        gap: 8px;
    }
    
    .map-panel {
        min-height: 250px;
    }
    
    /* Settings and other panels */
    .settings-container {
        padding: 4px !important;
        gap: 4px !important;
    }
    
    .settings-grid {
        gap: 4px !important;
    }
    
    .left-side, .right-side {
        gap: 4px !important;
    }
    
    .door-controls-panel-full, .user-management-panel-full, .activity-panel,
    .settings-panel, .status-panel {
        padding: 8px;
    }
    
    .door-controls-panel-full h3, .user-management-panel-full h3,
    .activity-panel h3, .settings-panel h3, .status-panel h3 {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .cabinet-info {
        gap: 2px;
    }
    
    .cabinet-info .status-tag {
        font-size: 9px;
        padding: 1px 4px;
    }
    
    .user-table-container {
        height: 150px;
    }
    
    .user-table-container table th,
    .user-table-container table td {
    padding: 2px 4px;
    font-size: 10px;
}

    .activity-panel {
        min-height: 150px;
    }
    
    .cabLogTable th,
    .cabLogTable td {
        padding: 4px;
        font-size: 11px;
    }
    
    .form-section h4 {
        font-size: 13px;
        margin-bottom: 6px;
    }
    
    /* Settings Panel Form Responsive - More Specific Selectors */
    .settings-panel .form-row-inline {
        margin-bottom: 6px !important;
    }
    
    .settings-panel .form-row-inline label {
        font-size: 11px !important;
    }
    
    .settings-panel .form-row-inline .input, 
    .settings-panel .form-row-inline select {
        font-size: 11px !important;
        padding: 4px 6px !important;
    }
    
    .status-item {
        padding: 4px 0;
    }
    
    .status-label {
        font-size: 10px;
    }
    
    .status-value {
        font-size: 10px;
    }
    
    .btn {
        padding: 6px 8px;
        font-size: 11px;
    }
    
    .btn-icon {
        min-width: 28px;
        height: 28px;
        padding: 4px;
    }
    
    .btn-icon i {
        font-size: 10px;
    }
}

/* Extra small devices (max-width: 360px) */
@media (max-width: 360px) {
    /* Door Status Panel - Extra Small */
    .cabinet-status-panel {
        padding: 8px;
        min-height: 160px;
    }
    
    .cabinet-status-panel h3 {
        font-size: 12px;
        margin: 0 0 8px 0;
    }
    
    .cabinet-status-panel h3 i {
        font-size: 12px;
    }
    
    .status-icons {
        gap: 4px;
    }
    
    .status-icon-item {
        min-width: calc(50% - 2px);
        max-width: calc(50% - 2px);
        padding: 6px 4px;
        gap: 3px;
    }
    
    .status-icon-item .status-icon {
        font-size: 16px;
    }
    
    .status-icon-item .status-text {
        font-size: 10px;
    }
    
    .map-panel {
        min-height: 200px;
    }
    
    /* Settings and other panels */
    .settings-container {
        padding: 2px;
        gap: 2px;
    }
    
    .door-controls-panel-full, .user-management-panel-full, .activity-panel,
    .settings-panel, .status-panel {
        padding: 6px;
    }
    
    .cabinet-info .status-tag {
        font-size: 8px;
        padding: 1px 3px;
    }
    
    .user-table-container {
        height: 120px;
    }
    
    .user-table-container table th,
    .user-table-container table td {
        padding: 1px 2px;
        font-size: 9px;
    }
    
    .activity-panel {
        min-height: 120px;
    }
    
    .cabLogTable th,
    .cabLogTable td {
        padding: 2px;
        font-size: 10px;
    }
    
    .form-row-inline .input, .form-row-inline select {
        font-size: 10px !important;
        padding: 3px 4px !important;
    }
    
    .btn {
        padding: 4px 6px;
        font-size: 10px;
    }
    
    .btn-icon {
        min-width: 24px;
        height: 24px;
        padding: 2px;
    }
    
    .btn-icon i {
        font-size: 9px;
    }
}
.card h3 {
    margin: 0 0 16px 0;
    font-size: 16px;
    font-weight: 600;
    color: #000;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ===== RESPONSIVE DASHBOARD STYLES (FROM TANK VERSION) ===== */

/* Dashboard Container - Bootstrap Integration */
.dashboard-container {
    padding: 12px !important;
}

/* Desktop: Fixed viewport height */
@media (min-width: 992px) {
    .dashboard-container {
        height: calc(100vh - 98px) !important; /* Navbar (50px) + Toolbar (48px) */
        max-height: calc(100vh - 98px);
        overflow: hidden !important;
    }
}

/* Mobile/Tablet: Auto height with scroll */
@media (max-width: 991px) {
    .dashboard-container {
        height: auto !important;
        min-height: calc(100vh - 120px);
        overflow-x: auto;
    }
}

/* Activity Header */
.activity-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e5e7eb;
}

/* Activity Table Wrapper */
.activity-table-wrapper {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    max-height: 400px;
}

/* Activity Table Styling */
.activity-th {
    text-align: left;
    padding: 8px 6px !important;
    background: #f3f4f6 !important;
    color: #374151 !important;
    border-bottom: 1px solid #d1d5db !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

#logTable tbody td {
    padding: 8px 6px;
    border-bottom: 1px solid #e5e7eb;
    font-size: 13px;
    vertical-align: middle;
}

/* Mobile Navigation Menu Styles */
.mobile-nav-toggle,
.mobile-menu-toggle {
    background: none !important;
    border: none !important;
    color: #fff !important;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    margin: 0;
    transition: background-color 0.2s;
    position: relative;
    z-index: 10001;
    pointer-events: auto;
}

.mobile-nav-toggle:hover,
.mobile-menu-toggle:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    border-radius: 4px;
}

/* Ensure hamburger icon is white */
.mobile-nav-toggle i,
.mobile-menu-toggle i {
    color: #fff !important;
}

.mobile-nav-menu,
.mobile-menu {
    display: none;
    position: fixed;
    top: 50px; /* Updated for new navbar height */
    right: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0 0 0 8px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
    min-width: 240px;
    max-width: 300px;
    z-index: 9999;
}

.mobile-nav-menu.open,
.mobile-menu.open {
    display: block !important;
}

.mobile-nav-content,
.mobile-menu-content {
    display: flex;
    flex-direction: column;
    padding: 8px 0;
}

.mobile-nav-link,
.mobile-menu-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #374151;
    text-decoration: none;
    transition: background-color 0.2s;
    border-left: 3px solid transparent;
}

.mobile-nav-link:hover,
.mobile-menu-link:hover {
    background: #f3f4f6;
    border-left-color: var(--brand);
}

.mobile-nav-link.active,
.mobile-menu-link.active {
    background: var(--brand-50);
    border-left-color: var(--brand);
    color: var(--brand);
    font-weight: 600;
}

.mobile-nav-link i,
.mobile-menu-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

/* Sidebar Responsive - Overlay on Mobile */
@media (max-width: 768px) {
    /* Show mobile menu toggle, hide desktop nav links */
    .mobile-menu-toggle {
        display: block !important;
    }
    
    .sidebar {
        position: fixed;
        left: 0;
        top: 50px; /* Updated for new navbar height */
        height: calc(100vh - 50px);
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        width: 280px !important;
        max-width: 85vw;
        box-shadow: 2px 0 15px rgba(0, 0, 0, 0.2);
        border-right: 1px solid #cbd5e1;
    }
    
    .sidebar:not(.collapsed) {
        transform: translateX(0);
    }
    
    .sidebar.collapsed {
        transform: translateX(-100%);
    }
    
    /* Remove the default width on desktop when collapsed */
    .sidebar.collapsed {
        width: 0;
        min-width: 0;
        padding: 0;
        overflow: hidden;
    }
    
    /* Overlay backdrop when sidebar is open on mobile */
    body::after {
        content: '';
        position: fixed;
        top: 50px; /* Updated for new navbar height */
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s ease-in-out;
        display: none;
    }
    
    body:has(.sidebar:not(.collapsed))::after {
        opacity: 1;
        pointer-events: auto;
        display: block;
    }
    
    /* Content should not shift on mobile */
    .content {
        margin-left: 0 !important;
        width: 100% !important;
    }
}

/* Dashboard Grid Responsive Styles */
@media (min-width: 992px) {
    .dashboard-container .row {
        height: 100% !important;
        max-height: 100%;
    }
    
    .dashboard-left {
        height: 100% !important;
        max-height: 100%;
    }
    
    .dashboard-right {
        height: 100% !important;
        max-height: 100%;
    }
    
    /* Map: Takes 55% of left column */
    .map-panel-responsive {
        flex: 0 0 calc(55% - 6px) !important;
        max-height: calc(55% - 6px);
        min-height: 400px;
    }
    
    /* Activity Log: Takes 45% of left column */
    .activity-panel-responsive {
        flex: 1 1 calc(45% - 6px) !important;
        min-height: 250px;
    }
    
    /* Summary: Full right column with scroll */
    .panel-2 {
        height: 100% !important;
        max-height: 100%; /* Constrain height to enable scroll */
        min-height: 500px;
        overflow-y: auto !important;
    }
}

/* Tablet Responsiveness (768px - 991px) */
@media (max-width: 991px) {
    .dashboard-container {
        height: auto;
        min-height: calc(100vh - 120px);
        overflow-x: visible;
    }
    
    .panel-1 {
        min-height: 500px; /* Increased map height for tablet/mobile */
    }
    
    .panel-2 {
        min-height: auto;
    }
    
    .panel-3 {
        min-height: 400px;
    }
    
    /* Stack summary cards on tablet */
    .summary-stats {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* Mobile Responsiveness (< 768px) */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
    }
    
    .dashboard-container {
        padding: 8px !important;
        height: auto;
        min-height: calc(100vh - 120px);
    }
    
    .row.g-3 {
        gap: 0.75rem !important;
    }
    
    /* Map height on mobile - increased for better visibility */
    .panel-1 {
        min-height: 60vh;
        max-height: 60vh;
    }
    
    #map {
        height: 100% !important;
    }
    
    /* Summary cards - stack vertically on mobile */
    .summary-stats {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    
    .stat-item {
        padding: 16px 12px !important;
    }
    
    .stat-number {
        font-size: 24px !important;
    }
    
    .stat-label {
        font-size: 12px !important;
    }
    
    /* Activity log table - make scrollable */
    .panel-3 {
        min-height: 300px;
        max-height: 400px;
    }
    
    .activity-table-wrapper {
        overflow-x: auto;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        max-height: 300px;
    }
    
    .activity-th {
        font-size: 11px !important;
        padding: 6px 4px !important;
    }
    
    #logTable tbody td {
        font-size: 11px;
        padding: 6px 4px;
        white-space: nowrap;
    }
    
    /* Toolbar responsive */
    .toolbar {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    /* Hide user name on very small screens */
    .avatar-btn span:not(.avatar) {
        display: none;
    }
}

/* Tablet Cabmap (768px - 991px) - ONLY for actual tablets, not desktop with DevTools */
@media (min-width: 768px) and (max-width: 991px) and (pointer: coarse) {
    body {
        overflow-y: auto !important;
    }
    
    .cabmap-container {
        flex-direction: column !important;
        padding: 12px;
        height: auto !important;
        overflow-y: visible !important;
        gap: 12px;
    }
    
    .left-panel {
        gap: 12px;
        width: 100% !important;
        min-width: auto !important;
    }
    
    .right-panel {
        width: 100% !important;
        max-width: none !important;
        flex: 1 1 auto !important;
    }
    
    .map-panel {
        height: 450px !important;
        min-height: 450px;
        margin-bottom: 12px;
    }
    
    .map-and-status {
        gap: 12px;
        margin-bottom: 12px;
    }
    
    .activity-panel {
        min-height: 300px;
        max-height: 450px;
    }
    
    .status-panel {
        min-height: 400px;
        padding: 18px;
        background: #ffffff;
        border-radius: 8px;
    }
    
    .status-panel .status-info {
        gap: 0;
        display: flex;
        flex-direction: column;
    }
    
    /* Ensure Open Cabinet button looks great on tablet */
    .open-btn {
        width: 100%;
        justify-content: center;
        font-size: 15px !important;
    }
    
    /* Better status item layout on tablet */
    .status-panel .status-item {
        display: flex !important;
        flex-direction: row !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 12px 14px;
        background: #ffffff;
        border: none;
        border-bottom: 1px solid #e5e7eb;
        border-radius: 0;
        margin-bottom: 0;
    }
    
    .status-panel .status-item:first-child {
        border-top: 1px solid #e5e7eb;
    }
    
    .status-panel .status-label {
        font-size: 13px;
        color: #6b7280;
        font-weight: 500;
        text-align: left;
        min-width: 130px;
        max-width: 40%;
    }
    
    .status-panel .status-value {
        font-size: 13px;
        font-weight: 600;
        color: #111827;
        text-align: right;
        flex: 1;
        word-break: break-word;
    }
    
    .status-panel h3 {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    .control-buttons {
        margin-bottom: 20px;
    }
    
    .control-btn {
        width: 100%;
        padding: 14px 16px;
        font-size: 15px;
    }
    
    /* Status badges styling for tablet */
    .status-panel .status-value.active,
    .status-panel .status-value.inactive,
    .status-panel .status-value.normal,
    .status-panel .status-value.unknown {
        padding: 4px 12px;
        font-size: 12px;
        border-radius: 6px;
    }
    
    /* Activity panel for tablet */
    .activity-panel {
        padding: 16px;
        min-height: 350px;
        max-height: 500px;
    }
    
    .activity-panel table {
        font-size: 13px;
    }
    
    .activity-panel th,
    .activity-panel td {
        padding: 10px 8px;
        font-size: 13px;
    }
    
    /* Cabinet status panel */
    .cabinet-status-panel {
        padding: 16px;
    }
    
    .cabinet-status-panel h3 {
        font-size: 16px;
        margin-bottom: 14px;
    }
    
    .status-icons {
        gap: 10px;
    }
    
    .status-icon-item {
        padding: 12px;
    }
}

/* Mobile Cabmap (< 768px) */
@media (max-width: 767px) {
    body {
        overflow-y: auto !important;
        overflow-x: hidden;
    }
    
    .cabmap-container {
        padding: 8px;
        height: auto !important;
        overflow-y: visible !important;
    }
    
    .map-panel {
        height: 400px;
        min-height: 400px;
        margin-bottom: 12px;
    }
    
    .activity-panel {
        min-height: 350px;
        max-height: 400px;
        margin-bottom: 12px;
    }
    
    .status-panel {
        min-height: 300px;
        margin-bottom: 20px;
        padding: 12px;
    }
    
    /* Better status item layout on mobile */
    .status-panel .status-item {
        flex-direction: row !important;
        justify-content: space-between;
        align-items: center;
        padding: 10px 12px !important;
        background: #f9fafb;
        border: 1px solid #e5e7eb;
        border-radius: 6px;
        margin-bottom: 6px;
    }
    
    .status-panel .status-label {
        font-size: 12px !important;
        font-weight: 500;
        color: #6b7280;
        min-width: auto !important;
        max-width: 50%;
        text-align: left !important;
        margin-right: 8px;
    }
    
    .status-panel .status-value {
        font-size: 12px !important;
        font-weight: 600;
        color: #111827;
        text-align: right !important;
        word-break: break-word;
        max-width: 50%;
    }
    
    /* Control button full width on mobile */
    .control-buttons {
        margin-bottom: 16px;
    }
    
    .control-btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }
}

/* Small Mobile (< 576px) */
@media (max-width: 576px) {
    .dashboard-container {
        padding: 4px !important;
        min-height: calc(100vh - 100px);
    }
    
    /* Cabmap small mobile styles */
    .cabmap-container {
        padding: 4px !important;
    }
    
    .map-panel {
        height: 350px !important;
        min-height: 350px;
    }
    
    .activity-panel {
        min-height: 300px;
        max-height: 400px;
    }
    
    .cabinet-status-panel {
        padding: 8px;
    }
    
    .status-panel {
        padding: 10px;
    }
    
    .status-panel h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    /* Compact status items for small screens */
    .status-panel .status-item {
        padding: 8px 10px !important;
        margin-bottom: 4px;
    }
    
    .status-panel .status-label {
        font-size: 11px !important;
    }
    
    .status-panel .status-value {
        font-size: 11px !important;
    }
    
    .control-btn {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .row.g-3 {
        gap: 0.5rem !important;
    }
    
    .panel-1 {
        min-height: 50vh; /* Increased map height for small mobile */
        max-height: 50vh;
    }
    
    .panel-2 {
        padding: 8px;
    }
    
    .panel-3 {
        padding: 8px;
        min-height: 250px;
    }
    
    .quick-summary h3 {
        font-size: 14px;
        margin-bottom: 12px;
    }
    
    .stat-item {
        padding: 12px 8px !important;
        border-radius: 12px;
    }
    
    .stat-icon {
        width: 40px !important;
        height: 40px !important;
        font-size: 18px !important;
    }
    
    .stat-number {
        font-size: 20px !important;
    }
    
    .stat-label {
        font-size: 11px !important;
    }
    
    .activity-header label {
        font-size: 12px;
    }
    
    .activity-th {
        font-size: 10px !important;
        padding: 4px 3px !important;
    }
    
    #logTable tbody td {
        font-size: 10px;
        padding: 4px 3px;
    }
    
    .status-badge {
        font-size: 9px !important;
        padding: 2px 6px !important;
    }
}

/* Map Responsive Styles */
@media (max-width: 768px) {
    .panel-1 #map {
        height: 100% !important;
    }
}

/* Remove fixed widths on mobile */
@media (max-width: 991px) {
    .container {
        max-width: 100% !important;
        padding-left: 12px;
        padding-right: 12px;
    }
}

/* Navbar responsive adjustments */
@media (max-width: 991px) {
    .navbar {
        padding: 6px 12px;
    }
    
    .logo {
        width: 120px;
        height: 30px;
    }
    
    .nav-left {
        gap: 8px;
    }
}

@media (max-width: 576px) {
    .navbar {
        padding: 4px 8px;
    }
    
    .logo {
        width: 100px;
        height: 26px;
    }
    
    .sidebar-toggle {
        font-size: 16px;
        padding: 2px;
    }
}

/* Content area adjustments when sidebar is present */
.content {
    transition: margin-left 0.3s ease;
}

@media (min-width: 769px) {
    .sidebar.collapsed + .content {
        margin-left: 0;
    }
}

/* Utility classes for responsive visibility */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }
}

/* Fix Bootstrap table responsive issues */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Ensure panels don't break layout */
.panel-1, .panel-2, .panel-3 {
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-1 {
    padding: 0;
    min-height: 200px;
}

.panel-2, .panel-3 {
    padding: 12px;
    min-height: 200px;
}

/* Desktop: Remove min-height constraints for proper flex behavior */
@media (min-width: 992px) {
    .panel-1, .panel-2, .panel-3 {
        min-height: 0;
    }
}

/* Map container full height fix */
.panel-1 .map-container,
.panel-1 #map {
    width: 100%;
    height: 100%;
    min-height: inherit;
    border-radius: 8px;
}

/* Summary cards grid adjustment */
.summary-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

@media (max-width: 768px) {
    .summary-stats {
        grid-template-columns: 1fr;
        gap: 12px;
    }
}

/* Activity log scrolling on mobile */
@media (max-width: 768px) {
    .panel-3 {
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }
    
    .activity-table-wrapper {
        flex: 1;
        overflow-y: auto;
        overflow-x: auto;
    }
}

/* Landscape mobile optimization */
@media (max-width: 896px) and (orientation: landscape) {
    .panel-1 {
        min-height: 80vh; /* Increased for landscape view */
        max-height: 80vh;
    }
    
    .panel-2 {
        min-height: auto;
    }
    
    .summary-stats {
        grid-template-columns: 1fr 1fr;
    }
}

/* High DPI / Retina displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .panel-1, .panel-2, .panel-3 {
        border-width: 0.5px;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .navbar,
    .toolbar,
    .mobile-nav-menu,
    .mobile-menu {
        display: none !important;
    }
    
    .content {
        width: 100% !important;
        margin: 0 !important;
    }
    
    .dashboard-container {
        height: auto !important;
        page-break-inside: avoid;
    }
}

/* Desktop sidebar behavior - ensure smooth transition */
@media (min-width: 769px) {
    .sidebar {
        position: relative;
        transform: none !important;
    }
    
    .sidebar.collapsed {
        width: 0 !important;
        min-width: 0 !important;
        padding: 0;
        border-right: none;
        overflow: hidden;
    }
    
    .content {
        transition: margin-left 0.3s ease;
    }
}

/* Improve button click responsiveness on touch devices */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .nav-link,
    .mobile-nav-link,
    .mobile-menu-link,
    .sidebar-toggle,
    .mobile-nav-toggle,
    .mobile-menu-toggle {
        -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
        user-select: none;
    }
}

/* Smooth scrolling for better UX */
html {
    scroll-behavior: smooth;
}

/* Better text rendering on all devices */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* Accessibility: Ensure focus states are visible */
a:focus,
button:focus,
input:focus,
select:focus,
textarea:focus {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Keep Quick Summary on the right and sticky on desktop */
@media (min-width: 992px) {
    .summary-aside {
        position: sticky;
        top: 98px; /* navbar (50px) + toolbar (48px) height */
        align-self: flex-start;
    }
    .summary-aside .summary-stats {
        grid-template-columns: 1fr !important; /* vertical cards */
    }
}

/* Dashboard grid fixes to avoid global .row override conflicts */
.dashboard-container .row {
    display: flex !important;
    flex-wrap: wrap !important;
}

/* Desktop: Use proper flex alignment */
@media (min-width: 992px) {
    .dashboard-container .row {
        align-items: stretch !important;
        gap: 0 !important; /* gutters handled by Bootstrap */
    }
}

/* Mobile/Tablet: Allow natural flow */
@media (max-width: 991px) {
    .dashboard-container .row {
        align-items: flex-start;
    }
}

/* Activity aside sidebar on desktop */
@media (min-width: 992px) {
    .activity-aside {
        position: sticky;
        top: 73px;
        align-self: flex-start;
    }
}