* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; }
#map { width: 100%; height: 100vh; }
.legend {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 13px;
    line-height: 1.8;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}
.legend h4 { margin: 0 0 6px 0; font-size: 14px; cursor: pointer; user-select: none; }
.legend.collapsed { padding: 8px 12px; }
.legend.collapsed .legend-body { display: none; }
.legend.collapsed h4 { margin: 0; }
@media (max-width: 768px) {
    .legend { font-size: 12px; padding: 8px 12px; }
    .budget-popup, .mission-popup { max-width: 90vw; font-size: 12px; }
    .info-panel { max-width: 85vw; font-size: 12px; }
}
.legend-item {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; user-select: none;
}
.legend-item:hover { opacity: 0.7; }
.legend-item.off { opacity: 0.35; }
.legend-item.off span { text-decoration: line-through; }
.legend-swatch {
    width: 16px; height: 16px; border-radius: 3px;
    border: 1px solid rgba(0,0,0,0.2); flex-shrink: 0;
}
.legend-line {
    width: 16px; height: 3px; flex-shrink: 0;
}
.legend-separator {
    border-top: 1px solid #ddd; margin: 6px 0;
}
.info-panel {
    background: white;
    padding: 12px 16px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 13px;
    max-width: 300px;
}
.info-panel h4 { margin: 0 0 4px 0; }
.stats { color: #555; margin-top: 8px; font-size: 12px; }
.loading {
    position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
    background: white; padding: 24px 32px; border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3); z-index: 9999;
    font-size: 16px;
}
.basemap-toggle {
    background: white;
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 12px;
    cursor: pointer;
    user-select: none;
}
.basemap-toggle:hover { background: #f0f0f0; }
.remove-toolbar {
    background: white;
    padding: 8px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    font-size: 12px;
    display: flex; flex-direction: column; gap: 4px;
}
.remove-btn {
    padding: 4px 10px; border-radius: 4px; border: 1px solid #ccc;
    cursor: pointer; font-size: 12px; background: white;
}
.remove-btn:hover { background: #f0f0f0; }
.remove-btn.active { background: #ff4444; color: white; border-color: #cc0000; }
.remove-btn.save { background: #22aa44; color: white; border-color: #188833; }
.remove-btn.save:hover { background: #1d8f3a; }
.remove-btn.clear { background: #888; color: white; border-color: #666; }
#map.remove-mode { cursor: crosshair; }
.budget-toggle {
    background: white; padding: 6px 10px; border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3); font-size: 12px;
    cursor: pointer; user-select: none;
}
.budget-toggle:hover { background: #f0f0f0; }
.budget-popup {
    position: fixed; z-index: 10000;
    background: white; padding: 0; border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.35); font-size: 12px;
    min-width: 360px; max-width: 440px;
    max-height: calc(100vh - 40px);
}
.budget-titlebar {
    display: flex; justify-content: space-between; align-items: center;
    padding: 8px 14px; background: #333; color: white; border-radius: 8px 8px 0 0;
    cursor: move; user-select: none; font-weight: bold; font-size: 13px;
}
.budget-titlebar .close-btn {
    cursor: pointer; font-size: 18px; line-height: 1; padding: 0 4px;
}
.budget-titlebar .close-btn:hover { color: #ff6666; }
.budget-body {
    padding: 12px 14px; overflow-y: auto; max-height: calc(100vh - 100px);
}
.budget-campaign { margin-bottom: 10px; }
.budget-campaign h5 {
    margin: 8px 0 4px 0; font-size: 11px; color: #666;
    border-bottom: 1px solid #eee; padding-bottom: 2px;
}
.budget-table { width: 100%; border-collapse: collapse; }
.budget-table th { text-align: left; font-size: 10px; color: #888; padding: 2px 4px; border-bottom: 1px solid #eee; }
.budget-table td { padding: 3px 4px; vertical-align: middle; }
.budget-table tr.disabled td { color: #bbb; text-decoration: line-through; }
.budget-table tr.disabled td:first-child { text-decoration: none; }
.budget-totals { border-top: 2px solid #333; font-weight: bold; margin-top: 8px; padding-top: 6px; font-size: 12px; }
.budget-totals .label { color: #333; }
.budget-totals .value { float: right; }
.budget-implements { font-size: 11px; color: #666; margin-top: 6px; border-top: 1px solid #ddd; padding-top: 4px; }
.budget-implements div { display: flex; justify-content: space-between; }
.budget-implements .not-needed { color: #bbb; text-decoration: line-through; }
/* Mission panel */
.mission-popup {
    position: absolute; z-index: 1200;
    background: white; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.3);
    width: 320px; font-size: 12px;
}
.mission-titlebar {
    background: #1a1a2e; color: white; padding: 6px 12px;
    border-radius: 8px 8px 0 0; cursor: move; display: flex;
    justify-content: space-between; align-items: center; font-size: 13px; font-weight: 600;
}
.mission-titlebar .close-btn { cursor: pointer; font-size: 18px; line-height: 1; opacity: 0.7; }
.mission-titlebar .close-btn:hover { opacity: 1; }
.mission-body { padding: 10px 12px; max-height: 500px; overflow-y: auto; }
.mission-body .status-line { margin: 4px 0; }
.mission-body .status-line .label { font-weight: 600; color: #555; }
.mission-body button {
    padding: 6px 12px; margin: 3px 2px; border: 1px solid #ccc;
    border-radius: 4px; cursor: pointer; font-size: 12px; background: #f8f8f8;
}
.mission-body button:hover { background: #e8e8e8; }
.mission-body button.primary { background: #2563eb; color: white; border-color: #2563eb; }
.mission-body button.primary:hover { background: #1d4ed8; }
.mission-body button.danger { background: #dc2626; color: white; border-color: #dc2626; }
.mission-body button.danger:hover { background: #b91c1c; }
.mission-body button.danger-lg { background: #dc2626; color: white; border-color: #dc2626; font-size: 14px; font-weight: bold; padding: 10px 20px; width: 100%; }
.mission-body button:disabled { opacity: 0.4; cursor: not-allowed; }
.mission-progress { background: #e5e7eb; border-radius: 4px; height: 12px; margin: 6px 0; overflow: hidden; }
.mission-progress-bar { background: #2563eb; height: 100%; transition: width 0.3s; }
.rtk-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; }
.rtk-1, .rtk-2, .rtk-3 { background: #dc2626; }
.rtk-5 { background: #f59e0b; }
.rtk-4 { background: #22c55e; }
.cal-point-marker { font-size: 11px; padding: 2px 0; color: #555; }
.cal-point-marker .recorded { color: #22c55e; font-weight: 600; }
