:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-hover: #059669;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --radius: 8px;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

header {
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-bottom: 2rem;
}

.header-content {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 1rem;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

header p {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.container {
    max-width: 99%;
    margin: 0 auto;
    padding: 0 0.5rem 3rem;
}

.hidden {
    display: none !important;
}

.step {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Upload Box */
.upload-box {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 4rem 2rem;
    text-align: center;
    background-color: var(--bg-card);
    transition: border-color 0.2s, background-color 0.2s;
    cursor: pointer;
}

.upload-box:hover, .upload-box.dragover {
    border-color: var(--primary);
    background-color: #f0fdf4;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-box h2 {
    font-size: 1.25rem;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}
.btn-primary:hover { background-color: var(--primary-hover); }

.btn-success {
    background-color: var(--success);
    color: white;
}
.btn-success:hover { background-color: var(--success-hover); }

.btn-danger {
    background-color: var(--danger);
    color: white;
}
.btn-danger:hover { background-color: var(--danger-hover); }

.btn-secondary {
    background-color: var(--secondary);
    color: white;
}
.btn-secondary:hover { background-color: var(--secondary-hover); }

.btn-warning {
    background-color: #f59e0b;
    color: white;
}
.btn-warning:hover { background-color: #d97706; }
.btn-warning:disabled { background-color: #fcd34d; cursor: not-allowed; opacity: 0.7; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.2rem;
    line-height: 1;
}

/* Progress */
.progress-container {
    margin-bottom: 1.5rem;
}

#progress-text {
    display: block;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-align: right;
}

.progress-bar {
    height: 8px;
    background-color: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background-color: var(--primary);
    width: 0%;
    transition: width 0.3s ease;
}

/* Cards */
.card {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.card-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--border);
}

.actions {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
}

/* Inputs */

.input-group input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color 0.2s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Preview Table */
.confirmed-preview {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
}

.confirmed-preview h4 {
    margin-bottom: 1rem;
    font-size: 1rem;
    color: var(--text-muted);
}

.table-responsive {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

table td {
    padding: 0.5rem;
    border-bottom: 1px solid var(--border);
}

table tr:last-child td {
    border-bottom: none;
}

/* Success Box */
.success-box {
    text-align: center;
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 4rem 2rem;
}

.success-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.success-box p {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Utils */
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.text-right { text-align: right; }

/* Loader */
.spinner {
    border: 3px solid rgba(0,0,0,0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loading {
    text-align: center;
    padding: 2rem;
}

/* Split Layout */
.split-layout {
    display: flex;
    gap: 2rem;
    align-items: stretch;
}

.left-panel {
    flex: 2.5;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    height: 85vh;
}

.csv-panel {
    flex: 0 0 30%;
    display: flex;
    flex-direction: column;
}

.csv-panel .card {
    margin-bottom: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.csv-panel .card-body {
    padding: 0;
    flex: 1;
    overflow: hidden;
}

.csv-panel .table-responsive {
    height: 100%;
    overflow-y: auto;
}

.pdf-panel {
    flex: 1 1 70%;
    min-width: 0;
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.pdf-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.pdf-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.pdf-viewer-container {
    flex: 1;
    overflow: auto;
    position: relative;
    padding: 1rem;
    background-color: #e2e8f0; /* dark background for PDF viewer */
    display: flex;
    justify-content: center;
}

/* Container inside the viewer to relatively position the canvas and highlight box */
.pdf-page-wrapper {
    position: relative;
    display: inline-block; /* wraps tightly around the canvas */
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

#pdf-canvas {
    display: block;
}

.highlight-box {
    position: absolute;
    background-color: rgba(250, 204, 21, 0.3); /* Yellow semi-transparent */
    border: 2px solid #eab308; /* Yellow border */
    border-radius: 4px;
    pointer-events: none; /* Let clicks pass through */
    transition: all 0.3s ease;
    z-index: 10;
}

.validation-panel {
    flex: 1;
    min-width: 380px;
    max-width: 500px;
    display: flex;
    flex-direction: column;
}

/* Form Elements */
.form-control {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
}

.row-inputs-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.input-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.modal,
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(15, 23, 42, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background-color: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
    width: 90%;
    max-width: 500px;
    overflow: hidden;
}

.modal-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background-color: #fffbeb; /* Light yellow warning bg */
}

.modal-header h3 {
    margin: 0;
    color: #b45309; /* Dark yellow/orange text */
}

.modal-body {
    padding: 1.5rem;
}

.modal-preview-box {
    margin-top: 0.5rem;
    padding: 1rem;
    background-color: #f1f5f9;
    border-radius: var(--radius);
    font-family: monospace;
    font-size: 0.9rem;
    border: 1px dashed var(--secondary);
    word-break: break-all;
}

.modal-footer {
    padding: 1rem 1.5rem;
    background-color: #f8fafc;
    border-top: 1px solid var(--border);
}

/* Tabs */
.tabs-container {
    display: flex;
    gap: 10px;
}

.tab-btn {
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 8px 16px;
    border-radius: var(--radius);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: rgba(37, 99, 235, 0.1);
}

.tab-btn.active {
    background: var(--primary);
    color: white;
}

.view-section {
    animation: fadeIn 0.3s ease-in-out;
}

/* Data Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table th, .data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background-color: #f1f5f9;
    font-weight: 600;
    color: var(--text-muted);
}

.data-table tr:hover {
    background-color: #f8fafc;
}

.entry-count {
    font-size: 0.85rem;
    font-weight: normal;
    color: var(--text-muted);
}

.address-table-scroll {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.address-table-scroll .data-table {
    margin: 0;
}

.address-table-scroll thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    box-shadow: 0 1px 0 var(--border);
}

/* Adressverwaltung: zwei Spalten, beide Listen immer sichtbar */
.address-left-panel {
    flex: 1;
    min-width: 0;
    max-height: 85vh;
    overflow-y: auto;
}

#address-split-layout.google-panel-open .address-left-panel {
    flex: 1 1 52%;
    max-width: 52%;
}

#address-split-layout.google-panel-open #google-frame-panel {
    flex: 1 1 48%;
    min-width: 320px;
}

.action-btn-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
}

.data-table .td-actions {
    white-space: nowrap;
    width: 1%;
}

.data-table .th-gender, .data-table .td-gender {
    width: 65px;
    max-width: 65px;
    white-space: nowrap;
    text-align: center;
}

.address-table-scroll {
    overflow-x: auto;
}

.address-mgmt-card {
    overflow: visible;
    margin-bottom: 0;
    height: auto;
}

.address-region-filter {
    max-width: 600px;
    margin-bottom: 1.25rem;
    flex-direction: row;
    align-items: flex-end;
    gap: 0.75rem;
}

.address-lists-grid {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.address-list-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.address-list-section h3 {
    margin: 0 0 0.5rem 0;
}

.address-search {
    max-width: 320px;
    margin-bottom: 0.5rem;
}

.address-search-row {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem 1.5rem;
    margin-bottom: 0.5rem;
}

.address-search-row .address-search {
    margin-bottom: 0;
    flex: 1;
    min-width: 200px;
    max-width: 320px;
}

.address-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    cursor: pointer;
    user-select: none;
    padding-bottom: 0.5rem;
    white-space: nowrap;
}

.address-filter-checkbox input {
    cursor: pointer;
}

.address-list-section .address-table-scroll {
    max-height: 380px;
}

.active-row {
    background-color: #fef9c3 !important; /* Soft beige/yellow */
}