:root{
  --bg:#0b1220;
  --card:#ffffff;
  --text:#111827;
  --muted:#6b7280;
  --primary:#2563eb;
  --primary2:#1d4ed8;
  --soft:#f3f4f6;
  --line:#e5e7eb;
  --danger:#b91c1c;
}

*{ box-sizing:border-box; }

body{
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--soft);
  color: var(--text);
}

header{
  background: var(--bg);
  color: white;
  padding: 14px 12px;
  text-align: center;
}

.logo-container{
  display:flex;
  align-items:center;
  justify-content:center;
  gap: 12px;
}

.logo{
  height: 44px;
  width: 44px;
  border-radius: 10px;
}

.head-txt h1{
  margin:0;
  font-size: 20px;
  line-height: 1.1;
}

.sub{
  font-size: 12px;
  color: rgba(255,255,255,.8);
  margin-top: 4px;
}

.mini{
  font-size: 12px;
  color: var(--muted);
}

main{
  padding: 12px;
  max-width: 980px;
  margin: 0 auto;
}

section{
  margin-bottom: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.04);
}

h2{
  margin: 0 0 10px 0;
  font-size: 16px;
}

h3{
  margin: 0 0 10px 0;
  font-size: 14px;
}

.hint{
  margin: 6px 0 0 0;
  font-size: 12px;
  color: var(--muted);
}

.err{
  margin-top: 8px;
  color: var(--danger);
  font-weight: 700;
}

input[type="file"],
input[type="text"],
input[type="number"],
select,
button{
  display:block;
  margin-top: 6px;
  margin-bottom: 10px;
  padding: 10px;
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: white;
}

label{
  font-size: 13px;
  color: var(--text);
}

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

.row > *{
  flex: 1;
  min-width: 220px;
}

.check{
  display:flex;
  gap: 8px;
  align-items: center;
  font-size: 13px;
  color: var(--text);
}

.check input{
  width: auto;
  margin: 0;
}

.checkline{
  display:flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.panel{
  border: 1px dashed var(--line);
  background: #fafafa;
  padding: 12px;
  border-radius: 14px;
  margin: 10px 0;
}

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

.grid .mini{
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
}

button{
  background: var(--primary);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 700;
  transition: background-color .2s ease;
}

button:hover{
  background: var(--primary2);
}

button.secondary{
  background: #111827;
}

button.secondary:hover{
  background: #0f172a;
}

/* -----------------------------
   Tabelle “mini” (noleggio canoni)
----------------------------- */
.table-wrap{
  display:block;
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.mini-table{
  width: 100%;
  border-collapse: collapse;
  min-width: 520px;
}

.mini-table th,
.mini-table td{
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 12px;
}

.mini-table th{
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* -----------------------------
   Tabella articoli (scroll iPhone)
----------------------------- */
#articoli-section{
  overflow: hidden;
}

#articoli-table{
  width: 100%;
  border-collapse: collapse;
  min-width: 980px; /* forza scrollbar su schermi piccoli */
}

#articoli-table th,
#articoli-table td{
  padding: 8px 6px;
  text-align: center;
  border: 1px solid var(--line);
  font-size: 12px;
}

#articoli-table th{
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

#articoli-table input[type="number"]{
  width: 92px;
  text-align: right;
  padding: 8px 8px;
  margin: 0;
}

/* rende la tabella scrollabile */
#articoli-section table{
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Totali */
#totaleGenerale{
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  padding: 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
}

/* -----------------------------
   Overlay errore (fuori media query)
----------------------------- */
.fatal{
  position:fixed; inset:0; z-index:9999;
  background: rgba(0,0,0,.72);
  display:flex; align-items:center; justify-content:center;
  padding:16px;
}
.fatal-card{
  width:min(820px, 100%);
  background:#fff;
  border-radius:16px;
  padding:14px;
  border:1px solid #e5e7eb;
  box-shadow:0 12px 40px rgba(0,0,0,.35);
}
.fatal-title{ font-size:18px; font-weight:800; margin:0 0 6px 0; }
.fatal-sub{ font-size:12px; color:#6b7280; margin:0 0 10px 0; }
.fatal pre{
  background:#0b1220; color:#e5e7eb;
  padding:12px; border-radius:12px;
  overflow:auto; max-height: 48vh;
  white-space:pre-wrap;
}

/* anagrafica: griglia più “larga” */
.grid-2{ grid-template-columns: repeat(2, minmax(0,1fr)); }

/* Mobile tweaks */
@media (max-width: 720px){
  .grid{
    grid-template-columns: 1fr;
  }
  .grid-2{
    grid-template-columns: 1fr;
  }
  input[type="file"],
  input[type="text"],
  input[type="number"],
  select,
  button{
    max-width: 100%;
  }
  .row > *{
    min-width: 100%;
  }
  .logo{
    height: 40px;
    width: 40px;
  }
  .head-txt h1{
    font-size: 18px;
  }
}
