/* Gestionale NFC: stesso look del sito (v3.18). Tema chiaro o scuro in base al browser. */
:root {
  color-scheme: light dark;
  --bg: #f4f6fb;
  --card: #fff;
  --ink: #0b1526;
  --muted: #56637a;
  --line: rgba(11, 21, 38, .12);
  --blue: #2f55d4;
  --accent: #3558d8;
  --campo: #fff;
  --campo-bordo: rgba(11, 21, 38, .3);
  --ok: #17633a;
  --ok-bg: #e3f5e9;
  --warn: #7a4f00;
  --warn-bg: #fff1cc;
  --err: #b42318;
  --err-bg: #fdecea;
  --brand: linear-gradient(90deg, #2a8be6, #7b4ff0);
  --viola: #7b4ff0;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(11, 21, 38, .06), 0 8px 24px rgba(11, 21, 38, .06);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --card: #101218;
    --ink: #f3f6fc;
    --muted: #aab6cb;
    --line: rgba(255, 255, 255, .13);
    --blue: #8aa4ff;
    --accent: #6f8dff;
    --campo: rgba(255, 255, 255, .06);
    --campo-bordo: rgba(255, 255, 255, .45);
    --ok: #a7f3c0;
    --ok-bg: rgba(34, 197, 94, .14);
    --warn: #fcd34d;
    --warn-bg: rgba(245, 158, 11, .16);
    --err: #fca5a5;
    --err-bg: rgba(239, 68, 68, .16);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }
html { font-size: clamp(15px, 14px + 0.2vw, 17px); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg);
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--blue); text-decoration: none; text-underline-offset: 4px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 1em; }
.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 20px; }
main.wrap { padding-top: 32px; padding-bottom: 64px; flex: 1 0 auto; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* Avviso di manutenzione: una striscia in cima a ogni pagina */
.avviso { padding: 10px 20px; background: #f5b301; color: #111; text-align: center; font-weight: 600; }

/* Testata: nera come le intestazioni del sito, con la luce viola e la riga a gradiente */
.testata {
  position: relative; color: #fff;
  background:
    radial-gradient(700px 220px at 92% 150%, rgba(123, 79, 240, .6), transparent 70%),
    radial-gradient(520px 200px at 0% 150%, rgba(42, 139, 230, .38), transparent 70%),
    #000;
}
.testata::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: linear-gradient(90deg, #2a8be6, #7b4ff0 55%, #b14ff0); }
.testata .wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 28px; min-height: 84px; padding-top: 10px; padding-bottom: 12px; }
.logo img { height: 56px; width: auto; filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .45)); }
.testata nav { display: flex; gap: 4px; }
.testata nav a { padding: 8px 14px; border-radius: 8px; color: #fff; font-weight: 600; text-decoration: none; transition: background-color .15s, box-shadow .15s; }
.testata nav a:hover { background: rgba(255, 255, 255, .08); box-shadow: inset 0 -2px 0 #6f8dff; }
.testata nav a.active { background: rgba(255, 255, 255, .16); box-shadow: inset 0 -2px 0 #6f8dff; }
.utente { margin-left: auto; display: flex; align-items: center; gap: 12px; color: #d6deeb; font-size: .9rem; }
.utente form { margin: 0; }
@media (max-width: 640px) { .logo img { height: 44px; } .utente span { display: none; } }

/* Bottoni: come sul sito (gradiente NFC il principale, contorno il secondario) */
.btn {
  display: inline-block; padding: 11px 20px; border: 1px solid transparent; border-radius: 10px;
  background: var(--brand); color: #fff; font: inherit; font-weight: 600; line-height: 1.3;
  text-decoration: none; cursor: pointer; transition: transform .15s, box-shadow .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(91, 110, 240, .45); text-decoration: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--campo-bordo); }
.btn-ghost:hover { background: rgba(111, 141, 255, .12); box-shadow: none; }
.testata .btn-ghost, .login .btn-ghost { color: #fff; border-color: rgba(255, 255, 255, .7); background: rgba(0, 0, 0, .35); }
.btn-small { padding: 6px 12px; font-size: .88rem; }
.btn-elimina { padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: none; color: var(--err); font: inherit; font-size: .85rem; cursor: pointer; }
.btn-elimina:hover { border-color: var(--err); }
.azioni { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Superfici */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 24px; }
.card + .card, .card + form, form + .card, .blocco + .blocco { margin-top: 20px; }
.card > :last-child { margin-bottom: 0; }
.intestazione { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.intestazione h1 { margin: 0; }
.eyebrow { margin: 0 0 6px; font-size: .8rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.colonne { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); align-items: start; }

/* Messaggi */
.messaggi { list-style: none; padding: 0; margin: 0 0 20px; display: grid; gap: 8px; }
.messaggi li { padding: 12px 16px; border-radius: 10px; font-weight: 500; }
.messaggi .success, .ok { background: var(--ok-bg); color: var(--ok); }
.messaggi .info { background: rgba(111, 141, 255, .14); color: var(--ink); }
.messaggi .warning { background: var(--warn-bg); color: var(--warn); }
.messaggi .error, .err { background: var(--err-bg); color: var(--err); }
.err { padding: 12px 16px; border-radius: 10px; }

/* Form */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
input, select, textarea {
  width: 100%; padding: 10px 12px; font: inherit; color: inherit;
  background: var(--campo); border: 1px solid var(--campo-bordo); border-radius: 10px;
}
input[type="checkbox"] { width: auto; }
select option { background: var(--card); color: var(--ink); }
textarea { resize: vertical; }
.campi { display: grid; gap: 16px 20px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 20px; }
.campi > div:has(textarea) { grid-column: 1 / -1; }
.helptext { color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
.errorlist { list-style: none; padding: 0; margin: 4px 0; color: var(--err); font-size: .88rem; font-weight: 600; }
.filtri { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-bottom: 20px; }
.filtri label { margin: 0; font-size: .8rem; color: var(--muted); }
.filtri select { width: auto; min-width: 150px; margin-top: 4px; }
.in-riga { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.in-riga > div { flex: 1 1 180px; }

/* Tabelle */
.tabella { padding: 0; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 10px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
thead th { color: var(--muted); font-weight: 600; font-size: .8rem; white-space: nowrap; }
tbody tr:last-child > * { border-bottom: 0; }
td input, td select { min-width: 90px; }
td.prodotto input { min-width: 320px; }
/* Tutta la riga della home riprende la pratica */
.cliccabili tbody tr { position: relative; }
.cliccabili tbody tr:hover { background: rgba(111, 141, 255, .08); }
.riga-link { font-weight: 700; }
.riga-link::after { content: ""; position: absolute; inset: 0; }
.check { text-align: center; }
.si { color: var(--ok); font-weight: 700; }
.no { color: var(--muted); }
.scaduta { color: var(--err); font-weight: 700; }

/* Stato e checklist */
.stato { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; white-space: nowrap; background: rgba(111, 141, 255, .14); }
.stato.pagata { background: var(--ok-bg); color: var(--ok); }
.stato.da_pagare { background: var(--warn-bg); color: var(--warn); }
.checklist { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; padding: 0; margin: 0 0 24px; }
.checklist li { padding: 4px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: .85rem; color: var(--muted); }
.checklist .fatto { border-color: transparent; background: var(--ok-bg); color: var(--ok); font-weight: 600; }

/* Fido */
.fido { padding: 16px 20px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); margin-bottom: 20px; }
.fido.superato { border: 2px solid var(--err); background: var(--err-bg); color: var(--err); padding: 24px; }
.fido.superato strong { display: block; font-size: 1.6rem; letter-spacing: .02em; margin-bottom: 6px; }
.fido p { margin: 0; }

/* Dati in sola lettura */
.dati { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; margin: 0; }
.dati dt { color: var(--muted); font-size: .88rem; }
.dati dd { margin: 0; white-space: pre-line; }
.dati + .campi, .dati + .tabella { margin-top: 20px; }
details { margin-top: 16px; }
.documenti { list-style: none; padding: 0; margin: 0 0 16px; }
.documenti li { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.documenti form { margin: 0 0 0 auto; }
pre.email { white-space: pre-wrap; font: inherit; font-size: .9rem; margin: 12px 0 0; }

/* Login: come la home del sito, foto con il testo sul lato scuro */
.pagina-login { background: #000; }
.login { position: relative; flex: 1; display: flex; align-items: center; padding: 48px 0; color: #fff; overflow: hidden; }
.login-sfondo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 65% 78%; }
.login::before {
  content: ""; position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(90deg, rgba(11, 21, 38, .92) 0%, rgba(11, 21, 38, .75) 45%, rgba(11, 21, 38, .2) 85%);
}
.login .wrap { position: relative; z-index: 2; }
.login-box {
  width: min(440px, 100%); padding: 36px; border-radius: var(--radius);
  background: rgba(10, 12, 18, .78); border: 1px solid rgba(255, 255, 255, .13);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .5); backdrop-filter: blur(6px);
}
.login-box .logo img { height: 72px; margin-bottom: 20px; }
.login-box .eyebrow { color: #9fb0c8; }
.login-box p { color: #d6deeb; }
.login-box input { background: rgba(255, 255, 255, .06); color: #f3f6fc; border-color: rgba(255, 255, 255, .45); }
.login-box .campo { margin-bottom: 16px; }
.login-box .btn { width: 100%; margin-top: 8px; }
.login-box .err { background: rgba(239, 68, 68, .16); color: #fca5a5; }
@media (max-width: 820px) { .login::before { background: rgba(11, 21, 38, .8); } }
