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

:root {
    --bg: #1a1a2e;
    --surface: #16213e;
    --surface-2: #1e2a4a;
    --border: #2a3a5e;
    --text: #e0e0e0;
    --text-muted: #8892a4;
    --primary: #4f8cff;
    --primary-hover: #3a7aff;
    --danger: #ff4d6d;
    --success: #4ade80;
    --radius: 8px;
    --shadow: 0 4px 24px rgba(0,0,0,.3);
}

html, body { height: 100%; font: 14px/1.5 system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); }

#app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
    width: 340px; min-width: 340px;
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 1000;
}

#sidebar header {
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border);
}
#sidebar h1 { font-size: 18px; font-weight: 700; }
#sidebar .subtitle { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* Category nav */
#category-nav {
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
}
#category-select {
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
    font-size: 14px;
    position: relative;
    z-index: 2;
    pointer-events: auto;
    -webkit-appearance: none;
    appearance: none;
    min-height: 44px;
}

#toolbar {
    display: flex; gap: 6px; padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
}

.btn {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 6px 12px; border: 1px solid var(--border);
    border-radius: var(--radius); background: var(--surface-2);
    color: var(--text); font-size: 12px; cursor: pointer;
    transition: background .15s, border-color .15s;
}
.btn:hover { background: #263a60; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.secondary { border-color: var(--border); }

#parcel-list {
    flex: 1; overflow-y: auto; padding: 8px 12px;
}
.list-empty {
    padding: 32px 16px; text-align: center;
    color: var(--text-muted); font-size: 13px;
}

.parcel-card {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 10px 14px; margin-bottom: 6px;
    cursor: pointer; transition: border-color .15s;
    position: relative;
}
.parcel-card:hover { border-color: var(--primary); }
.parcel-card.active { border-color: var(--primary); background: #1d2f55; }

.parcel-card .title { font-weight: 600; font-size: 14px; }
.parcel-card .meta {
    font-size: 12px; color: var(--text-muted);
    display: flex; gap: 12px; margin-top: 4px;
}
.parcel-card .delete-btn {
    position: absolute; top: 8px; right: 10px;
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; font-size: 16px; padding: 2px 4px;
    line-height: 1; border-radius: 4px;
}
.parcel-card .delete-btn:hover { color: var(--danger); background: rgba(255,77,109,.1); }

/* Footer stats */
#sidebar footer {
    padding: 10px 20px; border-top: 1px solid var(--border);
    background: var(--surface-2);
}
#stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--text-muted); }

/* Map */
#map-container { flex: 1; position: relative; }
#map { width: 100%; height: 100%; }

/* Leaflet overrides */
.leaflet-container { background: #0d1117 !important; }
.leaflet-control-zoom a { background: var(--surface-2) !important; color: var(--text) !important; border-color: var(--border) !important; }
.leaflet-draw-toolbar a { background: var(--surface-2) !important; color: var(--text) !important; }

/* Modal */
#modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    z-index: 10000;
}
#modal-overlay.hidden { display: none; }

#modal {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 24px; width: 380px;
    box-shadow: var(--shadow);
}
#modal h3 { margin-bottom: 12px; font-size: 16px; }
#parcel-title {
    width: 100%; padding: 8px 12px;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text); font-size: 14px;
    outline: none;
}
#parcel-title:focus { border-color: var(--primary); }

#parcel-preview {
    display: flex; gap: 16px; margin: 12px 0; font-size: 13px; color: var(--text-muted);
}
#parcel-preview strong { color: var(--text); }

.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-actions .btn { font-size: 13px; padding: 8px 20px; }

/* Responsive */
@media (max-width: 768px) {
    #app { flex-direction: column; }
    #sidebar { width: 100%; min-width: unset; max-height: 280px; border-right: none; border-bottom: 1px solid var(--border); }
}
