:root {
  --brand: #1d4ed8;
  --brand-2: #2563eb;
  --brand-dark: #1e3a8a;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #16a34a;
  --danger: #dc2626;
  --radius: 18px;
  --shadow: 0 10px 30px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body { display: flex; flex-direction: column; min-height: 100%; }

/* prevent iOS auto-zoom on focus: inputs must be >=16px */
input, select, button, textarea { font-size: 17px; font-family: inherit; }

/* ---- top bar ---- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: max(env(safe-area-inset-top), 14px) 22px 14px;
  background: var(--brand);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; }
.brand-logo { width: 34px; height: 34px; border-radius: 9px; }
.admin-link {
  color: #fff; text-decoration: none; font-weight: 600; font-size: 15px;
  padding: 9px 16px; border: 1.5px solid rgba(255,255,255,.5); border-radius: 999px;
}
.admin-link:active { background: rgba(255,255,255,.15); }

/* ---- kiosk layout ---- */
.kiosk-main {
  flex: 1; width: 100%; max-width: 760px; margin: 0 auto;
  padding: 28px 22px max(env(safe-area-inset-bottom), 28px);
}
.view { display: none; animation: fade .25s ease; }
.view.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 34px; margin: 6px 0 8px; letter-spacing: -.5px; }
.lead { font-size: 19px; color: var(--muted); margin: 0 0 26px; }
.muted { color: var(--muted); }

/* ---- home choices ---- */
.choice { display: grid; gap: 18px; margin-top: 10px; }
@media (min-width: 620px) { .choice { grid-template-columns: 1fr 1fr; } }

.big-btn {
  border: none; border-radius: var(--radius); cursor: pointer;
  padding: 30px 26px; text-align: left; display: flex; flex-direction: column; gap: 6px;
  transition: transform .08s ease, box-shadow .2s ease;
}
.big-btn:active { transform: scale(.98); }
.big-btn-title { font-size: 26px; font-weight: 700; }
.big-btn-sub { font-size: 16px; opacity: .85; }
.big-btn.primary { background: var(--brand); color: #fff; box-shadow: var(--shadow); }
.big-btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.big-btn.submit { align-items: center; text-align: center; margin-top: 10px; padding: 22px; font-size: 22px; font-weight: 700; }

.back {
  background: none; border: none; color: var(--brand); font-weight: 600;
  padding: 8px 0; margin-bottom: 6px; cursor: pointer; font-size: 17px;
}

/* ---- forms ---- */
.field { margin-bottom: 18px; display: flex; flex-direction: column; }
.field label { font-weight: 600; margin-bottom: 8px; font-size: 16px; }
.req { color: var(--danger); }
.field input, .field select {
  padding: 16px 16px; border: 1.5px solid var(--line); border-radius: 14px;
  background: var(--card); color: var(--ink); width: 100%; appearance: none;
}
.field input:focus, .field select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37,99,235,.15);
}
.field select { background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='3'><path d='M6 9l6 6 6-6'/></svg>"); background-repeat: no-repeat; background-position: right 16px center; padding-right: 44px; }
.grid-2 { display: grid; gap: 0 18px; }
@media (min-width: 620px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.form-error { color: var(--danger); font-weight: 600; margin: 0 0 14px; }
.returning {
  background: #ecfdf5; color: #065f46; border: 1.5px solid #a7f3d0;
  border-radius: 12px; padding: 12px 16px; margin: -6px 0 18px; font-weight: 600;
  animation: fade .25s ease;
}

/* ---- checkout results ---- */
.results { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 12px; }
.results li {
  background: var(--card); border-radius: 14px; box-shadow: var(--shadow);
  padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 14px;
}
.results .who { display: flex; flex-direction: column; gap: 3px; }
.results .who b { font-size: 19px; }
.results .who span { color: var(--muted); font-size: 15px; }
.results button {
  background: var(--brand); color: #fff; border: none; border-radius: 12px;
  padding: 14px 22px; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.results button:active { transform: scale(.97); }

/* ---- done ---- */
.view.done { text-align: center; padding-top: 40px; }
.check-circle {
  width: 110px; height: 110px; border-radius: 50%; background: var(--ok); color: #fff;
  font-size: 64px; line-height: 110px; margin: 0 auto 22px; box-shadow: var(--shadow);
}

/* ---- kiosk footer + privacy page ---- */
.kiosk-footer {
  text-align: center; padding: 16px 22px max(env(safe-area-inset-bottom), 18px);
}
.kiosk-footer a { color: var(--muted); text-decoration: none; font-size: 15px; font-weight: 600; }
.kiosk-footer a:active { color: var(--brand); }
.legal {
  white-space: pre-wrap; word-wrap: break-word; font-family: inherit; font-size: 17px;
  line-height: 1.6; color: var(--ink); background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 26px; margin: 0;
}

/* privacy editor (admin) */
.privacy-edit { margin-top: 16px; }
.privacy-edit textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: 12px; padding: 14px;
  font-family: inherit; font-size: 15px; line-height: 1.5; resize: vertical; min-height: 220px;
}
.privacy-edit textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 4px rgba(37,99,235,.15); }
.privacy-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.privacy-actions .btn { text-decoration: none; }

/* ================= ADMIN ================= */
.admin-body { background: var(--bg); }
.admin-wrap { max-width: 1200px; margin: 0 auto; padding: 22px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 18px; }
.admin-header h1 { margin: 0; }
.stats { display: flex; gap: 14px; }
.stat { background: var(--card); border-radius: 14px; box-shadow: var(--shadow); padding: 14px 22px; text-align: center; }
.stat .num { font-size: 28px; font-weight: 800; color: var(--brand); }
.stat .lbl { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 16px; }
.toolbar input[type=text], .toolbar input[type=date], .toolbar select {
  padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--card);
}
.toolbar input[type=text] { flex: 1; min-width: 200px; }
.btn { padding: 12px 18px; border-radius: 12px; border: none; font-weight: 700; cursor: pointer; }
.btn.primary { background: var(--brand); color: #fff; }
.btn.subtle { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn:active { transform: scale(.98); }

.hosts-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 20px; margin-bottom: 16px; }
.hosts-card summary { font-weight: 700; cursor: pointer; font-size: 16px; }
.hosts-card summary .muted { font-weight: 400; font-size: 14px; }
.host-add { display: flex; gap: 10px; margin: 16px 0 12px; }
.host-add input { flex: 1; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 12px; }
.host-list { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.host-list li {
  display: flex; align-items: center; gap: 8px; background: #eff6ff; color: #1e3a8a;
  border: 1.5px solid #bfdbfe; border-radius: 999px; padding: 8px 8px 8px 16px; font-weight: 600;
}
.host-del {
  width: 26px; height: 26px; border-radius: 50%; border: none; cursor: pointer;
  background: #dbeafe; color: #1e3a8a; font-size: 18px; line-height: 1; font-weight: 700;
}
.host-del:active { transform: scale(.9); }

.table-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 15px; vertical-align: middle; }
th { background: #f8fafc; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .5px; position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: none; }
.pill { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.pill.in { background: #dcfce7; color: #166534; }
.pill.out { background: #f1f5f9; color: #475569; }
.row-actions button { background: none; border: none; color: var(--danger); cursor: pointer; font-weight: 600; padding: 6px; }
.row-actions .checkout { color: var(--brand); }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }

/* PIN gate */
.gate { max-width: 380px; margin: 12vh auto; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 34px; text-align: center; }
.gate h1 { margin-top: 0; }
.gate input { width: 100%; text-align: center; letter-spacing: 8px; font-size: 26px; padding: 16px; border: 1.5px solid var(--line); border-radius: 14px; margin: 14px 0; }
.gate .form-error { text-align: center; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 999px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .25s; font-weight: 600; z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
