:root{
  --bg:#f4f6f8;
  --card:#fff;
  --ink:#1f2937;
  --muted:#6b7280;
  --accent:#0f766e;
  --accent2:#115e59;
  --line:#e5e7eb;
  --danger:#b91c1c
}

*{
  box-sizing:border-box
}

body{
  margin:0;
  font-family:Inter,system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:var(--bg);
  color:var(--ink)
}

a{
  color:inherit
}

.topbar{
  height:68px;
  background:#111827;
  color:#fff;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 28px
}

.brand{
  font-size:21px;
  font-weight:800;
  letter-spacing:.4px
}

.nav a{
  margin-left:18px;
  text-decoration:none;
  color:#e5e7eb
}

.container{
  max-width:1250px;
  margin:28px auto;
  padding:0 22px
}

.head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:20px;
  margin-bottom:20px
}

.btn{
  display:inline-block;
  background:var(--accent);
  color:#fff;
  border:0;
  border-radius:9px;
  padding:10px 15px;
  text-decoration:none;
  font-weight:700;
  cursor:pointer
}

.btn:hover{
  background:var(--accent2)
}

.btn.secondary{
  background:#374151
}

.kpis{
  display:grid;
  grid-template-columns:repeat(4,1fr);
  gap:16px;
  margin-bottom:22px
}

.kpi{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:18px;
  min-height:112px;
  display:flex;
  flex-direction:column;
  justify-content:space-between
}

.kpi .label{
  font-size:13px;
  color:var(--muted);
  font-weight:800
}

.kpi .number{
  font-size:34px;
  line-height:1;
  font-weight:900
}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:14px;
  padding:20px;
  overflow:auto
}

table{
  width:100%;
  border-collapse:collapse
}

th,
td{
  text-align:left;
  padding:12px 10px;
  border-bottom:1px solid var(--line);
  font-size:14px
}

th{
  font-size:12px;
  text-transform:uppercase;
  color:var(--muted)
}

.badge{
  display:inline-block;
  padding:5px 8px;
  border-radius:999px;
  background:#fef3c7;
  font-size:12px;
  font-weight:800
}

.badge.done{
  background:#dcfce7
}

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

.field label{
  display:block;
  font-size:13px;
  font-weight:800;
  margin-bottom:6px
}

.field input,
.field select,
.field textarea{
  width:100%;
  padding:11px;
  border:1px solid #d1d5db;
  border-radius:8px;
  background:#fff
}

.field textarea{
  min-height:100px
}

.full{
  grid-column:1/-1
}

.error{
  background:#fee2e2;
  color:var(--danger);
  padding:10px 12px;
  border-radius:8px;
  margin-bottom:14px
}

.login-wrap{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:20px
}

.login-box{
  width:min(410px,100%);
  background:#fff;
  border:1px solid var(--line);
  border-radius:16px;
  padding:28px;
  box-shadow:0 10px 30px rgba(0,0,0,.06)
}

.login-box h1{
  margin-top:0
}

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

/* AZIONI - pulsanti ordinati 2x2 */
.actions{
  display:grid;
  grid-template-columns:repeat(2,minmax(120px,1fr));
  gap:8px;
  align-items:stretch;
  min-width:260px
}

.actions form{
  margin:0;
  width:100%
}

.actions .btn,
.actions form .btn{
  width:100%;
  min-height:40px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  white-space:nowrap
}

table th:last-child,
table td:last-child{
  min-width:280px
}

@media(max-width:850px){
  .kpis{
    grid-template-columns:repeat(2,1fr)
  }

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

@media(max-width:520px){
  .kpis{
    grid-template-columns:1fr
  }

  .topbar{
    padding:0 14px
  }

  .nav a{
    margin-left:9px;
    font-size:13px
  }

  .actions{
    grid-template-columns:1fr;
    min-width:160px
  }

  table th:last-child,
  table td:last-child{
    min-width:180px
  }
}
