:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.92);
    --text-main: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

body { margin: 0; font-family: 'Inter', sans-serif; color: var(--text-main); overflow: hidden; background: #f1f5f9; }

/* --- Top Nav --- */
.top-nav {
    position: absolute; top: 0; left: 0; width: 100%; height: 64px;
    background: var(--surface-glass); backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border); z-index: 20;
    display: flex; justify-content: space-between; align-items: center; padding: 0 24px;
    box-sizing: border-box; box-shadow: var(--shadow-sm);
}

.brand-section { display: flex; gap: 12px; align-items: center; }
.logo-icon { 
    width: 40px; height: 40px; background: var(--primary); color: white; 
    border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
}
.brand-text h1 { font-size: 1.2rem; margin: 0; font-weight: 700; letter-spacing: -0.5px; }
.brand-text .highlight { color: var(--primary); }
.brand-text small { display: block; font-size: 0.75rem; color: var(--text-light); font-weight: 500; }

.status-indicator { 
    display: flex; align-items: center; gap: 8px; font-size: 0.85rem; 
    font-weight: 600; color: var(--text-light); background: #f8fafc; 
    padding: 6px 12px; border-radius: 20px; border: 1px solid var(--border);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; }
.dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2); }

/* --- Map --- */
#map { width: 100vw; height: 100vh; z-index: 1; }

/* --- Floating Toolbar (Left) --- */
.floating-toolbar {
    position: absolute; top: 84px; left: 20px; z-index: 10;
    background: var(--surface); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 8px;
    width: 220px; display: flex; flex-direction: column; gap: 4px;
}

.toolbar-header {
    padding: 8px 12px; font-size: 0.75rem; text-transform: uppercase;
    color: var(--text-light); font-weight: 700; letter-spacing: 0.5px;
}

.tool-btn {
    display: flex; align-items: center; gap: 12px; padding: 10px;
    border: none; background: transparent; cursor: pointer;
    border-radius: 8px; transition: all 0.2s ease; text-align: left;
    width: 100%; font-weight: 500; color: var(--text-main);
}

.tool-btn:hover { background: #f1f5f9; transform: translateX(2px); }
.tool-btn:active { background: #e2e8f0; transform: translateX(0); }

.icon-box {
    width: 32px; height: 32px; border-radius: 6px; 
    display: flex; align-items: center; justify-content: center; font-size: 0.9rem;
    color: white;
}
.icon-box.structure { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.icon-box.road { background: linear-gradient(135deg, #64748b, #475569); }
.icon-box.drain { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.icon-box.water { background: linear-gradient(135deg, #38bdf8, #0ea5e9); }
.icon-box.electric { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.icon-box.waste { background: linear-gradient(135deg, #a8a29e, #78716c); }

.divider { height: 1px; background: var(--border); margin: 4px 0; }

/* --- Right Panel --- */
.right-panel {
    position: absolute; top: 84px; right: 20px; z-index: 10;
    width: 300px; background: var(--surface-glass); backdrop-filter: blur(12px);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    display: flex; flex-direction: column; max-height: calc(100vh - 120px);
    border: 1px solid rgba(255,255,255,0.5);
}

.panel-header {
    padding: 16px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.panel-header h3 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.minimize-btn { background: none; border: none; color: var(--text-light); cursor: pointer; }

.panel-content { padding: 12px; overflow-y: auto; }

.accordion-item {
    background: white; border: 1px solid var(--border); margin-bottom: 8px;
    border-radius: 8px; overflow: hidden; transition: all 0.2s;
}
.accordion-header {
    padding: 12px; cursor: pointer; display: flex; align-items: center; gap: 10px;
    font-size: 0.85rem; font-weight: 600;
}
.accordion-header:hover { background: #f8fafc; }
.accordion-header input { cursor: pointer; width: 16px; height: 16px; accent-color: var(--primary); }

.accordion-body { padding: 12px; background: #f8fafc; border-top: 1px solid var(--border); }

.legend-item {
    display: flex; align-items: center; gap: 10px; padding: 4px 0;
    font-size: 0.8rem; color: var(--text-light);
}
.color-box { width: 10px; height: 10px; border-radius: 3px; }

/* --- Modal --- */
.modal-backdrop {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.4); backdrop-filter: blur(2px);
    z-index: 100; display: none; justify-content: center; align-items: center;
}

.modal-card {
    background: white; width: 480px; border-radius: 16px;
    box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
    max-height: 85vh; animation: popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.modal-header {
    padding: 20px 24px; border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; align-items: center;
}
.modal-header h3 { margin: 0; font-size: 1.1rem; }
.close-icon { border: none; background: none; font-size: 1.2rem; color: var(--text-light); cursor: pointer; }

.modal-body { padding: 24px; overflow-y: auto; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }
.form-control {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border);
    border-radius: 8px; font-size: 0.9rem; transition: all 0.2s;
    font-family: 'Inter', sans-serif; box-sizing: border-box;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

.modal-footer {
    padding: 16px 24px; background: #f8fafc; border-top: 1px solid var(--border);
    border-radius: 0 0 16px 16px; display: flex; justify-content: space-between;
}

.action-group { display: flex; gap: 12px; }

.btn {
    padding: 10px 20px; border-radius: 8px; font-weight: 600; font-size: 0.9rem;
    cursor: pointer; border: none; display: flex; align-items: center; gap: 8px;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border: 1px solid var(--border); color: var(--text-main); }
.btn-secondary:hover { background: #f1f5f9; }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-danger-text { color: #ef4444; }
.btn-danger-text:hover { background: #fee2e2; }

/* Custom InfoWindow (Popup) Style Override */
.gm-style .gm-style-iw-c { padding: 0 !important; border-radius: 12px !important; }
.gm-style-iw-d { overflow: hidden !important; }
.custom-iw { padding: 16px; min-width: 200px; }
.custom-iw h4 { margin: 0 0 8px 0; font-size: 1rem; color: var(--text-main); }
.custom-iw p { margin: 0 0 12px 0; font-size: 0.85rem; color: var(--text-light); }
.iw-actions { display: flex; gap: 8px; margin-top: 10px; }
.iw-btn { padding: 4px 10px; font-size: 0.75rem; border-radius: 4px; border: 1px solid var(--border); cursor: pointer; background: white; }