/* ========================================
   GIS Toolbox — Main Styles
   ======================================== */

:root {
    --primary: #dbac3f;
    --primary-dark: #0066cc;
    --primary-light: #409cff;
    --success: #30d158;
    --warning: #ffd60a;
    --error: #ff453a;
    --info: #64d2ff;
    --bg: #000000;
    --bg-panel: #1c1c1e;
    --bg-header: #1c1c1e;
    --bg-surface: #2c2c2e;
    --bg-modal: rgba(0,0,0,0.55);
    --text: #f5f5f7;
    --text-muted: #98989d;
    --text-light: #636366;
    --text-inverse: #393838;
    --border: rgba(255,255,255,0.08);
    --border-dark: rgba(255,255,255,0.14);
    --shadow: 0 2px 8px rgba(0,0,0,0.25);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.45);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --font: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', 'Consolas', monospace;
    --header-h: 52px;
    --transition: 0.2s cubic-bezier(0.25, 0.1, 0.25, 1);
    --gold: #d4a24e;
    --gold-light: #e8b84a;
}

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

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    overflow: hidden;
}

/* ========== Scrollbar ========== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.25); }

/* ========== Header ========== */
.header {
    height: var(--header-h);
    background: var(--bg-header);
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 10px;
    z-index: 100;
    flex-shrink: 0;
    position: relative;
    border-bottom: 1px solid var(--border);
}
.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.header-logo {
    display: flex;
    align-items: center;
}
.header-title {
    font-weight: 600;
    font-size: 16px;
    letter-spacing: -0.3px;
    white-space: nowrap;
    margin: 0;
    color: var(--gold-light);
}
.header-center {
    display: flex;
    align-items: center;
    gap: 4px;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}
.header-right {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.header-sep {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.1);
    margin: 0 6px;
}

/* Auto-save indicator */
.save-indicator {
    position: fixed;
    top: 52px;
    right: 16px;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255,255,255,0.7);
    background: rgba(28,28,30,0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 6px;
    opacity: 0;
    transform: translateY(-6px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    z-index: 900;
}
.save-indicator.visible {
    opacity: 1;
    transform: translateY(0);
}
.header .btn-icon-text { font-size: 14px; }
.header select {
    background: rgba(255,255,255,0.08);
    color: white;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius-sm);
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
}
.header select option { color: var(--text); background: var(--bg-panel); }

/* Header button overrides for dark background */
.header .btn-secondary { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.9); border: 1px solid rgba(255,255,255,0.1); }
.header .btn-secondary:hover:not(:disabled) { background: rgba(255,255,255,0.14); }
.header .btn-ghost { color: rgba(255,255,255,0.7); }
.header .btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.1); color: white; }

/* ========== Buttons ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    font-family: var(--font);
    letter-spacing: -0.1px;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-secondary { background: rgba(28, 28, 30, 0.8); color: var(--text); border: 1px solid rgba(255,255,255,0.12); }
.btn-secondary:hover:not(:disabled) { background: rgba(44, 44, 46, 0.85); }
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    padding: 7px 10px;
}
.btn-ghost:hover:not(:disabled) { background: rgba(255,255,255,0.06); color: var(--text); }
.btn-header {
    background: rgba(255,255,255,0.07);
    color: rgba(255,255,255,0.9);
    padding: 6px 12px;
    font-size: 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.08);
}
.btn-header:hover { background: rgba(255,255,255,0.12); }
.btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
}
.btn-icon:hover { background: rgba(255,255,255,0.06); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: var(--error); color: white; }
.btn-danger:hover:not(:disabled) { background: #d63030; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover:not(:disabled) { background: #28b84c; }

/* ========== Layout — Desktop 3-Panel ========== */
.app-layout {
    display: flex;
    height: calc(100vh - var(--header-h));
    overflow: hidden;
}

.panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
    overflow: hidden;
}
.panel-left,
.panel-right {
    position: relative;
    background: var(--bg-panel);
    background-image: url('../Side_Background.webp');
    background-size: cover;
    background-position: center;
}
.panel-left::before,
.panel-right::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.82);
    z-index: 0;
    pointer-events: none;
}
.panel-left > *,
.panel-right > * {
    position: relative;
    z-index: 1;
}
.panel-left {
    width: 320px;
    min-width: 240px;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
}
.panel-center {
    flex: 1;
    min-width: 200px;
    position: relative;
    background: var(--bg);
}
.panel-right {
    width: 300px;
    min-width: 220px;
    border-left: 1px solid var(--border);
    flex-shrink: 0;
}
.panel.collapsed { width: 0 !important; min-width: 0 !important; overflow: hidden; border: none; }

/* Expand tabs — fixed to viewport edges, visible when panel is collapsed */
.panel-expand-tab {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 60px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: var(--text-muted);
    z-index: 500;
    transition: background var(--transition), color var(--transition);
    padding: 0;
}
.panel-expand-tab:hover { background: var(--primary); color: white; }
.panel-expand-left {
    left: 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    border-left: none;
}
.panel-expand-right {
    right: 0;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    border-right: none;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
    font-size: 13px;
    background: rgba(20, 20, 22, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: var(--text);
    flex-shrink: 0;
    letter-spacing: -0.1px;
}
.panel-content, .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}
.panel-section {
    margin-bottom: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: var(--radius);
    overflow: hidden;
    background: rgba(20, 20, 22, 0.75);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}
.panel-section-header {
    padding: 9px 12px;
    background: rgba(255, 255, 255, 0.08);
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    user-select: none;
}
.panel-section-header .arrow { transition: transform var(--transition); }
.panel-section-header.collapsed .arrow { transform: rotate(-90deg); }
.panel-section-body { padding: 10px; }
.panel-section-body.hidden { display: none; }

/* ========== Resize Handle ========== */
.resize-handle {
    width: 4px;
    cursor: col-resize;
    background: transparent;
    transition: background var(--transition);
    flex-shrink: 0;
}
.resize-handle:hover, .resize-handle.active { background: var(--primary-light); }

/* ========== Map ========== */
#map-container {
    width: 100%;
    height: 100%;
    background: #121212;
}
#map-container .leaflet-popup-content { max-width: 300px; max-height: 250px; overflow-y: auto; font-size: 12px; }
#map-container .leaflet-popup-content table { width: 100%; border-collapse: collapse; }
#map-container .leaflet-popup-content td,
#map-container .leaflet-popup-content th {
    padding: 2px 6px; border-bottom: 1px solid var(--border); text-align: left; font-size: 11px;
}
#map-container .leaflet-popup-content th { font-weight: 600; color: var(--text-muted); white-space: nowrap; }

/* Dark Leaflet popup overrides */
.leaflet-popup-content-wrapper {
    background: var(--bg-surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius) !important;
    border: 1px solid var(--border);
}
.leaflet-popup-tip { background: var(--bg-surface); }
.leaflet-popup-content-wrapper a { color: var(--primary-light); }

/* Map context menu */
.map-context-menu {
    position: fixed; z-index: 10000;
    background: var(--bg-surface); border: 1px solid var(--border-dark);
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
    min-width: 180px; padding: 6px 0; font-size: 13px;
}
.map-context-menu .ctx-header {
    padding: 4px 12px; font-size: 10px; color: var(--text-muted);
    border-bottom: 1px solid var(--border); margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.map-context-menu .ctx-item {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 12px; cursor: pointer; color: var(--text);
    transition: background 0.1s;
}
.map-context-menu .ctx-item:hover { background: rgba(255,255,255,0.06); }
.map-context-menu .ctx-item .ctx-icon { width: 16px; text-align: center; flex-shrink: 0; }
.map-context-menu .ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* Dark Leaflet control overrides */
.leaflet-control-zoom a {
    background: var(--bg-surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
    border-radius: var(--radius-sm) !important;
}
.leaflet-control-zoom a:hover { background: rgba(255,255,255,0.1) !important; }
.leaflet-control-attribution {
    background: rgba(15, 17, 23, 0) !important;
    color: var(--text-muted) !important;
    font-size: 10px;
}
.leaflet-control-attribution a { color: var(--text-light) !important; }

.map-overlay-msg,
.map-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(28,28,30,0.92);
    padding: 24px 36px;
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--text-muted);
    z-index: 400;
    pointer-events: none;
    display: none;
    border: 1px solid var(--border);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
#map-container.dragover .map-overlay {
    display: block;
}

/* ========== Forms / Inputs ========== */
.form-group { margin-bottom: 10px; }
.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
}
input[type="text"], input[type="number"], input[type="url"],
input[type="search"], select, textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
    color: var(--text);
    background: rgba(0,0,0,0.4);
    transition: border var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(10,132,255,0.2);
}
textarea { resize: vertical; min-height: 60px; }
.input-with-btn {
    display: flex;
    gap: 4px;
}
.input-with-btn input { flex: 1; }

/* Checkbox / Radio */
.checkbox-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 0;
    font-size: 13px;
    cursor: pointer;
}
.checkbox-row input[type="checkbox"],
.checkbox-row input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
}

/* Toggle switch */
.toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}
.toggle input { display: none; }
.toggle-track {
    width: 40px;
    height: 22px;
    background: var(--text-light);
    border-radius: 11px;
    position: relative;
    transition: background var(--transition);
}
.toggle input:checked + .toggle-track { background: var(--primary); }
.toggle-track::after {
    content: '';
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.toggle input:checked + .toggle-track::after { transform: translateX(18px); }

/* ========== Tags / Badges ========== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-primary { background: rgba(10,132,255,0.12); color: var(--primary-light); }
.badge-success { background: rgba(48,209,88,0.12); color: var(--success); }
.badge-warning { background: rgba(255,214,10,0.12); color: var(--warning); }
.badge-error { background: rgba(255,69,58,0.12); color: var(--error); }
.badge-info { background: rgba(100,210,255,0.12); color: var(--info); }

/* ========== Field List ========== */
.field-list { list-style: none; }
.field-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    cursor: pointer;
    transition: background var(--transition);
}
.field-item:hover { background: rgba(255,255,255,0.08); }
.field-item .field-name { flex: 1; font-weight: 500; word-break: break-all; }
.field-item .field-type {
    font-size: 10px;
    color: var(--text-light);
    background: rgba(255,255,255,0.1);
    padding: 1px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}
.field-item .field-stats {
    font-size: 10px;
    color: var(--text-light);
}
.field-actions { display: flex; gap: 2px; }

/* ========== Layer List ========== */
.layer-item {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--transition);
    position: relative;
}
.layer-item:hover { background: rgba(255,255,255,0.08); }
.layer-item.active { background: rgba(10,132,255,0.08); border-left: 3px solid var(--primary); }
.layer-icon { font-size: 16px; flex-shrink: 0; }
.layer-name-row { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.layer-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; letter-spacing: -0.1px; }
.layer-bottom-row { width: 100%; display: flex; align-items: center; gap: 4px; padding-left: 24px; }
.layer-meta { font-size: 11px; color: var(--text-muted); flex: 1; min-width: 0; }
.layer-actions {
    display: flex; gap: 2px;
    opacity: 0; pointer-events: none;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.layer-item:hover .layer-actions,
.layer-item.active .layer-actions { opacity: 1; pointer-events: auto; }
.layer-order-btns { display: flex; gap: 0; flex-shrink: 0; }
.layer-order-btns button {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 10px; line-height: 1; padding: 1px 4px;
}
.layer-order-btns button:hover { color: var(--text); }
.layer-order-btns button:disabled { opacity: 0.2; cursor: default; }
.layer-filter-badge {
    display: inline-block; font-size: 9px; background: var(--gold); color: #000;
    border-radius: 3px; padding: 0 4px; cursor: pointer; font-weight: 700; flex-shrink: 0;
}
.layer-filter-badge:hover { filter: brightness(1.2); }

/* ========== Data Table Preview ========== */
.data-table-wrap {
    overflow: auto;
    max-height: 300px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 11px;
    white-space: nowrap;
}
.data-table th {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    font-weight: 600;
    text-align: left;
    padding: 6px 8px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
}
.data-table td {
    padding: 4px 8px;
    border-bottom: 1px solid var(--border);
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
}
.data-table tr:hover td { background: rgba(255,255,255,0.03); }

/* ========== Modal / Drawer ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg-modal);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.15s ease;
}
.modal {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 400px;
    border: 1px solid var(--border);
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 15px;
    letter-spacing: -0.2px;
}
.modal-body { flex: 1; overflow-y: auto; padding: 18px; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 18px;
    border-top: 1px solid var(--border);
}

/* Bottom sheet for mobile */
.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-surface);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
    z-index: 1001;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
    border: 1px solid var(--border);
    border-bottom: none;
}
.bottom-sheet-handle {
    width: 40px;
    height: 4px;
    background: var(--border-dark);
    border-radius: 2px;
    margin: 8px auto;
    flex-shrink: 0;
}
.bottom-sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px 12px;
    font-weight: 700;
    font-size: 16px;
}
.bottom-sheet-body { flex: 1; overflow-y: auto; padding: 0 16px 16px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* ========== Progress Bar ========== */
.progress-bar-container {
    position: relative;
    height: 20px;
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    overflow: hidden;
    margin: 8px 0;
}
.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 10px;
    transition: width 0.3s ease;
    min-width: 2%;
}
.progress-bar-text {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--text);
}
.progress-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 50;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========== Toast Notifications ========== */
.toast-container {
    position: fixed;
    top: 56px;
    right: 12px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 12px 16px;
    box-shadow: var(--shadow-lg);
    border-left: 4px solid var(--primary);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    font-size: 13px;
    max-width: 380px;
    pointer-events: auto;
    animation: slideIn 0.2s ease;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}
.toast.toast-error { border-left-color: var(--error); }
.toast.toast-warning { border-left-color: var(--warning); }
.toast.toast-success { border-left-color: var(--success); }
.toast .toast-close { cursor: pointer; color: var(--text-light); margin-left: auto; }
.toast-details {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
    cursor: pointer;
}
.toast-details-body {
    font-family: var(--mono);
    font-size: 10px;
    background: rgba(0,0,0,0.3);
    padding: 6px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
    max-height: 100px;
    overflow-y: auto;
    word-break: break-all;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ========== Tabs ========== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    background: transparent;
}
.tab {
    padding: 10px 16px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all var(--transition);
    white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ========== Logs Panel ========== */
.logs-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 250px;
    background: #141414;
    color: var(--text);
    z-index: 900;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.3);
    font-family: var(--mono);
    font-size: 11px;
    border-top: 1px solid var(--border);
}
.logs-panel.hidden { display: none; }
.logs-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #0a0a0a;
    flex-shrink: 0;
}
.logs-header h3 {
    font-size: 12px;
    font-weight: 600;
    margin: 0;
    color: var(--text-muted);
}
.logs-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    background: #0a0a0a;
    flex-shrink: 0;
}
.logs-toolbar input {
    background: #1c1c1e;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    width: 150px;
}
.logs-toolbar select {
    background: #1c1c1e;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 11px;
}
.logs-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 8px;
}
.log-entry { padding: 1px 0; white-space: pre-wrap; word-break: break-all; }
.log-entry .ts { color: #48484a; }
.log-entry .lvl-DEBUG { color: #98989d; }
.log-entry .lvl-INFO { color: #64d2ff; }
.log-entry .lvl-WARN { color: #ffd60a; }
.log-entry .lvl-ERROR { color: #ff453a; }

/* ========== Empty State ========== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted);
    gap: 12px;
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.4; }
.empty-state p { font-size: 13px; max-width: 250px; }

/* ========== Misc ========== */
.divider { height: 1px; background: var(--border); margin: 8px 0; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.text-mono { font-family: var(--mono); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.p-8 { padding: 8px; }
.p-12 { padding: 12px; }
.mt-8 { margin-top: 8px; }
.mb-8 { margin-bottom: 8px; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* Global drop overlay */
#global-drop-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(10, 132, 255, 0.08);
    border: 3px dashed var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}
#global-drop-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
.drop-overlay-content {
    background: var(--bg-panel);
    padding: 32px 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
    pointer-events: none;
}
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.clickable { cursor: pointer; }
.drag-handle { cursor: grab; color: var(--text-light); }
.drop-zone {
    border: 2px dashed rgba(255,255,255,0.12);
    border-radius: var(--radius);
    padding: 30px;
    text-align: center;
    color: var(--text-muted);
    transition: all var(--transition);
    cursor: pointer;
}
.drop-zone:hover, .drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(10,132,255,0.06);
    color: var(--primary-light);
}
.error-box {
    background: rgba(255,69,58,0.08);
    border: 1px solid rgba(255,69,58,0.2);
    border-radius: var(--radius);
    padding: 12px;
    color: var(--error);
    font-size: 13px;
}
.error-box .error-title { font-weight: 700; margin-bottom: 4px; }
.error-box .error-guidance { color: var(--text); margin-top: 6px; }
.error-box .error-details-toggle {
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    margin-top: 6px;
    text-decoration: underline;
}
.error-box .error-technical {
    font-family: var(--mono);
    font-size: 10px;
    background: rgba(255,69,58,0.04);
    padding: 6px;
    border-radius: var(--radius-sm);
    margin-top: 4px;
    word-break: break-all;
}
.success-box {
    background: rgba(48,209,88,0.08);
    border: 1px solid rgba(48,209,88,0.2);
    border-radius: var(--radius);
    padding: 12px;
    color: var(--success);
    font-size: 13px;
}
.info-box {
    background: rgba(100,210,255,0.08);
    border: 1px solid rgba(100,210,255,0.2);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 13px;
    color: var(--info);
}
.warning-box {
    background: rgba(255,214,10,0.08);
    border: 1px solid rgba(255,214,10,0.2);
    border-radius: var(--radius);
    padding: 12px;
    font-size: 13px;
    color: var(--warning);
}

/* ========== Wizard Steps ========== */
.wizard-steps {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
}
.wizard-step {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-muted);
}
.wizard-step.active { color: var(--primary); font-weight: 600; }
.wizard-step.done { color: var(--success); }
.wizard-step-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}
.wizard-step.active .wizard-step-num { background: var(--primary); color: white; }
.wizard-step.done .wizard-step-num { background: var(--success); color: white; }
.wizard-step-line { width: 20px; height: 2px; background: rgba(255,255,255,0.08); }

/* ========== Photo grid ========== */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}
.photo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    cursor: pointer;
    transition: box-shadow var(--transition);
}
.photo-card:hover { box-shadow: var(--shadow); }
.photo-card img {
    width: 100%;
    aspect-ratio: 1;
    object-fit: cover;
    display: block;
}
.photo-card .photo-info {
    padding: 4px 6px;
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.photo-card.no-gps { opacity: 0.6; }
.photo-card.no-gps::after {
    content: 'No GPS';
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--warning);
    color: white;
    font-size: 9px;
    padding: 1px 4px;
    border-radius: 3px;
}

/* ===================== */
/* Geoprocessing Tooltip */
/* ===================== */
.geo-tool-btn {
    position: relative;
}
/* Hidden inline — the text is read by JS and shown in the floating portal */
.geo-tool-btn .geo-tip {
    display: none;
}
/* Body-level floating tooltip portal (created by JS) */
.geo-tip-portal {
    position: fixed;
    z-index: 100000;
    background: var(--bg-surface);
    color: var(--text);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 10px 14px;
    font-size: 12px;
    line-height: 1.5;
    white-space: normal;
    width: 240px;
    box-shadow: var(--shadow-lg);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
}
.geo-tip-portal.visible { opacity: 1; }
.geo-tip-portal .tip-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-top-color: var(--gold);
    pointer-events: none;
}
.geo-tip-portal.below .tip-arrow {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--gold);
}

/* ========================== */
/* Map Interaction Banner     */
/* ========================== */
.map-interaction-banner {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 800;
    background: var(--bg-surface);
    border: 1px solid var(--gold);
    border-radius: var(--radius);
    padding: 10px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 600;
    color: var(--gold-light);
    white-space: nowrap;
    animation: fadeIn 0.15s ease;
}
.map-interaction-banner .interaction-cancel {
    background: var(--error);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
}

/* =========================== */
/* Feature Selection Toolbar   */
/* =========================== */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: rgba(0, 229, 255, 0.06);
    border: 1px solid rgba(0, 229, 255, 0.2);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: #00e5ff;
    margin-bottom: 6px;
    flex-wrap: wrap;
}
.selection-bar .sel-count {
    font-weight: 700;
    font-size: 13px;
}
.selection-bar .sel-btn {
    background: rgba(0, 229, 255, 0.15);
    border: 1px solid rgba(0, 229, 255, 0.3);
    color: #00e5ff;
    border-radius: 4px;
    padding: 2px 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}
.selection-bar .sel-btn:hover {
    background: rgba(0, 229, 255, 0.25);
}
.selection-bar .sel-btn.sel-clear {
    color: #ff6b6b;
    border-color: rgba(255,107,107,0.3);
    background: rgba(255,107,107,0.1);
}
.selection-bar .sel-btn.sel-clear:hover {
    background: rgba(255,107,107,0.2);
}
.btn-selection-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.15s ease;
}
.btn-selection-toggle.active {
    background: rgba(0, 229, 255, 0.15);
    border-color: #00e5ff;
    color: #00e5ff;
}

/* ————— DRAW TOOLBAR ————— */
.draw-toolbar {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: var(--bg-surface);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    padding: 10px 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}
.draw-toolbar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.draw-toolbar-title {
    font-size: 12px;
    color: var(--text);
    white-space: nowrap;
}
.draw-toolbar-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    padding: 2px 6px;
    border-radius: 3px;
    line-height: 1;
}
.draw-toolbar-close:hover {
    background: var(--bg);
    color: var(--text);
}
.draw-toolbar-tools {
    display: flex;
    gap: 4px;
}
.draw-tool-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 7px 10px;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 12px;
    transition: all 0.15s ease;
    flex: 1;
    justify-content: center;
}
.draw-tool-btn:hover {
    background: rgba(255,255,255,0.08);
    border-color: var(--primary);
    color: var(--text);
}
.draw-tool-btn.active {
    background: rgba(255,214,10,0.1);
    border-color: var(--warning);
    color: var(--warning);
}
.draw-tool-btn svg {
    flex-shrink: 0;
}
.draw-toolbar-hint {
    font-size: 10px;
    color: var(--text-muted);
    min-height: 14px;
    line-height: 1.3;
}

/* Draw options modal */
.draw-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.draw-option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: rgba(20,20,22,0.7);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    color: var(--text);
    transition: all 0.15s ease;
}
.draw-option-btn:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--primary);
}

/* ————— MOBILE DROPDOWN MENU ————— */
.mobile-menu-btn { display: none; }

.mobile-dropdown-menu {
    position: fixed;
    top: var(--header-h);
    right: 8px;
    z-index: 1100;
    background: var(--bg-surface);
    border: 1px solid var(--border-dark);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    padding: 6px 0;
    animation: fadeIn 0.12s ease;
}
.mobile-dropdown-menu.hidden { display: none; }
.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 16px;
    background: none;
    border: none;
    color: var(--text);
    font-size: 14px;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.1s;
    text-align: left;
}
.mobile-menu-item:hover,
.mobile-menu-item:active {
    background: rgba(255,255,255,0.06);
}
.mobile-menu-item span:first-child {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}
.mobile-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}
.mobile-dropdown-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1099;
    background: transparent;
}
