/* Liquidazioni: scadenzario, riconciliazione, stanziamento, estratto conto (anche in stampa). Usa i token di app.css. */

/* ---- Base comune delle viste di controllo ---------------------------------------------------------------- */

.rep { min-width: 0; }
.rep-body { min-width: 0; transition: opacity 0.15s; }
.rep.is-loading .rep-body, .account-host.is-loading > .statement { opacity: 0.55; }
.rep [hidden] { display: none !important; }

.rep-bar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; margin-bottom: 14px; }
.rep-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; max-width: 100%; font-size: 12px; font-weight: 550; color: var(--muted); }
.rep-field select, .rep-field input { max-width: 100%; }
.rep-host { display: inline-flex; min-width: 0; max-width: 100%; }
.rep-host select { max-width: 100%; }
.rep-quick { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 6px; }
.rep-estimate { align-items: center; }
.rep-note { margin: 10px 0 0; color: var(--muted); font-size: 12.5px; }
.rep-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.rep-retry { margin-left: 10px; }

/* Filtri segmentati con il conteggio: il numero e il punto esclamativo dicono ciò che il colore rinforza. */
.rep-seg { flex-wrap: wrap; max-width: 100%; }
.rep-seg button { display: inline-flex; align-items: center; gap: 6px; }
.rep-count {
  min-width: 1.7em;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 650;
  line-height: 1.6;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.rep-count.urgent { background: var(--danger-soft); color: var(--danger); }
.rep-count.warn { background: var(--warn-soft); color: var(--warn); }

/* Scadenze: il testo («scaduta da 3 giorni») è il segnale, il colore lo rinforza. */
.rep-due { font-variant-numeric: tabular-nums; }
.rep .rep-hide-narrow { display: block; }
.rep-due.tone-danger { color: var(--danger); }
.rep-due.tone-warn { color: var(--warn); }
.rep-schedule .data-table td { vertical-align: top; }
.rep .th-sub { display: block; color: var(--faint); font-size: 11px; font-weight: 450; white-space: normal; }
.rep .rep-actions { flex-wrap: nowrap; justify-content: flex-end; }

/* Colonne e righe di sintesi per gli schermi stretti: le colonne di dettaglio (.col-opt) le nasconde settlements.css. */
.rep .narrow-only { display: none; }
.rep-details { margin-top: 14px; }
.rep .alert, .rep .rep-notes li, .rep .rep-reasons li, .rep-sum-list li { overflow-wrap: anywhere; }
.rep-due { white-space: nowrap; }
.rep .rep-action { white-space: normal; text-align: center; line-height: 1.25; }
@media (min-width: 761px) { .rep-schedule .data-table td:first-child { min-width: 9.5rem; } }
.rep-details > summary { padding: 6px 0; font-weight: 550; cursor: pointer; }
.rep-notes { margin: 10px 0 0; padding-left: 18px; color: var(--muted); font-size: 12.5px; }
.rep-sheet .card-header { margin-bottom: 8px; }

/* ---- Riconciliazione ------------------------------------------------------------------------------------------- */

.rep-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 20px; margin-bottom: 14px; }
.rep-head h2 { margin: 0 0 4px; }
.rep-head-text { flex: 1 1 320px; min-width: 0; }
.rep-lead { margin: 0 0 4px; font-weight: 550; }
.rep-head p.small { margin: 0; }
.rep-job {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -6px 0 14px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 13px;
}
.rep-pills { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 14px; }
.rep-pill { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 10px; background: var(--surface); font-size: 13px; }
.rep-pill.active { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; font-weight: 600; }
.rep-listbar { margin-bottom: 10px; }

.rep-selbar {
  position: sticky;
  top: 8px;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 12px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--surface);
  box-shadow: 0 6px 20px rgba(16, 24, 40, 0.18);
}

/* Un periodo: il bordo a sinistra rinforza lo stato scritto nel badge. */
.rep-period { margin-bottom: 12px; padding: 14px 16px; border-left: 4px solid var(--border); }
.rep-period.status-to-adjust { border-left-color: var(--warn); }
.rep-period.status-stale { border-left-color: var(--info); }
.rep-period.status-not-comparable { border-left-style: dashed; border-left-color: var(--faint); }
.rep-period.status-aligned { border-left-color: var(--ok); }
.rep-period-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 10px 16px; }
.rep-check { flex: none; width: 18px; height: 18px; margin: 3px 0 0; cursor: pointer; }
.rep-period-title { flex: 1 1 220px; min-width: 0; }
.rep-period-title h3 { margin: 0 0 6px; font-size: 15px; }
.rep-period-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.rep-period-delta { display: flex; flex-direction: column; align-items: flex-end; margin-left: auto; text-align: right; font-variant-numeric: tabular-nums; }
.rep-label { color: var(--muted); font-size: 11.5px; }
.rep-delta { font-variant-numeric: tabular-nums; }
.rep-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 18px; margin: 12px 0 8px; }
.rep-facts > div { min-width: 0; }
.rep-facts dt { color: var(--faint); font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; }
.rep-facts dd { margin: 0; overflow-wrap: anywhere; }
.rep-reasons { margin: 8px 0; font-size: 13px; }
.rep-reasons ul { margin: 4px 0 0; padding-left: 18px; }
.rep-period .alert.compact { margin: 8px 0; }
.rep-period .data-table { margin: 0; }
.rep-criteria { margin-top: 3px; }
.rep-criteria summary { color: var(--muted); font-size: 12px; cursor: pointer; }
.rep-criteria ul { margin: 4px 0 0; padding-left: 16px; color: var(--muted); font-size: 12px; }

/* Riepilogo nel dialogo di rettifica */
.rep-sum { padding: 8px 0 10px; border-bottom: 1px solid var(--border); }
.rep-sum-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.rep-sum-list { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.rep-sum-list.warn { color: var(--warn); }
.rep-sum p { margin: 6px 0 0; }
.rep-acks:empty { display: none; }
.rep-acks { margin-top: 10px; }

/* ---- Estratto conto ---------------------------------------------------------------------------------------------- */

.rep-subject select { min-width: min(280px, 100%); }
.statement-toolbar .rep-host { align-self: flex-end; }
.account-host { min-width: 0; }
.account-host > .empty-state { max-width: 210mm; margin: 0 auto; }
.account-legend { margin: 0 0 8px; }
.account-balance {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 14px;
  margin: 8px 0 10px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.account-balance-label { color: var(--muted); font-size: 12px; font-weight: 550; }
.account-balance strong { font-size: 14px; font-variant-numeric: tabular-nums; }
.account-balance-text { color: var(--muted); font-size: 12.5px; }
.statement-total .account-balance-text { margin-top: 2px; }
.account-statement .statement-table td { vertical-align: top; }
.account-statement .narrow-only { display: none; }
.account-statement .statement-table .cell-sub { font-size: 0.88em; }
.account-statement .statement-table tr.rep-reversed td { color: var(--muted); }
.account-statement .statement-table tfoot td { border-top: 1.5px solid var(--text); }
.account-statement .statement-table tbody tr:last-child td { border-bottom: 1px solid var(--border); }
.statement-table caption.doc-caption {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- Telefono (375 px): una colonna, nessuno scorrimento orizzontale della pagina ----------------------------------- */

@media (max-width: 760px) {
  .rep .narrow-only, .account-statement .narrow-only { display: block; }
  .rep .rep-hide-narrow { display: none; }
  .rep-due { white-space: normal; }
  .rep .data-table th, .rep .data-table td { padding-left: 7px; padding-right: 7px; }
  .account-statement .statement-table th, .account-statement .statement-table td { padding-left: 5px; padding-right: 5px; }
  .rep a.button.narrow-only { display: inline-flex; margin-top: 6px; }
  .account-statement .col-opt { display: none; }
  .rep-bar > .rep-field, .rep-bar > .rep-host, .rep-bar .rep-host select { flex: 1 1 100%; width: 100%; }
  .rep-bar input[type="date"] { width: 100%; }
  .rep-bar > .spacer { display: none; }
  .rep .rep-action, .rep .rep-actions .button { white-space: normal; text-align: center; }
  .rep-period-delta { align-items: flex-start; margin-left: 0; text-align: left; }
  .rep-period { padding: 12px; }
  .rep-selbar { top: 4px; }
  .rep-subject, .statement-toolbar .rep-host { flex: 1 1 100%; }
  .rep-subject select { width: 100%; }
  .account-balance { flex-direction: column; align-items: flex-start; }
}

/* ---- Stampa ---------------------------------------------------------------------------------------------------------- */

@media print {
  .rep-noprint { display: none !important; }
  .rep .rep-body { opacity: 1 !important; }
  .rep .narrow-only, .account-statement .narrow-only { display: none !important; }
  .rep .col-opt, .account-statement .col-opt { display: table-cell !important; }
  .account-statement .statement-table th, .account-statement .statement-table td { padding: 4px 5px; }
  .account-statement .statement-section { break-inside: auto; }
  .account-balance, .rep-count, .rep-period { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rep-period { break-inside: avoid; }
}
