:root {
  --brand: #1b3a5b; --brand-2: #27568a; --ok: #2e7d32; --no: #c62828;
  --bg: #eef1f4; --card: #fff; --line: #dfe4ea; --txt: #1a1a1a; --muted: #6b7480;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { font-family: system-ui, "Segoe UI", Roboto, sans-serif; color: var(--txt);
  background: var(--bg); display: flex; flex-direction: column; min-height: 100vh; }

header.app { background: #fff; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 10px; padding: 8px 14px; position: sticky; top: 0; z-index: 10; }
header.app img { height: 36px; }
header.app .title { font-size: .95rem; font-weight: 600; color: var(--brand); }
header.app .net { margin-left: auto; font-size: .72rem; padding: 4px 9px; border-radius: 20px; }
.net.online { background: #e6f4ea; color: var(--ok); }
.net.offline { background: #fdecea; color: var(--no); }

main { flex: 1; width: 100%; max-width: 760px; margin: 0 auto; padding: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; margin-bottom: 12px; }
.card > h2 { margin: 0 0 4px; font-size: 1.05rem; color: var(--brand); }
.card > .sub { margin: 0 0 12px; color: var(--muted); font-size: .85rem; }

label { display: block; font-size: .8rem; color: #4a5560; margin: 10px 0 4px; font-weight: 500; }
input, select { width: 100%; padding: 11px; border: 1px solid #c7ced6; border-radius: 9px;
  font-size: 1rem; background: #fff; color: var(--txt); }
input:focus, select:focus { outline: 2px solid var(--brand-2); border-color: var(--brand-2); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

button.btn { border: 0; border-radius: 10px; padding: 13px 16px; font-size: 1rem;
  font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
button.btn.sec { background: #eaeef3; color: var(--brand); }
button.btn.danger { background: #fbe9e7; color: var(--no); }
button.btn:disabled { opacity: .5; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.pill { display: inline-block; background: #eef2f6; border-radius: 20px; padding: 3px 10px;
  font-size: .74rem; color: #44515f; }
.chip-no { background: #fdecea; color: var(--no); }
.small { font-size: .8rem; color: var(--muted); }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.item .hd { display: flex; align-items: center; gap: 8px; }
.item .hd .grow { flex: 1; }

/* Login */
.login-card { max-width: 380px; margin: 6vh auto 0; text-align: center; }
.login-logo { width: 150px; margin: 4px auto 10px; display: block; }

/* Launcher a riquadri */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .tiles { grid-template-columns: 1fr; } }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px 16px; text-align: center; cursor: pointer; transition: transform .08s, box-shadow .12s; }
.tile:active { transform: scale(.98); }
.tile:hover { box-shadow: 0 4px 14px rgba(27,58,91,.12); border-color: var(--brand-2); }
.tile .ic { font-size: 2.4rem; line-height: 1; }
.tile .tt { font-weight: 700; color: var(--brand); margin-top: 8px; font-size: 1.05rem; }
.tile .ds { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.tile.soon { opacity: .55; cursor: default; }

.userbar { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.userbar .grow { flex: 1; }
.userbar .who { font-weight: 600; }

/* Segmenti (categoria) e bottoni esito */
.iv-btns { display: grid; gap: 10px; margin: 4px 0 8px; }
.iv-btns.two { grid-template-columns: 1fr 1fr; }
.iv-btns button { padding: 13px 0; font-size: 1rem; font-weight: 700; border: 2px solid var(--line);
  border-radius: 12px; background: #fff; cursor: pointer; }
.iv-btns button.sel-si { background: var(--brand); color: #fff; border-color: var(--brand); }

/* Foto */
.foto-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 6px; }
.foto-th { position: relative; width: 90px; height: 90px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.foto-th img { width: 100%; height: 100%; object-fit: cover; }
.foto-th .foto-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border: 0;
  border-radius: 50%; background: rgba(198,40,40,.92); color: #fff; font-size: .8rem; cursor: pointer; }
button.btn.ghost { background: none; color: var(--brand); cursor: pointer; border: 0; font-weight: 600; padding: 8px; }
.gal-th { width: 108px; height: 108px; }
.gal-th a { display: block; width: 100%; height: 100%; }

/* Barra aggiornamento app */
.upd-banner { position: fixed; left: 0; right: 0; bottom: 0; z-index: 100;
  background: var(--brand); color: #fff; display: flex; align-items: center;
  justify-content: center; gap: 14px; padding: 10px 14px; font-size: .9rem; font-weight: 600;
  box-shadow: 0 -2px 10px rgba(0,0,0,.18); }
.upd-banner button { background: #fff; color: var(--brand); border: 0; border-radius: 8px;
  padding: 8px 16px; font-weight: 700; cursor: pointer; }

/* Coda foto offline */
.card.coda { background: #fff8e1; border-color: #f0d98a; }

/* Dashboard */
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-align: center; }
.stat .n { font-size: 2rem; font-weight: 800; color: var(--brand); line-height: 1; }
.stat .et { font-size: .85rem; color: var(--txt); margin-top: 4px; font-weight: 600; }
.stat .sub2 { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.chip-ok { background: #e6f4ea; color: var(--ok); }
.riga2 { display: flex; align-items: center; gap: 8px; padding: 8px 2px; border-top: 1px solid var(--line); }
.riga2:first-of-type { border-top: 0; }
.riga2 .grow { flex: 1; }
.riga2 .col { width: 64px; text-align: center; }
.riga2.head { font-size: .78rem; color: var(--muted); font-weight: 600; text-transform: uppercase; }

.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #263238; color: #fff; padding: 10px 16px; border-radius: 24px; font-size: .9rem;
  opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 50; max-width: 90%; }
.toast.show { opacity: .96; }
.hidden { display: none !important; }
