:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  /* Palette Bargain: nero/grigi del marchio, blu e rosso del sito */
  --brand: #111111;
  --accent: #2064b6;
  --accent-soft: #e8f0fa;
  --ee: #d97706;
  --gas: #2563eb;
  --danger: #cc0101;
  --radius: 10px;
  font-family: "Manrope", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); font-size: 14px; line-height: 1.45; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* layout */
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { background: var(--brand); color: #d0d5dd; padding: 20px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: block; margin: 4px 8px 26px; }
.brand img { display: block; width: 150px; max-width: 100%; height: auto; }
.brand small { display: block; color: #8a8a8a; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; margin-top: 8px; }
.sidebar nav a { display: block; color: #d0d5dd; padding: 8px 10px; border-radius: 6px; margin-bottom: 2px; }
.sidebar nav a:hover { background: #222; text-decoration: none; }
.sidebar nav a.attivo { background: #222; color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar .sezione { text-transform: uppercase; font-size: 11px; letter-spacing: .06em; color: #8890a0; margin: 18px 10px 6px; }
.sidebar .utente { position: absolute; bottom: 16px; left: 14px; right: 14px; font-size: 12px; color: #98a2b3; }
.sidebar .utente form { display: inline; }
.sidebar .utente button { background: none; border: 0; color: #d0d5dd; cursor: pointer; padding: 0; text-decoration: underline; }
main { padding: 24px 28px 48px; min-width: 0; }
.testata { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }

/* cards & grid */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.griglia { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.kpi { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi .card { padding: 14px 16px; }
.kpi .valore { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .etichetta { color: var(--muted); font-size: 12px; }
.mb { margin-bottom: 16px; }

/* tables */
.tabella-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; background: #fafbfc; }
th a { color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tfoot td { font-weight: 650; background: #fafbfc; }
tr:hover td { background: #fbfcfd; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.tipo-EE { background: #fef3c7; color: #92400e; }
.tipo-GAS { background: #dbeafe; color: #1e40af; }
.stato-INS { background: #f2f4f7; color: #344054; }
.stato-VER { background: #fef0c7; color: #93370d; }
.stato-INV { background: #e0eaff; color: #3538cd; }
.stato-ATT { background: #d1e9ff; color: #175cd3; }
.stato-ON { background: #d1fadf; color: #05603a; }
.stato-KO { background: #fee4e2; color: #b42318; }
.stato-OFF { background: #eaecf0; color: #475467; }

/* forms */
.filtri { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
input, select, textarea { font: inherit; padding: 7px 10px; border: 1px solid #d0d5dd; border-radius: 8px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.filtri input[type=search] { min-width: 260px; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid #d0d5dd; background: #fff; color: var(--ink); font-weight: 600; cursor: pointer; font-size: 14px; }
.btn:hover { text-decoration: none; background: #f9fafb; }
.btn.primario { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primario:hover { background: #333; }
.form-griglia { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.campo label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
.campo input, .campo select, .campo textarea { width: 100%; }
.campo .aiuto { color: var(--muted); font-size: 12px; margin-top: 3px; }
.campo .errori { color: var(--danger); font-size: 12px; margin-top: 3px; }
.campo.largo { grid-column: 1 / -1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; margin: 0 0 16px; background: #fff; }
legend { font-weight: 650; padding: 0 6px; }

/* misc */
.messaggi { list-style: none; padding: 0; margin: 0 0 16px; }
.messaggi li { padding: 10px 14px; border-radius: 8px; background: var(--accent-soft); color: #174a87; margin-bottom: 6px; }
.messaggi li.error { background: #fee4e2; color: var(--danger); }
.dati { display: grid; grid-template-columns: 170px 1fr; gap: 6px 14px; margin: 0; }
.dati dt { color: var(--muted); }
.dati dd { margin: 0; }
.barra { display: grid; grid-template-columns: 140px 1fr 110px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.barra .traccia { background: #f2f4f7; border-radius: 4px; height: 10px; overflow: hidden; }
.barra .riempi { background: var(--accent); height: 100%; border-radius: 4px; }
.barra .val { text-align: right; font-variant-numeric: tabular-nums; }
.colonne { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 8px; }
.colonne .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 11px; color: var(--muted); }
.colonne .col .b { width: 100%; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.colonne .col .n { color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.colonne .col.corrente .b { background: var(--brand); }
.paginazione { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.avviso { background: #fffaeb; border: 1px solid #fedf89; color: #93370d; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }
.note { white-space: pre-wrap; }
.login { max-width: 380px; margin: 10vh auto; }
.login .logo-login { display: block; width: 220px; max-width: 80%; margin: 4px auto 22px; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { padding: 6px 0; border-bottom: 1px dashed var(--line); font-size: 13px; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar .utente { position: static; margin-top: 12px; }
  .g2, .g3, .form-griglia { grid-template-columns: 1fr; }
  main { padding: 16px; }
}
