* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --color-primary: #0066cc;
    --color-primary-dark: #0052a3;
    --color-danger: #d32f2f;
    --color-success: #2e7d32;
    --color-text: #212121;
    --color-text-secondary: #616161;
    --color-border: #e0e0e0;
    --color-bg: #fafafa;
    --color-surface: #ffffff;
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 16px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    color: var(--color-text);
    background: var(--color-bg);
    line-height: 1.5;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.header {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0 var(--spacing-lg);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.header-meta {
    display: flex;
    gap: var(--spacing-lg);
    align-items: center;
}

.status-badge {
    background: var(--color-bg);
    padding: var(--spacing-xs) var(--spacing-md);
    border-radius: 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}

.status-badge.loading {
    background: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.status-badge.success {
    background: #e8f5e9;
    border-color: #2e7d32;
    color: #1b5e20;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.count-display {
    font-size: 13px;
    color: var(--color-text-secondary);
}

.count-display strong {
    color: var(--color-text);
}

.count-display.error-count {
    color: var(--color-danger);
}

.count-display.error-count strong {
    color: var(--color-danger);
    font-weight: 700;
}

.btn-help {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-help:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

/* Main Layout */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 320px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.content {
    flex: 1;
    position: relative;
}

/* Panel */
.panel {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.panel h2 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-md);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-md);
}

.panel-header h2 {
    margin: 0;
}

/* Forms */
.form-group {
    margin-bottom: var(--spacing-md);
}

/* Country Selector */
.country-selector {
    display: flex;
    gap: var(--spacing-sm);
}

.country-option {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: 2px;
    cursor: pointer;
    transition: all 0.15s;
    background: var(--color-surface);
}

.country-option:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.country-option input[type="radio"] {
    display: none;
}

.country-option span {
    color: var(--color-text);
    font-size: 13px;
    font-weight: 500;
}

.country-option:has(input:checked) {
    background: var(--color-primary);
    border-color: var(--color-primary);
}

.country-option:has(input:checked) span {
    color: white;
    font-weight: 600;
}

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xs);
}

textarea,
input[type="text"] {
    width: 100%;
    padding: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: 2px;
    font-family: inherit;
    font-size: 13px;
    color: var(--color-text);
    background: var(--color-surface);
    transition: border-color 0.15s;
}

textarea:focus,
input[type="text"]:focus {
    outline: none;
    border-color: var(--color-primary);
}

input[type="file"] {
    width: 100%;
    padding: var(--spacing-sm);
    font-size: 12px;
    border: 1px solid var(--color-border);
    border-radius: 2px;
    background: var(--color-surface);
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
}

.input-group input {
    flex: 1;
}

/* Buttons */
button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: all 0.15s;
}

.btn-primary {
    width: 100%;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--color-primary);
    color: white;
    font-size: 13px;
    font-weight: 500;
    border-radius: 2px;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-icon {
    width: 32px;
    height: 32px;
    background: var(--color-primary);
    color: white;
    font-size: 18px;
    font-weight: 500;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--color-primary-dark);
}

.btn-text {
    background: transparent;
    color: var(--color-danger);
    font-size: 12px;
    font-weight: 500;
    padding: var(--spacing-xs) var(--spacing-sm);
}

.btn-text:hover {
    background: rgba(211, 47, 47, 0.05);
}

/* Postcode List */
.postcode-list {
    max-height: calc(100vh - 520px);
    overflow-y: auto;
}

.postcode-list:empty::after {
    content: 'Geen postcodes';
    display: block;
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 12px;
    padding: var(--spacing-lg) 0;
}

.postcode-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm);
    margin-bottom: 1px;
    background: var(--color-bg);
    transition: background 0.15s;
}

.postcode-item:hover {
    background: #f5f5f5;
}

.postcode-item.postcode-error {
    background: #ffebee;
    border-left: 3px solid var(--color-danger);
}

.postcode-item.postcode-error:hover {
    background: #ffcdd2;
}

.postcode-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    flex: 1;
}

.postcode-number {
    width: 24px;
    height: 24px;
    background: var(--color-text);
    color: white;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    flex-shrink: 0;
}

.postcode-error-icon {
    width: 24px;
    height: 24px;
    background: var(--color-danger);
    color: white;
    border-radius: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    flex-shrink: 0;
}

.postcode-details {
    flex: 1;
    min-width: 0;
}

.postcode-code {
    font-weight: 600;
    font-size: 13px;
    color: var(--color-text);
}

.postcode-location {
    font-size: 12px;
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.postcode-item.postcode-error .postcode-code {
    color: var(--color-danger);
}

.postcode-item.postcode-error .postcode-location {
    color: var(--color-danger);
    opacity: 0.8;
}

.remove-btn {
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 16px;
    padding: var(--spacing-xs);
    opacity: 0;
    transition: opacity 0.15s;
}

.postcode-item:hover .remove-btn {
    opacity: 1;
}

.remove-btn:hover {
    color: var(--color-danger);
}

/* Status Messages */
.status-message {
    margin: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: 2px;
    font-size: 12px;
    display: none;
}

.status-message.show {
    display: block;
}

.status-message.success {
    background: #e8f5e9;
    color: var(--color-success);
    border-left: 3px solid var(--color-success);
}

.status-message.error {
    background: #ffebee;
    color: var(--color-danger);
    border-left: 3px solid var(--color-danger);
}

.status-message.info {
    background: #e3f2fd;
    color: #1565c0;
    border-left: 3px solid #1565c0;
}

.status-message.warning {
    background: #fff3e0;
    color: #e65100;
    border-left: 3px solid #ff9800;
}

/* Map */
#map {
    width: 100%;
    height: 100%;
}

/* Privacy Button */
.privacy-btn {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 500;
    transition: all 0.15s;
}

.privacy-btn:hover {
    background: var(--color-bg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transform: translateY(-1px);
}

/* Custom Marker */
.custom-marker {
    background: white;
    border: 2px solid var(--color-primary);
    border-radius: 2px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 12px;
    color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--color-surface);
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.modal-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--color-text-secondary);
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
}

.help-section {
    margin-bottom: var(--spacing-lg);
}

.help-section:last-child {
    margin-bottom: 0;
}

.help-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--spacing-sm);
}

.help-section ul {
    margin-left: var(--spacing-lg);
    color: var(--color-text-secondary);
}

.help-section li {
    margin-bottom: var(--spacing-sm);
    font-size: 13px;
    line-height: 1.6;
}

.help-section li strong {
    color: var(--color-text);
}

.help-section p {
    font-size: 13px;
    color: var(--color-text-secondary);
    margin-bottom: var(--spacing-xs);
}

.help-section code {
    display: inline-block;
    background: var(--color-bg);
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 2px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: var(--color-primary);
}

.help-section a {
    color: var(--color-primary);
    text-decoration: none;
    word-break: break-all;
}

.help-section a:hover {
    text-decoration: underline;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Scrollbar */
.postcode-list::-webkit-scrollbar,
.sidebar::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.postcode-list::-webkit-scrollbar-track,
.sidebar::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.postcode-list::-webkit-scrollbar-thumb,
.sidebar::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 3px;
}

.postcode-list::-webkit-scrollbar-thumb:hover,
.sidebar::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #bdbdbd;
}

/* Responsive */
@media (max-width: 768px) {
    .main-layout {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        max-height: 50vh;
    }
    
    .postcode-list {
        max-height: 200px;
    }

    .modal-content {
        width: 95%;
        max-height: 90vh;
    }
}
