/* Presenze Energy Light - foglio di stile unico, mobile first.
   Colori presi dall'identita' del sito www.energy-light.it: il gradiente
   ufficiale del marchio e' linear-gradient(125deg, #574f9c 20%, #de017f 100%).
   Per cambiare la veste basta questo blocco. */
:root {
  --viola: #574f9c;          /* estremo sinistro del gradiente del logo */
  --magenta: #de017f;        /* estremo destro del gradiente del logo */
  --brand: #de017f;          /* accento principale (pulsanti, stati attivi) */
  --brand-scuro: #b60168;
  --brand-grad: linear-gradient(125deg, #574f9c 20%, #de017f 100%);
  --giallo: #fbc729;         /* accento secondario del sito */
  --ciano: #32e4e4;          /* accento secondario del sito */
  --ink: #2b2450;            /* testate: viola profondo, derivato dal marchio */
  --ink-2: #423a6b;
  --grigio: #6b7280;
  --bordo: #e2e0ec;
  --sfondo: #f6f5fa;
  --card: #ffffff;
  --ok: #1f8a52;
  --ok-bg: #e6f5ec;
  --ko: #c0392b;
  --ko-bg: #fdeceb;
  --attesa: #96690a;
  --attesa-bg: #fdf6e3;
  --raggio: 12px;
  --ombra: 0 1px 2px rgba(43, 36, 80, .06), 0 4px 12px rgba(43, 36, 80, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--sfondo); color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(68px + env(safe-area-inset-bottom));
}
body.pubblica { padding-bottom: 24px; }

/* ---------- intestazione ---------- */
.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: var(--ink); color: #fff;
  border-bottom: 3px solid transparent;
  border-image: var(--brand-grad) 1;      /* filo del gradiente del marchio */
}
.marchio { display: flex; align-items: center; gap: 10px; color: #fff;
  text-decoration: none; font-weight: 700; letter-spacing: .2px; }
/* logo bianco: la testata e' scura */
.marchio img { height: 26px; width: auto; display: block; }
.marchio span { font-size: 15px; font-weight: 600; padding-left: 10px;
  border-left: 1px solid rgba(255, 255, 255, .28); }
.top-dx { display: flex; align-items: center; gap: 10px; }
.link { background: none; border: 0; color: #cfd8e3; font: inherit; font-size: 14px;
  cursor: pointer; padding: 6px; text-decoration: underline; }
.link:hover { color: #fff; }
form.inline { display: inline; margin: 0; }

.avviso { margin: 0; padding: 10px 16px; background: var(--attesa-bg);
  color: var(--attesa); font-size: 14px; border-bottom: 1px solid #f0e2bb; }

/* ---------- struttura ---------- */
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 21px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 15px; margin: 0 0 8px; }
p { margin: 0 0 12px; }
.muto { color: var(--grigio); font-size: 14px; }
.centro { text-align: center; }

.card {
  background: var(--card); border: 1px solid var(--bordo); border-radius: var(--raggio);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--ombra);
}
.card.piatta { box-shadow: none; }
/* logo a gradiente: si usa sui fondi chiari (card, login, foglio QR, stampa) */
.logo-chiaro { display: block; height: 34px; width: auto; margin: 0 auto 14px; }
.logo-chiaro.grande { height: 46px; margin-bottom: 18px; }
.griglia { display: grid; gap: 14px; }
@media (min-width: 700px) { .griglia.due { grid-template-columns: 1fr 1fr; } }

/* ---------- pulsanti ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px; border: 0; border-radius: 10px; background: var(--ink);
  color: #fff; font: inherit; font-weight: 600; text-decoration: none;
  cursor: pointer; min-height: 48px;
}
.btn:active { transform: translateY(1px); }
/* pulsante principale: il gradiente del marchio, testo bianco */
.btn.brand { background: var(--brand-grad); color: #fff; }
.btn.giallo { background: var(--giallo); color: var(--ink); }
.btn.ok { background: var(--ok); }
.btn.ko { background: var(--ko); }
.btn.chiaro { background: #fff; color: var(--ink); border: 1px solid var(--bordo); }
.btn.grande { width: 100%; font-size: 18px; padding: 20px; min-height: 64px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-riga { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- form ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=time], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; padding: 12px; font: inherit; color: var(--ink);
  border: 1px solid var(--bordo); border-radius: 10px; background: #fff;
  min-height: 46px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--magenta); outline-offset: 1px; border-color: var(--magenta);
}
fieldset { border: 1px solid var(--bordo); border-radius: 10px; padding: 12px; margin: 12px 0; }
legend { font-size: 13px; font-weight: 600; color: var(--grigio); padding: 0 6px; }
.aiuto { font-size: 13px; color: var(--grigio); margin: 6px 0 0; }
/* riga con casella di spunta: area di tocco comoda anche da telefono */
label.spunta { display: flex; align-items: center; gap: 10px; margin: 16px 0 0;
  font-weight: 500; cursor: pointer; min-height: 44px; }
label.spunta input[type=checkbox] { width: 22px; height: 22px; margin: 0;
  accent-color: var(--brand-scuro); flex: 0 0 auto; }
.riga-campi { display: grid; gap: 10px; }
@media (min-width: 560px) { .riga-campi.due { grid-template-columns: 1fr 1fr; } }

/* ---------- messaggi ---------- */
.msg { padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 15px; }
.msg.errore { background: var(--ko-bg); color: var(--ko); border: 1px solid #f3c7c2; }
.msg.buono { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe3ce; }
.msg.info { background: var(--attesa-bg); color: var(--attesa); border: 1px solid #f0e2bb; }

/* ---------- etichette di stato ---------- */
.tag { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px;
  font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.tag.in_attesa { background: var(--attesa-bg); color: var(--attesa); }
.tag.approvata, .tag.ingresso { background: var(--ok-bg); color: var(--ok); }
.tag.rifiutata, .tag.uscita { background: var(--ko-bg); color: var(--ko); }
.tag.annullata, .tag.fuori_fascia { background: #eef1f5; color: var(--grigio); }
.tag.mattina { background: #fff6d9; color: #8a6100; }
.tag.pomeriggio { background: #e7effb; color: #1c4f9c; }

/* ---------- avatar ---------- */
.avatar { width: 42px; height: 42px; border-radius: 50%; object-fit: cover;
  background: var(--brand-grad); color: #fff; display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700; flex: 0 0 auto; }
.avatar.sm { width: 32px; height: 32px; font-size: 13px; }
.avatar.lg { width: 96px; height: 96px; font-size: 30px; }

/* ---------- liste ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; align-items: center; gap: 12px; padding: 12px 0;
  border-bottom: 1px solid var(--bordo); }
.lista li:last-child { border-bottom: 0; }
.lista .cresci { flex: 1 1 auto; min-width: 0; }
.lista strong { display: block; }

.tabella-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--bordo);
  white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--grigio); }
td.avvolgi, th.avvolgi { white-space: normal; }

/* ---------- orologio / timbratura ---------- */
.orologio { font-size: 44px; font-weight: 700; letter-spacing: -1px; margin: 0; }
.grande-esito { font-size: 26px; font-weight: 700; margin: 8px 0; }
.cerchio { width: 76px; height: 76px; border-radius: 50%; display: inline-flex;
  align-items: center; justify-content: center; margin-bottom: 8px; }
.cerchio.ok { background: var(--ok-bg); }
.cerchio.ko { background: var(--ko-bg); }
.cerchio svg { width: 40px; height: 40px; }
.cerchio.ok svg { fill: var(--ok); }
.cerchio.ko svg { fill: var(--ko); }

/* ---------- calendario ---------- */
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { text-align: center; font-size: 11px; padding: 6px 2px; }
.cal td { border: 1px solid var(--bordo); height: 62px; vertical-align: top;
  padding: 3px; white-space: normal; font-size: 12px; }
.cal td.fuori { background: #fafbfc; color: #b6bfca; }
.cal td.oggi { outline: 2px solid var(--brand); outline-offset: -2px; }
.cal .num { font-weight: 600; font-size: 12px; }
.cal .voce { display: block; border-radius: 4px; padding: 1px 4px; margin-top: 2px;
  font-size: 10px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; }
.cal .voce.approvata { background: var(--ok-bg); color: var(--ok); }
.cal .voce.in_attesa { background: var(--attesa-bg); color: var(--attesa); }
.cal .voce.rifiutata { background: var(--ko-bg); color: var(--ko);
  text-decoration: line-through; }
.legenda { display: flex; flex-wrap: wrap; gap: 12px; font-size: 13px; margin: 12px 0 0; }
.legenda span::before { content: ""; display: inline-block; width: 11px; height: 11px;
  border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legenda .l-ok::before { background: var(--ok); }
.legenda .l-att::before { background: var(--attesa); }
.legenda .l-ko::before { background: var(--ko); }
.navmese { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 12px; }

/* ---------- barra inferiore ---------- */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--bordo);
  padding-bottom: env(safe-area-inset-bottom);
}
.barra a {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px; font-size: 10.5px; color: var(--grigio); text-decoration: none;
}
.barra a.attivo { color: var(--brand); font-weight: 700; }
.barra svg { width: 23px; height: 23px; fill: currentColor; }

/* ---------- scanner ---------- */
#video { width: 100%; max-width: 480px; border-radius: var(--raggio); background: #000;
  aspect-ratio: 3/4; object-fit: cover; }
.mirino { position: relative; display: inline-block; }
.mirino::after { content: ""; position: absolute; inset: 15%; border: 3px solid var(--brand);
  border-radius: 14px; pointer-events: none; }

/* ---------- QR da stampare ---------- */
.foglio { background: #fff; padding: 28px; border-radius: var(--raggio);
  border: 1px solid var(--bordo); text-align: center; }
.foglio .qr { width: 100%; max-width: 380px; margin: 0 auto; display: block; }
.foglio h2 { font-size: 26px; margin: 0 0 4px; }
.foglio .istruzioni { text-align: left; max-width: 420px; margin: 18px auto 0;
  font-size: 14px; color: var(--ink-2); }

@media print {
  .top, .barra, .no-stampa, .avviso { display: none !important; }
  body { background: #fff; padding: 0; }
  main { max-width: none; padding: 0; }
  .foglio { border: 0; padding: 0; }
}
