:root {
    --bg-dark: #1e1e1e;
    --sidebar-bg: #2d2d2d;
    --border-color: #404040;
    --text-primary: #cccccc;
    --text-secondary: #999999;
    --accent: #4a90d9;
    --accent-hover: #3a7bc8;
    --danger: #c0392b;
    --input-bg: #383838;
    --input-border: #555555;
    --button-bg: #404040;
    --button-hover: #505050;
    --header-text: #e0e0e0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', -apple-system, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    overflow: hidden;
    font-size: 13px;
}

#app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Sidebar Styling */
#sidebar {
    width: 350px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    background: #252525;
}

header h1 {
    font-size: 16px;
    font-weight: 500;
    color: var(--header-text);
    margin: 0;
}

.control-group {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
}

details.control-group summary {
    list-style: none;
    cursor: pointer;
    outline: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
details.control-group summary::-webkit-details-marker {
    display: none;
}
details.control-group summary h3 {
    margin-bottom: 0 !important;
}
details.control-group summary::after {
    content: '▼';
    font-size: 10px;
    color: var(--text-secondary);
    transition: transform 0.2s;
}
details.control-group[open] summary::after {
    transform: rotate(-180deg);
}
details.control-group[open] summary {
    margin-bottom: 10px;
}

.control-group h3 {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.help-text {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 10px;
}

/* Toggle Buttons */
.toggle-container {
    display: flex;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    margin-bottom: 10px;
    overflow: hidden;
}

.toggle-container button {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 6px 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    font-size: 12px;
}

.toggle-container button.active {
    background: var(--button-bg);
    color: var(--text-primary);
}

/* Common UI Elements */
.hidden {
    display: none !important;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.file-upload-btn, .secondary-btn, .primary-btn {
    display: block;
    width: 100%;
    text-align: center;
    padding: 6px 12px;
    border-radius: 3px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid var(--border-color);
}

.file-upload-btn {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.file-upload-btn:hover {
    background: var(--button-hover);
}

.secondary-btn {
    background: var(--button-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.secondary-btn:hover:not(:disabled) {
    background: var(--button-hover);
}

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

.primary-btn {
    background: var(--accent);
    color: white;
    border: 1px solid var(--accent-hover);
    padding: 8px 16px;
    font-size: 13px;
}

.primary-btn:hover {
    background: var(--accent-hover);
}

/* List Section */
.list-section {
    flex: 1;
    overflow-y: auto;
    padding: 14px 16px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}
::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Surface Item */
.surface-item {
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.surface-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.surface-header span {
    font-size: 12px;
    color: var(--text-primary);
    font-weight: 500;
}

.btn-delete {
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 2px;
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-group label {
    font-size: 12px;
    color: var(--text-secondary);
    width: 60px;
}

.input-group input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 2px;
    color: var(--text-primary);
    padding: 4px 6px;
    font-family: inherit;
    font-size: 12px;
    outline: none;
}

.input-group input:focus {
    border-color: var(--accent);
}

/* Export Section */
.export-section {
    padding: 14px 16px;
    border-top: 1px solid var(--border-color);
    background: var(--sidebar-bg);
}

/* Map Wrapper */
#map-wrapper {
    flex: 1;
    position: relative;
    background-color: var(--bg-dark);
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Custom Marker Styles */
.ref-marker-container {
    position: relative;
    width: 16px;
    height: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ref-axes {
    position: absolute;
    top: 50%;
    left: 50%;
    pointer-events: none;
}
.ref-axes.hidden {
    display: none;
}

/* X Axis (Red) */
.ref-axis-x {
    position: absolute;
    top: -1px;
    left: -5000px;
    width: 10000px;
    height: 2px;
    background-color: rgba(239, 68, 68, 0.7); /* Red */
    z-index: -1;
}

/* Y Axis (Green) */
.ref-axis-y {
    position: absolute;
    left: -1px;
    top: -5000px;
    height: 10000px;
    width: 2px;
    background-color: rgba(34, 197, 94, 0.7); /* Green */
    z-index: -1;
}

.ref-marker-dot {
    background-color: var(--danger);
    border: 2px solid #fff;
    border-radius: 50%;
    width: 12px;
    height: 12px;
    position: absolute;
    z-index: 2;
}

.ref-marker-label {
    position: absolute;
    top: -20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 2px 4px;
    border-radius: 2px;
    font-size: 11px;
    pointer-events: none;
    white-space: nowrap;
}

/* Sidebar Footer */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.sidebar-footer p {
    font-size: 11px;
    color: var(--text-secondary);
}

.sidebar-footer a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-footer a:hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* =============================================
   Leaflet Controls – Dark Mode Overrides
   ============================================= */

/* --- Toolbar containers (Geoman, zoom, generic bar) --- */
.leaflet-bar,
.leaflet-control-layers,
.leaflet-pm-toolbar,
.leaflet-pm-toolbar .button-container {
    background-color: var(--sidebar-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    border-radius: 4px !important;
    overflow: hidden;
}

/* Remove double-borders between stacked items */
.leaflet-pm-toolbar .button-container + .button-container {
    border-top: 1px solid var(--border-color) !important;
}

/* --- Individual buttons (Geoman + Leaflet zoom +/−) --- */
.leaflet-bar a,
.leaflet-control-layers-toggle,
.leaflet-pm-toolbar .leaflet-buttons-control-button {
    background-color: var(--sidebar-bg) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.leaflet-bar a:last-child,
.leaflet-pm-toolbar .button-container:last-child .leaflet-buttons-control-button {
    border-bottom: none !important;
}

/* Hover state */
.leaflet-bar a:hover,
.leaflet-pm-toolbar .leaflet-buttons-control-button:hover {
    background-color: var(--button-hover) !important;
    color: #ffffff !important;
}

/* Active / selected tool */
.leaflet-bar a.active,
.leaflet-pm-toolbar .button-container.active .leaflet-buttons-control-button {
    background-color: var(--accent) !important;
    color: #ffffff !important;
}

/* --- Replace Geoman icons with thin-line SVGs matching the rect tool --- */
.leaflet-pm-toolbar .leaflet-buttons-control-button [class^="leaflet-pm-icon"] {
    background-size: 18px 18px !important;
    background-position: center center !important;
    background-repeat: no-repeat !important;
}

/* Polygon tool */
.leaflet-pm-icon-polygon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2 L22 8.5 L19 19.5 L5 19.5 L2 8.5 Z'/%3E%3Ccircle cx='12' cy='2' r='1.5'/%3E%3Ccircle cx='22' cy='8.5' r='1.5'/%3E%3Ccircle cx='19' cy='19.5' r='1.5'/%3E%3Ccircle cx='5' cy='19.5' r='1.5'/%3E%3Ccircle cx='2' cy='8.5' r='1.5'/%3E%3C/svg%3E") !important;
}

/* Edit / vertex editing tool */
.leaflet-pm-icon-edit {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7'/%3E%3Cpath d='M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z'/%3E%3C/svg%3E") !important;
}

/* Drag / move tool */
.leaflet-pm-icon-drag {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='5 9 2 12 5 15'/%3E%3Cpolyline points='9 5 12 2 15 5'/%3E%3Cpolyline points='15 19 12 22 9 19'/%3E%3Cpolyline points='19 9 22 12 19 15'/%3E%3Cline x1='2' y1='12' x2='22' y2='12'/%3E%3Cline x1='12' y1='2' x2='12' y2='22'/%3E%3C/svg%3E") !important;
}

/* Delete / removal tool */
.leaflet-pm-icon-delete {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23cccccc' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 5.5 L8.5 17 L4 21 L3 17 L14.5 5.5 C15.3 4.7 16.7 4.7 17.5 5.5 L20 5.5Z'/%3E%3Cline x1='6' y1='15' x2='10' y2='19'/%3E%3Cline x1='2' y1='22' x2='22' y2='22'/%3E%3C/svg%3E") !important;
}

/* Active state: brighten icons */
.leaflet-pm-toolbar .button-container.active .leaflet-buttons-control-button [class^="leaflet-pm-icon"] {
    filter: brightness(2) !important;
}

/* --- Zoom control (+/−) text colour --- */
.leaflet-control-zoom-in,
.leaflet-control-zoom-out {
    color: var(--text-primary) !important;
    font-size: 18px !important;
    line-height: 30px !important;
}

/* --- Geocoder / Search bar --- */
.leaflet-control-geocoder {
    background-color: var(--sidebar-bg) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
    border-radius: 4px !important;
}

.leaflet-control-geocoder.leaflet-control-geocoder-expanded {
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
}

.leaflet-control-geocoder-icon {
    filter: invert(0.85) !important;
    background-color: transparent !important;
}

.leaflet-control-geocoder-form input {
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border: none !important;
    outline: none !important;
    font-family: inherit !important;
    font-size: 13px !important;
}

.leaflet-control-geocoder-alternatives {
    background-color: var(--sidebar-bg) !important;
    border: 1px solid var(--border-color) !important;
}

.leaflet-control-geocoder-alternatives li {
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.leaflet-control-geocoder-alternatives li:hover {
    background-color: var(--button-hover) !important;
}

/* --- Leaflet attribution --- */
.leaflet-control-attribution {
    background-color: rgba(30, 30, 30, 0.75) !important;
    color: var(--text-secondary) !important;
    font-size: 10px !important;
}

.leaflet-control-attribution a {
    color: var(--accent) !important;
}
/ *  
 D e t a i l s  
 /  
 S u m m a r y  
 s t y l i n g  
 f o r  
 c o m p a c t  
 s i d e b a r  
 * /  
 