body, html { margin: 0; padding: 0; height: 100%; width: 100%; font-family: 'Segoe UI', Arial, sans-serif; overflow: hidden; background: #f4f7f6; }
#dashboard { display: flex; height: 100vh; width: 100vw; flex-direction: row; } 

/* --- LOGIN SCREEN (OVERLAY) --- */
#login-screen { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: #2c3e50; z-index: 9999; display: flex; justify-content: center; align-items: center; transition: opacity 0.3s ease; }
.login-card { background: #fff; padding: 30px; border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); width: 380px; max-width: 90%; text-align: center; }
.login-card h2 { color: #9b59b6; margin-top: 0; margin-bottom: 25px; }

/* Sidebar & Product Selector */
#sidebar { width: 400px; background: #f8f9fa; display: flex; flex-direction: column; box-shadow: 2px 0 5px rgba(0,0,0,0.1); z-index: 1000; overflow-y: auto; box-sizing: border-box; }
#sidebar h2 { margin: 0; padding: 20px 20px 10px 20px; color: #9b59b6; font-size: 1.5em; text-align: center; }

.product-selector { display: flex; justify-content: center; gap: 5px; padding: 0 10px 10px 10px; border-bottom: 2px solid #3498db; }
.prod-btn { flex: 1; padding: 10px 0; border: 1px solid #ccc; border-radius: 4px; background: #fff; cursor: pointer; font-weight: bold; font-size: 0.9em; color: #555; transition: all 0.2s; }
.prod-btn:hover { background: #e9ecef; }

/* Dynamic Button Active Colors */
.active-ir { background-color: #ffe6ea !important; border-color: #ffb3c1 !important; color: #c9184a !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.active-dr { background-color: #f5d6b8 !important; border-color: #e6b89c !important; color: #9c6644 !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.active-nr { background-color: #bae6fd !important; border-color: #7dd3fc !important; color: #0369a1 !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.active-wr { background-color: #e0f2fe !important; border-color: #bae6fd !important; color: #0284c7 !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }
.active-uh { background-color: #dcfce7 !important; border-color: #bbf7d0 !important; color: #166534 !important; box-shadow: inset 0 2px 4px rgba(0,0,0,0.1); }

/* Theme Wrapper */
#theme-wrapper { padding: 15px 20px; flex-grow: 1; transition: background-color 0.3s ease; display: flex; flex-direction: column; }
.theme-ir { background-color: #ffe6ea; } 
.theme-dr { background-color: #f5d6b8; } 
.theme-nr { background-color: #bae6fd; }
.theme-wr { background-color: #e0f2fe; } 
.theme-uh { background-color: #dcfce7; } 

/* Tabs */
.tab-buttons { display: flex; margin-bottom: 15px; }
.tab-buttons button { flex: 1; padding: 10px 2px; cursor: pointer; background: rgba(255,255,255,0.5); border: 1px solid rgba(0,0,0,0.1); border-bottom: 2px solid rgba(0,0,0,0.1); font-weight: bold; color: #495057; transition: background 0.2s; border-radius: 4px 4px 0 0; white-space: nowrap; font-size: 0.88em; }
.tab-buttons button:hover { background: rgba(255,255,255,0.8); }
.tab-buttons button.active-btn { background: #fff; border-bottom: 2px solid #fff; color: #2c3e50; box-shadow: 0 -2px 5px rgba(0,0,0,0.05); }
.tab-content { display: none; background: #fff; padding: 15px; border-radius: 0 4px 4px 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); }
.tab-content.active { display: block; }

/* Compact Form Layout */
.form-row { display: flex; align-items: center; margin-bottom: 8px; }
.form-row label { flex: 0 0 115px; margin-top: 0; font-size: 0.85em; font-weight: bold; color: #333; line-height: 1.1; }
.form-row input { flex: 1; width: 100%; padding: 6px 8px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; font-size: 0.9em;}

.form-row-multi { display: flex; align-items: center; margin-bottom: 8px; gap: 5px; }
.form-row-multi label { flex: 0 0 auto; margin-top: 0; font-size: 0.85em; font-weight: bold; color: #333; }
.form-row-multi input { flex: 1; min-width: 0; padding: 6px 8px; box-sizing: border-box; border: 1px solid #ccc; border-radius: 4px; font-size: 0.9em;}
::placeholder { font-size: 0.85em; color: #aaa; }

.fake-input { flex: 1; padding: 6px 8px; border: 1px solid rgba(0,0,0,0.1); border-radius: 4px; background-color: #f1f3f5; font-size: 0.85em; display: flex; align-items: center; min-height: 16px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* Buttons */
.btn { padding: 12px 14px; border: none; cursor: pointer; border-radius: 6px; width: 100%; margin-top: 10px; font-weight: bold; font-size: 1em; transition: opacity 0.1s, transform 0.1s; touch-action: manipulation; min-height: 44px; display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.btn:hover { opacity: 0.9; }
.btn:active { transform: scale(0.98); }
.btn-primary { background: #3498db; color: white; margin-top: 15px;}
.btn-info { background: #17a2b8; color: white; }
.btn-warning { background: #f39c12; color: white; }
.btn-purple { background: #9b59b6; color: white; margin-top: 15px;}

/* Layer Controls */
.layer-group { margin-bottom: 15px; border-bottom: 1px solid #eee; padding-bottom: 10px; }
.layer-group > label { margin-top: 0; font-size: 0.95em; display: flex; align-items: center; gap: 8px; cursor: pointer; color: #2c3e50; font-weight: bold; }
.layer-actions { margin-top: 8px; display: flex; flex-direction: column; gap: 10px; padding-left: 25px; }
.layer-action-item { display: flex; align-items: center; gap: 12px; font-size: 0.9em; touch-action: manipulation; }
.layer-action-item input[type="checkbox"] { width: 18px; height: 18px; margin: 0; cursor: pointer; touch-action: manipulation; }
.action-link { cursor: pointer; color: #3498db; text-decoration: underline; padding: 6px 0; touch-action: manipulation; display: inline-block; }
.action-link:hover { color: #2980b9; }

/* Product Thumbnail */
.product-thumb-container { width: 100%; margin-top: auto; padding-top: 15px; box-sizing: border-box; }
.product-thumb-container img { width: 100%; height: auto; display: block; object-fit: cover; border-radius: 6px; box-shadow: 0 2px 6px rgba(0,0,0,0.15); border: 1px solid rgba(0,0,0,0.1); }

/* Logos */
.logos { display: flex; justify-content: space-around; align-items: center; padding: 15px 20px 20px 20px; background: #ffffff; border-top: 1px solid #ddd; }
.logos img { max-height: 100px; max-width: 160px; object-fit: contain; }

/* Bulletproof Map Layout */
#main-content { flex: 1; display: flex; flex-direction: column; position: relative; height: 100vh; min-width: 0; }
#map-container { flex: 1; position: relative; width: 100%; min-height: 0; }
#map { position: absolute; top: 0; bottom: 0; left: 0; right: 0; z-index: 1; }
.north-arrow { position: absolute; top: 20px; right: 20px; z-index: 999; width: 45px; pointer-events: none; filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3)); }

/* --- FIXED: SEAMLESS CUSTOM ZOOM & EXTENT CONTROLS --- */
/* Nuke Leaflet's native tiny square constraints */
.custom-zoom-block.leaflet-bar { 
    border: 2px solid rgba(0,0,0,0.2) !important; 
    border-radius: 4px !important; 
    background: #fff; 
    box-shadow: 0 1px 5px rgba(0,0,0,0.4); 
    overflow: hidden; 
    display: flex; 
    flex-direction: column; 
    width: auto !important;
    min-width: 90px;
}

.custom-zoom-block .zoom-title { 
    text-align: center; 
    font-size: 11px; 
    font-family: Arial, sans-serif;
    color: #333; 
    border-bottom: 1px solid #ccc; 
    padding: 6px 0; 
    margin: 0;
    background: #e0e0e0;
}

.custom-zoom-block .zoom-in-out { 
    display: flex; 
    width: 100%; 
    border-bottom: 1px solid #ccc; 
}

/* Force A tags to stretch 100% of the box */
.custom-zoom-block a { 
    display: flex !important; 
    align-items: center !important; 
    justify-content: center !important; 
    width: 100% !important; 
    height: auto !important; 
    line-height: normal !important; 
    padding: 8px 10px !important; 
    color: #333 !important; 
    text-decoration: none !important; 
    box-sizing: border-box !important; 
    border-radius: 0 !important;
    font-family: Arial, sans-serif;
}

.custom-zoom-block .zoom-in-out a { 
    flex: 1 !important; 
    font-size: 20px !important; 
    font-weight: bold !important; 
    border-bottom: none !important; 
    padding: 4px 0 !important;
}

.custom-zoom-block .zoom-in-out a:first-child { border-right: 1px solid #ccc !important; }

.custom-zoom-block .custom-ext-btn { 
    font-size: 12px !important; 
    border-bottom: 1px solid #ccc !important; 
    white-space: nowrap !important; 
}

.custom-zoom-block .custom-ext-btn:last-child { border-bottom: none !important; }
.custom-zoom-block a:hover { background-color: #f4f4f4 !important; color: #000 !important; }

/* Attribute Table */
#table-panel { height: 250px; background: #fff; border-top: 3px solid #3498db; overflow-y: auto; overflow-x: auto; display: none; z-index: 2; position: relative; width: 100%; box-sizing: border-box; }
.close-table { position: sticky; left: 10px; top: 5px; background: #e74c3c; color: white; border: none; padding: 5px 10px; cursor: pointer; font-size: 0.8em; z-index: 10; float: right; margin: 5px; border-radius: 3px;}
#table-panel table { width: 100%; border-collapse: collapse; font-size: 0.9em; white-space: nowrap; }
#table-panel th, #table-panel td { border: 1px solid #ddd; padding: 8px; text-align: left; }
#table-panel th { background-color: #f8f9fa; position: sticky; top: 0; z-index: 1; box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.4); }
.leaflet-tooltip.clean-label { background-color: transparent !important; border: none !important; box-shadow: none !important; padding: 0 !important; }

/* Market Scope UI */
.market-split-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 5px; }
.or-divider-text { text-align: center; color: #a6acaf; font-size: 0.9em; margin: 10px 0; font-family: monospace; }
.mark-map-row { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 20px; }
.btn-icon-map { background: #d6eaf8; border: 1px solid #aed6f1; border-radius: 4px; padding: 5px 12px; cursor: pointer; font-size: 1.2em; transition: background 0.2s; }
.btn-icon-map:hover { background: #aed6f1; }
.btn-orange { background: #f39c12 !important; width: 100%; font-size: 1.1em; padding: 12px; border-radius: 4px; border: none; color: white; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.btn-orange:hover { background: #e67e22 !important; }
.market-progress-row { display: flex; align-items: center; gap: 10px; }
.btn-teal { background: #1abc9c !important; color: white; padding: 10px 40px; border-radius: 4px; border: none; font-weight: bold; cursor: pointer; transition: background 0.2s; }
.btn-teal:hover { background: #16a085 !important; }

/* Route Maps Label Styles */
.track-route-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 800;
    font-size: 14px;
    color: #333;
    text-shadow: -2px -2px 0 rgba(255,255,255,0.9), 2px -2px 0 rgba(255,255,255,0.9), -2px 2px 0 rgba(255,255,255,0.9), 2px 2px 0 rgba(255,255,255,0.9);
}

.agent-halo-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    font-weight: 700;
    font-size: 12px;
    color: #111;
    text-shadow: -1.5px -1.5px 0 rgba(255,255,255,0.9), 1.5px -1.5px 0 rgba(255,255,255,0.9), -1.5px 1.5px 0 rgba(255,255,255,0.9), 1.5px 1.5px 0 rgba(255,255,255,0.9);
    margin-top: -12px;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {
    #dashboard { flex-direction: column-reverse; }
    #main-content { flex: 0 0 45vh; width: 100%; } 
    #sidebar { flex: 1; width: 100%; height: 55vh; } 
    .form-row label { flex: 0 0 100px; } 
    .product-thumb-container { padding-top: 5px; }
}

/* --- CARTOGRAPHIC PRINT ENGINE --- */
.print-only { display: none !important; }

@media print {
    @page { size: landscape; margin: 5mm; }
    
    body * { visibility: hidden; }
    body, html { margin: 0; padding: 0; background: white; }
    
    #dashboard { flex-direction: column; overflow: visible !important; }
    #sidebar { display: none !important; }
    
    #main-content {
        position: absolute !important;
        left: 0 !important;
        top: 0 !important;
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        min-height: 100% !important;
        overflow: hidden !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: avoid !important;
        page-break-before: avoid !important;
        display: flex !important;
        flex-direction: row !important;
        flex: 0 0 100% !important;
        visibility: visible !important;
        box-sizing: border-box !important;
        border: 2px solid #2c3e50 !important;
        margin: 0 !important;
    }
    
    #map-container {
        flex: 1;
        position: relative;
        height: 100%;
        border-right: 2px solid #2c3e50;
        visibility: visible !important;
        display: block !important;
    }
    
    #map {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        height: 100%;
        visibility: visible;
    }
    #map * { visibility: visible; }
    
    #print-layout-sidebar {
        width: 170px;
        height: 100%;
        display: flex !important;
        flex-direction: column;
        align-items: center;
        justify-content: space-evenly;
        padding: 5px;
        box-sizing: border-box;
        background: #ffffff;
        visibility: visible !important;
    }
    #print-layout-sidebar * { visibility: visible !important; }
    
    /* Prevent printing multiple pages by suppressing vertical overflows implicitly */
    html { overflow: hidden; }
    
    /* Ensure Leaflet controls like Custom Zoom disappear but Scale stays */
    .leaflet-control-zoom, .custom-zoom-block { display: none !important; }
    .leaflet-control-scale { visibility: visible !important; bottom: 20px !important; left: 20px !important; transform: scale(1.5); transform-origin: left bottom; }
}
