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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: #1a1a1a;
    color: #ffffff;
}

header {
    background-color: #2c3e50;
    padding: 15px 20px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
}

header h1 {
    font-size: 24px;
    margin: 0;
    color: #3498db;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 10px;
    flex-wrap: nowrap;
}

.legal-btn {
    padding: 4px 12px;
    font-size: 12px;
    background-color: #7f8c8d;
    border: none;
    border-radius: 4px;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s;
    white-space: nowrap;
}

.legal-btn:hover {
    background-color: #95a5a6;
}

.legal-btn.active {
    background-color: #e74c3c;
}

.controls {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

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

.control-group label {
    font-size: 14px;
    color: #ecf0f1;
}

.control-group input,
.control-group select {
    padding: 6px 10px;
    border: 1px solid #34495e;
    border-radius: 4px;
    background-color: #34495e;
    color: #ecf0f1;
    font-size: 14px;
}

.control-group input:focus,
.control-group select:focus {
    outline: none;
    border-color: #3498db;
}

button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    background-color: #3498db;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s;
}

button:hover:not(:disabled) {
    background-color: #2980b9;
}

button:disabled {
    background-color: #7f8c8d;
    cursor: not-allowed;
}

#status-message {
    font-size: 14px;
    color: #e74c3c;
    margin-left: 10px;
}

#status-message.success {
    color: #2ecc71;
}

#status-message.loading {
    color: #f39c12;
}

/* Bounds Panel */
#bounds-panel {
    background-color: #34495e;
    padding: 8px 20px;
    border-bottom: 1px solid #2c3e50;
}

.bounds-inline {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.bounds-label {
    font-size: 13px;
    color: #3498db;
    font-weight: bold;
}

.bounds-input-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.bounds-input-inline label {
    font-size: 12px;
    color: #bdc3c7;
    min-width: 18px;
}

.bounds-input-inline input {
    width: 70px;
    padding: 4px 6px;
    background-color: #2c3e50;
    border: 1px solid #3498db;
    border-radius: 4px;
    color: #ecf0f1;
    font-size: 12px;
    text-align: center;
}

.bounds-input-inline input:focus {
    outline: none;
    border-color: #2ecc71;
}

.draw-bounds-btn {
    padding: 5px 12px;
    font-size: 12px;
    background-color: #2c3e50;
    border: 1px solid #e67e22;
    color: #e67e22;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.draw-bounds-btn:hover {
    background-color: #e67e22;
    color: #fff;
}

.draw-bounds-btn.active {
    background-color: #e67e22;
    color: #fff;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Drawing mode cursor */
.leaflet-container.drawing-mode {
    cursor: crosshair !important;
}

.leaflet-container.drawing-mode * {
    cursor: crosshair !important;
}

#main-content {
    display: flex;
    flex: 1;
    height: calc(100vh - 140px);
    overflow: hidden;
}

/* Variables Panel (left) */
#variables-panel {
    width: 140px;
    background-color: #2c3e50;
    padding: 10px;
    overflow-y: auto;
    border-right: 1px solid #34495e;
}

#variables-panel h3 {
    font-size: 14px;
    color: #3498db;
    margin-bottom: 10px;
    text-align: center;
}

.var-section {
    margin-bottom: 12px;
}

.var-section h4 {
    font-size: 10px;
    color: #7f8c8d;
    text-transform: uppercase;
    margin-bottom: 4px;
    padding-bottom: 2px;
    border-bottom: 1px solid #34495e;
}

.var-btn {
    display: block;
    width: 100%;
    padding: 5px 8px;
    margin-bottom: 3px;
    font-size: 11px;
    text-align: left;
    background-color: #34495e;
    border: 1px solid transparent;
    border-radius: 3px;
    color: #bdc3c7;
    cursor: pointer;
    transition: all 0.15s;
}

.var-btn:hover {
    background-color: #3d566e;
    color: #ecf0f1;
}

.var-btn.selected {
    background-color: #3498db;
    color: #fff;
    border-color: #2980b9;
}

#map-container {
    flex: 1;
    position: relative;
    background-color: #34495e;
}

#map {
    width: 100%;
    height: 100%;
}

/* Control Panel (right) - 20% smaller */
#control-panel {
    width: 255px;
    background-color: #2c3e50;
    padding: 15px;
    overflow-y: auto;
    border-left: 1px solid #34495e;
}

#control-panel h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #3498db;
}

#station-info {
    background-color: #34495e;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

#station-info p {
    font-size: 13px;
    line-height: 1.6;
    margin-bottom: 8px;
}

#station-info .station-name {
    font-size: 16px;
    font-weight: bold;
    color: #3498db;
    margin-bottom: 10px;
}

.data-section {
    margin-top: 12px;
    padding-top: 8px;
    border-top: 1px solid #2c3e50;
}

.data-section h4 {
    font-size: 12px;
    color: #3498db;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 3px 0;
    font-size: 12px;
}

.data-label {
    color: #bdc3c7;
}

.data-value {
    color: #ecf0f1;
    font-weight: 500;
}

/* Colorbar Styles - Vertical */
#colorbar-container {
    background-color: #34495e;
    padding: 15px;
    border-radius: 6px;
    margin-top: 15px;
}

#colorbar-title {
    font-size: 13px;
    font-weight: bold;
    color: #3498db;
    margin-bottom: 10px;
    text-align: center;
}

#colorbar {
    display: flex;
    flex-direction: row;
    gap: 8px;
    height: 180px;
}

.colorbar-gradient {
    width: 20px;
    height: 100%;
    border-radius: 4px;
    border: 1px solid #2c3e50;
}

.colorbar-labels {
    display: flex;
    flex-direction: column-reverse;
    justify-content: space-between;
    font-size: 10px;
    color: #bdc3c7;
}

.colorbar-labels span {
    text-align: left;
    line-height: 1;
}

/* QC Flag Styles */
.qc-flag {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    margin-left: 5px;
}

.qc-flag.valid {
    background-color: #27ae60;
    color: white;
}

.qc-flag.questionable {
    background-color: #f39c12;
    color: white;
}

.qc-flag.bad {
    background-color: #e74c3c;
    color: white;
}

.qc-flag.missing {
    background-color: #7f8c8d;
    color: white;
}

/* Dropdown Menu Styles */
.dropdown-container {
    position: relative;
    display: inline-block;
}

.dropdown-btn {
    padding: 8px 16px;
    background: #34495e;
    border: 1px solid #3498db;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.dropdown-btn:hover {
    background: #3d566e;
}

.dropdown-btn.active {
    background: #3498db;
    color: #1a1a1a;
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 140px;
    background: #2c3e50;
    border: 1px solid #3498db;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    margin-top: 4px;
    padding: 6px 0;
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    color: #ecf0f1;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.dropdown-item:hover {
    background: #34495e;
}

.dropdown-item input[type="radio"],
.dropdown-item input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #3498db;
    cursor: pointer;
}

/* Variable Dropdown */
.variable-dropdown {
    min-width: 200px;
    max-height: 400px;
    overflow-y: auto;
}

.variable-section {
    padding: 8px 12px;
    border-bottom: 1px solid #34495e;
}

.variable-section:last-child {
    border-bottom: none;
}

.variable-section h4 {
    font-size: 11px;
    color: #3498db;
    margin-bottom: 6px;
    text-transform: uppercase;
}

/* Overlay Dropdown Styles */
.overlay-dropdown {
    min-width: 220px;
    padding: 0;
}

.overlay-item {
    border-bottom: 1px solid #34495e;
}

.overlay-item:last-child {
    border-bottom: none;
}

.overlay-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
}

.overlay-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ecf0f1;
    font-size: 13px;
    cursor: pointer;
}

.overlay-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #3498db;
    cursor: pointer;
}

.overlay-settings-btn {
    background: transparent;
    border: 1px solid #3498db;
    color: #3498db;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    padding: 0;
}

.overlay-settings-btn:hover {
    background: #3498db;
    color: #1a1a1a;
}

.overlay-settings-btn.active {
    background: #3498db;
    color: #1a1a1a;
}

.overlay-settings {
    background: #34495e;
    padding: 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.overlay-settings.hidden {
    display: none;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: #bdc3c7;
}

.setting-row span:first-child {
    min-width: 50px;
}

.setting-row input[type="range"] {
    flex: 1;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #2c3e50;
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.setting-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

.setting-row input[type="color"] {
    width: 28px;
    height: 20px;
    padding: 0;
    border: 1px solid #3498db;
    border-radius: 3px;
    background: transparent;
    cursor: pointer;
}

.setting-value {
    min-width: 35px;
    text-align: right;
    color: #2ecc71;
}

.setting-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 11px;
    color: #bdc3c7;
}

.setting-checkbox input[type="checkbox"] {
    width: 14px;
    height: 14px;
    cursor: pointer;
    accent-color: #3498db;
}

/* Grid labels on map */
.grid-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Options Dropdown Styles */
.options-dropdown {
    min-width: 180px;
    padding: 8px 12px;
}

.options-item {
    margin-bottom: 8px;
}

.options-item:last-child {
    margin-bottom: 0;
}

.options-item .setting-row span {
    min-width: 80px;
}

.options-item input[type="number"] {
    width: 70px;
    padding: 4px 8px;
    background: #34495e;
    border: 1px solid #3498db;
    border-radius: 4px;
    color: #ecf0f1;
    font-size: 0.85rem;
    text-align: center;
}

.options-item input[type="number"]:focus {
    outline: none;
    box-shadow: 0 0 6px rgba(52, 152, 219, 0.4);
}

.options-divider {
    border-top: 1px solid #34495e;
    padding-top: 8px;
    margin-top: 4px;
}

.options-btn {
    width: 100%;
    padding: 8px 12px;
    background: #34495e;
    border: 1px solid #3498db;
    color: #3498db;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.options-btn:hover {
    background: #3498db;
    color: #1a1a1a;
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: #2c3e50;
    border: 1px solid #3498db;
    border-radius: 10px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #34495e;
}

.modal-header h3 {
    color: #3498db;
    font-size: 1.1rem;
    margin: 0;
}

.modal-close {
    background: transparent;
    border: none;
    color: #888;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover {
    color: #e74c3c;
}

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

/* Marker Add Section */
.marker-add-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #34495e;
}

.marker-add-section h4,
.marker-list-section h4 {
    color: #3498db;
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.marker-input-row {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.marker-input-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.marker-input-group label {
    font-size: 0.8rem;
    color: #888;
}

.marker-input-group input[type="number"],
.marker-input-group input[type="text"] {
    padding: 8px 10px;
    background: #34495e;
    border: 1px solid #2c3e50;
    border-radius: 4px;
    color: #ecf0f1;
    font-size: 0.9rem;
}

.marker-input-group input[type="number"]:focus,
.marker-input-group input[type="text"]:focus {
    border-color: #3498db;
    outline: none;
}

.marker-input-group input[type="color"] {
    width: 100%;
    height: 32px;
    padding: 2px;
    background: #34495e;
    border: 1px solid #2c3e50;
    border-radius: 4px;
    cursor: pointer;
}

.marker-input-group input[type="range"] {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #34495e;
    border-radius: 3px;
    cursor: pointer;
}

.marker-input-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    background: #3498db;
    border-radius: 50%;
    cursor: pointer;
}

.marker-input-group span#markerSizeValue {
    min-width: 24px;
    text-align: center;
    color: #2ecc71;
    font-size: 0.85rem;
}

.marker-input-row .marker-input-group:has(input[type="range"]) {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.marker-input-row .marker-input-group:has(input[type="range"]) label {
    min-width: 35px;
}

.primary-btn {
    width: 100%;
    padding: 10px;
    background: #3498db;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}

.primary-btn:hover {
    background: #2980b9;
}

/* Marker List Section */
.marker-list-section h4 span {
    color: #2ecc71;
    font-weight: normal;
}

.marker-list-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.small-btn {
    padding: 6px 12px;
    background: #34495e;
    border: 1px solid #2c3e50;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.small-btn:hover {
    background: #2c3e50;
    color: #fff;
}

.small-btn.danger {
    border-color: #e74c3c;
    color: #e74c3c;
}

.small-btn.danger:hover {
    background: #e74c3c;
    color: #fff;
}

.marker-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #34495e;
    border-radius: 6px;
    background: #1a1a1a;
}

.marker-list .placeholder {
    padding: 20px;
    text-align: center;
    color: #666;
    font-style: italic;
    font-size: 0.85rem;
}

.marker-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #34495e;
    transition: background 0.15s;
}

.marker-list-item:last-child {
    border-bottom: none;
}

.marker-list-item:hover {
    background: #2c3e50;
}

.marker-item-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid #fff;
    flex-shrink: 0;
}

.marker-item-info {
    flex: 1;
    min-width: 0;
}

.marker-item-label {
    display: block;
    font-size: 0.9rem;
    color: #ecf0f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.marker-item-coords {
    display: block;
    font-size: 0.75rem;
    color: #888;
}

.marker-item-actions {
    display: flex;
    gap: 4px;
}

.marker-action-btn {
    width: 28px;
    height: 28px;
    padding: 0;
    background: #34495e;
    border: 1px solid #2c3e50;
    color: #ccc;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.marker-action-btn:hover {
    background: #2c3e50;
    color: #fff;
}

.marker-action-btn.goto:hover {
    border-color: #3498db;
    color: #3498db;
}

.marker-action-btn.toggle.hidden-marker {
    opacity: 0.5;
}

.marker-action-btn.delete:hover {
    border-color: #e74c3c;
    color: #e74c3c;
}

/* Legal Modal Styles */
.legal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    overflow-y: auto;
    padding: 20px;
}

.legal-modal.hidden {
    display: none !important;
}

.legal-modal-content {
    background-color: #2c3e50;
    border-radius: 8px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.legal-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #34495e;
}

.legal-modal-header h2 {
    color: #3498db;
    font-size: 24px;
    margin: 0;
}

.legal-close-btn {
    background: none;
    border: none;
    color: #ecf0f1;
    font-size: 32px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.3s;
}

.legal-close-btn:hover {
    color: #e74c3c;
}

.legal-modal-body {
    padding: 25px;
    overflow-y: auto;
    color: #ecf0f1;
}

.legal-section {
    margin-bottom: 30px;
}

.legal-section h3 {
    color: #3498db;
    font-size: 18px;
    margin-bottom: 12px;
    border-bottom: 1px solid #34495e;
    padding-bottom: 8px;
}

.legal-section p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.legal-section ul {
    margin-left: 25px;
    margin-bottom: 10px;
}

.legal-section li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.legal-section a {
    color: #3498db;
    text-decoration: none;
}

.legal-section a:hover {
    text-decoration: underline;
}

.warning-box {
    background-color: #e67e22;
    border-left: 4px solid #d35400;
    padding: 15px;
    margin: 15px 0;
    border-radius: 4px;
}

.warning-box p {
    margin: 0;
    color: #ffffff;
}

.warning-box strong {
    font-size: 16px;
}

.legal-footer {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #34495e;
    text-align: center;
    color: #95a5a6;
    font-size: 14px;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    background-color: #2c3e50;
    color: #ecf0f1;
}

.leaflet-popup-content {
    font-size: 13px;
    line-height: 1.6;
}

.leaflet-popup-tip {
    background-color: #2c3e50;
}

/* Scrollbar styling */
#control-panel::-webkit-scrollbar {
    width: 8px;
}

#control-panel::-webkit-scrollbar-track {
    background: #34495e;
}

#control-panel::-webkit-scrollbar-thumb {
    background: #3498db;
    border-radius: 4px;
}

#control-panel::-webkit-scrollbar-thumb:hover {
    background: #2980b9;
}

/* Responsive design */
@media (max-width: 1024px) {
    #control-panel {
        width: 280px;
    }

    header h1 {
        font-size: 20px;
    }

    .controls {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    #main-content {
        flex-direction: column;
    }

    #variables-panel {
        display: none;
    }

    #control-panel {
        width: 100%;
        height: 200px;
        border-left: none;
        border-top: 1px solid #34495e;
    }

    .bounds-middle {
        max-width: 100%;
    }
}
