:root {
  --bg: #16131a;
  --surface: #201c26;
  --surface-2: #2a2531;
  --line: #383040;
  --text: #f3eff4;
  --muted: #a79daf;
  --red: #e8273f;
  --red-press: #c41730;
  --green: #35c77b;
  --amber: #e7a93a;
  --radius: 14px;
  --tap: 48px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  color-scheme: dark;
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}

body::before {
  content: "";
  position: fixed;
  inset: -50vh -50vw;
  z-index: -1;
  background: radial-gradient(circle at 10% 10%, #251f2e 0%, #16131a 35%, #100d14 100%);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(22, 19, 26, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  max-width: 560px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}

.brand {
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand strong {
  color: var(--text);
  font-weight: 700;
}

.brand-mark {
  color: var(--red);
  margin-right: 2px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.layout {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 12px 48px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 10px;
}

h3 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 18px 0 8px;
}

h4 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.event-title {
  font-size: 22px;
  line-height: 1.25;
  margin-bottom: 2px;
}

.event-date {
  margin: 0 0 16px;
  font-size: 14px;
}

.google-login-btn {
  display: flex;
  justify-content: center;
  width: 100%;
  min-height: 44px;
}

button {
  font: inherit;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
}

button:active {
  transform: scale(0.985);
}

button.primary {
  background: var(--red);
  color: #fff;
  font-weight: 700;
}

button.primary:active {
  background: var(--red-press);
}

button.secondary {
  background: var(--surface-2);
  border-color: var(--line);
}

button.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

button.ghost:active {
  color: var(--text);
}

button.block {
  width: 100%;
}

button.big {
  min-height: 56px;
  font-size: 17px;
}

button.icon-btn {
  padding: 0 14px;
  font-size: 14px;
}

button.filter {
  background: transparent;
  color: var(--muted);
  border: none;
}

button.filter.active {
  background: var(--red);
  color: #fff;
}

button.small {
  min-height: 38px;
  font-size: 13px;
  padding: 0 12px;
  border: 1px solid var(--line);
}

button.small.status-readonly {
  color: var(--muted);
  border-color: #5a5168;
  background: transparent;
}

button.small.status-readonly.refunded {
  color: var(--amber);
  border-color: var(--amber);
}

button.danger {
  border-color: var(--red);
  color: var(--red);
}

button.has-spinner-right,
button.has-spinner-left {
  position: relative;
}

button.has-spinner-right::after,
button.has-spinner-left::before {
  content: "";
  position: relative;
  display: inline-block;
  width: 0;
  height: 0;
  margin: 0;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  opacity: 0;
  vertical-align: middle;
}

button.is-loading.has-spinner-right::after,
button.is-loading.has-spinner-left::before {
  width: 0.9em;
  height: 0.9em;
  opacity: 1;
  animation: spin 0.8s linear infinite;
}

button.is-loading.has-spinner-right::after {
  margin-left: 8px;
}

button.is-loading.has-spinner-left::before {
  margin-right: 8px;
}

button.click-bounce {
  animation: click-bounce 0.22s ease;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}

.segmented {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  gap: 4px;
  margin-bottom: 14px;
}

.segmented button {
  flex: 1;
  min-height: 40px;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  border: none;
  font-size: 15px;
  font-weight: 600;
}

.segmented .tab-btn.active,
.segmented button.filter.active {
  background: var(--red);
  color: #fff;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.search-row input {
  flex: 1;
}

.search-row button {
  flex: 0 0 auto;
}

input {
  font: inherit;
  font-size: 16px;
  min-height: var(--tap);
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  width: 100%;
}

input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  text-align: left;
  color: var(--text);
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.row-main .title {
  font-weight: 600;
}

.row-main .muted {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}

.event-row {
  cursor: pointer;
}

.event-row:hover {
  background: #312b3a;
}

.attendee-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill {
  flex: 0 0 auto;
  font-size: 13px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  min-height: 36px;
}

.pill.live {
  border-color: var(--green);
  color: var(--green);
}

.pill.upcoming {
  border-color: var(--amber);
  color: var(--amber);
}

.pill.past {
  border-color: #756a80;
  color: #c8bfd1;
}

.ring {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
}

.ring svg {
  width: 100%;
  height: 100%;
  display: block;
}

.ring circle {
  fill: none;
  stroke-width: 4;
}

.ring .track {
  stroke: var(--line);
}

.ring .fill {
  stroke: var(--red);
  stroke-linecap: round;
}

.ring .fill.full {
  stroke: var(--green);
}

.ring .pct {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-anchor: middle;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: grid;
  gap: 4px;
}

.stat-card span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.stat-card strong {
  font-size: 20px;
  line-height: 1.2;
}

.stat-block {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.ticket-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid #3a3443;
}

.ticket-row:last-child {
  border-bottom: none;
}

.disclosure summary {
  list-style: none;
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--muted);
  user-select: none;
}

.disclosure summary::-webkit-details-marker {
  display: none;
}

.disclosure[open] summary {
  color: var(--text);
  margin-bottom: 10px;
}

.add-attendee {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field span {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.card.log {
  padding: 10px 16px;
}

.output {
  margin: 0;
  font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 70px;
}

.output.is-error {
  border-color: var(--red);
  color: #ffc2cb;
}

.empty {
  border: 1px dashed #4b4257;
  border-radius: 12px;
  padding: 16px;
  color: var(--muted);
}

.scanner-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #000;
  display: flex;
  flex-direction: column;
}

.scanner-screen[hidden] {
  display: none;
}

.scanner-cam {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4a4453;
  font-size: 14px;
  background: radial-gradient(ellipse at 50% 40%, #1b1721 0%, #000 75%);
  overflow: hidden;
}

#scannerRegion__dashboard_section {
  opacity: 0.95;
}

.viewfinder {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(70vw, 320px);
  height: min(70vw, 320px);
  transform: translate(-50%, -58%);
  pointer-events: none;
}

.viewfinder i {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 3px solid var(--red);
}

.viewfinder i:nth-child(1) {
  top: 0;
  left: 0;
  border-right: none;
  border-bottom: none;
  border-top-left-radius: 8px;
}

.viewfinder i:nth-child(2) {
  top: 0;
  right: 0;
  border-left: none;
  border-bottom: none;
  border-top-right-radius: 8px;
}

.viewfinder i:nth-child(3) {
  bottom: 0;
  left: 0;
  border-right: none;
  border-top: none;
  border-bottom-left-radius: 8px;
}

.viewfinder i:nth-child(4) {
  bottom: 0;
  right: 0;
  border-left: none;
  border-top: none;
  border-bottom-right-radius: 8px;
}

.scanner-top {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: linear-gradient(rgba(0, 0, 0, 0.65), transparent);
}

.scanner-top .title {
  font-weight: 700;
  letter-spacing: 0.03em;
}

.close-btn {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  padding: 0;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  border: none;
}

.scan-result {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: calc(56px + env(safe-area-inset-bottom));
  z-index: 3;
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(22, 19, 26, 0.92);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(53, 199, 123, 0.65);
  color: #d8ffe9;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 0.22s ease, transform 0.22s ease;
  pointer-events: none;
  font-weight: 600;
}

.scan-result.show {
  opacity: 1;
  transform: translateY(0);
}

.scan-result.error {
  border-color: rgba(232, 39, 63, 0.7);
  color: #ffd7de;
}

.scanner-status {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  color: #c8bfd1;
  font-size: 13px;
  z-index: 3;
  padding: 0 10px;
}

[hidden] {
  display: none !important;
}

@keyframes click-bounce {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(0.96);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

@media (max-width: 560px) {
  .row {
    flex-direction: column;
    align-items: stretch;
  }

  .attendee-actions {
    justify-content: flex-start;
  }

  .search-row {
    flex-direction: column;
  }
}

@media (min-width: 600px) {
  .layout {
    padding: 24px 16px 64px;
  }

  .card {
    padding: 22px 20px;
  }
}
