/* Modul B – Berichte & Abrechnung. Präfix rp-. Nur Tokens aus theme.css. Mobile first. */

.rp-page { gap: 14px; }
.rp-nowrap { white-space: nowrap; }
.rp-lead { margin: 0 0 12px; font-size: var(--fs-sm); }
.rp-note { display: flex; align-items: center; gap: 6px; margin: 0; }
.rp-link {
  border: 0; background: none; padding: 0; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--brand); cursor: pointer;
}
.rp-link:hover { text-decoration: underline; }
.is-loading { opacity: .6; transition: opacity .15s; }

/* ------------------------------------------------------------------ Filter */
.rp-filters { padding: 10px 12px; display: flex; flex-direction: column; gap: 10px; }
.rp-filter-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rp-filter-top .daterange { flex: 0 1 auto; min-width: 0; }
@media (max-width: 599px) {
  .rp-filter-top { flex-wrap: nowrap; }
  .rp-filter-top .daterange { flex: 1 1 0; }
  .rp-filter-top .daterange-label { flex: 1; min-width: 0; padding-left: 4px; padding-right: 4px; }
  /* Am Handy reicht der Name des Zeitraums – die Daten stehen im Seitenkopf */
  .rp-filters .daterange-label strong ~ .muted { display: none; }
}
.rp-filter-actions { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.rp-reset {
  border: 0; background: none; font: inherit; font-size: var(--fs-sm); font-weight: 600; color: var(--brand);
  min-height: 36px; padding: 4px 8px; cursor: pointer; border-radius: var(--radius-sm);
}
.rp-reset:hover { background: var(--surface-2); }
.rp-count {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-left: 2px;
  border-radius: 999px; background: var(--brand); color: var(--brand-contrast); font-size: var(--fs-xs); font-weight: 700;
}
.rp-filter-summary { display: flex; align-items: center; gap: 6px; margin: 0; }
.rp-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 599px) {
  /* Handy: Kunde und Projekt über die ganze Breite, eine allein stehende letzte Auswahl ebenso */
  .rp-filter-grid > :first-child, .rp-filter-grid .rp-project-field, .rp-filter-grid > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}
.rp-filter-grid .field-label { font-size: var(--fs-xs); }
.rp-project-pick { display: flex; align-items: center; gap: 4px; min-width: 0; }
.rp-project-pick .picker { flex: 1; min-width: 0; }
@media (min-width: 600px) { .rp-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 900px) {
  .rp-filters { padding: 12px 16px 14px; }
  /* 4 Spalten bleiben auch bei 1920 px: der Inhalt ist auf --content-max begrenzt (7 Spalten wären zu schmal) */
  .rp-filter-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 12px; }
}

/* ------------------------------------------------------------------ Tabs */
.rp-tabs { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.rp-tabs .segmented-item { min-height: 34px; padding: 6px 16px; }

/* ------------------------------------------------------------------ Übersicht */
.rp-overview { display: flex; flex-direction: column; gap: 14px; }
.rp-stats .stat-value { font-size: var(--fs-lg); }
@media (min-width: 380px) { .rp-stats .stat-value { font-size: var(--fs-xl); } }
.rp-chart-card .card-head { flex-wrap: wrap; }
/* Gruppierung am Handy: 16 px Schrift, sonst zoomt iOS Safari beim Antippen */
.rp-group-select .input { min-height: var(--tap); padding-top: 5px; padding-bottom: 5px; font-size: 16px; }

/* Balkendiagramm: Beschriftung | Balken | Wert (Handy: Beschriftung + Wert oben, Balken darunter) */
.rp-chart { display: flex; flex-direction: column; gap: 10px; }
.rp-bar-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "bar bar";
  align-items: center; column-gap: 12px; row-gap: 4px; padding: 2px 0; cursor: default;
}
.rp-bar-label { grid-area: label; display: flex; align-items: center; gap: 8px; min-width: 0; font-size: var(--fs-sm); }
.rp-bar-track { grid-area: bar; height: 14px; background: var(--surface-2); border-radius: 0 4px 4px 0; overflow: hidden; }
.rp-bar { height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .3s ease-out; }
.rp-bar-value { grid-area: value; display: flex; align-items: baseline; gap: 4px; font-variant-numeric: tabular-nums; font-size: var(--fs-sm); white-space: nowrap; }
.rp-unit { color: var(--text-muted); font-size: var(--fs-xs); }
.rp-bar-amount { color: var(--text-muted); margin-left: 8px; min-width: 72px; text-align: right; }
.rp-bar-row:hover .rp-bar-label { color: var(--brand-strong); }
@media (min-width: 720px) {
  .rp-bar-row { grid-template-columns: minmax(140px, 240px) minmax(0, 1fr) auto; grid-template-areas: "label bar value"; row-gap: 0; }
  .rp-bar-track { height: 18px; }
  .rp-bar-value { min-width: 150px; justify-content: flex-end; }
  .rp-chart.no-amounts .rp-bar-value { min-width: 70px; }
}

/* Tabellen */
.rp-table-card { overflow: hidden; }
.rp-table td small, .rp-table th small { display: block; font-size: var(--fs-xs); font-weight: 400; }
.rp-table tbody tr:last-child td { border-bottom: 0; }
.rp-table tfoot td { background: var(--surface); }
.rp-proj { display: inline-flex; align-items: baseline; gap: 8px; min-width: 0; }
.rp-proj .dot { transform: translateY(-1px); }
.rp-proj > span { display: flex; flex-direction: column; min-width: 0; }
.rp-col-opt { display: none; }
@media (min-width: 720px) { .rp-col-opt { display: table-cell; } }
.rp-count-sub { color: var(--text-faint); }
.rp-group-table td:first-child { min-width: 140px; }

/* ------------------------------------------------------------------ Detail */
.rp-detail { display: flex; flex-direction: column; gap: 14px; }
.rp-table.rp-detail-table { font-size: var(--fs-sm); }
.rp-detail-table th, .rp-detail-table td { padding: 7px 9px; }
.rp-detail-table td.rp-desc { min-width: 240px; }
.rp-detail-table td.rp-proj-cell { min-width: 170px; }
/* Lange Wörter (URLs, Pfade) umbrechen, statt die Spalten Std./CHF/Status aus dem Bild zu schieben */
.rp-detail-table td.rp-desc, .rp-detail-table td.rp-proj-cell, .rp-import-table td.rp-desc, .rp-import-table td.rp-proj-cell { overflow-wrap: anywhere; }
.rp-detail-table tbody tr.is-click { cursor: pointer; }
.rp-detail-table tbody tr.is-click:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
.rp-item.is-click { cursor: pointer; }
.rp-item.is-click:hover { background: var(--surface-2); }
.rp-item.is-click:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--brand); }
.rp-detail-table td.rp-svc-cell { min-width: 130px; }
.rp-detail-table .rp-month-row td {
  background: var(--surface-2); font-weight: 650; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); padding-top: 7px; padding-bottom: 7px;
}
.rp-detail-table .rp-month-row td.num { text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); color: var(--text); }
.rp-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.rp-badges:empty { display: none; }
.rp-more { display: flex; justify-content: center; padding: 12px; }

.rp-cards { display: flex; flex-direction: column; gap: 14px; }
.rp-month-head {
  display: flex; justify-content: space-between; gap: 8px; margin: 0 4px 6px;
  font-size: var(--fs-xs); font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted);
}
.rp-month-head .num { text-transform: none; letter-spacing: 0; color: var(--text); }
.rp-card-list { overflow: hidden; }
.rp-item { padding: 11px 14px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.rp-item:last-child { border-bottom: 0; }
.rp-item-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.rp-item-date { font-size: var(--fs-sm); color: var(--text-muted); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-item-hours { font-weight: 700; }
.rp-item-desc { margin: 0; overflow-wrap: anywhere; }
.rp-item-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: var(--fs-sm); color: var(--text-muted); }
.rp-item-proj { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }

.rp-expenses .card-head { margin-bottom: 4px; }
.rp-exp-list { list-style: none; margin: 0; padding: 0; }
.rp-exp-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.rp-exp-list li:first-child { border-top: 0; }
.rp-exp-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rp-exp-desc { overflow-wrap: anywhere; }

/* ------------------------------------------------------------------ Export-Dialog */
.rp-toggles { display: flex; flex-direction: column; gap: 12px; padding: 4px 0; }
.rp-toggles .toggle { min-height: 36px; }
.rp-export-check { margin: 0; }
.rp-export-count { display: flex; align-items: center; gap: 6px; margin: 0; min-height: 20px; }
@media (min-width: 600px) { .rp-toggles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; } }
.rp-export .segmented { align-self: flex-start; }
.rp-export .segmented-item { min-width: 72px; min-height: 34px; }

/* ------------------------------------------------------------------ Abrechnung */
.rp-inv-table td small { color: var(--text-muted); }
.rp-inv-table td .badge { margin-top: 4px; }
.rp-actions-col { width: 1%; white-space: nowrap; text-align: right; }
/* iPad quer / kleine Laptops: Tabelle breiter als die Karte → Aktionen rechts fixiert, immer erreichbar */
@media (max-width: 1299px) {
  .rp-inv-table .rp-actions-col {
    position: sticky; right: 0; z-index: 1; background: var(--surface);
    box-shadow: inset 1px 0 0 var(--border), -8px 0 10px -8px var(--border-strong);
  }
  .rp-inv-table thead .rp-actions-col { background: var(--surface-2); z-index: 2; }
  .rp-inv-table tbody tr:hover .rp-actions-col { background: var(--surface-2); }
}
.rp-row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 2px; }
.rp-inv-cards { display: flex; flex-direction: column; gap: 10px; }
.rp-inv-card { padding: 12px 12px 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.rp-inv-card > .badge { align-self: flex-start; }
.rp-inv-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.rp-inv-title { display: flex; flex-direction: column; min-width: 0; padding-top: 2px; }
.rp-inv-title strong { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.rp-inv-no { font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.rp-inv-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin: 4px 0 2px; }
.rp-inv-nums dt { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rp-inv-nums dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.rp-inv-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.rp-inv-actions .btn { flex: 1; }

.rp-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rp-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.rp-preview {
  border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 12px 14px;
}
.rp-preview p { margin: 0; display: flex; align-items: flex-start; gap: 8px; }
.rp-preview p > .icon, .rp-preview p > .spinner { flex: none; margin-top: 2px; }
.rp-preview p > span { min-width: 0; }
.rp-preview-warn { margin: 12px 0 0; }
.rp-preview.is-empty { background: var(--warning-soft); border-color: transparent; }
.rp-preview-error { color: var(--danger); }
.rp-preview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rp-preview-grid > div { display: flex; flex-direction: column; min-width: 0; }
.rp-preview-grid strong { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; }
.rp-preview-grid .muted { font-size: var(--fs-xs); }
.rp-pv-label { font-size: var(--fs-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.rp-pv-total strong { color: var(--brand-strong); }
@media (min-width: 720px) { .rp-preview-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.rp-success { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 8px 0 4px; }
.rp-success h3 { font-size: var(--fs-xl); }
.rp-success p { margin: 0; max-width: 420px; }
.rp-success-icon { width: 60px; height: 60px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }
.rp-success-sum { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; width: 100%; margin: 10px 0; padding: 12px; background: var(--surface-2); border-radius: var(--radius); }
.rp-success-sum dt { font-size: var(--fs-xs); color: var(--text-muted); }
.rp-success-sum dd { margin: 0; font-weight: 650; font-variant-numeric: tabular-nums; }
.rp-success-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
@media (max-width: 480px) {
  .rp-success-sum { grid-template-columns: minmax(0, 1fr); text-align: left; }
  .rp-success-sum > div { display: flex; justify-content: space-between; gap: 8px; }
  .rp-success-actions .btn { flex: 1 1 100%; }
}

/* ------------------------------------------------------------------ Import */
.rp-import { display: flex; flex-direction: column; gap: 14px; }
.rp-import .card-head { flex-wrap: wrap; }
.rp-drop {
  display: flex; align-items: center; gap: 12px; padding: 16px; min-height: 72px; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); color: var(--text-muted);
  transition: border-color .12s, background .12s;
}
.rp-drop:hover, .rp-drop.is-drag { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-strong); }
.rp-drop:focus-within { box-shadow: var(--focus); }
.rp-drop.has-file { border-style: solid; }
.rp-drop-text { display: flex; flex-direction: column; min-width: 0; flex: 1; color: var(--text); }
.rp-drop-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-import-summary { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.rp-import-summary .alert > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.rp-import-errors ul { margin: 6px 0 0; padding-left: 18px; max-height: 240px; overflow-y: auto; }
.rp-import-table { margin-top: 12px; border: 1px solid var(--border); border-radius: var(--radius); max-height: 460px; overflow: auto; }
.rp-import-table .table { font-size: var(--fs-sm); }
.rp-import-table td.rp-desc { min-width: 220px; }
.rp-import-table td.rp-proj-cell { min-width: 170px; }
.rp-import-table td.rp-svc-cell { min-width: 140px; }
.rp-import-table th, .rp-import-table td { padding: 7px 9px; }
.rp-import-table tr.is-dup td { color: var(--text-faint); }
.rp-import-table tr.is-err td { background: var(--danger-soft); }
.rp-import-cards { list-style: none; margin: 12px 0 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.rp-import-cards li { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 3px; }
.rp-import-cards li:last-child { border-bottom: 0; }
.rp-import-cards li.is-dup { opacity: .6; }
.rp-import-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.rp-import-confirm ul { margin: 6px 0; padding-left: 18px; }
.rp-confirm-check { align-items: flex-start; font-size: var(--fs-sm); font-weight: 600; }
.rp-confirm-check input { margin-top: 1px; flex: none; }
.rp-unrated { margin: 0; }
@media (max-width: 480px) { .rp-import-actions .btn { flex: 1; } }

.rp-help { padding: 0; }
.rp-help summary {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 10px 16px; cursor: pointer; list-style: none; font-weight: 600;
}
.rp-help summary::-webkit-details-marker { display: none; }
.rp-help summary > span { flex: 1; }
.rp-help summary .icon { color: var(--text-muted); }
.rp-help[open] .rp-help-caret { transform: rotate(180deg); }
.rp-help-body { padding: 0 16px 16px; }
.rp-help-cols { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; margin: 12px 0; }
.rp-help-cols > div { display: grid; gap: 2px; }
.rp-help-cols dt { font-weight: 650; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rp-help-cols dd { margin: 0; color: var(--text-muted); font-size: var(--fs-sm); }
@media (min-width: 720px) { .rp-help-cols > div { grid-template-columns: 220px minmax(0, 1fr); gap: 12px; } }

/* ------------------------------------------------------------------ Touch-Ziele ≥ 44 px (SPEC §11 Kern) */
@media (pointer: coarse), (max-width: 899px) {
  .rp-page .btn, .rp-page .btn-sm, .rp-export .btn, .rp-new-invoice .btn { min-height: var(--tap); }
  .rp-page .btn-icon, .rp-page .btn-icon.btn-sm { width: var(--tap); min-width: var(--tap); }
  .rp-page .segmented-item, .rp-tabs .segmented-item, .rp-export .segmented-item { min-height: var(--tap); }
  .rp-page .daterange-label, .rp-chips .chip { min-height: var(--tap); }
  .rp-reset, .rp-toggles .toggle, .rp-confirm-check { min-height: var(--tap); }
  .rp-filter-grid .input, .rp-filter-grid .picker { min-height: var(--tap); }
  .rp-link { display: inline-flex; align-items: center; min-height: var(--tap); }
}

@media print {
  .rp-filters, .rp-tabs, .rp-row-actions, .rp-more { display: none !important; }
}
/* Kompakte Detailtabelle (900–1249 px): Leistungsbereich unter der Tätigkeit */
.rp-svc-inline { display: block; margin-top: 2px; font-size: var(--fs-xs); color: var(--text-muted); }
