/* ==========================================
   INVOICE / OFFER STYLES
   ========================================== */

/* Invoice Popup Container - overlay within the org popup */
.invoice-popup-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.invoice-popup-content {
    background: #fff;
    border-radius: 12px;
    max-width: 920px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

/* Header */
.invoice-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E5E7EB;
    background: #F9FAFB;
    position: sticky;
    top: 0;
    z-index: 1;
}

.invoice-popup-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}

.invoice-popup-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.invoice-add-btn {
    padding: 6px 14px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    color: #374151;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.invoice-add-btn:hover {
    background: #10B981;
    color: #fff;
    border-color: #10B981;
}

.invoice-close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 20px;
    color: #6B7280;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.invoice-close-btn:hover {
    background: #F3F4F6;
    color: #111827;
}

/* Invoice List */
.invoice-list {
    padding: 16px 20px;
    overflow-y: auto;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.invoice-loading,
.invoice-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6B7280;
    font-size: 14px;
}

/* Invoice Card */
.invoice-card {
    border: 1px solid #E5E7EB;
    border-radius: 10px;
    padding: 14px 16px;
    background: #fff;
    transition: box-shadow 0.15s ease;
}

.invoice-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.invoice-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.invoice-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.invoice-status {
    font-size: 12px;
    font-weight: 500;
}

.invoice-card-body {
    margin-bottom: 10px;
}

.invoice-title {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 4px;
}

.invoice-amount {
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.invoice-deadline {
    font-size: 12px;
    color: #6B7280;
}

/* Card Actions */
.invoice-card-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 10px;
    border-top: 1px solid #F3F4F6;
}

.invoice-action-btns {
    display: flex;
    align-items: center;
    gap: 6px;
}

.invoice-upload-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    color: #6B7280;
    transition: all 0.15s ease;
}

.invoice-upload-label:hover {
    background: #F3F4F6;
    color: #111827;
}

.invoice-doc-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    color: #3B82F6;
    transition: all 0.15s ease;
    text-decoration: none;
}

.invoice-doc-link:hover {
    background: #EFF6FF;
}

.invoice-delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: none;
    background: none;
    border-radius: 6px;
    color: #9CA3AF;
    cursor: pointer;
    transition: all 0.15s ease;
}

.invoice-delete-btn:hover {
    background: #FEF2F2;
    color: #EF4444;
}

/* Status Pipeline */
.invoice-status-pipeline {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
}

.pipeline-step {
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid #E5E7EB;
    background: #F9FAFB;
    color: #9CA3AF;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.pipeline-step:hover {
    border-color: #10B981;
    color: #10B981;
}

.pipeline-step.active {
    background: #ECFDF5;
    border-color: #10B981;
    color: #059669;
}

.pipeline-step.overdue {
    background: #FEF2F2;
    border-color: #EF4444;
    color: #DC2626;
}

.pipeline-arrow {
    font-size: 10px;
    color: #D1D5DB;
    margin: 0 1px;
    user-select: none;
}

/* Invoice Button Dynamic States */
.invoice-btn.invoice-ok {
    border-color: #10B981 !important;
    color: #059669 !important;
}

.invoice-btn.invoice-warn {
    border-color: #F59E0B !important;
    color: #D97706 !important;
    background: #FFFBEB !important;
}

.invoice-btn.invoice-overdue {
    border-color: #EF4444 !important;
    color: #DC2626 !important;
    background: #FEF2F2 !important;
    animation: invoice-pulse 2s ease-in-out infinite;
}

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

/* Responsive */
@media (max-width: 640px) {
    .invoice-popup-container {
        padding: 10px;
    }

    .invoice-popup-content {
        max-height: 90vh;
    }

    .invoice-popup-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .invoice-status-pipeline {
        flex-wrap: wrap;
    }

    .pipeline-step {
        font-size: 10px;
        padding: 2px 6px;
    }

    .invoice-card-actions {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }
}

/* Invoice Category */
.invoice-category {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.invoice-category-label {
    font-size: 12px;
    color: #6B7280;
    font-weight: 500;
}

.invoice-category-select {
    font-size: 12px;
    padding: 3px 6px;
    border: 1px solid #D1D5DB;
    border-radius: 6px;
    background: #fff;
    color: #374151;
}

/* Reconciliation (Provisions-Abgleich) */
.invoice-recon-toggle {
    background: #F3F4F6;
    border: 1px solid #D1D5DB;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    transition: background 0.15s ease;
}

.invoice-recon-toggle:hover {
    background: #E5E7EB;
}

.invoice-reconciliation {
    margin: 12px 0;
    padding: 16px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 10px;
}

.recon-header {
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 12px;
}

.recon-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.recon-table th,
.recon-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #E5E7EB;
}

.recon-table th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6B7280;
    font-weight: 600;
}

.recon-table .recon-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.recon-model {
    display: inline-block;
    font-size: 10px;
    color: #6B7280;
    background: #EEF2FF;
    padding: 1px 6px;
    border-radius: 6px;
    margin-left: 4px;
}

.recon-open-pos {
    color: #DC2626;
    font-weight: 600;
}

.recon-open-neg {
    color: #059669;
    font-weight: 600;
}

.recon-open-zero {
    color: #6B7280;
}

.recon-unassigned td {
    color: #92400E;
    background: #FFFBEB;
}

.recon-totals td {
    font-weight: 700;
    color: #111827;
    border-top: 2px solid #D1D5DB;
    border-bottom: none;
}

.recon-empty {
    text-align: center;
    color: #9CA3AF;
    padding: 16px;
}

/* ─── KPI-Kopf ───────────────────────────────────────────────── */
.invoice-kpis {
    display: flex;
    gap: 10px;
    padding: 12px 16px 0;
    flex-wrap: wrap;
}
.invoice-kpi {
    flex: 1 1 120px;
    background: #F9FAFB;
    border: 1px solid #E5E7EB;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.invoice-kpi-label { font-size: 11px; color: #6B7280; text-transform: uppercase; letter-spacing: 0.3px; }
.invoice-kpi-value { font-size: 17px; font-weight: 700; color: #111827; }
.invoice-kpi-overdue { background: #FEF2F2; border-color: #FECACA; }
.invoice-kpi-overdue .invoice-kpi-value { color: #DC2626; }
.invoice-kpi-paid { background: #ECFDF5; border-color: #A7F3D0; }
.invoice-kpi-paid .invoice-kpi-value { color: #059669; }
.invoice-kpi-est { background: #EEF2FF; border-color: #C7D2FE; }
.invoice-kpi-est .invoice-kpi-value { color: #4338CA; }

/* ─── Filter-Tabs ────────────────────────────────────────────── */
.invoice-filters {
    display: flex;
    gap: 6px;
    padding: 12px 16px 0;
    flex-wrap: wrap;
}
.invoice-filter-tab {
    border: 1px solid #E5E7EB;
    background: #fff;
    color: #6B7280;
    border-radius: 16px;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}
.invoice-filter-tab:hover { border-color: #9CA3AF; color: #111827; }
.invoice-filter-tab.active { background: #111827; border-color: #111827; color: #fff; }
.invoice-filter-tab.has-overdue { border-color: #FECACA; }
.invoice-filter-count { opacity: 0.7; font-weight: 600; }

/* ─── Projekt-Gruppen ────────────────────────────────────────── */
.invoice-group { margin-bottom: 14px; }
.invoice-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 2px 8px;
    border-bottom: 1px solid #F3F4F6;
    margin-bottom: 8px;
}
.invoice-group-title { font-size: 13px; font-weight: 700; color: #374151; }
.invoice-group-meta { display: flex; align-items: center; gap: 10px; }
.invoice-group-est {
    font-size: 12px;
    font-weight: 600;
    color: #4338CA;
    background: #EEF2FF;
    border-radius: 4px;
    padding: 2px 8px;
    white-space: nowrap;
}
.invoice-group-sum { font-size: 12px; color: #6B7280; white-space: nowrap; }
.invoice-group-sum-empty { font-style: italic; color: #9CA3AF; }

/* ─── Karte: neue Elemente ───────────────────────────────────── */
.invoice-status-badge {
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.invoice-project-select {
    margin-left: auto;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 11px;
    color: #374151;
    max-width: 160px;
    background: #fff;
}
.invoice-title-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    margin-bottom: 6px;
}
.invoice-title-input:hover { border-color: #E5E7EB; }
.invoice-title-input:focus { border-color: #3B82F6; outline: none; background: #F9FAFB; }
.invoice-amount-row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.invoice-amount-input {
    width: 110px;
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}
.invoice-amount-input:focus { border-color: #3B82F6; outline: none; }
.invoice-amount-cur { font-size: 12px; color: #6B7280; }
.invoice-deadline-edit { font-size: 12px; color: #6B7280; display: inline-flex; align-items: center; gap: 6px; }
.invoice-date-input {
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    padding: 2px 6px;
    font-size: 12px;
    color: #374151;
}
.invoice-duration {
    font-size: 12px;
    font-weight: 600;
    margin-top: 6px;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-block;
}
.invoice-duration.open { background: #EFF6FF; color: #2563EB; }
.invoice-duration.overdue { background: #FEF2F2; color: #DC2626; }
.invoice-duration.paid { background: #ECFDF5; color: #059669; }
.invoice-timeline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
    color: #6B7280;
}
.invoice-tl-step b { color: #374151; font-weight: 600; }

/* Upload-/leer-Buttons */
.invoice-add-upload { font-weight: 600; }
.invoice-add-blank { opacity: 0.85; }

/* ─── Netto/MwSt-Ausweisung ──────────────────────────────────── */
.invoice-net-hint {
    padding: 6px 16px 0;
    font-size: 11px;
    color: #6B7280;
}
.invoice-net-hint strong { color: #374151; }

.invoice-amount-tag {
    margin-left: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6B7280;
    background: #F3F4F6;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    padding: 1px 5px;
}

.invoice-vat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
    font-size: 12px;
    color: #6B7280;
}
.invoice-vat-label { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.invoice-vat-input {
    width: 52px;
    padding: 2px 4px;
    font-size: 12px;
    border: 1px solid #E5E7EB;
    border-radius: 4px;
    text-align: right;
}
.invoice-gross { font-weight: 600; color: #374151; }
.invoice-gross-none { font-weight: 400; font-style: italic; color: #9CA3AF; }

.recon-net-tag {
    margin-left: 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #4338CA;
    background: #EEF2FF;
    border: 1px solid #C7D2FE;
    border-radius: 4px;
    padding: 1px 5px;
    vertical-align: middle;
}

/* Rotes €-Icon in der Org-Liste: signalisiert ueberfaellige Rechnung/Angebot */
.org-overdue-euro {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    color: #fff;
    background: #EF4444;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 0 2px #FEE2E2;
    animation: org-overdue-pulse 2s ease-in-out infinite;
}
.org-overdue-euro:hover { background: #DC2626; }

@keyframes org-overdue-pulse {
    0%, 100% { box-shadow: 0 0 0 2px #FEE2E2; }
    50%      { box-shadow: 0 0 0 4px #FECACA; }
}
