/* BASE RESET & LAYOUT */
*, *::before, *::after { box-sizing: border-box; }
body, html { 
    margin: 0; padding: 0; width: 100vw; height: 100vh; 
    font-family: 'Share Tech Mono', 'Segoe UI', monospace; 
    overflow: hidden; background: #050505; color: #ccc;
}

#app-layout { display: flex; flex-direction: row; height: 100%; width: 100%; }

/* SIDEBAR */
#unified-sidebar {
    width: 360px; height: 100%; background: #0a0a0a; display: flex; flex-direction: column;
    border-right: 1px solid #333; z-index: 2000; box-shadow: 2px 0 15px rgba(255, 87, 34, 0.1);
}

.sidebar-header-fixed { flex-shrink: 0; background: #0a0a0a; z-index: 10; }
.sidebar-header { padding: 15px; border-bottom: 2px solid #ff5722; background: #111; }

.mars-logo-text { 
    margin: 0; font-size: 24px; color: #ff5722; font-family: 'Oswald', sans-serif; 
    letter-spacing: 2px; text-shadow: 0 0 10px rgba(255, 87, 34, 0.6); text-transform: uppercase; 
}
.sidebar-subtitle { font-size: 11px; color: #888; font-weight: bold; letter-spacing: 1px; }

.sidebar-scroll-area { flex: 1; overflow-y: auto; padding: 15px; }

/* CARDS & CONTROLS */
.card { background: #151515; border: 1px solid #333; border-radius: 4px; padding: 12px; margin-bottom: 15px; }
.card h3 { margin: 0 0 10px 0; font-size: 14px; color: #03a9f4; text-transform: uppercase; border-bottom: 1px dashed #444; padding-bottom: 6px;}

select { width: 100%; padding: 8px; background: #222; color: #fff; border: 1px solid #444; border-radius: 4px; font-family: inherit; }

.layer-toggles label { display: block; padding: 6px 0; color: #ccc; font-size: 13px; cursor: pointer; }
.layer-toggles input { margin-right: 8px; cursor: pointer; accent-color: #ff5722; transform: scale(1.2); }

.telemetry-box { background: #0a0a0a; padding: 10px; border: 1px solid #333; font-size: 13px; line-height: 1.6; }

.disclaimer-text { font-size: 10px; color: #ff5722; font-style: italic; line-height: 1.3; margin-top: 4px; }

/* USA STAMP & TOGGLES */
.made-in-usa-stamp {
    margin: 0.5rem auto; display: inline-block; padding: 4px 12px; border-radius: 4px; font-weight: bold; 
    background-color: #ffffff; border: 1px solid #ccc; box-shadow: 0 2px 4px rgba(0,0,0,0.1); color: #111;
}

.usa-toggle {
    background-color: #ffffff !important; border: 1px solid #ccc; box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    color: #111 !important; padding: 6px 10px !important; border-radius: 4px; font-weight: bold;
    display: block; margin-top: 10px;
}

/* MAP AREA */
#map-area-wrapper { flex: 1; position: relative; background: #000; display: flex; flex-direction: row; overflow: hidden; }
#map-container { flex: 1; position: relative; height: 100%; }

#center-pin {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -100%);
    width: 36px; height: 36px; pointer-events: none; z-index: 500;
}

/* DATA DESK (DASHBOARD) */
#dashboard-container {
    width: 400px; flex-shrink: 0; background: #050505; border-left: 1px solid #333; 
    display: flex; flex-direction: column; overflow: hidden;
}
.mars-table { width: 100%; border-collapse: collapse; font-size: 12px; color: #ccc; }
.mars-table th { background: #222; color: #ff5722; padding: 10px; text-align: left; position: sticky; top: 0; cursor: pointer; border-bottom: 1px solid #ff5722;}
.mars-table th:hover { background: #333; }
.mars-table td { padding: 10px; border-bottom: 1px solid #222; }
.mars-table tr.clickable-row { cursor: pointer; transition: background 0.2s; }
.mars-table tr.clickable-row:hover { background: #1a1a1a; }

/* TOOLTIP & LOADING */
#persistent-tooltip {
    position: absolute; z-index: 3500; background: rgba(10, 10, 10, 0.95); color: #fff;
    padding: 15px; border-radius: 4px; max-width: 320px; font-size: 13px; 
    border: 1px solid #ff5722; box-shadow: 0 0 15px rgba(255, 87, 34, 0.3);
    transform: translate(-50%, -110%); margin-top: -10px; pointer-events: auto;
}
.close-tooltip-btn {
    position: absolute; top: 4px; right: 4px; background: rgba(255, 255, 255, 0.2);
    color: white; border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer;
}

#loading-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: #050505; z-index: 4000;
    display: flex; flex-direction: column; justify-content: center; align-items: center; color: #ff5722; font-size: 18px; transition: opacity 0.5s;
}
.spinner { border: 4px solid #111; border-top: 4px solid #ff5722; border-radius: 50%; width: 40px; height: 40px; animation: spin 1s linear infinite; margin-bottom: 10px; }
@keyframes spin { 100% { transform: rotate(360deg); } }
.hidden { opacity: 0; pointer-events: none; }

/* Desktop / Mobile Rules */
@media (min-width: 769px) { .mobile-only { display: none !important; } }
@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    #app-layout { flex-direction: column; }
    #unified-sidebar { width: 100%; height: 50vh; border-right: none; border-bottom: 1px solid #333; }
    #dashboard-container { display: none !important; }
}