/* Rosy & Vale - Consolidamento grafico finale V8.3.5
   Completa uniformazione PC/mobile mantenendo invariata la logica applicativa. */
:root{
  --rvf-primary:#1769d2;--rvf-primary-soft:#eaf3ff;--rvf-success:#54b900;
  --rvf-warning:#ffb300;--rvf-danger:#dc3545;--rvf-info:#0f8f83;
  --rvf-ink:#16324f;--rvf-muted:#6b7d90;--rvf-line:#dce5ed;--rvf-bg:#f5f8fb;
  --rvf-card:#fff;--rvf-radius:15px;--rvf-shadow:0 4px 14px rgba(27,58,87,.07);
}

/* Layout generale */
body.rv-unified{background:var(--rvf-bg);color:var(--rvf-ink)}
body.rv-unified main.container,body.rv-unified main.container-fluid{width:100%;max-width:1540px}
body.rv-unified .container,body.rv-unified .container-fluid{min-width:0}
body.rv-unified img{max-width:100%;height:auto}
body.rv-unified .row>*{min-width:0}

/* Titoli e intestazioni comuni */
body.rv-unified .rv-page-head,body.rv-unified .dept-head,body.rv-unified .rv-price-head,
body.rv-unified .rv-system-hero,body.rv-unified .external-head,body.rv-unified .page-header{
  border:1px solid var(--rvf-line)!important;border-radius:var(--rvf-radius)!important;
  background:#fff!important;box-shadow:var(--rvf-shadow)!important;padding:16px!important;margin-bottom:14px!important;
}
body.rv-unified h1,body.rv-unified h2,body.rv-unified h3{color:#132b45}

/* Card e pannelli */
body.rv-unified .card,body.rv-unified .card-main,body.rv-unified .table-card,
body.rv-unified .rv-system-panel,body.rv-unified .rv-system-card,body.rv-unified .cm-card,
body.rv-unified .external-main-card,body.rv-unified .lista-card{
  border:1px solid var(--rvf-line)!important;border-radius:var(--rvf-radius)!important;background:#fff;
  box-shadow:var(--rvf-shadow)!important;
}

/* Comandi */
body.rv-unified .btn{min-height:42px;border-radius:9px;font-weight:700;white-space:normal}
body.rv-unified .btn-sm{min-height:36px}
body.rv-unified .btn-lg{min-height:48px}
body.rv-unified .form-control,body.rv-unified .form-select,body.rv-unified .input-group-text{
  min-height:44px;border-radius:10px;border-color:#cfdbe5;
}
body.rv-unified .input-group>.form-control,body.rv-unified .input-group>.form-select{border-radius:0}
body.rv-unified .input-group>:first-child{border-top-left-radius:10px!important;border-bottom-left-radius:10px!important}
body.rv-unified .input-group>:last-child{border-top-right-radius:10px!important;border-bottom-right-radius:10px!important}
body.rv-unified .form-label,body.rv-unified label.small.fw-bold{color:#35516d;font-weight:700}
body.rv-unified textarea.form-control{min-height:90px}

/* Filtri e barre operative */
body.rv-unified .rv-operativa-main,body.rv-unified .rv-operativa-sub,
body.rv-unified .filter-row,body.rv-unified .filters-row,body.rv-unified .external-nav,
body.rv-unified .toolbar,body.rv-unified .actions-bar{flex-wrap:wrap!important;overflow:visible!important}
body.rv-unified .rv-operativa-main>*,body.rv-unified .rv-operativa-sub>*{min-width:135px}
body.rv-unified .external-page .external-nav{display:grid!important;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:8px!important}
body.rv-unified .external-page .btn-round{width:100%!important;height:auto!important;min-width:0!important;min-height:48px!important;border-radius:11px!important;padding:10px!important;box-shadow:none!important}
body.rv-unified .external-page .btn-round img{width:34px!important;margin:0 0 4px!important}

/* Tabelle desktop */
body.rv-unified table.table{width:100%;margin-bottom:0}
body.rv-unified table.table thead th{background:#f1f5f8!important;color:#334e68!important;border-bottom:1px solid #d6e0e8!important;font-size:.78rem;text-transform:uppercase;letter-spacing:.025em;padding:11px 10px;vertical-align:middle}
body.rv-unified table.table td{padding:11px 10px;vertical-align:middle;border-color:#e8eef3}
body.rv-unified table.table tbody tr:hover{background:#f8fbff}
body.rv-unified .table-responsive{border-radius:12px}

/* Stato e KPI */
body.rv-unified .badge,body.rv-unified [class*="badge"]{font-weight:700}
body.rv-unified .rv-system-badge{border-radius:999px}
body.rv-unified .rv-backup-kpi,body.rv-unified .rv-system-grid{gap:12px}

/* Consegne */
body.rv-unified .cm-wrap{max-width:1280px}
body.rv-unified .cm-actions{border:1px solid var(--rvf-line);border-radius:14px;box-shadow:0 4px 16px rgba(27,58,87,.12)}
body.rv-unified .cm-order{border-left:5px solid var(--rvf-success)!important}
body.rv-unified .cm-row{border-color:#edf1f4}

/* Reparti */
body.rv-unified .dept-page .filter-row{display:flex!important;gap:7px!important}
body.rv-unified .dept-page .filter-chip{min-height:40px;white-space:normal;display:inline-flex;align-items:center}
body.rv-unified .work-list{gap:10px}
body.rv-unified .work-card{border:1px solid var(--rvf-line)!important;border-radius:13px!important;box-shadow:0 2px 8px rgba(27,58,87,.05)!important}

/* Quality Service */
body.rv-unified .quality-page .card,body.rv-unified [class*="quality"] .card{border-color:#cfe0ef!important}
body.rv-unified input[name*="quality"],body.rv-unified input[name*="numero_quality"],body.rv-unified input[name*="numero_qs"]{
  font-size:1.15rem;font-weight:800;letter-spacing:.06em;text-align:center;
}

/* Servizi e listini */
body.rv-unified .rv-price-head,body.rv-unified .catalog-page .card,body.rv-unified .services-page .card{background:#fff!important}
body.rv-unified .price-missing,body.rv-unified .prezzo-mancante{border-left:4px solid var(--rvf-danger)!important}
body.rv-unified .price-ok,body.rv-unified .prezzo-presente{border-left:4px solid var(--rvf-success)!important}

/* Accessi e backup */
body.rv-unified .rv-device-row{border:1px solid var(--rvf-line)!important;border-radius:12px!important;background:#fff!important;padding:12px!important}
body.rv-unified .rv-device-actions{display:flex;flex-wrap:wrap;gap:6px}
body.rv-unified .rv-device-actions form{flex:1 1 110px}
body.rv-unified .rv-device-actions .btn{width:100%}
body.rv-unified .rv-codebox{overflow-wrap:anywhere;word-break:break-word}

/* Elementi secondari richiudibili */
body.rv-unified details.rv-secondary{border:1px solid var(--rvf-line);border-radius:12px;background:#fff;overflow:hidden}
body.rv-unified details.rv-secondary>summary{padding:11px 13px;background:#f7fafc;font-weight:800;color:#35516d;cursor:pointer}

/* Tablet */
@media(max-width:991.98px){
  body.rv-unified .rv-operativa-wrap{top:64px}
  body.rv-unified .rv-operativa-main,body.rv-unified .rv-operativa-sub{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));gap:7px!important;padding-bottom:0!important}
  body.rv-unified .rv-operativa-main>*,body.rv-unified .rv-operativa-sub>*{min-width:0!important;width:100%!important}
  body.rv-unified .rv-op-btn{width:100%;min-width:0!important}
}

/* Smartphone: card al posto delle tabelle, nessuno scroll orizzontale */
@media(max-width:767.98px){
  html,body{max-width:100%;overflow-x:hidden!important}
  body.rv-unified main.container,body.rv-unified main.container-fluid{padding-left:8px!important;padding-right:8px!important}
  body.rv-unified .row{margin-left:-4px;margin-right:-4px}
  body.rv-unified .row>*{padding-left:4px;padding-right:4px}
  body.rv-unified .btn:not(.btn-close){min-height:44px}
  body.rv-unified .d-flex.gap-2,body.rv-unified .d-flex.gap-3{flex-wrap:wrap}
  body.rv-unified .btn-group{display:flex;flex-wrap:wrap;gap:6px;width:100%}
  body.rv-unified .btn-group>.btn{flex:1 1 130px;border-radius:9px!important}
  body.rv-unified .table-responsive{overflow:visible!important;width:100%!important;max-width:100%!important}

  body.rv-unified table.rv-mobile-cards{display:block!important;width:100%!important;min-width:0!important;border:0!important;background:transparent!important}
  body.rv-unified table.rv-mobile-cards thead{display:none!important}
  body.rv-unified table.rv-mobile-cards tbody{display:grid!important;width:100%!important;gap:10px}
  body.rv-unified table.rv-mobile-cards tr{display:block!important;width:100%!important;margin:0!important;padding:10px 12px!important;border:1px solid var(--rvf-line)!important;border-radius:13px!important;background:#fff!important;box-shadow:0 2px 8px rgba(27,58,87,.05)!important}
  body.rv-unified table.rv-mobile-cards td{display:grid!important;grid-template-columns:minmax(100px,34%) minmax(0,1fr);gap:8px;width:100%!important;max-width:100%!important;border:0!important;border-bottom:1px solid #edf1f4!important;padding:7px 0!important;text-align:left!important;white-space:normal!important;overflow-wrap:anywhere;align-items:start}
  body.rv-unified table.rv-mobile-cards td:last-child{border-bottom:0!important}
  body.rv-unified table.rv-mobile-cards td::before{content:attr(data-label);font-size:.72rem;text-transform:uppercase;letter-spacing:.02em;color:var(--rvf-muted);font-weight:800;line-height:1.35}
  body.rv-unified table.rv-mobile-cards td[data-label=""]::before,body.rv-unified table.rv-mobile-cards td[colspan]::before{content:none}
  body.rv-unified table.rv-mobile-cards td[colspan]{display:block!important}
  body.rv-unified table.rv-mobile-cards td .d-flex,body.rv-unified table.rv-mobile-cards td form{flex-wrap:wrap!important;gap:6px}
  body.rv-unified table.rv-mobile-cards td .btn{min-width:44px}
  body.rv-unified table.rv-mobile-cards td input,body.rv-unified table.rv-mobile-cards td select{max-width:100%}

  body.rv-unified .external-page .external-nav{grid-template-columns:repeat(2,minmax(0,1fr))!important}
  body.rv-unified .dept-page .filter-row{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr));width:100%}
  body.rv-unified .dept-page .filter-chip{width:100%;justify-content:center}
  body.rv-unified .work-list,body.rv-unified .work-meta{grid-template-columns:1fr!important}

  body.rv-unified .rv-system-grid,body.rv-unified .rv-backup-kpi{grid-template-columns:1fr!important}
  body.rv-unified .rv-device-row{display:grid!important;grid-template-columns:1fr!important;gap:10px!important}
  body.rv-unified .rv-system-hero{display:flex!important;flex-direction:column!important;align-items:stretch!important;gap:10px!important}
  body.rv-unified .rv-system-hero>.btn,body.rv-unified .rv-system-hero>form,body.rv-unified .rv-system-hero>form>.btn{width:100%}

  body.rv-unified .cm-actions{position:sticky;bottom:74px;padding:9px}
  body.rv-unified .cm-actions .btn{width:100%}
  body.rv-unified .cm-row .row>div{width:100%;flex:0 0 100%;max-width:100%}
  body.rv-unified .cm-price{max-width:none!important;width:100%}

  body.rv-unified .card-main{padding:14px!important}
  body.rv-unified .card-main>.d-flex{flex-wrap:wrap;gap:10px}
  body.rv-unified .text-end{overflow-wrap:anywhere}
}

@media(max-width:430px){
  body.rv-unified .rv-operativa-main,body.rv-unified .rv-operativa-sub,
  body.rv-unified .external-page .external-nav,body.rv-unified .dept-page .filter-row{grid-template-columns:1fr!important}
  body.rv-unified table.rv-mobile-cards td{grid-template-columns:1fr;gap:3px}
  body.rv-unified .rv-page-head,body.rv-unified .dept-head,body.rv-unified .rv-price-head,body.rv-unified .rv-system-hero{padding:12px!important}
}

/* Stampa: nessuna trasformazione card */
@media print{
  body.rv-unified table.rv-mobile-cards{display:table!important}
  body.rv-unified table.rv-mobile-cards thead{display:table-header-group!important}
  body.rv-unified table.rv-mobile-cards tbody{display:table-row-group!important}
  body.rv-unified table.rv-mobile-cards tr{display:table-row!important;box-shadow:none!important}
  body.rv-unified table.rv-mobile-cards td{display:table-cell!important}
  body.rv-unified table.rv-mobile-cards td::before{display:none!important}
}
