/* Font aziendale: Satoshi (variabile, pesi 300-900) */
@font-face {
  font-family: "Satoshi";
  src: url("../fonts/Satoshi-Variable.woff2") format("woff2");
  font-weight: 300 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Satoshi";
  src: url("../fonts/Satoshi-VariableItalic.woff2") format("woff2");
  font-weight: 300 900;
  font-style: italic;
  font-display: swap;
}

/* Palette dalla tavola di stile Leonardelli:
   Verde #5bb65f · Nero 90% #3c3c3b · Nero 10% #ededed */
:root {
  --verde: #5bb65f;
  --nero-90: #3c3c3b;
  --nero-10: #ededed;

  --bg: var(--nero-10);
  --surface: #ffffff;
  --text: var(--nero-90);
  --muted: #6b6b69;
  --border: #dcdcda;
  --brand: var(--nero-90);
  /* Il verde del marchio su bianco ha poco contrasto per i testi:
     per link e pulsanti si usa una tonalità più scura dello stesso verde */
  --accent: #37853b;
  --accent-marchio: var(--verde);
  --accent-soft: #e6f4e7;
  --warn: #b25e00;
  --warn-soft: #fff1de;
  --danger: #b42318;
  --danger-soft: #fdecea;
  --info-soft: #e8f0fe;
  /* Stato (palette fissa, sempre con icona + testo) */
  --stato-ok: #0ca30c;
  --stato-attenzione: #fab219;
  --stato-critico: #d03b3b;
  --stato-ok-testo: #006300;
  --barra-fondo: #e9ecf1;
  --barra-neutra: #5b7fa6;
  --tacca: #1d2330;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(60, 60, 59, .06), 0 1px 3px rgba(60, 60, 59, .10);
  --font: "Satoshi", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.5; font-size: 16px; font-weight: 450; }
a { color: var(--accent); text-underline-offset: 2px; }
strong, b { font-weight: 700; }
h1 { font-size: 1.75rem; font-weight: 800; letter-spacing: -.015em; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; font-weight: 700; letter-spacing: -.01em; margin: 2rem 0 .75rem; }
h3 { font-size: 1rem; font-weight: 700; margin: .25rem 0; }

/* --- Barra superiore e menu --- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 14px;
  height: var(--topbar-h); padding: 0 20px; background: var(--surface); color: var(--text);
  border-bottom: 3px solid var(--verde);
}
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); }
.brand img { height: 34px; width: auto; display: block; }
.brand span { font-size: .8rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
  border-left: 1px solid var(--border); padding-left: 12px; }
.topbar-user { margin-left: auto; font-size: .9rem; font-weight: 600; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-toggle { display: none; }
.menu-btn { display: none; font-size: 1.5rem; cursor: pointer; padding: 4px 8px; color: var(--text); }

.layout { display: flex; min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--nero-90); color: #fff;
  padding: 18px 12px; display: flex; flex-direction: column; gap: 2px;
}
.sidebar a { display: block; padding: 8px 12px; border-radius: 8px; color: #f2f2f1; text-decoration: none; font-weight: 500;
  border-left: 3px solid transparent; }
.sidebar a:hover { background: rgba(255, 255, 255, .08); }
.sidebar a.attivo { background: rgba(91, 182, 95, .18); border-left-color: var(--verde); color: #fff; font-weight: 700; }
.nav-gruppo { margin: 16px 12px 4px; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #a9a9a6; }
.nav-esci { margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, .12); }
.nav-esci button { width: 100%; text-align: left; padding: 8px 12px; border: 0; background: none; color: #ffb4ad; font: inherit; font-weight: 600; cursor: pointer; border-radius: 8px; }
.nav-esci button:hover { background: rgba(255, 255, 255, .08); }

.content { flex: 1; min-width: 0; padding: 24px 32px 48px; max-width: 1200px; }

@media (max-width: 800px) {
  .menu-btn { display: block; }
  .brand img { height: 28px; }
  .brand span, .topbar-user { display: none; }
  .sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; z-index: 15; transform: translateX(-100%);
    transition: transform .2s ease; box-shadow: var(--shadow); overflow-y: auto;
  }
  .menu-toggle:checked ~ .layout .sidebar { transform: none; }
  .content { padding: 16px 16px 40px; }
}

/* --- Accesso --- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: linear-gradient(180deg, var(--nero-10) 0%, var(--nero-10) 60%, #e2e2e0 100%); }
.auth-box { width: 100%; max-width: 400px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 32px 28px; border-top: 4px solid var(--verde); }
.auth-brand { margin-bottom: 22px; text-align: center; }
.auth-brand img { width: 230px; max-width: 100%; height: auto; display: block; margin: 0 auto 6px; }
.auth-brand span { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .16em; color: var(--muted); }
.auth h1 { font-size: 1.35rem; }

/* --- Form --- */
.form { display: flex; flex-direction: column; gap: 6px; }
.form-stretto { max-width: 420px; }
.form label { font-weight: 600; font-size: .9rem; margin-top: 8px; }
.form input, .filtri input[type=search] {
  font: inherit; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); width: 100%;
}
.form input:focus, .filtri input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
input[autocomplete="one-time-code"] { font-size: 1.5rem; letter-spacing: .4em; text-align: center; }
.form-secondario { margin-top: 12px; }
.errore { color: var(--danger); font-size: .85rem; }
.nota { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-block; padding: 9px 18px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); text-decoration: none; font: inherit; font-weight: 700; cursor: pointer;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primario { background: var(--accent); border-color: var(--accent); color: #fff; margin-top: 14px; }
.btn-primario:hover { background: #2d6e31; color: #fff; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; text-decoration: underline; }

/* --- Messaggi --- */
.messaggi { margin-bottom: 16px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 8px; background: var(--info-soft); font-size: .92rem; margin-bottom: 8px; }
.msg-success { background: var(--accent-soft); }
.msg-warning { background: var(--warn-soft); }
.msg-error { background: var(--danger-soft); color: var(--danger); }

/* --- Home --- */
.sottotitolo { color: var(--muted); margin: 0 0 20px; }
.contatori { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.contatore {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px;
  text-decoration: none; color: var(--text); display: flex; flex-direction: column;
}
.contatore { border-left: 4px solid var(--verde); }
.contatore strong { font-size: 2rem; font-weight: 800; color: var(--text); line-height: 1.1; }
.contatore span { color: var(--muted); font-size: .9rem; }

/* --- Elenchi e schede --- */
.intestazione { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.filtri { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filtri input[type=search] { max-width: 280px; }
.tabs { display: flex; gap: 4px; background: var(--surface); border-radius: 8px; padding: 4px; box-shadow: var(--shadow); }
.tabs a { padding: 6px 12px; border-radius: 6px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.tabs a.attivo { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.griglia { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.scheda { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.scheda-link { display: block; color: inherit; text-decoration: none; height: 100%; }
.scheda-link:hover h3 { color: var(--accent); }
.scheda-img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); }
.scheda-img-vuota { display: grid; place-items: center; color: var(--muted); font-size: .85rem; }
.scheda-corpo { padding: 12px 14px 14px; }
.scheda-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 0; }
.date { color: var(--muted); font-size: .88rem; margin: 4px 0 0; }
.scade { display: inline-block; margin-left: 6px; color: var(--warn); font-weight: 600; }
.allegati-n { color: var(--muted); font-size: .8rem; margin: 4px 0 0; }

.badge { font-size: .72rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--bg); color: var(--muted); }
.badge-volantino { background: var(--info-soft); color: var(--text); }
.badge-bolli { background: var(--warn-soft); color: var(--warn); }
.badge-promo_brand { background: var(--accent-soft); color: var(--accent); }
.badge-bozza, .badge-stato-scaduta { background: var(--danger-soft); color: var(--danger); }
.badge-stato-in_corso { background: var(--accent-soft); color: var(--accent); }
.brand-tag { font-size: .8rem; font-weight: 600; }

.vuoto { color: var(--muted); padding: 32px 0; }
.briciole { color: var(--muted); font-size: .85rem; margin: 0 0 8px; }

/* --- Dettaglio --- */
.dettaglio { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 24px; align-items: start; }
.dettaglio-img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow); }
.descrizione { background: var(--surface); padding: 4px 16px; border-radius: var(--radius); box-shadow: var(--shadow); }
.allegati { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.allegati li { display: flex; align-items: center; gap: 10px; background: var(--surface); padding: 10px 12px; border-radius: 8px; box-shadow: var(--shadow); }
.allegati .ext { font-size: .7rem; font-weight: 700; text-transform: uppercase; background: var(--bg); color: var(--muted); padding: 2px 6px; border-radius: 4px; min-width: 42px; text-align: center; }
.allegati .scarica { margin-left: auto; font-size: .85rem; }
.insegna { font-size: .72rem; font-weight: 600; padding: 2px 7px; border-radius: 999px; white-space: nowrap; border: 1px solid var(--line, #ddd); color: var(--muted); }
.insegna-leonardelli { color: var(--accent); border-color: currentColor; }
.insegna-trony { color: #b4232a; border-color: currentColor; }
@media (max-width: 800px) { .dettaglio { grid-template-columns: 1fr; } }

/* --- Risultati --- */
section { margin-bottom: 8px; }
.etichetta { margin: 0; color: var(--muted); font-size: .85rem; }
.stato { display: inline-flex; align-items: center; gap: 4px; font-size: .8rem; font-weight: 600; white-space: nowrap; color: var(--text); }
.stato-in_linea span { color: var(--stato-ok); }
.stato-vicino span { color: var(--stato-attenzione); }
.stato-sotto span { color: var(--stato-critico); }
.stato-bg-in_linea { background: var(--stato-ok); }
.stato-bg-vicino { background: var(--stato-attenzione); }
.stato-bg-sotto { background: var(--stato-critico); }
.ok { color: var(--stato-ok-testo); font-weight: 600; font-size: .85rem; }

.barra { position: relative; display: block; height: 10px; background: var(--barra-fondo); border-radius: 99px; overflow: visible; }
.barra-grande { height: 14px; margin: 10px 0 14px; }
.barra-piccola { height: 8px; flex: 1; min-width: 60px; }
.riempimento { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 99px; min-width: 4px; }
.riempimento-neutro { background: var(--barra-neutra); }
.tacca { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--tacca); border-radius: 1px; }

.kpi-negozio, .premio-mio { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; }
.kpi-evidenza { border-left: 4px solid var(--verde); }
.kpi-testa { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.kpi-testa h3 { margin: 0; font-size: 1rem; }
.kpi-valore { font-size: 2.2rem; font-weight: 700; line-height: 1.1; margin-top: 6px; }
.kpi-valore span { font-size: .95rem; font-weight: 400; color: var(--muted); }
.kpi-dettagli { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px 16px; margin: 0; }
.kpi-dettagli dt { color: var(--muted); font-size: .8rem; }
.kpi-dettagli dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }
.kpi-dettagli small { color: var(--muted); font-weight: 400; }

.premio-mio { border-left: 4px solid var(--verde); margin-bottom: 8px; }
.premio-testa { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
.premio-totale { font-size: 2.6rem; font-weight: 700; line-height: 1.1; margin: 2px 0 0; color: var(--accent); font-variant-numeric: tabular-nums; }
.premio-posizione { text-align: right; color: var(--muted); font-size: .9rem; }
.premio-potenziale { margin: 6px 0 0; color: var(--muted); font-size: .92rem; }
.premio-potenziale strong { color: var(--text); }
.non-applicato, .non-applicato dd, .non-applicato dt { color: var(--muted); }
.kpi-dettagli .non-applicato dd { font-weight: 400; }
.premio-posizione strong { color: var(--text); font-size: 1.2rem; }

.confronto { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 6px 0; }
.confronto-riga {
  display: grid; grid-template-columns: 110px minmax(80px, 1fr) 64px 130px; grid-template-areas: "nome barra valore stato" ". extra extra extra";
  align-items: center; gap: 2px 12px; padding: 10px 16px; color: var(--text); text-decoration: none; border-left: 4px solid transparent;
}
.confronto-riga:hover { background: var(--bg); }
.confronto-riga.mia { border-left-color: var(--verde); background: var(--accent-soft); }
.confronto-nome { grid-area: nome; font-weight: 600; }
.confronto-riga .barra { grid-area: barra; }
.confronto-valore { grid-area: valore; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.confronto-stato { grid-area: stato; }
.confronto-extra { grid-area: extra; color: var(--muted); font-size: .8rem; }
@media (max-width: 600px) {
  .confronto-riga { grid-template-columns: 1fr auto; grid-template-areas: "nome valore" "barra barra" "stato stato" "extra extra"; gap: 6px; }
  .premio-posizione { text-align: left; }
}

.tabella-scroll { overflow-x: auto; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); }
.tabella { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabella th, .tabella td { padding: 8px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tabella thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.tabella .num { text-align: right; font-variant-numeric: tabular-nums; }
.tabella .col-barra { min-width: 170px; }
.tabella .col-barra .barra, .tabella .col-barra .barra-valore { display: inline-block; vertical-align: middle; }
.tabella .col-barra .barra { width: calc(100% - 80px); }
.barra-valore { width: 72px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tabella tbody tr:hover { background: var(--bg); }
.tabella tfoot th { border-bottom: 0; }
.riga-mia { background: var(--accent-soft); font-weight: 600; }
.riga-corrente td { font-weight: 600; }
.rettifiche { margin-top: 12px; }
.rettifiche summary, .premi-tutti summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.premi-tutti summary h2 { display: inline; }
.premi-tutti[open] summary { margin-bottom: 12px; }
/* --- Ricerca e risorse --- */
.nav-cerca { margin: 0 2px 10px; }
.nav-cerca input, .ricerca-grande input {
  font: inherit; width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 99px;
  background: var(--bg); color: var(--text);
}
.nav-cerca input { background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .18); color: #fff; padding-left: 16px; }
.nav-cerca input::placeholder { color: #c4c4c1; }
.nav-cerca input:focus { outline: 2px solid var(--verde); border-color: transparent; }
.ricerca-grande { display: flex; gap: 8px; margin: 8px 0 20px; max-width: 640px; }
.ricerca-grande input { background: var(--surface); padding: 12px 14px; font-size: 1.05rem; }
.ricerca-grande .btn-primario { margin-top: 0; }

.elenco-risorse, .elenco-brand { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.elenco-risorse li { display: flex; align-items: flex-start; gap: 12px; background: var(--surface); padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); }
.elenco-risorse .ext { font-size: .7rem; font-weight: 700; text-transform: uppercase; background: var(--bg); color: var(--muted); padding: 2px 6px; border-radius: 4px; min-width: 46px; text-align: center; margin-top: 2px; }
.risorsa-corpo { flex: 1; min-width: 0; }
.risorsa-titolo { font-weight: 600; }
.risorsa-descrizione { color: var(--muted); font-size: .9rem; margin-top: 4px; overflow-wrap: anywhere; }
.elenco-risorse .scarica { font-size: .85rem; white-space: nowrap; }
.elenco-brand li > a, .elenco-brand .voce-semplice {
  display: block; background: var(--surface); padding: 12px 14px; border-radius: 8px; box-shadow: var(--shadow); color: var(--text); text-decoration: none;
}
.elenco-brand li > a:hover strong { color: var(--accent); }

.alfabeto { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.alfabeto a { min-width: 30px; text-align: center; padding: 4px 6px; border-radius: 6px; background: var(--surface); box-shadow: var(--shadow); text-decoration: none; font-weight: 600; }
.brand-tutti { display: flex; flex-wrap: wrap; gap: 6px; }
.brand-tutti a { padding: 5px 10px; background: var(--surface); border-radius: 99px; box-shadow: var(--shadow); color: var(--text); text-decoration: none; font-size: .9rem; }
.brand-tutti a:hover { color: var(--accent); }

.schede-brand { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.blocco-brand { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin: 0; }
.blocco-brand.mia { border-left: 4px solid var(--verde); }
.blocco-brand h3 { margin: 0 0 8px; font-size: 1rem; }
.scheda-categoria { margin-bottom: 24px; }
.scheda-categoria > h2 { margin-top: 12px; }
.testo-contatti { overflow-wrap: anywhere; font-size: .95rem; }
.testo-contatti a.tel { white-space: nowrap; }
.accessi { margin-top: 10px; padding: 8px 10px; background: var(--warn-soft); border-radius: 8px; }
.accessi summary { cursor: pointer; font-weight: 600; color: var(--warn); }

.griglia-telefoni { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.scheda-telefoni { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 18px; margin: 0; }
.scheda-telefoni.mia { border-left: 4px solid var(--verde); }
.scheda-telefoni h2 { margin: 0 0 8px; font-size: 1rem; }
.scheda-telefoni ul { list-style: none; margin: 0; padding: 0; }
.scheda-telefoni li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.scheda-telefoni li:last-child { border-bottom: 0; }
.scheda-telefoni strong { font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.scheda-telefoni small { display: block; color: var(--muted); }
/* --- Griglia documenti --- */
.filtri form { flex: 1; max-width: 320px; }
.scheda { position: relative; }
.scheda-img-vuota { position: relative; overflow: hidden; }
.scheda-img-vuota > span { font-size: 1.4rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: #fff; opacity: .95; }
.scheda-img-vuota > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #fff; }
.scheda-tipo-pdf { background: #b54a3c; }
.scheda-tipo-drive { background: var(--accent); }
.scheda-tipo-video { background: var(--nero-90); }
.scheda-tipo-link { background: #4f6d8a; }
.scheda-tipo-nota { background: #8a7a4f; }
.scheda-tipo-xlsx, .scheda-tipo-xls { background: #2e7d4f; }
.scheda-tipo-docx, .scheda-tipo-doc { background: #2f5b9a; }
.scheda-testo { padding: 0 14px 12px; font-size: .9rem; }
.scheda-testo summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.scheda-modifica { position: absolute; top: 8px; right: 8px; background: rgba(255,255,255,.92); padding: 2px 10px; border-radius: 99px; font-size: .8rem; font-weight: 700; box-shadow: var(--shadow); }
.miniatura { width: 46px; height: 46px; object-fit: cover; border-radius: 6px; flex-shrink: 0; background: var(--bg); }

.codici-centralino { margin-top: 28px; }
.istruzioni-codici { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 4px 18px; margin-bottom: 16px; border-left: 4px solid var(--verde); }
.scheda-codici h3 { margin: 0 0 4px; font-size: 1.05rem; }
.scheda-codici .nota { margin: 0 0 8px; }
.scheda-codici li.mio { background: var(--accent-soft); margin: 0 -10px; padding: 6px 10px; border-radius: 6px; }
.codice { font-size: 1.15rem; letter-spacing: .06em; white-space: nowrap; }

.filtri select { font: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
