/* Presenze — the terminal (paired iPad, landscape) and the small back office. */
:root {
  --bg: #f4f3ef; --panel: #fff; --line: #ddd8cc; --ink: #222; --muted: #6b6b66; --brand: #2f5a2f;
  --in: #2e7d32; --in-dark: #1b5e20; --out: #c62828; --out-dark: #8e0000; --warn-bg: #fff8e1; --warn-line: #f0dc9c;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
button, input, select { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.grow { flex: 1; }
.cap { text-transform: capitalize; }

/* ---------------------------------------------------------------- terminal */
body.term { height: 100vh; overflow: hidden; overscroll-behavior: none; user-select: none; -webkit-user-select: none; }
.screen { position: fixed; inset: 0; display: flex; flex-direction: column;
  padding: max(18px, env(safe-area-inset-top)) max(26px, env(safe-area-inset-right)) max(18px, env(safe-area-inset-bottom)) max(26px, env(safe-area-inset-left)); }
.top { display: flex; align-items: flex-start; gap: 16px; }
.top .place { font-weight: 600; color: var(--brand); font-size: 18px; }
.top .when { text-align: right; }
.top .day { color: var(--muted); font-size: 16px; }
.top .time { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
h1.ask { font-size: 30px; margin: 6px 0 18px; }
.names { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; align-content: start;
  overflow: auto; flex: 1; padding-bottom: 8px; }
.names button { min-height: 76px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-size: 22px; font-weight: 600; color: var(--brand); text-transform: capitalize; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.names button:active, .btn:active, .big:active { transform: scale(.97); }
.foot { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 15px; padding-top: 10px; }
.btn { min-height: 54px; padding: 0 24px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  cursor: pointer; font-size: 17px; font-weight: 500; color: #444; }
.btn.link { border: 0; background: none; color: var(--brand); text-decoration: underline; padding: 0 6px; min-height: 44px; }
.btn.warn { color: var(--out); border-color: #e8b4b0; }
.banner { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 12px; padding: 12px 18px; margin: 0 0 14px;
  font-weight: 600; }
.empty { color: var(--muted); max-width: 560px; }

.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 8px; }
.who { font-size: 34px; font-weight: 700; text-transform: capitalize; margin: 0; }
.sub { color: var(--muted); font-size: 18px; margin: 0; }
.msg { min-height: 1.5em; color: var(--out); font-weight: 600; margin: 8px 0 0; }
.state { font-size: 22px; margin: 4px 0 22px; }
.state.in { color: var(--in-dark); font-weight: 600; }
.big { width: min(560px, 80vw); min-height: 130px; border: 0; border-radius: 22px; cursor: pointer; color: #fff;
  font-size: 40px; font-weight: 800; letter-spacing: 1px; box-shadow: 0 3px 10px rgba(0,0,0,.18);
  display: flex; align-items: center; justify-content: center; gap: 28px; font-variant-numeric: tabular-nums; }
.big.E { background: var(--in); }
.big.U { background: var(--out); }
.big .t { font-weight: 600; opacity: .95; }
.big[disabled] { opacity: .5; }
.bar { display: flex; align-items: center; gap: 16px; }
.done-mark { width: 110px; height: 110px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 64px; color: #fff; background: var(--in); margin-bottom: 10px; }
.done-mark.U { background: var(--out); }
.done-mark.grey { background: #9e9e9e; }
.done-mark.err { background: #b26a00; }
.done-title { font-size: 32px; font-weight: 700; margin: 0; }
.back { position: absolute; top: max(18px, env(safe-area-inset-top)); left: max(26px, env(safe-area-inset-left)); }

dialog { border: 0; border-radius: 16px; padding: 0; max-width: min(680px, 92vw); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .in { padding: 22px 28px; }
dialog h2 { margin: 0 0 10px; font-size: 22px; }
dialog ul { padding-left: 20px; margin: 8px 0; }
dialog li { margin: 6px 0; }
dialog footer { display: flex; justify-content: flex-end; padding: 0 28px 22px; }
.draft { background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 8px; padding: 6px 10px; font-size: 14px; }

/* ---------------------------------------------------------------- login page */
body.loginpage { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login { background: var(--panel); border-radius: 16px; padding: 28px 32px; width: min(440px, 94vw); box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.login h1 { font-size: 22px; margin: 0 0 16px; color: var(--brand); }
.seg { display: flex; gap: 6px; margin-bottom: 14px; }
.seg button { flex: 1; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.login label { display: block; margin: 10px 0; }
.login input { display: block; width: 100%; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.go { display: block; width: 100%; text-align: center; margin-top: 12px; min-height: 50px; line-height: 50px; border: 0; border-radius: 12px;
  background: var(--brand); color: #fff; font-weight: 700; text-decoration: none; cursor: pointer; }
#err { color: var(--out); min-height: 1.4em; }

/* ---------------------------------------------------------------- back office */
body.admin { padding: 0 0 40px; }
.abar { display: flex; align-items: center; gap: 12px; background: var(--brand); color: #fff; padding: 12px 22px; }
.abar .title { font-size: 20px; font-weight: 600; }
.abar .btn { min-height: 38px; padding: 0 14px; }
.apage { max-width: 980px; margin: 0 auto; padding: 0 18px; }
.card { background: var(--panel); border-radius: 14px; padding: 18px 22px; margin: 18px 0; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card h2 { margin: 0 0 10px; font-size: 19px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 8px; border-bottom: 1px solid #eee; vertical-align: top; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row label { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); gap: 4px; }
.row input, .row select { padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; min-width: 180px; color: var(--ink); }
.small { font-size: 14px; }
.code { font: 700 30px/1.2 ui-monospace, Menlo, monospace; letter-spacing: 3px; color: var(--brand); }
.btn.small { min-height: 36px; padding: 0 12px; font-size: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #333; color: #fff; padding: 10px 18px;
  border-radius: 10px; z-index: 50; }
