*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #0f766e;
  --brand-dark: #0d6460;
  --brand-light: #ccfbf1;
  --danger: #dc2626;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f9fafb;
  --card: #ffffff;
  --wa: #25d366;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
}

html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--text); background: var(--bg); }

.hidden { display: none !important; }

/* ── PIN / Setup pages ─────────────────────────────────────────────────────── */
.pin-page { background: var(--brand); }

.fullscreen-center {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.pin-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,.2);
}

.portal-logo {
  width: 60px; height: 60px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--brand);
}

.pin-title { font-size: 1.25rem; font-weight: 700; margin-bottom: .25rem; }
.pin-subtitle { font-size: .875rem; color: var(--muted); margin-bottom: 1.5rem; }
.step-label { font-size: .875rem; font-weight: 600; color: var(--muted); margin-bottom: .75rem; }

.pin-dots { display: flex; gap: .75rem; justify-content: center; margin-bottom: 1rem; }
.dot {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  transition: background .15s, border-color .15s;
}
.dot.filled { background: var(--brand); border-color: var(--brand); }

.pin-error { font-size: .8125rem; color: var(--danger); margin-bottom: .75rem; }

.pin-keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
  margin-top: 1rem;
}

.key {
  height: 58px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .1s;
  -webkit-tap-highlight-color: transparent;
}
.key:active { background: var(--brand-light); }
.key-empty { background: transparent; border-color: transparent; cursor: default; }
.key-back { font-size: 1rem; }

.fatal-error { color: #fff; font-size: 1rem; text-align: center; max-width: 300px; }

/* ── Portal page ───────────────────────────────────────────────────────────── */
.portal-page { display: flex; flex-direction: column; min-height: 100vh; }

.portal-header {
  background: var(--brand);
  color: #fff;
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-space  { font-size: 1rem; font-weight: 700; }
.header-estate { font-size: .75rem; opacity: .75; margin-top: .1rem; }

.tab-bar {
  display: flex;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: .75rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: .875rem;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.pane { flex: 1; overflow-y: auto; }
.pane-inner { padding: 1rem; max-width: 480px; margin: 0 auto; }

.section-title { font-size: 1rem; font-weight: 700; margin-bottom: 1rem; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }

/* ── Forms ─────────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.form-label { display: block; font-size: .8125rem; font-weight: 600; margin-bottom: .375rem; color: var(--text); }
.optional { font-weight: 400; color: var(--muted); }

.form-input {
  width: 100%;
  padding: .6875rem .875rem;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: .9375rem;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
.form-input:focus { border-color: var(--brand); }

.form-error {
  font-size: .8125rem;
  color: var(--danger);
  margin-bottom: .75rem;
  padding: .5rem .75rem;
  background: #fef2f2;
  border-radius: 6px;
}

/* ── Buttons ───────────────────────────────────────────────────────────────── */
.btn-primary {
  width: 100%;
  padding: .875rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  margin-top: .25rem;
}
.btn-primary:active { background: var(--brand-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-secondary {
  padding: .75rem 1.25rem;
  background: var(--bg);
  color: var(--text);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-outline {
  padding: .75rem 1.25rem;
  background: transparent;
  color: var(--brand);
  border: 1.5px solid var(--brand);
  border-radius: 10px;
  font-size: .9375rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-whatsapp {
  width: 100%;
  padding: .875rem;
  background: var(--wa);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: .625rem;
}

.btn-sm-primary {
  padding: .4rem .875rem;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
}

/* ── Pass result ───────────────────────────────────────────────────────────── */
.result-card { text-align: center; padding-top: 1.5rem; }

.result-check {
  width: 56px; height: 56px;
  background: var(--brand-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1.25rem;
  color: var(--brand);
}

.result-code {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--brand);
  margin-bottom: 1rem;
}

.result-qr { margin-bottom: 1rem; }

.result-meta {
  display: flex;
  flex-direction: column;
  gap: .25rem;
  font-size: .9375rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
}
.result-unit { font-weight: 600; color: var(--text); }

.result-actions { display: flex; flex-direction: column; gap: .625rem; }

/* ── Staff list ────────────────────────────────────────────────────────────── */
.add-form {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1rem;
}
.add-form-actions { display: flex; gap: .625rem; }
.add-form-actions .btn-primary { margin-top: 0; flex: 1; }
.add-form-actions .btn-outline { flex: 1; }

.staff-list { display: flex; flex-direction: column; gap: .625rem; }

.staff-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.staff-card.inactive { opacity: .5; }

.staff-name { font-weight: 600; font-size: .9375rem; }
.staff-role { font-size: .8125rem; color: var(--muted); margin-top: .125rem; }

.staff-right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

.staff-code {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .05em;
  color: var(--brand);
}

.btn-copy-code {
  padding: .3rem .625rem;
  background: var(--brand-light);
  color: var(--brand);
  border: none;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-remove {
  padding: .3rem .625rem;
  background: #fef2f2;
  color: var(--danger);
  border: none;
  border-radius: 6px;
  font-size: .75rem;
  font-weight: 600;
  cursor: pointer;
}

.badge-inactive {
  font-size: .75rem;
  color: var(--muted);
  padding: .2rem .5rem;
  background: var(--bg);
  border-radius: 4px;
}

.list-loading, .list-empty { text-align: center; color: var(--muted); padding: 2rem 0; font-size: .9375rem; }

/* ── Active passes list ─────────────────────────────────────────────────────── */
.passes-section { border-top: 1.5px solid var(--border); padding-top: 1.25rem; }
.passes-section-title { font-size: .8125rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.passes-list { display: flex; flex-direction: column; gap: .625rem; margin-top: .75rem; }
.pass-card {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: .875rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
}
.pass-info { flex: 1; min-width: 0; }
.pass-guest { font-weight: 600; font-size: .9375rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pass-dates { font-size: .8125rem; color: var(--muted); margin-top: .125rem; }
.pass-code-col { flex-shrink: 0; text-align: right; }
.pass-code-val { font-size: 1rem; font-weight: 700; letter-spacing: .06em; color: var(--brand); display: block; }

/* ── Powered-by footer ─────────────────────────────────────────────────────── */
.powered-by {
  position: fixed;
  bottom: .75rem;
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .3125rem;
  font-size: .6875rem;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}
.pin-page .powered-by  { color: rgba(255,255,255,.45); }
.portal-page .powered-by { color: var(--muted); opacity: .65; }
.powered-by img { width: 14px; height: 14px; border-radius: 3px; }

/* ── Slug / address input ──────────────────────────────────────────────────── */
.slug-input-wrap { margin: 1rem 0; }
.slug-input {
  width: 100%;
  padding: .75rem 1rem;
  font-size: 1rem;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  box-sizing: border-box;
  outline: none;
  letter-spacing: .02em;
}
.slug-input::placeholder { color: var(--muted); }
.slug-input:focus { border-color: var(--brand); background: #fff; }

/* ── Continue button ───────────────────────────────────────────────────────── */
.pin-continue-btn {
  width: 100%;
  padding: .85rem;
  font-size: 1rem;
  font-weight: 700;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  margin-top: .25rem;
  transition: background .15s;
}
.pin-continue-btn:hover { background: var(--brand-dark); }
.pin-continue-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Back link ─────────────────────────────────────────────────────────────── */
.back-link {
  display: inline-block;
  color: var(--brand);
  opacity: .7;
  font-size: .875rem;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  margin-bottom: .75rem;
  align-self: flex-start;
}
.back-link:hover { opacity: 1; }

/* ── Forgot / secondary links ──────────────────────────────────────────────── */
.forgot-link {
  margin-top: .75rem;
  font-size: .8125rem;
  color: var(--muted);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.forgot-link:hover { color: var(--text); }

/* ── Staff dots (6) ────────────────────────────────────────────────────────── */
.staff-dots { gap: .5rem; }
.staff-dots .dot { width: 14px; height: 14px; }

/* ── OTP input ─────────────────────────────────────────────────────────────── */
.otp-input-wrap { margin: .75rem 0; }
.otp-input {
  width: 100%;
  padding: .85rem;
  font-size: 1.5rem;
  letter-spacing: .3em;
  text-align: center;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  outline: none;
}
.otp-input:focus { border-color: var(--brand); }
