:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-strong: #edf2f7;
  --ink: #17202a;
  --muted: #667085;
  --line: #d7dee8;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warning: #c2410c;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(34, 49, 74, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 14px;
  font-weight: 800;
  cursor: pointer;
}

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

button:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

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

input,
select {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 0 12px;
}

.app {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 18px;
}

#loginScreen[hidden],
#adminApp[hidden],
#adminApp:not(.is-ready) {
  display: none !important;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 20px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-panel h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.login-panel p:not(.eyebrow):not(.login-message) {
  color: var(--muted);
  font-weight: 700;
  line-height: 1.6;
}

.login-panel .primary {
  width: 100%;
  margin-top: 20px;
}

.login-message {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--danger);
  font-weight: 800;
}

.panel,
.hero,
.toolbar,
.ticket,
.camera-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.header-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: end;
  padding: 16px;
}

.header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.icon-button {
  width: 44px;
  padding: 0;
  color: var(--muted);
  font-size: 20px;
}

.field-label {
  display: block;
  margin: 12px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.field-label:first-child {
  margin-top: 0;
}

.event-input {
  font-size: 22px;
  font-weight: 900;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 8px;
}

.stats div {
  display: grid;
  place-items: center;
  min-height: 62px;
  border-radius: 8px;
  background: var(--surface-strong);
}

.stats span {
  font-size: 24px;
  font-weight: 900;
}

.stats small,
.issued-pair span {
  color: var(--muted);
  font-weight: 800;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: stretch;
  margin-top: 16px;
  padding: 16px;
}

.capture-board {
  display: grid;
  align-content: center;
  gap: 18px;
  min-height: 390px;
  border-radius: 8px;
  background: #101828;
  color: #ffffff;
  padding: 24px;
  text-align: center;
}

.capture-kicker {
  font-size: clamp(18px, 3vw, 30px);
  font-weight: 900;
}

.capture-shout {
  color: #fbbf24;
  font-size: clamp(52px, 11vw, 120px);
  font-weight: 1000;
  line-height: 0.95;
}

.issued-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.issued-pair div {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  padding: 16px 10px;
}

.issued-pair strong {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  font-size: clamp(32px, 8vw, 88px);
  line-height: 1;
  letter-spacing: 0;
}

.issued-pair div:last-child strong {
  font-size: clamp(22px, 4.6vw, 52px);
}

.capture-board p {
  margin: 0;
  color: #dbe7f3;
  font-size: clamp(16px, 2.2vw, 24px);
  font-weight: 800;
}

.issue-panel {
  display: grid;
  align-content: center;
  gap: 10px;
}

.member-builder {
  display: grid;
  grid-template-columns: 68px minmax(72px, 1fr) repeat(3, 58px);
  gap: 8px;
  align-items: center;
}

.member-builder select {
  padding: 0 8px;
  text-align: center;
  font-weight: 900;
}

.fixed-code {
  display: grid;
  place-items: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-strong);
  font-weight: 900;
}

.member-preview {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: #ecfdf5;
  color: var(--accent-dark);
  padding: 0 12px;
}

.member-preview span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.member-preview strong {
  overflow-wrap: anywhere;
  font-size: 18px;
  font-weight: 1000;
}

.scan-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.issue-panel .primary {
  min-height: 74px;
  margin-top: 6px;
}

.hint {
  color: var(--muted);
  line-height: 1.5;
}

.camera-panel {
  margin-top: 16px;
  padding: 16px;
}

.camera-panel[hidden] {
  display: none;
}

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

#scannerVideo {
  width: 100%;
  max-height: 360px;
  border-radius: 8px;
  background: #101828;
}

#scanStatus {
  margin: 10px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.toolbar,
.utility-panel {
  display: grid;
  gap: 12px;
  align-items: end;
  margin-top: 16px;
  padding: 16px;
}

.toolbar {
  grid-template-columns: minmax(0, 1fr) 150px;
}

.utility-panel {
  grid-template-columns: 1fr;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.empty {
  margin: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.ticket {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
}

.ticket-main {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.ticket-number {
  display: grid;
  place-items: center;
  width: 76px;
  min-width: 76px;
  height: 62px;
  border-radius: 8px;
  background: #d1fae5;
  color: var(--accent-dark);
  font-size: 30px;
  font-weight: 1000;
}

.ticket-name {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 900;
}

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

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

.ticket.is-cancelled {
  opacity: 0.52;
}

.ticket.is-cancelled .ticket-number {
  background: #fee2e2;
  color: var(--danger);
}

@media (max-width: 760px) {
  .app {
    padding: 12px;
  }

  .header-panel,
  .hero,
  .toolbar,
  .utility-panel,
  .ticket {
    grid-template-columns: 1fr;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
  }

  .header-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .capture-board {
    min-height: 360px;
    padding: 18px;
  }

  .issued-pair {
    grid-template-columns: 1fr;
  }

  .scan-row {
    grid-template-columns: 1fr;
  }

  .member-builder {
    grid-template-columns: 52px minmax(58px, 1fr) repeat(3, 44px);
    gap: 6px;
  }

  .member-builder select,
  .fixed-code {
    min-height: 42px;
    padding: 0 4px;
  }

  .ticket-actions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}
