/* Liquidazioni agenzie: richieste di pagamento (elenco, modulo di emissione con anteprima A4, documento) e fotografia degli addebiti.
   Usa i token di app.css (temi chiaro e scuro) e riprende le classi di settlements*.css. Il foglio A4 resta bianco in ogni tema:
   è un documento, non una pagina dell'applicazione. */

.rq-root, .rq-tab { min-width: 0; }
.rq-root { max-width: 1480px; }
.rq-root [hidden], .rq-tab [hidden] { display: none !important; }
.rq-slot { min-width: 0; }
.rq-tab.is-loading .rq-slot { opacity: 0.55; transition: opacity 0.15s; }
.rq-warn { color: var(--warn); }
.rq-pre { white-space: pre-line; overflow-wrap: anywhere; }
.rq-from { overflow-wrap: anywhere; }
.rq-retry { margin-left: 10px; }
.rq-sub { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.rq-more { margin-top: 12px; }
.rq-more > summary { padding: 6px 0; font-weight: 550; cursor: pointer; }
.rq-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.rq-badges { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.rq-duedate { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rq-duedate.tone-danger { color: var(--danger); font-weight: 600; }
.rq-duedate.tone-warn { color: var(--warn); font-weight: 600; }
.rq-blocker { color: var(--warn); max-width: 28ch; }

/* ---- Elenco delle richieste ---- */
.rq-bar { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; margin: 0 0 14px; }
.rq-tab > .actions { margin-bottom: 14px; }
.rq-seg { flex-wrap: wrap; max-width: 100%; }
.rq-seg button { display: inline-flex; align-items: center; gap: 6px; }
.rq-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; min-width: 0; }
.rq-filters > .combobox { flex: 0 1 240px; min-width: 200px; }
.rq-filters .rep-field input, .rq-filters .rep-field select { min-width: 180px; }
.rq-search input { min-width: 220px; }
.rq-positions { display: flex; flex-wrap: wrap; gap: 4px 6px; }
.rq-pos { display: inline-flex; align-items: center; gap: 6px; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); font-size: 12px; white-space: nowrap; }
.rq-pos-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.rq-pos.side-A { background: var(--warn-soft); color: var(--warn); }

/* ---- Modulo di emissione ---- */
.rq-layout { display: grid; grid-template-columns: minmax(340px, 460px) minmax(0, 1fr); gap: 18px; align-items: start; transition: opacity 0.15s; }
.rq-layout.is-loading .rq-sheet-box { opacity: 0.55; }
@media (max-width: 1180px) { .rq-layout { grid-template-columns: minmax(0, 1fr); } }
.rq-side { min-width: 0; }
.rq-side .kpis { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.rq-side .kpi .value { font-size: 20px; }
.rq-preview { min-width: 0; }
.rq-preview-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 12px; margin-bottom: 10px; }
.rq-preview-head h2 { margin: 0; }
.rq-preview-head .hint { color: var(--muted); font-size: 13px; }
.rq-sheet-box { min-width: 0; padding: 4px 2px 12px; }
.rq-due { margin: 12px 0 0; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; }
.rq-due legend { padding: 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.rq-due .choice { margin-top: 6px; }
.rq-due-custom { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 16px; margin: 10px 0 0 26px; }
.rq-due-custom input[type="number"] { width: 8em; }
.rq-warnings .alert { margin-top: 8px; }
.rq-side .card textarea { width: 100%; }

/* ---- Foglio A4 ---- */
.rq-sheet {
  --paper: #ffffff;
  --ink: #111111;
  --ink-soft: #555555;
  --rule: #b8b8b8;
  --head: #ececec;
  position: relative;
  box-sizing: border-box;
  width: 794px;
  aspect-ratio: 210 / 297;
  margin: 0 auto;
  padding: 36px 34px 30px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--border);
  box-shadow: 0 2px 14px rgba(16, 24, 40, 0.16);
  font-size: 12px;
  line-height: 1.4;
}
/* Il foglio ha sempre la larghezza di un A4; nello spazio più stretto (telefono) si riduce in scala (request-sheet.js
   imposta --rq-scale sul contenitore): nessuno scorrimento laterale. Dove manca `zoom` il foglio resta intero e scorre. */
.rq-fit { min-width: 0; max-width: 100%; --rq-scale: 1; }
.rq-fit > .rq-sheet { zoom: var(--rq-scale); }
@supports not (zoom: 1) { .rq-fit { overflow-x: auto; } }
.rq-sheet * { color: inherit; }
.rq-sheet .rq-muted, .rq-sheet .rq-line.sub, .rq-sheet dt { color: var(--ink-soft); }
.rq-sheet.provisional::before { content: ""; position: absolute; inset: 0; border: 2px dashed rgba(59, 91, 219, 0.35); pointer-events: none; }
.rq-ribbon { position: absolute; top: 10px; right: 12px; padding: 1px 9px; border-radius: 4px; background: #3b5bdb; color: #fff; font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.rq-sheet .rq-ribbon { color: #fff; }
.rq-parties { display: grid; grid-template-columns: minmax(0, 250fr) minmax(0, 237fr); gap: 28px; margin-bottom: 16px; }
.rq-party { min-width: 0; overflow-wrap: anywhere; }
.rq-name { display: block; margin-bottom: 3px; font-size: 1.1em; }
.rq-party.recipient .rq-name { font-size: 1.05em; }
.rq-text { font-size: 0.9em; }
.rq-title { margin: 0 0 2px; font-size: 1.22em; font-weight: 700; letter-spacing: 0; }
.rq-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 28px; margin: 12px 0; }
.rq-details > * { min-width: 0; }
.rq-details dt { margin: 0; font-size: 0.78em; }
.rq-details dd { margin: 0 0 4px; font-weight: 700; font-size: 1em; }
.rq-subject { margin: 4px 0 14px; }
.rq-block { margin: 0 0 14px; }
.rq-h { margin: 0 0 5px; font-size: 1em; font-weight: 700; }
.rq-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.86em; }
.rq-table th, .rq-table td { padding: 3px 4px; border-bottom: 0.4px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; text-align: left; position: static; background: transparent; }
.rq-table th { background: var(--head); font-size: 0.88em; font-weight: 700; }
.rq-table td.num, .rq-table th.num { text-align: right; white-space: normal; font-variant-numeric: tabular-nums; }
.rq-table tfoot td { border-top: 0.8px solid var(--ink); border-bottom: none; font-weight: 700; }
.rq-table tr:last-child td { border-bottom: 0.4px solid var(--rule); }
.rq-table tfoot tr:last-child td { border-bottom: none; }
.rq-line { display: block; }
.rq-line.strong { font-weight: 700; }
.rq-line.sub { font-size: 0.93em; }
.rq-totals { width: 250px; max-width: 100%; margin: 4px 0 16px auto; padding-top: 5px; border-top: 0.5px solid var(--rule); }
.rq-total-line { display: flex; justify-content: space-between; gap: 12px; padding: 1px 0; }
.rq-total-line.strong { margin-top: 2px; font-size: 1.12em; font-weight: 700; }
.rq-total-line .num { text-align: right; font-variant-numeric: tabular-nums; }
.rq-pay { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 3px 8px; margin: 0; }
.rq-pay dt { font-size: 0.9em; }
.rq-pay dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }
.rq-note { margin: 0; white-space: pre-line; font-size: 0.92em; }
.rq-footer { margin-top: 18px; padding-top: 6px; border-top: 0.5px solid var(--rule); font-size: 0.78em; color: var(--ink-soft); }

/* ---- Documento e fotografia ---- */
.rq-root .card.collapsible { margin-bottom: 18px; }
.rq-root .card.collapsible .rq-sheet { margin-top: 4px; }
.rq-rows-bar { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 14px; margin-bottom: 12px; }
.rq-rows-bar .rep-field select { min-width: 260px; max-width: 100%; }
.rq-issues { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 8px; font-size: 13.5px; }
.rq-issues ul { margin: 4px 0 0; padding-left: 18px; }
.data-table tr.rq-chosen td { background: var(--accent-soft); }
.rq-root .wrap-code { font-size: 12px; }

@media (max-width: 760px) {
  .rq-filters > .combobox, .rq-filters .rep-field, .rq-search { flex: 1 1 100%; }
  .rq-filters .rep-field input, .rq-filters .rep-field select, .rq-search input { width: 100%; min-width: 0; }
  .rq-rows-bar .rep-field select { min-width: 0; width: 100%; }
  .rq-due-custom { margin-left: 0; }
  .rq-row-actions { justify-content: flex-start; }
}

@media print {
  .rq-side, .rq-preview-head, .sticky-actions { display: none !important; }
  .rq-layout { display: block; }
  /* In stampa il foglio prende la larghezza della pagina (fino a un A4), senza scala. */
  .rq-fit > .rq-sheet { zoom: 1; width: 100%; max-width: 794px; }
  .rq-sheet { box-shadow: none; border: none; }
}
