/* ── Reset & base ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: #f0f2f5;
  color: #1a1a2e;
  min-height: 100vh;
}

/* ── Top navbar (autenticata) ─────────────────────────────────── */
.topnav {
  display: flex; justify-content: space-between; align-items: center;
  background: #1a1a2e; padding: 0 24px; height: 48px;
  position: sticky; top: 0; z-index: 100;
}
.topnav-brand { color:#fff; font-weight:700; font-size:16px; text-decoration:none; margin-right:20px; }
.topnav-link  { color:#9aa3c2; text-decoration:none; font-size:13px; padding:0 12px; line-height:48px; transition:color .15s; }
.topnav-link:hover,.topnav-link.active { color:#fff; }
.topnav-left,.topnav-right { display:flex; align-items:center; }
.topnav-user   { color:#9aa3c2; font-size:13px; margin-right:16px; }
.topnav-logout { color:#9aa3c2; text-decoration:none; font-size:13px; padding:4px 10px; border:1px solid #4a4a8a; border-radius:6px; }
.topnav-logout:hover { color:#fff; border-color:#fff; }
.role-badge  { display:inline-block; padding:1px 7px; border-radius:10px; font-size:11px; font-weight:600; margin-left:6px; }
.role-admin  { background:#fef3c7; color:#d97706; }
.role-editor { background:#ede9fe; color:#7c3aed; }
.role-viewer { background:#f0fdf4; color:#16a34a; }

/* ── Header ───────────────────────────────────────────────────── */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #1a1a2e;
  color: #fff;
  padding: 14px 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.header-left { display: flex; align-items: center; gap: 14px; }

header h1 { font-size: 20px; font-weight: 700; letter-spacing: .3px; }

.ente-label {
  background: #2d2d5e;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  color: #b0b8d8;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-right label { color: #9aa3c2; font-size: 13px; }

#sel-commessa {
  background: #2d2d5e;
  color: #fff;
  border: 1px solid #4a4a8a;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  cursor: pointer;
}

#btn-refresh {
  background: #4f46e5;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background .2s;
}
#btn-refresh:hover { background: #4338ca; }

/* ── KPI section label ────────────────────────────────────────── */
.kpi-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: #9ca3af;
  padding: 18px 24px 0;
}

/* ── KPI grid ─────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
  padding: 8px 24px 4px;
}

.kpi-card {
  background: #fff;
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  border-left: 4px solid #dde1ea;
}
.kpi-card.accent-blue   { border-left-color: #4f46e5; }
.kpi-card.accent-green  { border-left-color: #16a34a; }
.kpi-card.accent-red    { border-left-color: #dc2626; }
.kpi-card.accent-purple { border-left-color: #9333ea; }

.kpi-value {
  font-size: 26px;
  font-weight: 700;
  color: #1a1a2e;
  line-height: 1.1;
}
.kpi-label {
  font-size: 12px;
  color: #6b7280;
  margin-top: 4px;
}
.kpi-sub {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 3px;
}

/* ── Charts ───────────────────────────────────────────────────── */
.charts-row {
  display: flex;
  gap: 16px;
  padding: 10px 24px;
  flex-wrap: wrap;
}

.chart-box {
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
  flex: 1 1 260px;
  min-width: 260px;
}

.chart-box--wide {
  flex: 2 1 500px;
}

.chart-box h2 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 14px;
}

canvas { max-height: 260px; }

/* ── Tabella confronto inline ─────────────────────────────────── */
.confronto-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 8px;
}
.confronto-table th {
  background: #f8f9fc;
  color: #6b7280;
  font-weight: 600;
  padding: 6px 8px;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
}
.confronto-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f0f2f5;
}
.confronto-table td:not(:first-child) {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.confronto-table tr.row-pagato td { color: #16a34a; font-weight: 600; }
.confronto-table tr.row-nonpagato td { color: #dc2626; font-weight: 600; }

/* ── Tabella ──────────────────────────────────────────────────── */
.table-section {
  margin: 10px 24px 30px;
  background: #fff;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}

.table-section h2 {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: #f8f9fc;
  color: #6b7280;
  font-weight: 600;
  padding: 8px 10px;
  text-align: left;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
}
th.num { text-align: right; }

tbody tr:hover { background: #f8f9fc; }
tbody td {
  padding: 7px 10px;
  border-bottom: 1px solid #f0f2f5;
  vertical-align: middle;
}
td.num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.badge-si       { background: #fef2f2; color: #dc2626; }
.badge-no       { background: #f0fdf4; color: #16a34a; }
.badge-eredi    { background: #fff7ed; color: #ea580c; }
.badge-sospeso  { background: #eff6ff; color: #2563eb; }
.badge-ok       { background: #f0fdf4; color: #16a34a; }
