/* Modern Dark Theme */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 3rem;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

/* Upload Section */
.upload-section {
    margin-bottom: 2rem;
}

.dropzone {
    background: var(--bg-secondary);
    border: 2px dashed var(--border);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.dropzone:hover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
}

.dropzone.dragover {
    border-color: var(--accent);
    background: var(--bg-tertiary);
    transform: scale(1.02);
}

.upload-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 1rem;
    color: var(--accent);
}

.dropzone h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.dropzone p {
    color: var(--text-secondary);
}

.dropzone-uploading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 1rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

/* Stats */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    padding: 1.5rem;
    border-radius: 0.75rem;
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Filter */
.filter-section {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input, .filter-select {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

.search-input {
    flex: 1;
    min-width: 250px;
}

.search-input:focus, .filter-select:focus {
    border-color: var(--accent);
}

/* Table */
.table-section {
    background: var(--bg-secondary);
    border-radius: 0.75rem;
    border: 1px solid var(--border);
    overflow: hidden;
}

.invoice-table {
    width: 100%;
    border-collapse: collapse;
}

.invoice-table thead {
    background: var(--bg-tertiary);
}

.invoice-table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
}

.invoice-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.2s;
    cursor: pointer;
}

.invoice-table tbody tr:hover {
    background: var(--bg-tertiary);
}

.invoice-table td {
    padding: 1rem;
    color: var(--text-primary);
}

.invoice-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.invoice-type.strom {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.invoice-type.nettleie {
    background: rgba(139, 92, 246, 0.2);
    color: #a78bfa;
}

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.25rem;
    transition: color 0.2s;
}

.btn-icon:hover {
    color: var(--text-primary);
}

.btn-icon.edit:hover {
    color: var(--accent);
}

.btn-icon.delete:hover {
    color: var(--danger);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
}

.empty-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1rem;
    color: var(--text-secondary);
}

.empty-state h3 {
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--text-secondary);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: 1rem;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.modal-small {
    max-width: 500px;
}

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

.modal-header h2 {
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow: auto;
}

#pdfViewer {
    width: 100%;
    height: 70vh;
    border-radius: 0.5rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--accent);
}

.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

.btn-danger {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

/* Toast */
#toastContainer {
    position: fixed;
    top: 2rem;
    right: 2rem;
    z-index: 2000;
}

.toast {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: 0 4px 6px var(--shadow);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    border-left: 4px solid var(--success);
}

.toast.error {
    border-left: 4px solid var(--danger);
}

.toast.warning {
    border-left: 4px solid var(--warning);
}

/* ===== TABS (Fase 1) ===== */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid var(--border);
}

.tab-button {
    padding: 1rem 2rem;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: -2px;
}

.tab-button:hover {
    color: var(--text-primary);
}

.tab-button.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ===== TENANTS (Fase 1) ===== */
.tenants-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.tenants-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.75rem;
}

.tenant-section {
    margin-bottom: 3rem;
}

.section-title {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 500;
}

.tenant-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 1.5rem;
}

.tenant-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s;
}

.tenant-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.tenant-card.active {
    border-color: var(--success);
    border-width: 2px;
}

.tenant-card.inactive {
    opacity: 0.8;
}

.tenant-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.tenant-status {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tenant-status.active {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.tenant-status.inactive {
    background: var(--text-secondary);
}

.tenant-card-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
    flex: 1;
}

.tenant-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.tenant-info-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.tenant-info-row svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.tenant-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.empty-state-small {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    border: 1px dashed var(--border);
    border-radius: 0.75rem;
}

.empty-state-small p {
    margin: 0;
}

/* ===== FORM SECTIONS ===== */
.form-section {
    margin-bottom: 2rem;
}

.form-section h4 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 500;
}

.form-hint {
    display: block;
    margin-top: 0.25rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.date-input-group {
    display: flex;
    gap: 0.5rem;
}

.date-input-group input {
    flex: 1;
}

.info-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-top: 1rem;
}

.info-box strong {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.info-box ul {
    margin: 0;
    padding-left: 1.5rem;
    color: var(--text-secondary);
}

.info-box li {
    margin: 0.25rem 0;
}

.confirm-text {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.modal-medium {
    max-width: 600px;
}

.modal-large {
    max-width: 900px;
}

/* ===== PERIODS (Fase 2) ===== */
.periods-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.periods-header h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.75rem;
}

.period-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.period-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s;
}

.period-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px var(--shadow);
}

.period-card.status-aktiv {
    border-color: var(--success);
}

.period-card.status-planlagt {
    border-color: #3b82f6;
}

.period-card.status-avsluttet {
    border-color: var(--text-secondary);
    opacity: 0.85;
}

.period-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.period-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.period-status-indicator.aktiv {
    background: var(--success);
    box-shadow: 0 0 8px var(--success);
}

.period-status-indicator.planlagt {
    background: #3b82f6;
    box-shadow: 0 0 8px #3b82f6;
}

.period-status-indicator.avsluttet {
    background: var(--text-secondary);
}

.period-card-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--text-primary);
    flex: 1;
}

.period-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.period-info-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.period-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Quick date buttons */
.quick-dates {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

/* Radio group */
.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.radio-label:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.radio-label input[type="radio"] {
    margin: 0;
}

.radio-label input[type="radio"]:checked + span {
    font-weight: 600;
    color: var(--primary);
}

/* Period details */
.period-details-section {
    margin-bottom: 2rem;
}

.period-details-section h3 {
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.invoice-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.invoice-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.invoice-item-check {
    width: 20px;
}

.invoice-item-info {
    flex: 1;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.meter-reading-card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    margin-bottom: 1rem;
}

.meter-reading-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.meter-reading-header h4 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.meter-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.meter-image-thumb {
    position: relative;
    aspect-ratio: 4/3;
    border-radius: 0.5rem;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}

.meter-image-thumb:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--shadow);
}

.meter-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.meter-image-delete {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}

.meter-image-thumb:hover .meter-image-delete {
    opacity: 1;
}

/* Image viewer */
.image-viewer-content {
    text-align: center;
}

.image-viewer-content img {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.image-viewer-info {
    text-align: left;
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 0.5rem;
    margin-top: 1rem;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 0.5rem;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-zone:hover {
    border-color: var(--primary);
    background: rgba(59, 130, 246, 0.05);
}

.upload-zone.dragover {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 1rem;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filter-section {
        flex-direction: column;
    }
    
    .search-input {
        width: 100%;
    }
    
    .invoice-table {
        font-size: 0.875rem;
    }
    
    .invoice-table th,
    .invoice-table td {
        padding: 0.75rem 0.5rem;
    }
    
    /* Tenant responsive */
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-button {
        flex: 1;
        min-width: 120px;
    }
    
    .tenants-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .tenants-header .btn {
        width: 100%;
    }
    
    .tenant-cards {
        grid-template-columns: 1fr;
    }
    
    .tenant-actions {
        flex-direction: column;
    }
    
    .tenant-actions .btn {
        width: 100%;
    }
    
    /* Period responsive */
    .periods-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .periods-header .btn {
        width: 100%;
    }
    
    .period-cards {
        grid-template-columns: 1fr;
    }
    
    .period-actions {
        flex-direction: column;
    }
    
    .period-actions .btn {
        width: 100%;
    }
    
    .quick-dates {
        flex-direction: column;
    }
    
    .quick-dates .btn {
        width: 100%;
    }
    
    .radio-group {
        flex-direction: column;
    }
    
    .radio-label {
        width: 100%;
    }
    
    /* Auto-assign responsive */
    .auto-assign-banner {
        flex-direction: column;
        gap: 1rem;
    }
    
    .auto-assign-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .unmatched-list {
        grid-template-columns: 1fr;
    }
}

/* ====================
   AUTO-ASSIGNMENT (Fase 3)
   ==================== */

.auto-assign-banner {
    background: linear-gradient(135deg, var(--accent) 0%, #2563eb 100%);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.2);
}

.banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.banner-icon {
    font-size: 2rem;
}

.banner-text {
    color: white;
    font-size: 0.95rem;
}

.banner-text strong {
    font-size: 1.5rem;
    font-weight: 700;
}

.auto-assign-preview {
    min-height: 300px;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    gap: 1rem;
}

.loading-spinner p {
    color: var(--text-secondary);
}

.auto-assign-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.summary-stat {
    text-align: center;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: 8px;
}

.summary-stat strong {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.summary-stat.success strong { color: var(--success); }
.summary-stat.warning strong { color: var(--warning); }
.summary-stat.danger strong { color: var(--danger); }

.summary-stat span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.assignment-section {
    margin-bottom: 2rem;
}

.section-heading {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border);
}

.assignment-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.assignment-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--accent);
}

.assignment-info {
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex: 1;
}

.invoice-info,
.period-info {
    display: flex;
    flex-direction: column;
}

.invoice-info strong,
.period-info strong {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.invoice-info span,
.period-info span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.assignment-arrow {
    font-size: 1.5rem;
    color: var(--accent);
}

.info-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.unmatched-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
}

.unmatched-item {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 3px solid var(--danger);
}

.unmatched-item strong {
    display: block;
    margin-bottom: 0.5rem;
}

.unmatched-item span {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Period select dropdown in invoice table */
.period-select {
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.period-select:hover {
    border-color: var(--accent);
}

.period-badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--accent);
    color: white;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.period-badge.unassigned {
    background: var(--text-secondary);
}

/* Settlement Styling (Fase 4) */
.settlement-content {
    max-width: 800px;
    margin: 0 auto;
}

.settlement-header {
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border);
}

.settlement-header h2 {
    margin-bottom: 0.5rem;
}

.settlement-subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
}

.settlement-badge {
    display: inline-block;
    padding: 0.5rem 1rem;
    margin-top: 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
}

.settlement-badge.saved {
    background: var(--success);
    color: white;
}

.settlement-badge.preview {
    background: var(--warning);
    color: white;
}

.settlement-status {
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 500;
}

.settlement-status.owe {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--danger);
    color: var(--danger);
}

.settlement-status.credit {
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid var(--success);
    color: var(--success);
}

.settlement-status.even {
    background: rgba(59, 130, 246, 0.1);
    border: 2px solid var(--accent);
    color: var(--accent);
}

.settlement-status strong {
    display: block;
    font-size: 1.8rem;
    margin-top: 0.5rem;
}

.settlement-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 12px;
}

.settlement-section h3 {
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
    color: var(--accent);
}

.settlement-table {
    width: 100%;
    border-collapse: collapse;
}

.settlement-table tr {
    border-bottom: 1px solid var(--border);
}

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

.settlement-table td {
    padding: 0.75rem 0.5rem;
}

.settlement-table .text-right {
    text-align: right;
}

.settlement-table .settlement-highlight {
    background: rgba(59, 130, 246, 0.05);
    font-weight: 600;
}

.settlement-table .settlement-divider {
    border-top: 2px solid var(--border);
    font-weight: 600;
}

.settlement-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

.meter-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.meter-card {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.meter-card h4 {
    margin-bottom: 0.75rem;
    color: var(--accent);
}

/* ===== SETTLEMENTS TAB (Fase B) ===== */

.settlements-header {
    margin-bottom: 2rem;
    text-align: center;
}

.settlements-header h2 {
    margin-bottom: 0.5rem;
}

.settlements-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.settlements-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.settlement-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    transition: all 0.2s;
}

.settlement-card:hover {
    border-color: var(--accent);
    box-shadow: 0 4px 12px var(--shadow);
}

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

.settlement-card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary);
}

.settlement-status-badge {
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
}

.settlement-status-badge.owe {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

.settlement-status-badge.credit {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.settlement-status-badge.even {
    background: rgba(59, 130, 246, 0.1);
    color: var(--accent);
    border: 1px solid var(--accent);
}

.settlement-info {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.settlement-info-row {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.settlement-card .settlement-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}
