/* ── Layout postazione (mobile first) ──────────────────────────────────── */
body { min-height: 100dvh; }
#app { min-height: 100dvh; }

.screen { padding: 20px 16px calc(24px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }
.screen.center { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; }

.brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; font-weight: 700; font-size: 20px; letter-spacing: .02em; }
.brand .logo {
  width: 38px; height: 38px; border-radius: 10px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-size: 18px;
}
.lead { color: var(--text-muted); margin: -6px 0 18px; line-height: 1.45; }
.msg-error { background: var(--danger-soft); color: var(--danger); border-radius: var(--r-md); padding: 10px 14px; margin-bottom: 14px; font-size: 15px; }

#pin-input { letter-spacing: .3em; text-align: center; font-size: 22px; }

/* ── Barra superiore ───────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: linear-gradient(180deg, #1f2a4e 0%, #1a2342 100%); color: #fff;
}
.topbar .where { flex: 1; min-width: 0; }
.topbar .varco { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .op    { font-size: 13px; color: #c6cde0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .btn   { text-decoration: none; min-height: 36px; padding: 0 12px; font-size: 13px; color: #fff; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.2); }

main.tab { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); max-width: 520px; margin: 0 auto; }

/* ── Navigazione inferiore ─────────────────────────────────────────────── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; min-height: 62px; border: 0; background: none;
  color: var(--text-muted); font-size: 13px; font-weight: 600;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
}
.tabs button .ico { font-size: 22px; line-height: 1; }
.tabs button.active { color: var(--brand); background: var(--brand-soft); }
.tabs .badge {
  display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px;
  border-radius: 10px; background: var(--in); color: #fff; font-size: 12px; line-height: 20px;
}

/* ── Autocompletamento ─────────────────────────────────────────────────── */
.sug {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 15;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--r-md);
  box-shadow: var(--shadow-md); overflow: hidden;
}
.sug-item { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 16px; line-height: 1.3; }
.sug-item:last-child { border-bottom: 0; }
.sug-item:active { background: var(--brand-soft); }
.sug-item small { display: block; color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.sug-item .dentro { float: right; font-size: 11px; font-weight: 700; color: var(--in); background: var(--in-soft); padding: 2px 8px; border-radius: 10px; }

/* ── Bottoni INGRESSO / USCITA ─────────────────────────────────────────── */
.actions-gate { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 8px; }
.gate-btn {
  min-height: 92px; border: 0; border-radius: var(--r-lg);
  color: #fff; font-size: 20px; font-weight: 800; letter-spacing: .04em;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  box-shadow: var(--shadow-md);
  transition: transform .08s, opacity .15s, box-shadow .15s;
}
.gate-btn .arrow { font-size: 28px; line-height: 1; }
.gate-btn.in  { background: var(--in); }
.gate-btn.out { background: var(--out); }
.gate-btn:active:not(:disabled) { transform: scale(.97); }
.gate-btn:disabled { opacity: .4; }
.gate-btn.suggested { box-shadow: 0 0 0 4px rgba(36, 81, 199, .45), var(--shadow-md); }
.hint { text-align: center; font-size: 13px; color: var(--text-muted); min-height: 18px; margin-top: 10px; }

/* ── Liste (presenti / ultime) ─────────────────────────────────────────── */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.search { margin-bottom: 12px; height: 46px; }

.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 12px 14px; margin-bottom: 8px;
}
.row .main { flex: 1; min-width: 0; }
.row .nome { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.row .sub  { font-size: 13px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.row .time { font-size: 13px; color: var(--text-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row.annullato { opacity: .55; }
.row.annullato .nome { text-decoration: line-through; }

.tag { display: inline-block; font-size: 11px; font-weight: 800; letter-spacing: .04em; padding: 2px 8px; border-radius: 10px; margin-right: 6px; vertical-align: 1px; }
.tag.in  { color: var(--in);  background: var(--in-soft); }
.tag.out { color: var(--out); background: var(--out-soft); }
.tag.void { color: var(--danger); background: var(--danger-soft); }

.empty { text-align: center; color: var(--text-muted); padding: 36px 12px; }
