/* Report programmati: elenco (scheda «Programmati»), modulo, dettaglio con storico.
   Usa i token di app.css (temi chiaro e scuro). Prefisso .rps-*; la ricerca a chip dell'ambito è quella di report.css (.rep-chip*). */

.rps, .rps-root { min-width: 0; }
.rps [hidden], .rps-root [hidden] { display: none !important; }
.rps .tone-warn, .rps-root .tone-warn { color: var(--warn); font-weight: 550; }

/* ---- Elenco ---- */
.rps-toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 16px; margin-bottom: 12px; }
.rps-intro { margin: 0; max-width: 72ch; flex: 1 1 320px; }
.rps-summary { margin: 0 0 8px; }
.rps-row-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.rps-dests { display: flex; flex-wrap: wrap; gap: 4px; }
.rps-retry { margin-left: 10px; }

/* ---- Modulo ---- */
.rps-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(260px, 340px); gap: 18px; align-items: start; }
.rps-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.rps-side { position: sticky; top: 56px; min-width: 0; }
.rps-actions { grid-column: 1 / -1; }
@media (max-width: 960px) {
  .rps-layout { grid-template-columns: minmax(0, 1fr); }
  .rps-side { position: static; }
}

.rps-main .card { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rps-main .card .card-header { margin-bottom: 0; }
.rps-root .field { display: flex; flex-direction: column; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.rps-root .field > span:first-child { font-weight: 600; font-size: 12.5px; color: var(--muted); }
.rps-root .field.error > span:first-child { color: var(--danger); }
.rps-root .field > small { line-height: 1.35; }
.rps-type .segmented, .rps-scope .segmented { align-self: flex-start; max-width: 100%; flex-wrap: wrap; }
.rps-root input[type="date"], .rps-root input[type="time"], .rps-root input[type="number"] { max-width: 220px; }
.rps-root select { max-width: 100%; }

.rps-fieldset { margin: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 8px; min-width: 0; }
.rps-fieldset legend { padding: 0 6px; color: var(--muted); font-size: 12.5px; font-weight: 550; }
.rps-options { display: flex; flex-direction: column; gap: 10px; }

.rps-recurrence { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rps-when-row { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 16px; }
.rps-when-row > .field { margin: 0; flex: 0 1 auto; min-width: 0; }
.rps-when-row > .field[hidden] { display: none; }
.rps-f-frequency select { width: 190px; max-width: 100%; }
.rps-f-anchor select { width: 180px; max-width: 100%; }
.rps-f-day input { width: 96px; }
.rps-f-day small { display: block; max-width: 200px; }
.rps-f-time input { width: 120px; }
.rps-when-row input[type="date"] { width: 170px; max-width: 100%; }
.rps-period { display: flex; flex-direction: column; gap: 6px; padding-top: 14px; border-top: 1px solid var(--border); }
.rps-days { display: flex; flex-wrap: wrap; gap: 6px; }
.rps-day { position: relative; justify-content: center; min-width: 3.2em; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 13px; user-select: none; }
.rps-day input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.rps-day:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.rps-day:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.rps-quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }

.rps-dest-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; margin-top: 4px; }
.rps-dest-list > p { grid-column: 1 / -1; }
.rps-dest-card { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; transition: border-color 0.15s, background 0.15s, box-shadow 0.15s; }
.rps-dest-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.rps-dest-card:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 1px var(--accent) inset; }
.rps-dest-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.rps-dest-card.off { opacity: 0.65; cursor: not-allowed; }
.rps-dest-top { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rps-dest-top input { margin: 0 0 0 auto; width: 18px; height: 18px; flex: none; cursor: inherit; }
.rps-dest-name { font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.rps-dest-detail { color: var(--muted); font-size: 12.5px; line-height: 1.4; min-width: 0; overflow-wrap: anywhere; }
.rps-notify-card { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px 14px; border: 1px dashed var(--border); border-radius: 10px; cursor: pointer; }
.rps-notify-card:has(input:checked) { border-style: solid; background: var(--surface-2); }
.rps-notify-card input { margin: 2px 0 0; width: 18px; height: 18px; flex: none; }
.rps-notify-card > span { display: flex; flex-direction: column; gap: 2px; }
.rps-notify { align-self: flex-start; }

.rps-preview .card-header { margin-bottom: 8px; }
.rps-preview-label { font-weight: 600; margin: 0 0 8px; }
.rps-next { margin: 0 0 8px; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-variant-numeric: tabular-nums; }
.rps-preview-body p { margin: 8px 0 0; }
.rps-preview-body .alert { margin: 8px 0 0; }

/* ---- Dettaglio ---- */
.rps-detail { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 18px; align-items: start; margin-bottom: 18px; }
@media (max-width: 960px) { .rps-detail { grid-template-columns: minmax(0, 1fr); } }
.rps-deliveries { display: flex; flex-direction: column; gap: 6px; }
.rps-delivery { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.rps-delivery-name { overflow-wrap: anywhere; }
.rps-root .page-header h1 .badge { vertical-align: middle; font-size: 12px; }
