:root {
  --bg: #1f1118;
  --paper: #fffaf3;
  --paper-soft: #fff1dc;
  --ink: #281820;
  --muted: #74646c;
  --line: rgba(40, 24, 32, .16);
  --primary: #281820;
  --danger: #b73e3e;
  --ok: #246b4a;
  --warn: #9a6a00;
  --dark: #34232c;
  --radius: 28px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, #f7d8ff 0, transparent 28%),
    radial-gradient(circle at 80% 15%, #ffe0ad 0, transparent 25%),
    linear-gradient(135deg, #26121d, #4b2636 55%, #25141c);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled, input:disabled { opacity: .45; cursor: not-allowed; }

.app-shell {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 18px;
}
.hero {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 16px;
  align-items: center;
  color: white;
  padding: 14px 4px 22px;
}
.logo { width: 92px; height: auto; filter: drop-shadow(0 12px 24px rgba(0,0,0,.28)); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 6px; font-size: clamp(2rem, 8vw, 4rem); line-height: .92; letter-spacing: -.05em; }
h2 { margin-bottom: 8px; font-size: 1.35rem; }
.eyebrow { margin-bottom: 6px; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: #ffd891; }
.muted { color: var(--muted); }
.hero .muted { color: rgba(255,255,255,.72); }

.card {
  background: linear-gradient(180deg, var(--paper), var(--paper-soft));
  border: 1px solid rgba(255,255,255,.32);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 24px 70px rgba(0,0,0,.25);
}
.hidden { display: none !important; }
.stack { display: grid; gap: 12px; }
.topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
label { display: block; margin: 14px 0 8px; font-weight: 800; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,.82);
  color: var(--ink);
  padding: 15px 16px;
  outline: none;
}
input:focus, select:focus { border-color: rgba(40,24,32,.65); box-shadow: 0 0 0 4px rgba(40,24,32,.08); }

.actions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}
button {
  border: 0;
  border-radius: 18px;
  padding: 14px 16px;
  font-weight: 900;
  letter-spacing: .01em;
}
.primary { background: var(--primary); color: white; }
.secondary { background: #f1dfc7; color: var(--ink); }
.danger { background: var(--danger); color: white; }
.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }

.status, .result {
  border-radius: 22px;
  padding: 16px;
  margin-top: 14px;
  font-weight: 850;
  line-height: 1.2;
}
.status.dark, .result.dark { background: #32212b; color: #fff2e3; }
.status.ok, .result.ok { background: #e0f3e7; color: var(--ok); }
.status.free, .result.free { background: #00FF5E; color: #000; }
.status.warn, .result.warn { background: #fff0bd; color: var(--warn); }

.status.error, .result.error { background: #ffe0de; color: #a02d2d; }
.result-primary {
  display: block;
  font-size: clamp(2rem, 9vw, 3.25rem);
  font-weight: 950;
  line-height: .95;
  letter-spacing: -.035em;
  text-transform: none;
  overflow-wrap: anywhere;
}
.result-secondary {
  display: block;
  margin-top: 10px;
  font-size: clamp(.95rem, 3.8vw, 1.2rem);
  font-weight: 800;
  line-height: 1.2;
  opacity: .92;
  overflow-wrap: anywhere;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 11px;
  font-size: .8rem;
  font-weight: 900;
  background: #eee;
}
.badge.online { background: #ddf3e5; color: var(--ok); }
.badge.offline { background: #ffe0de; color: #a02d2d; }

.scanner-box {
  position: relative;
  overflow: hidden;
  min-height: 270px;
  background: #241821;
  border-radius: 26px;
  border: 1px solid rgba(255,255,255,.2);
}
.qr-reader {
  width: 100%;
  min-height: 320px;
  background: #241821;
}
.qr-reader video,
#cameraVideo {
  width: 100% !important;
  height: 320px !important;
  object-fit: cover;
  display: block;
  background: #241821;
}
.qr-reader canvas {
  width: 100% !important;
  height: 320px !important;
  object-fit: cover;
}
.qr-reader > div {
  border: 0 !important;
}
.scanner-overlay {
  position: absolute;
  inset: auto 14px 14px 14px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(0,0,0,.58);
  color: white;
  font-weight: 850;
  backdrop-filter: blur(8px);
}
.manual-box { margin-top: 16px; }
.manual-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }
.person {
  margin-top: 12px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,.55);
  border-radius: 20px;
  padding: 14px;
}
.person p { margin: 6px 0 0; }
.pending { margin: 12px 4px 0; font-size: .9rem; }

@media (max-width: 580px) {
  .app-shell { padding: 12px; }
  .hero { grid-template-columns: 72px 1fr; }
  .logo { width: 72px; }
  .card { padding: 16px; border-radius: 24px; }
  .actions-grid { grid-template-columns: 1fr; }
  .manual-row { grid-template-columns: 1fr; }
  .qr-reader { min-height: 260px; }
  .qr-reader video,
  #cameraVideo,
  .qr-reader canvas { height: 260px !important; }
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.event-choice {
  width: 100%;
  display: grid;
  gap: 6px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255,255,255,.78);
  color: var(--ink);
  padding: 16px;
}
.event-choice strong {
  font-size: 1.1rem;
  line-height: 1.1;
}
.event-choice span {
  color: var(--muted);
  font-weight: 800;
  font-size: .92rem;
}
.event-choice:focus,
.event-choice:hover {
  border-color: rgba(40,24,32,.65);
  box-shadow: 0 0 0 4px rgba(40,24,32,.08);
}
.event-empty {
  border: 1px dashed var(--line);
  border-radius: 22px;
  padding: 16px;
  color: var(--muted);
  font-weight: 850;
}
.top-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.one-action {
  grid-template-columns: 1fr;
}
#selectedEventTitle {
  font-weight: 850;
  color: var(--ink);
  margin-bottom: 4px;
}

@media (max-width: 580px) {
  .topline {
    align-items: stretch;
    flex-direction: column;
  }
  .top-actions {
    justify-content: stretch;
  }
  .top-actions button {
    flex: 1;
  }
}
