/* ── Umsatzplanung Modul ─────────────────────────────────────────────────────── */

.usp-module {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px);
    overflow: hidden;
    background: var(--background);
}

/* ── Header / Tabs ─────────────────────────────────────────────────────────── */
.usp-header {
    flex-shrink: 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 20px;
}

.usp-title-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0 8px;
}

.usp-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin: 0;
}

.usp-tabs {
    display: flex;
    gap: 2px;
}

.usp-tab {
    padding: 9px 18px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
}

.usp-tab:hover { color: var(--text-main); }
.usp-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ── Content ───────────────────────────────────────────────────────────────── */
.usp-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.usp-loading, .usp-error, .usp-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: .95rem;
    gap: 8px;
}
.usp-error { color: var(--danger); }

/* ── Toolbar ───────────────────────────────────────────────────────────────── */
.usp-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.usp-pl-select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--text-main);
    font-size: .88rem;
    min-width: 200px;
    cursor: pointer;
}

.usp-Jahr-badge {
    font-size: .8rem;
    color: var(--text-muted);
    padding: 4px 10px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.usp-btn {
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--background);
    color: var(--text-main);
    font-size: .83rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background .15s, border-color .15s;
    white-space: nowrap;
}
.usp-btn:hover { background: var(--border); }
.usp-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.usp-btn.primary:hover { opacity: .88; }
.usp-btn.danger { color: var(--danger); border-color: var(--danger); }
.usp-btn.danger:hover { background: #fee2e2; }
.usp-btn.xs { padding: 3px 8px; font-size: .78rem; }

.usp-spacer { flex: 1; }

.usp-stand {
    font-size: .78rem;
    color: var(--text-muted);
}

/* ── PL-Planung Sub-Tabs ─────────────────────────────────────────────────── */
.usp2-subtabs {
    display: flex;
    gap: 2px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.usp2-subtab {
    padding: 7px 16px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .83rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
}
.usp2-subtab:hover { color: var(--text-main); }
.usp2-subtab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* ── PL-Planung: Tabelle ───────────────────────────────────────────────────── */
.usp-table-outer {
    flex: 1;
    overflow: auto;
    position: relative;
}

.usp-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: .8rem;
    min-width: max-content;
    width: 100%;
}

.usp-table th, .usp-table td {
    white-space: nowrap;
    padding: 0;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* ── Sticky Spalten (Freeze Panes) ─────────────────────────────────────────── */
.usp-table .sc {
    position: sticky;
    z-index: 2;
    background: var(--surface);
}
.usp-table thead th.sc { z-index: 6; background: var(--background); }
.usp-table tbody tr:hover td.sc { background: #f0f4ff; }

/* Cumulative left offsets für 11 fixe Spalten */
.usp-table .sc-0  { left: 0;     min-width: 36px;  max-width: 36px; }
.usp-table .sc-1  { left: 36px;  min-width: 95px;  max-width: 95px; }
.usp-table .sc-2  { left: 131px; min-width: 175px; max-width: 175px; }
.usp-table .sc-3  { left: 306px; min-width: 125px; max-width: 125px; }
.usp-table .sc-4  { left: 431px; min-width: 58px;  max-width: 58px; }
.usp-table .sc-5  { left: 489px; min-width: 90px;  max-width: 90px; }
.usp-table .sc-6  { left: 579px; min-width: 80px;  max-width: 80px; }
.usp-table .sc-7  { left: 659px; min-width: 38px;  max-width: 38px; }
.usp-table .sc-8  { left: 697px; min-width: 68px;  max-width: 68px; }
.usp-table .sc-9  { left: 765px; min-width: 88px;  max-width: 88px; }
.usp-table .sc-10 { left: 853px; min-width: 52px;  max-width: 52px; }

/* Trennlinie nach den fixen Spalten */
.usp-table .sc-10 { border-right: 2px solid var(--primary) !important; }

/* ── Sticky thead ────────────────────────────────────────────────────────────── */
/* top = KAP-Block-Höhe (via JS als --usp-kap-h gesetzt), damit thead direkt
   unter dem KAP-Block klebt und nicht überlappt.                                 */
.usp-table thead {
    position: sticky;
    top: var(--usp-kap-h, 0);
    z-index: 10;
}

/* ── Header-Zeilen ─────────────────────────────────────────────────────────── */
.usp-table thead th {
    background: var(--background);
    font-weight: 600;
    text-align: center;
    color: var(--text-muted);
    font-size: .75rem;
    padding: 4px 5px;
    border-top: 1px solid var(--border);
}

/* Fixe Spalten in thead: horizontal sticky */
.usp-table thead th.sc {
    position: sticky;
    z-index: 6;
    background: var(--background);
}

/* Monats-Header Zeile 1 */
.usp-th-monat {
    background: var(--primary) !important;
    color: #fff !important;
    font-weight: 700 !important;
    font-size: .78rem !important;
    padding: 5px 8px !important;
    text-align: left !important;
}
.usp-th-monat-placeholder {
    background: #1e293b !important;
    color: #fff !important;
}

/* KW-Header Zeile 2 */
.usp-th-kw {
    background: #f8fafc !important;
    font-size: .73rem !important;
    min-width: 65px;
    max-width: 65px;
    color: var(--text-main) !important;
}
.usp-th-kw-monat {
    background: #e0e7ff !important;
    min-width: 80px;
    max-width: 80px;
    font-weight: 700 !important;
    color: #3730a3 !important;
}
.usp-th-kw.current-kw {
    background: #fef3c7 !important;
    color: #92400e !important;
}

/* Soll-Std / Arbeitstage-Zeile */
.usp-th-meta {
    background: #f1f5f9 !important;
    font-size: .7rem !important;
    color: var(--text-muted) !important;
    font-weight: 400 !important;
}
.usp-th-ат-edit {
    cursor: pointer;
    transition: background .15s;
}
.usp-th-ат-edit:hover { background: #fef3c7 !important; }
.usp-th-ат-edit input {
    width: 100%;
    border: none;
    background: transparent;
    text-align: center;
    font-size: .7rem;
    color: var(--text-main);
    padding: 0;
}
.usp-th-ат-edit input:focus { background: #fffbeb; }

/* ── Tabellen-Zellen ───────────────────────────────────────────────────────── */
.usp-table tbody td {
    padding: 0 5px;
    height: 28px;
    color: var(--text-main);
}

.usp-table tbody tr:nth-child(even) td:not(.sc) { background: #fafafa; }
.usp-table tbody tr:hover td:not(.sc) { background: #f0f4ff; }

/* Summen-Zeile (tfoot / bottom) */
.usp-table tr.usp-sum-row td {
    font-weight: 700;
    background: #e0e7ff !important;
    color: #1e1b4b;
    position: sticky;
    bottom: 0;
    z-index: 1;
    border-top: 2px solid #818cf8;
}
.usp-table tr.usp-sum-row td.sc { z-index: 3; }

/* Gesamt-Zeile (tbody top) — überschreibt sticky-bottom */
.usp-table tbody tr.usp-top-sum td {
    position: sticky !important;
    top: var(--usp-thead-h, 0px);
    bottom: auto !important;
    z-index: 4 !important;
    border-top: none;
    border-bottom: 2px solid #818cf8;
    background: #ede9fe !important;
    color: #3b0764;
}
/* Fixe Spalten (.sc) in usp-top-sum höher als scrollbare KW-Zellen */
.usp-table tbody tr.usp-top-sum td.sc {
    z-index: 6 !important;
}

/* KW-Zelle */
.usp-kw-cell {
    min-width: 65px;
    max-width: 65px;
    text-align: right;
    padding: 0 !important;
    cursor: text;
    position: relative;
}
.usp-kw-cell.monat-cell {
    min-width: 80px;
    max-width: 80px;
    background: #f0f4ff;
    font-weight: 600;
    color: #1e3a8a;
}
.usp-kw-cell .cell-val {
    display: block;
    padding: 0 5px;
    height: 28px;
    line-height: 28px;
    width: 100%;
    text-align: right;
    font-size: .8rem;
}
.usp-kw-cell .cell-val.has-value { color: var(--text-main); }
.usp-kw-cell .cell-val.empty { color: transparent; }
.usp-kw-cell .cell-val.negative { color: var(--danger); }
.usp-kw-cell.usp-kw-cell-auto { cursor: default; }
.usp-kw-cell.usp-kw-cell-auto .cell-val.has-value { color: #6366f1; font-style: italic; }
.usp-kw-cell input.cell-edit {
    display: block;
    width: 100%;
    height: 28px;
    padding: 0 5px;
    border: 2px solid var(--primary);
    border-radius: 0;
    background: #eff6ff;
    font-size: .8rem;
    text-align: right;
    outline: none;
    box-sizing: border-box;
}

/* Stammdaten-Zellen */
.usp-td-nr    { text-align: center; color: var(--text-muted); font-size: .75rem; }
.usp-td-pnr   { font-family: monospace; font-size: .78rem; color: #1d4ed8; padding: 0 5px !important; }
.usp-td-bez   { padding: 0 6px !important; overflow: hidden; text-overflow: ellipsis; }
.usp-td-kunde { padding: 0 5px !important; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; font-size: .78rem; }
.usp-td-num   { text-align: right; padding: 0 6px !important; font-variant-numeric: tabular-nums; }
.usp-td-intern { text-align: center; }
.usp-td-intern .tag-intern { font-size: .65rem; padding: 1px 5px; border-radius: 3px; background: #dbeafe; color: #1e40af; }
.usp-td-intern .tag-extern { font-size: .65rem; padding: 1px 5px; border-radius: 3px; background: #dcfce7; color: #14532d; }
.usp-td-kum   { color: #6366f1; font-weight: 600; }
.usp-td-actions { text-align: center; }

/* ── Projekt-Dialog ────────────────────────────────────────────────────────── */
.usp-dlg-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1000;
    display: flex; align-items: center; justify-content: center;
}
.usp-dlg {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    padding: 28px 32px;
    min-width: 480px;
    max-width: 580px;
    width: 100%;
}
.usp-dlg h3 { margin: 0 0 20px; font-size: 1rem; }
.usp-dlg .form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 16px;
}
.usp-dlg .form-grid .full { grid-column: 1 / -1; }
.usp-dlg label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }
.usp-dlg input, .usp-dlg select, .usp-dlg textarea {
    width: 100%; padding: 7px 10px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--background); color: var(--text-main);
    font-size: .88rem; box-sizing: border-box;
}
.usp-dlg textarea { resize: vertical; min-height: 60px; }
.usp-dlg .dlg-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    margin-top: 22px; padding-top: 16px;
    border-top: 1px solid var(--border);
}
.usp-dlg-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-weight: 600; font-size: .95rem;
}
.usp-dlg.large { max-width: 640px; width: 100%; padding: 0; }

/* ── Budget-Tab ────────────────────────────────────────────────────────────── */
.usp-budget-wrap {
    flex: 1;
    overflow: auto;
    padding: 16px;
}
.usp-budget-table {
    border-collapse: collapse;
    width: 100%;
    font-size: .84rem;
}
.usp-budget-table th, .usp-budget-table td {
    padding: 7px 12px;
    border: 1px solid var(--border);
    text-align: right;
    white-space: nowrap;
}
.usp-budget-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-muted);
    font-size: .78rem;
    position: sticky; top: 0; z-index: 2;
}
.usp-budget-table td:first-child, .usp-budget-table th:first-child {
    text-align: left; position: sticky; left: 0;
    background: var(--surface); z-index: 1;
    min-width: 180px;
}
.usp-budget-table tr:hover td { background: #f0f4ff; }
.usp-budget-table tr.sum-row td {
    font-weight: 700; background: #e0e7ff;
    border-top: 2px solid #818cf8;
}
.usp-budget-table .editable {
    cursor: text; padding: 0;
}
.usp-budget-table .editable input {
    width: 100%; padding: 6px 12px;
    border: none; background: transparent;
    text-align: right; font-size: .84rem;
    color: var(--text-main);
}
.usp-budget-table .editable input:focus {
    background: #eff6ff; outline: none;
}
.usp-budget-table .ist-cell { color: #059669; }
.usp-budget-table .neg-cell { color: var(--danger); }

/* ── VC Tab ────────────────────────────────────────────────────────────────── */
.usp-vc-wrap {
    flex: 1; overflow: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 20px;
}
.usp-vc-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}
.usp-vc-section-title {
    padding: 10px 16px;
    font-weight: 700; font-size: .85rem;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 8px;
}
.usp-vc-matrix {
    overflow-x: auto;
}
.usp-vc-table {
    border-collapse: collapse;
    width: 100%; font-size: .82rem;
    min-width: max-content;
}
.usp-vc-table th, .usp-vc-table td {
    padding: 6px 10px;
    border: 1px solid var(--border);
    text-align: right; white-space: nowrap;
}
.usp-vc-table th {
    background: var(--background);
    font-weight: 600; font-size: .75rem;
    color: var(--text-muted);
}
.usp-vc-table td:first-child { text-align: left; font-weight: 500; min-width: 180px; }
.usp-vc-table .row-budget  { background: #eff6ff; }
.usp-vc-table .row-geplant { background: #f0fdf4; }
.usp-vc-table .row-abw     { background: #fff7ed; font-size: .78rem; color: var(--text-muted); }
.usp-vc-table .row-kum     { font-weight: 700; background: #e0e7ff; }

/* Vertriebsliste */
.usp-vertrieb-list { padding: 12px 16px; }
.usp-vertrieb-row {
    display: grid;
    grid-template-columns: 1fr 2fr 100px 60px 80px 90px 36px;
    gap: 8px; align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: .83rem;
}
.usp-vertrieb-row:last-child { border-bottom: none; }
.usp-vt-header { font-weight: 600; color: var(--text-muted); font-size: .75rem; }
.usp-vtag {
    padding: 2px 8px; border-radius: 4px;
    font-size: .72rem; font-weight: 600;
    display: inline-block; text-align: center;
}
.usp-vtag.offen    { background: #fef3c7; color: #92400e; }
.usp-vtag.gewonnen { background: #dcfce7; color: #14532d; }
.usp-vtag.verloren { background: #fee2e2; color: #991b1b; }

/* ── Übersicht KW Tab ──────────────────────────────────────────────────────── */
.usp-uebersicht-wrap {
    flex: 1; overflow: auto;
}
/* Tooltip-Icon (ⓘ) neben Spaltenüberschriften — analog zu psb-tt im Projektstatusblatt */
.usp-tt {
    color: #cbd5e1;
    font-size: .65rem;
    margin-left: 4px;
    cursor: help;
    vertical-align: middle;
    transition: color .15s;
}
.usp-tt:hover { color: #60a5fa; }

.usp-uebersicht-table {
    border-collapse: separate; border-spacing: 0;
    width: 100%; font-size: .8rem;
    min-width: max-content;
}
.usp-uebersicht-table th, .usp-uebersicht-table td {
    padding: 5px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.usp-uebersicht-table thead th {
    position: sticky; top: 0; z-index: 6;
    background: var(--background);
    font-weight: 600; font-size: .75rem;
    color: var(--text-muted); text-align: center;
}
.usp-uebersicht-table td:nth-child(1),
.usp-uebersicht-table td:nth-child(2),
.usp-uebersicht-table td:nth-child(3) {
    position: sticky; z-index: 2;
    background: var(--surface);
}
/* Fixe Spalten im thead müssen zusätzlich über den anderen sticky-th liegen (vertikal + horizontal
   sticky gleichzeitig) — sonst schieben sich beim horizontalen Scrollen die Datenspalten sichtbar
   über die fixierten Spalten statt dahinter (gemeldet 06.07.2026). */
.usp-uebersicht-table thead th:nth-child(1),
.usp-uebersicht-table thead th:nth-child(2),
.usp-uebersicht-table thead th:nth-child(3) { z-index: 7; }
.usp-uebersicht-table td:nth-child(1),
.usp-uebersicht-table th:nth-child(1) { left: 0; min-width: 90px; }
.usp-uebersicht-table td:nth-child(2),
.usp-uebersicht-table th:nth-child(2) { left: 90px; min-width: 60px; }
.usp-uebersicht-table td:nth-child(3),
.usp-uebersicht-table th:nth-child(3) { left: 150px; min-width: 60px; font-weight: 600; border-right: 2px solid var(--primary) !important; }
.usp-uebersicht-table .num { text-align: right; }
.usp-uebersicht-table .sum-monat td { background: #e0e7ff; font-weight: 700; }
.usp-uebersicht-table .sum-monat td:nth-child(1),
.usp-uebersicht-table .sum-monat td:nth-child(2),
.usp-uebersicht-table .sum-monat td:nth-child(3) { z-index: 3; }
.usp-uebersicht-table .current-kw td { background: #fef3c7; }

/* ── PL-Budget (händische Jahres-Budgetmatrix) ───────────────────────────────── */
.usp-budget-table {
    border-collapse: separate; border-spacing: 0;
    width: 100%; font-size: .8rem;
    min-width: max-content;
}
.usp-budget-table th, .usp-budget-table td {
    padding: 5px 10px;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: right;
}
.usp-budget-table thead th {
    position: sticky; top: 0; z-index: 4;
    background: var(--background);
    font-weight: 600; font-size: .75rem;
    color: var(--text-muted); text-align: center;
}
.usp-budget-table th:first-child,
.usp-budget-table td.usp-budget-pl-name {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
    text-align: left; font-weight: 600;
    border-right: 2px solid var(--primary);
}
.usp-budget-table thead th:first-child { z-index: 5; text-align: left; }
.usp-budget-table .usp-budget-summe { font-weight: 700; }
.usp-budget-table tfoot .sum-monat td { background: #e0e7ff; font-weight: 700; }
.usp-budget-table tfoot .sum-monat td:first-child { z-index: 3; }
.usp-budget-input {
    width: 100%; min-width: 80px; text-align: right;
    border: none; background: transparent; font: inherit; color: inherit;
    padding: 2px 0;
}
.usp-budget-input:focus { outline: 2px solid var(--primary); border-radius: 3px; }
.usp-budget-row-inactive { opacity: .55; background: repeating-linear-gradient(45deg, transparent, transparent 8px, rgba(0,0,0,.02) 8px, rgba(0,0,0,.02) 16px); }
.usp-budget-row-inactive td.usp-budget-pl-name { background: var(--surface); }
.usp-budget-ex-badge {
    display: inline-block; font-size: .68rem; font-weight: 600;
    color: #92400e; background: #fef3c7; border: 1px solid #fde68a;
    border-radius: 4px; padding: 1px 6px; margin-left: 6px; vertical-align: middle;
}

/* ── Responsiv ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .usp-toolbar { padding: 8px 10px; gap: 6px; }
    .usp-pl-select { min-width: 160px; }
}
.usp-col-panel {
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    margin: 0 0 8px 0;
    box-shadow: 0 4px 16px rgba(0,0,0,.1);
    max-height: 400px;
    min-width: 560px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}
.usp-col-panel-inner { display:flex; flex-direction:column; height:100%; }
.usp-col-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-weight: 600;
    font-size: .88rem;
    background: var(--background, #f8fafc);
    border-radius: 8px 8px 0 0;
    flex-shrink: 0;
}
.usp-col-panel-body {
    display: flex;
    gap: 0;
    overflow-y: auto;
    flex: 1;
    padding: 10px 14px;
}
.usp2-col-section { flex-shrink: 0; }
.usp2-col-section-title {
    font-size: .70rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted, #94a3b8);
    margin-bottom: 8px;
}
.usp2-col-section-kw { flex: 1; margin-left: 20px; border-left: 1px solid var(--border-color,#e2e8f0); padding-left: 16px; }
.usp2-col-checks { display: flex; flex-direction: column; gap: 4px; }
.usp2-col-check {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: .82rem;
    cursor: pointer;
    padding: 3px 6px;
    border-radius: 4px;
    white-space: nowrap;
    transition: background .12s;
}
.usp2-col-check:hover { background: var(--hover-bg, #f1f5f9); }
.usp2-col-check input[type=checkbox] { cursor: pointer; accent-color: var(--primary, #2563eb); }
.usp2-col-kw-grid { display: flex; flex-direction: column; gap: 0; }
.usp2-col-month-group {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    padding: 4px 0;
    border-bottom: 1px solid var(--border-color, #f1f5f9);
    gap: 8px;
}
.usp2-col-month-group:last-child { border-bottom: none; }
.usp2-col-month-toggle {
    min-width: 105px;
    flex-shrink: 0;
    color: var(--text-main, #1e293b);
    font-size: .82rem;
    font-weight: 600;
    padding-top: 1px;
}
.usp2-col-month-kws {
    display: flex;
    flex-wrap: wrap;
    gap: 1px 6px;
    flex: 1;
}
.usp2-col-kw-item { color: var(--text-muted, #64748b); font-size: .78rem; }

/* ── Resize Handle ──────────────────────────────────────────────────────────── */
.usp2-th-inner {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
    padding-right: 12px;
    overflow: visible;
    white-space: nowrap;
}
.usp2-th-inner > span,
.usp2-th-inner > :not(.usp2-resize-handle) {
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.usp2-resize-handle {
    position: absolute;
    right: -3px;
    top: 0;
    bottom: 0;
    width: 10px;
    cursor: col-resize;
    background: transparent;
    border-right: 3px solid transparent;
    transition: border-color .15s;
    z-index: 10;
}
.usp2-resize-handle:hover,
.usp2-resize-handle:active {
    border-right-color: var(--primary, #2563eb);
    background: rgba(37,99,235,.08);
}
/* Fixe Spalten-Header: th-inner aktivieren */
.usp2-th-fixed { padding: 0 !important; }
.usp2-th-fixed .usp2-th-inner { padding: 4px 10px 4px 6px; }

/* ── Sticky fixe Datenzellen ─────────────────────────────────────────────────── */
.usp2-td-fixed {
    background: var(--card-bg, #fff);
}
tbody tr:hover .usp2-td-fixed {
    background: var(--hover-bg, #f8fafc);
}

/* Span-Labels in th-inner für Text-Truncation */
.usp2-th-inner > span {
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

/* ── Status-Filter Dropdown ────────────────────────────────────────────────── */
.usp-sf-wrap {
    position: relative;
}
.usp-sf-toggle {
    white-space: nowrap;
    gap: 4px;
}
.usp-sf-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 200;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-color, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,.12);
    padding: 6px 4px;
    min-width: 160px;
}
.usp-sf-opt {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    font-size: .82rem;
    cursor: pointer;
    border-radius: 5px;
    user-select: none;
    white-space: nowrap;
}
.usp-sf-opt:hover { background: var(--hover-bg, #f1f5f9); }
.usp-sf-opt input { cursor: pointer; accent-color: var(--primary, #2563eb); }
.usp-sf-sep {
    height: 1px;
    background: var(--border-color, #e2e8f0);
    margin: 4px 8px;
}

/* ── Sync-Status Badge (identisch Kapazitätsplanung) ─────────────────────── */
.usp-sync-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: .72rem;
    color: #0369a1;
    background: #e0f2fe;
    border: 1px solid #bae6fd;
    border-radius: 4px;
    padding: 2px 7px;
    cursor: default;
    white-space: nowrap;
}

/* ── Standalone KAP-Block (im gemeinsamen Scroll-Container) ─────────────────── */
/* position:sticky → bleibt beim vertikalen Scrollen oben stehen.               */
/* Horizontales Scrollen läuft über den gemeinsamen Container → kein JS-Sync.   */
.usp-kap-standalone-outer {
    position: sticky;
    top: 0;
    z-index: 11;   /* > thead z-index:10 → KAP-Block liegt immer oben */
    background: var(--background);
    border-bottom: 2px solid var(--primary);
}
.usp-kap-standalone-outer.usp-kap-collapsed { display: none; }

.usp-kap-standalone-table {
    border-collapse: separate;
    border-spacing: 0;
    font-size: .8rem;
    min-width: max-content;
}

/* Alle Zellen im KAP-Block */
.usp-kap-standalone-table td {
    height: 22px;
    font-size: .71rem;
    background: #f8fafc;
    color: var(--text-muted);
    text-align: right;
    padding: 0 5px;
    white-space: nowrap;
    cursor: default;
    font-weight: 400;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

/* Erste KAP-Zeile: Trennlinie oben */
.usp-kap-standalone-table tbody tr:first-child td {
    border-top: 1px solid var(--border);
}

/* Std./KW-Zeile: Werte etwas dunkler */
.usp-kap-row-std_kw td:not(.usp-kap-label-cell) {
    color: var(--text-main) !important;
    font-weight: 500 !important;
}

/* Label-Zelle (Std./KW, MA, Stunden, Arbeitstage)
   Breite = stickyLeft (nötig für Spaltenausrichtung mit der Haupttabelle).
   Hintergrund = Seitenhintergrund → der leere linke Bereich ist unsichtbar.
   Text ist rechtsbündig, erscheint als schmaler Streifen am rechten Rand. */
.usp-kap-label-cell {
    position: sticky !important;
    left: 0 !important;
    z-index: 7 !important;
    background: var(--background) !important;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    text-align: right !important;
    padding: 0 10px 0 8px !important;
    font-size: .7rem !important;
    border-right: 2px solid var(--primary) !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* KAP-Tabelle Header-Zeile (KW-Labels oben im Block) */
.usp-kap-standalone-table thead th {
    height: 22px;
    font-size: .73rem;
    font-weight: 600;
    text-align: right;
    padding: 0 5px;
    white-space: nowrap;
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
/* Leere linke Ecke im KAP-Header – wie Label-Zelle unsichtbar */
.usp-kap-col-hdr-empty {
    background: var(--background) !important;
    border-right: 2px solid var(--primary) !important;
}
/* KW-Spaltenköpfe in der KAP-Headerzeile: gleiche Optik wie Haupttabelle */
.usp-kap-col-header-row .usp-th-kw-monat { text-align: right !important; }
.usp-kap-col-header-row .usp-th-kw       { text-align: right !important; }
.usp-kap-col-header-row .usp-th-kum      { text-align: right !important; }

/* KW-Wert-Zellen */
.usp-kap-cell {
    min-width: 65px;
    max-width: 65px;
    font-variant-numeric: tabular-nums;
}
.usp-kap-cell.usp-kap-monat {
    min-width: 80px;
    max-width: 80px;
    background: #e0e7ff !important;
    font-weight: 600 !important;
    color: #3730a3 !important;
}

/* ── Kumuliert-Spalte (laufende Monatssumme) ─────────────────────────────── */
.usp-th-kum {
    background: #ede9fe !important;
    color: #5b21b6 !important;
    font-weight: 700 !important;
    min-width: 80px;
    max-width: 80px;
}
.usp-kw-cell.kum-cell {
    min-width: 80px;
    max-width: 80px;
    background: #f5f3ff;
    color: #5b21b6;
    font-weight: 600;
    cursor: default;
}
.usp-table tr.usp-sum-row td.kum-cell {
    background: #c4b5fd !important;
    color: #3b0764 !important;
}
.usp-kap-cell.usp-kap-kum {
    min-width: 80px;
    max-width: 80px;
    background: #ede9fe !important;
    color: #5b21b6 !important;
    font-weight: 500 !important;
}

/* KAP-Toggle-Button */
#usp-kap-toggle { gap: 5px; }
#usp-kap-toggle:hover { background: var(--border); }

/* ── PDS Abrechnung KW-Zellen (blau, read-only) ──────────────────────────── */
.usp-kw-cell.pds-abrechnung {
    background: #eff6ff;
    cursor: default;
}
.usp-kw-cell.pds-abrechnung .cell-val {
    color: #1d4ed8;
    font-weight: 600;
}
.usp-kw-cell.pds-abrechnung:hover {
    background: #dbeafe;
}

/* ── Potentiale: Angebotstyp-Tabs ───────────────────────────────────────────── */
#usp-pot-atyp-bar {
    flex-shrink: 0;
    overflow: hidden;
}
.usp-pot-atyp-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px 0;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.usp-pot-atyp-tab {
    padding: 6px 14px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .82rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: -1px;
}
.usp-pot-atyp-tab:hover { color: var(--text-main); }
.usp-pot-atyp-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

.usp-pot-info-btn {
    margin-left: auto;
    margin-bottom: 3px;
    align-self: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: .95rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: color .15s, background .15s;
    position: relative;
}
.usp-pot-info-btn:hover { color: var(--primary); background: var(--hover); }

.usp-pot-info-popover {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 8px;
    z-index: 200;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0,0,0,.18);
    padding: 18px 20px;
    width: 480px;
    font-size: .83rem;
    color: var(--text-main);
    line-height: 1.5;
}
.usp-pot-info-popover.visible { display: block; }
.usp-pot-info-popover-title {
    font-weight: 700;
    font-size: .9rem;
    margin-bottom: 10px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 7px;
}
.usp-pot-info-popover p { margin: 0 0 12px; }
.usp-pot-info-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .82rem;
    margin-bottom: 0;
}
.usp-pot-info-table th {
    text-align: left;
    padding: 5px 8px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    font-size: .78rem;
}
.usp-pot-info-table td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.usp-pot-info-table tr:last-child td { border-bottom: none; }
.usp-pot-info-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: .75rem;
    font-weight: 600;
    margin-right: 4px;
}
.usp-pot-info-badge.offen     { background: #dcfce7; color: #15803d; }
.usp-pot-info-badge.ausgegeben { background: #dbeafe; color: #1d4ed8; }

/* Damit das Popover relativ zur Tabs-Zeile positioniert werden kann */
.usp-pot-atyp-tabs { position: relative; }
