:root{
  --p:#0b82e8;--pd:#155f9e;--ps:#eaf5ff;--bg:#f4f7fb;--card:#fff;
  --line:#dfe7f1;--text:#1f2937;--muted:#6b7280;--ok:#16a34a;
  --warn:#f59e0b;--bad:#dc2626;--dark:#334155;--shadow:0 12px 30px rgba(32,75,120,.09)
}
*{box-sizing:border-box}
body{margin:0;background:var(--bg);font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;color:var(--text)}
.demo-shell{max-width:1580px;margin:0 auto;padding:26px}
.demo-note{display:flex;justify-content:space-between;gap:18px;align-items:center;background:#fff7e6;border:1px solid #f1d498;border-radius:14px;padding:13px 15px;margin-bottom:20px}
.demo-note strong{color:#805000}
.role-switch,.actions{display:flex;gap:9px;flex-wrap:wrap}
.btn{border:0;border-radius:11px;padding:10px 14px;font:inherit;font-weight:800;cursor:pointer}
.btn.primary{color:#fff;background:linear-gradient(#168de9,#0a78d3);box-shadow:0 7px 18px rgba(11,130,232,.2)}
.btn.secondary{background:#fff;border:1px solid #d7e1ec;color:#31546f}
.btn.success{background:#eaf8ef;border:1px solid #bfe5cb;color:#147a35}
.btn.danger{background:#fff0f0;border:1px solid #f0c7c7;color:#b42318}
.page-head{display:flex;justify-content:space-between;align-items:flex-end;gap:18px;margin-bottom:20px}
.page-head h1{margin:0 0 5px;font-size:30px}.page-head p{margin:0;color:var(--muted)}
.tabs{display:flex;gap:7px;flex-wrap:wrap;background:#eaf1f8;border-radius:14px;padding:6px;margin-bottom:20px}
.tab{border:0;background:transparent;color:#526274;padding:10px 14px;border-radius:10px;font-weight:800;cursor:pointer}
.tab.active{background:#fff;color:var(--pd);box-shadow:0 4px 14px rgba(57,88,120,.1)}
.section{display:none}.section.active{display:block}
.kpis{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:14px;margin-bottom:20px}
.kpi{background:#fff;border:1px solid #e7edf4;border-radius:16px;padding:18px;box-shadow:var(--shadow)}
.kpi .lab{font-size:11px;color:var(--muted);font-weight:900;text-transform:uppercase;letter-spacing:.4px}
.kpi .val{font-size:27px;font-weight:900;margin-top:7px}.delta{font-size:12px;margin-top:6px}.up{color:var(--ok)}.down{color:var(--bad)}
.grid2{display:grid;grid-template-columns:minmax(0,1.4fr) minmax(330px,.8fr);gap:20px}
.equal{display:grid;grid-template-columns:1fr 1fr;gap:20px}
.card{background:#fff;border:1px solid #e7edf4;border-radius:18px;box-shadow:var(--shadow);overflow:hidden;margin-bottom:20px}
.card-head{padding:18px 20px;border-bottom:1px solid var(--line);display:flex;justify-content:space-between;align-items:center;gap:12px}
.card-head h2,.card-head h3{margin:0;font-size:17px}.card-body{padding:20px}
.status{display:inline-flex;align-items:center;gap:7px;border-radius:999px;padding:7px 10px;font-size:12px;font-weight:900}
.status:before{content:"";width:9px;height:9px;border-radius:50%;background:currentColor}
.pending{background:#fff6df;color:#b77900}.approved{background:#eaf8ef;color:#14803a}.rejected{background:#fff0f0;color:#c22727}.cancelled{background:#eef1f4;color:#3f4853}.draft{background:#eaf5ff;color:#176aa8}
.table-wrap{overflow:auto;border:1px solid var(--line);border-radius:13px}
table{width:100%;border-collapse:collapse;min-width:900px}
th{background:#eef6ff;color:#2f5677;font-size:11px;text-transform:uppercase;letter-spacing:.35px;padding:11px 10px;text-align:left;border-bottom:1px solid #cfe0ef}
td{padding:10px;border-bottom:1px solid #edf1f5;font-size:13px;vertical-align:middle}tbody tr:hover{background:#fbfdff}
.quick{display:grid;gap:10px}.quick button{width:100%;display:flex;justify-content:space-between;align-items:center;padding:15px;background:#fbfdff;border:1px solid #e2e9f1;border-radius:13px;color:#245f97;font-weight:900;cursor:pointer}
.filters,.form-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:12px;margin-bottom:16px}
.form-grid{grid-template-columns:repeat(3,minmax(0,1fr));margin-bottom:0}
.field{display:flex;flex-direction:column;gap:6px}.field label{font-size:11px;font-weight:900;text-transform:uppercase;color:#526274}
.field input,.field select,.field textarea{border:1px solid #d5e0ea;border-radius:10px;padding:10px 11px;font:inherit;background:#fff;outline:none}
.field textarea{min-height:82px;resize:vertical}.field input:focus,.field select:focus,.field textarea:focus{border-color:#7ab7e8;box-shadow:0 0 0 3px rgba(11,130,232,.08)}
.reimb-table{min-width:1420px}.reimb-table input,.reimb-table select{width:100%;border:1px solid transparent;background:transparent;border-radius:7px;padding:8px;font:inherit;font-size:12px;outline:none}
.reimb-table input:focus,.reimb-table select:focus{background:#fff;border-color:#80bae9;box-shadow:0 0 0 3px rgba(11,130,232,.07)}
.filelabel{display:inline-flex;padding:7px 9px;border-radius:8px;background:#eef6ff;border:1px solid #d4e7f8;color:#155f9e;font-size:11px;font-weight:800;cursor:pointer}
.remove{border:0;background:#fff0f0;color:#c02626;width:31px;height:31px;border-radius:8px;cursor:pointer;font-weight:900}
.chart{height:275px}.chart canvas{width:100%;height:100%}
.compare{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.compare-box{padding:14px;border:1px solid #dfe7f1;border-radius:13px;background:#fbfdff}
.compare-box span{font-size:11px;color:var(--muted);text-transform:uppercase;font-weight:800}.compare-box strong{display:block;font-size:20px;margin-top:5px}
.insights{display:grid;gap:10px}.insight{padding:13px 14px;border-left:4px solid var(--p);border-radius:10px;background:#f8fbff}.insight strong{display:block;margin-bottom:3px}.insight span{font-size:13px;color:var(--muted)}
.pareto{display:grid;gap:9px}.prow{display:grid;grid-template-columns:170px 1fr 70px;gap:10px;align-items:center;font-size:12px}.barbg{height:12px;border-radius:999px;background:#e8eef4;overflow:hidden}.barfill{height:100%;background:linear-gradient(90deg,#0b82e8,#64b2ef)}
.ishikawa{position:relative;min-height:315px;border:1px solid #e2e9f1;border-radius:14px;background:#fbfdff;overflow:hidden}
.spine{position:absolute;left:12%;right:13%;top:50%;height:4px;background:#557a9b}.head{position:absolute;right:3%;top:41%;width:160px;padding:14px;border:2px solid var(--pd);border-radius:14px;background:#eef6ff;text-align:center;font-weight:900;color:var(--pd)}
.bone{position:absolute;width:185px;font-size:12px}.bone strong{display:block;margin-bottom:4px}.bone:after{content:"";position:absolute;width:145px;height:3px;background:#8aa4bb;transform-origin:left}
.b1{left:15%;top:11%}.b1:after{left:95px;top:44px;transform:rotate(28deg)}.b2{left:42%;top:11%}.b2:after{left:85px;top:44px;transform:rotate(28deg)}
.b3{left:18%;bottom:9%}.b3:after{left:95px;top:-5px;transform:rotate(-28deg)}.b4{left:47%;bottom:9%}.b4:after{left:90px;top:-5px;transform:rotate(-28deg)}
.modal{position:fixed;inset:0;background:rgba(15,23,42,.45);display:none;align-items:center;justify-content:center;z-index:9999;padding:18px}.modal.open{display:flex}
.modal-card{width:min(1000px,96vw);max-height:90vh;overflow:auto;background:#fff;border-radius:18px;box-shadow:0 24px 70px rgba(0,0,0,.25)}
.detailgrid{display:grid;grid-template-columns:1.25fr .75fr;gap:18px}.sumlist{display:grid;gap:8px}.sumrow{display:flex;justify-content:space-between;padding:9px 0;border-bottom:1px solid #edf1f5}
@media(max-width:1150px){.kpis{grid-template-columns:repeat(3,1fr)}.grid2,.detailgrid{grid-template-columns:1fr}.filters{grid-template-columns:repeat(3,1fr)}}
@media(max-width:800px){.demo-shell{padding:14px}.kpis{grid-template-columns:1fr 1fr}.equal{grid-template-columns:1fr}.filters,.form-grid{grid-template-columns:1fr}.compare{grid-template-columns:1fr 1fr}.page-head,.demo-note{align-items:flex-start;flex-direction:column}}

/* ==========================================================
   CORESS RIMBORSI - integrazioni Django
   ========================================================== */

html{scroll-behavior:smooth}

body{
  min-height:100vh;
  background:
    radial-gradient(circle at top right, rgba(11,130,232,.06), transparent 25%),
    var(--bg);
}

a{color:inherit}

.topbar{
  min-height:72px;
  padding:0 28px;
  background:linear-gradient(90deg,#0b82e8 0%,#167fce 55%,#2f75b5 100%);
  box-shadow:0 8px 24px rgba(20,79,131,.14);
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  position:sticky;
  top:0;
  z-index:100;
}

.topbar .brand{
  color:#fff;
  font-size:20px;
  font-weight:900;
  letter-spacing:.2px;
  white-space:nowrap;
}

.topbar nav{
  display:flex;
  align-items:center;
  gap:6px;
  flex-wrap:wrap;
}

.topbar nav a{
  color:#fff;
  text-decoration:none;
  font-size:13px;
  font-weight:800;
  padding:9px 12px;
  border-radius:10px;
  transition:.18s ease;
}

.topbar nav a:hover{
  background:rgba(255,255,255,.16);
}

.container{
  max-width:1580px;
  margin:0 auto;
  padding:26px;
}

.demo-shell{
  max-width:1580px;
}

.page-head{
  padding-top:4px;
}

.page-head h1{
  letter-spacing:-.4px;
}

.page-head p{
  max-width:850px;
  line-height:1.5;
}

/* Links used as tabs */
.tabs a.tab{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
}

/* Dashboard layout */
.dashboard-grid{
  display:grid;
  grid-template-columns:minmax(0,1.45fr) minmax(320px,.75fr);
  gap:20px;
}

.quick-list{
  display:grid;
  gap:10px;
}

.quick-list a{
  width:100%;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:14px;
  padding:15px;
  background:#fbfdff;
  border:1px solid #e2e9f1;
  border-radius:13px;
  color:#245f97;
  font-weight:900;
  text-decoration:none;
  transition:.18s ease;
}

.quick-list a:hover{
  transform:translateY(-1px);
  border-color:#afd5f3;
  box-shadow:0 8px 20px rgba(44,105,155,.07);
}

/* Generic card content used by the Django templates */
.card > .table-wrap{
  margin:20px;
}

.card > h2{
  margin:20px 20px 0;
}

.card > form.stack{
  margin:20px;
}

.card > .actions{
  margin:20px;
}

.card > .pagination{
  margin:0 20px 20px;
}

.card.filters{
  padding:18px 20px;
  overflow:visible;
}

.filter-row{
  display:flex;
  align-items:end;
  gap:10px;
  flex-wrap:wrap;
}

.filter-row label{
  font-size:11px;
  font-weight:900;
  text-transform:uppercase;
  color:#526274;
}

.filter-row select{
  min-width:220px;
}

/* Django form widgets */
.form-grid > div,
.stack{
  display:flex;
  flex-direction:column;
  gap:6px;
}

.form-grid > div label,
.stack label{
  font-size:11px;
  font-weight:900;
  text-transform:uppercase;
  color:#526274;
}

input,
select,
textarea{
  border:1px solid #d5e0ea;
  border-radius:10px;
  padding:10px 11px;
  font:inherit;
  color:var(--text);
  background:#fff;
  outline:none;
  transition:border-color .16s ease,box-shadow .16s ease,background .16s ease;
}

input:focus,
select:focus,
textarea:focus{
  border-color:#7ab7e8;
  box-shadow:0 0 0 3px rgba(11,130,232,.08);
}

textarea{
  resize:vertical;
}

.form-grid{
  padding:20px;
  grid-template-columns:repeat(4,minmax(0,1fr));
}

.edit-table{
  min-width:1550px;
}

.edit-table input,
.edit-table select,
.edit-table textarea{
  width:100%;
  min-width:105px;
  padding:8px;
  font-size:12px;
}

.edit-table textarea{
  min-height:46px;
}

.edit-table input[type="checkbox"]{
  min-width:auto;
  width:auto;
  transform:scale(1.12);
}

.edit-table input[type="file"]{
  min-width:180px;
  padding:6px;
  background:#f8fbff;
}

.actions.end{
  display:flex;
  justify-content:flex-end;
  padding:0 20px 20px;
}

/* Status classes generated dynamically by Django */
.status-inviato{
  background:#fff6df;
  color:#b77900;
}

.status-approvato{
  background:#eaf8ef;
  color:#14803a;
}

.status-respinto{
  background:#fff0f0;
  color:#c22727;
}

.status-cancellato{
  background:#eef1f4;
  color:#3f4853;
}

.status-bozza{
  background:#eaf5ff;
  color:#176aa8;
}

/* Messages */
.messages{
  display:grid;
  gap:10px;
  margin-bottom:18px;
}

.message{
  border-radius:12px;
  padding:12px 14px;
  border:1px solid #cfe2f3;
  background:#f3f9ff;
  color:#255778;
  font-size:13px;
  font-weight:700;
}

.message.success{
  border-color:#bfe5cb;
  background:#eaf8ef;
  color:#147a35;
}

.message.error{
  border-color:#f0c7c7;
  background:#fff0f0;
  color:#b42318;
}

/* Login */
.login-shell{
  min-height:calc(100vh - 124px);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:30px 0;
}

.login-card{
  width:min(470px,96vw);
  padding:32px;
  background:#fff;
  border:1px solid #e7edf4;
  border-radius:22px;
  box-shadow:0 22px 65px rgba(31,78,119,.13);
}

.login-badge{
  width:56px;
  height:56px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:17px;
  background:linear-gradient(145deg,#168de9,#0a78d3);
  color:#fff;
  font-size:27px;
  font-weight:900;
  box-shadow:0 10px 24px rgba(11,130,232,.22);
}

.login-card h1{
  margin:15px 0 8px;
  font-size:30px;
  letter-spacing:-.4px;
}

.login-card p{
  margin:0 0 22px;
  color:var(--muted);
  line-height:1.55;
}

.login-card .stack{
  gap:9px;
}

.full{width:100%;margin-top:8px}

/* Approval page */
.card .stack textarea{
  min-height:100px;
}

.card .stack .actions{
  margin-top:8px;
}

.pagination{
  display:flex;
  justify-content:center;
  align-items:center;
  gap:14px;
  padding:16px 0;
  color:var(--muted);
  font-size:13px;
}

.pagination a{
  text-decoration:none;
  color:var(--pd);
  font-weight:900;
  padding:8px 11px;
  border:1px solid #dbe6ef;
  border-radius:9px;
  background:#fff;
}

/* Empty rows */
tbody td[colspan]{
  color:var(--muted);
}

/* Error rendering from Django forms */
.errorlist{
  list-style:none;
  padding:0;
  margin:6px 0;
  color:#b42318;
  font-size:12px;
  font-weight:700;
}

.error-box{
  margin:0 20px 20px;
  padding:13px 14px;
  border-radius:11px;
  background:#fff0f0;
  border:1px solid #f0c7c7;
  color:#b42318;
  font-size:13px;
}

/* Better table scrollbar */
.table-wrap::-webkit-scrollbar{height:10px}
.table-wrap::-webkit-scrollbar-track{background:#f2f5f8;border-radius:999px}
.table-wrap::-webkit-scrollbar-thumb{background:#bfd1df;border-radius:999px}

/* Responsiveness */
@media(max-width:1150px){
  .dashboard-grid{grid-template-columns:1fr}
  .form-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}

@media(max-width:800px){
  .topbar{
    position:static;
    padding:14px;
    align-items:flex-start;
    flex-direction:column;
  }

  .topbar nav{
    width:100%;
  }

  .container{
    padding:14px;
  }

  .form-grid{
    grid-template-columns:1fr;
  }

  .filter-row{
    align-items:stretch;
    flex-direction:column;
  }

  .filter-row select{
    width:100%;
    min-width:0;
  }
}
/* ==========================================================
   PATCH RESPONSIVE - TUTTA L'APP CORESS RIMBORSI
   Nessuno scroll orizzontale del body.
   ========================================================== */

html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Contenitori principali sempre fluidi */
.container,
.demo-shell,
.card,
.card-body,
.table-wrap {
    max-width: 100%;
}

/* Tabelle desktop: occupano il contenitore, senza margini eccessivi */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
}

/* =========================
   NUOVO RIMBORSO - DESKTOP
   ========================= */

.edit-table {
    width: 100%;
    min-width: 0 !important;
    table-layout: fixed;
    border-collapse: collapse;
}

.edit-table th,
.edit-table td {
    padding: 8px 8px;
    vertical-align: middle;
}

.edit-table th {
    font-size: 10.5px;
    line-height: 1.2;
    white-space: normal;
}

.edit-table td {
    height: auto;
}

/* Larghezze proporzionate */
.edit-table th:nth-child(1),
.edit-table td:nth-child(1) { width: 3.5%; }  /* A/R */

.edit-table th:nth-child(2),
.edit-table td:nth-child(2) { width: 8%; }    /* Data */

.edit-table th:nth-child(3),
.edit-table td:nth-child(3) { width: 10.5%; } /* Partenza */

.edit-table th:nth-child(4),
.edit-table td:nth-child(4) { width: 10.5%; } /* Destinazione */

.edit-table th:nth-child(5),
.edit-table td:nth-child(5) { width: 9%; }    /* Giustificativo */

.edit-table th:nth-child(6),
.edit-table td:nth-child(6) { width: 8.5%; }  /* Spese tracciabili */

.edit-table th:nth-child(7),
.edit-table td:nth-child(7) { width: 8.5%; }  /* Spese non tracciabili */

.edit-table th:nth-child(8),
.edit-table td:nth-child(8) { width: 7.5%; }  /* Km comune */

.edit-table th:nth-child(9),
.edit-table td:nth-child(9) { width: 8.5%; }  /* Km fuori */

.edit-table th:nth-child(10),
.edit-table td:nth-child(10) { width: 11%; }  /* Allegato */

.edit-table th:nth-child(11),
.edit-table td:nth-child(11) { width: 10.5%; }/* Note */

.edit-table th:nth-child(12),
.edit-table td:nth-child(12) { width: 4%; }   /* Elimina */

/* Campi compatti */
.edit-table input,
.edit-table select,
.edit-table textarea {
    width: 100%;
    min-width: 0 !important;
    max-width: 100%;
    height: 38px;
    min-height: 38px;
    margin: 0;
    padding: 7px 8px;
    font-size: 12px;
    border-radius: 8px;
}

/* Note leggibili ma compatte */
.edit-table textarea {
    resize: vertical;
    height: 42px;
    min-height: 42px !important;
    max-height: 120px;
    line-height: 1.3;
}

/* Checkbox non viene stirato */
.edit-table input[type="checkbox"] {
    width: 18px;
    height: 18px;
    min-height: 18px;
}

/* Upload file compatto */
.edit-table input[type="file"] {
    height: 38px;
    min-height: 38px;
    padding: 5px;
    font-size: 11px;
}

/* Meno spazio verticale tra le righe */
.edit-table .form-row {
    min-height: 54px;
}

/* Card dettaglio più compatta */
.card-head {
    padding: 14px 18px;
}

.card > .table-wrap {
    margin: 10px 16px 14px;
}

/* =========================
   DASHBOARD
   ========================= */

.kpis {
    grid-template-columns: repeat(5, minmax(0, 1fr));
}

.dashboard-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, .75fr);
}

/* =========================
   TABLET
   ========================= */

@media (max-width: 1100px) {

    .container,
    .demo-shell {
        padding: 18px;
    }

    .kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .dashboard-grid,
    .grid2,
    .equal,
    .detailgrid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    /* Nuovo rimborso: tabella diventa blocchi/card */
    .edit-table,
    .edit-table thead,
    .edit-table tbody,
    .edit-table tr,
    .edit-table th,
    .edit-table td {
        display: block;
        width: 100% !important;
    }

    .edit-table thead {
        display: none;
    }

    .edit-table tbody {
        display: grid;
        gap: 14px;
    }

    .edit-table .form-row {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
        padding: 14px;
        border: 1px solid #dfe7f1;
        border-radius: 14px;
        background: #fbfdff;
        box-shadow: 0 6px 18px rgba(32,75,120,.05);
    }

    .edit-table td {
        padding: 0;
        border: 0;
        display: flex;
        flex-direction: column;
        gap: 5px;
        min-width: 0;
    }

    /* Etichette automatiche su tablet/mobile */
    .edit-table td:nth-child(1)::before { content: "A/R"; }
    .edit-table td:nth-child(2)::before { content: "Data"; }
    .edit-table td:nth-child(3)::before { content: "Partenza"; }
    .edit-table td:nth-child(4)::before { content: "Destinazione"; }
    .edit-table td:nth-child(5)::before { content: "Giustificativo"; }
    .edit-table td:nth-child(6)::before { content: "Spese tracciabili"; }
    .edit-table td:nth-child(7)::before { content: "Spese non tracciabili"; }
    .edit-table td:nth-child(8)::before { content: "Km Comune"; }
    .edit-table td:nth-child(9)::before { content: "Km fuori Comune"; }
    .edit-table td:nth-child(10)::before { content: "Allegato"; }
    .edit-table td:nth-child(11)::before { content: "Note"; }
    .edit-table td:nth-child(12)::before { content: "Elimina"; }

    .edit-table td::before {
        font-size: 10px;
        font-weight: 900;
        text-transform: uppercase;
        letter-spacing: .35px;
        color: #526274;
    }

    .edit-table textarea {
        min-height: 70px !important;
        height: 70px;
    }

    .edit-table td:nth-child(11) {
        grid-column: 1 / -1;
    }

    .edit-table td:nth-child(10) {
        grid-column: 1 / 2;
    }

    .edit-table td:nth-child(12) {
        grid-column: 2 / 3;
        justify-content: end;
    }

    .table-wrap {
        overflow-x: visible;
    }
}

/* =========================
   SMARTPHONE
   ========================= */

@media (max-width: 768px) {

    .topbar {
        position: static;
        padding: 12px 14px;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .topbar .brand {
        font-size: 18px;
    }

    .topbar nav {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .topbar nav a {
        text-align: center;
        background: rgba(255,255,255,.10);
    }

    .container,
    .demo-shell {
        padding: 12px;
    }

    .page-head {
        align-items: stretch;
        flex-direction: column;
        gap: 12px;
    }

    .page-head .btn,
    .page-head > .status {
        width: 100%;
        justify-content: center;
    }

    .tabs {
        width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .tabs::-webkit-scrollbar {
        display: none;
    }

    .tab {
        flex: 0 0 auto;
    }

    .kpis {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .edit-table .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 13px;
    }

    .edit-table td:nth-child(10),
    .edit-table td:nth-child(11),
    .edit-table td:nth-child(12) {
        grid-column: auto;
    }

    .edit-table textarea {
        min-height: 86px !important;
        height: 86px;
    }

    /* Tabelle archivio/approvazioni: card responsive */
    .card .table-wrap table:not(.edit-table),
    .card .table-wrap table:not(.edit-table) thead,
    .card .table-wrap table:not(.edit-table) tbody,
    .card .table-wrap table:not(.edit-table) tr,
    .card .table-wrap table:not(.edit-table) th,
    .card .table-wrap table:not(.edit-table) td {
        display: block;
        width: 100%;
    }

    .card .table-wrap table:not(.edit-table) thead {
        display: none;
    }

    .card .table-wrap table:not(.edit-table) tbody {
        display: grid;
        gap: 12px;
    }

    .card .table-wrap table:not(.edit-table) tr {
        border: 1px solid #dfe7f1;
        border-radius: 13px;
        padding: 12px;
        background: #fff;
        box-shadow: 0 5px 14px rgba(32,75,120,.04);
    }

    .card .table-wrap table:not(.edit-table) td {
        border: 0;
        padding: 6px 0;
        min-width: 0;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .card > .table-wrap {
        margin: 10px 12px 14px;
    }

    .filter-row {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-row select,
    .filter-row input,
    .filter-row .btn {
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    .actions .btn {
        width: 100%;
    }

    .pagination {
        flex-direction: column;
        gap: 8px;
    }
}

/* =========================
   SMARTPHONE PICCOLO
   ========================= */

@media (max-width: 480px) {

    .container,
    .demo-shell {
        padding: 9px;
    }

    .card {
        border-radius: 14px;
    }

    .card-head {
        padding: 12px 14px;
        align-items: flex-start;
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .topbar nav {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 22px 18px;
    }

    .login-card h1 {
        font-size: 25px;
    }
}

