:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --surface: #ffffff;
  --ink: #17211d;
  --muted: #64716d;
  --line: #dce3e1;
  --primary: #116a4d;
  --primary-dark: #0a4a36;
  --accent: #d85b38;
  --accent-dark: #b74023;
  --danger: #b42318;
  --shadow: 0 18px 60px rgba(23, 33, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.page {
  min-height: 100vh;
}

.participant-page {
  background:
    linear-gradient(135deg, rgba(17, 106, 77, 0.88), rgba(216, 91, 56, 0.82)),
    url("https://images.unsplash.com/photo-1513151233558-d860c5398176?auto=format&fit=crop&w=1600&q=80") center/cover;
}

.register-shell {
  width: min(100%, 520px);
  min-height: 100vh;
  display: grid;
  align-items: center;
  padding: 24px;
}

.register-panel,
.login-panel,
.panel,
.metric {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.register-panel,
.login-panel {
  padding: clamp(24px, 6vw, 44px);
}

.brand-mark {
  width: fit-content;
  color: var(--primary-dark);
  border: 1px solid rgba(17, 106, 77, 0.24);
  background: rgba(17, 106, 77, 0.08);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 24px;
  font-size: clamp(2rem, 7vw, 3.7rem);
  line-height: 0.98;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 1.2rem;
  letter-spacing: 0;
}

.stacked-form {
  display: grid;
  gap: 16px;
}

.compact-form {
  gap: 12px;
  margin-bottom: 18px;
}

label,
.field-block {
  display: grid;
  gap: 7px;
}

label span,
.field-block span {
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(17, 106, 77, 0.14);
}

.primary-button,
.accent-button,
.ghost-button,
.danger-button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-weight: 800;
}

.primary-button {
  background: var(--primary);
  color: #fff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.accent-button {
  background: var(--accent);
  color: #fff;
}

.accent-button:hover {
  background: var(--accent-dark);
}

.ghost-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.ghost-button:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.danger-button {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.danger-button:hover {
  background: rgba(180, 35, 24, 0.14);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.form-message.success {
  color: var(--primary-dark);
}

.form-message.error {
  color: var(--danger);
}

.admin-page {
  background: var(--bg);
}

.admin-layout {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.login-panel {
  width: min(100%, 420px);
  margin: 10vh auto 0;
}

.dashboard {
  display: grid;
  gap: 18px;
}

.hidden {
  display: none !important;
}

.admin-header,
.section-heading,
.header-actions,
.inline-form,
.toggle-row {
  display: flex;
  align-items: center;
}

.admin-header,
.section-heading {
  justify-content: space-between;
  gap: 16px;
}

.admin-header h1 {
  margin: 10px 0 0;
  font-size: clamp(2rem, 6vw, 3rem);
}

.header-actions {
  flex-wrap: wrap;
  gap: 8px;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.metric {
  padding: 18px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 2rem;
}

.panel {
  padding: 18px;
}

.draw-panel {
  border-left: 4px solid var(--accent);
}

.inline-form {
  gap: 12px;
  margin-top: 16px;
}

.inline-form label {
  flex: 1;
}

.toggle-row {
  grid-template-columns: none;
  gap: 8px;
  white-space: nowrap;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.two-column {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.participants-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(17, 106, 77, 0.09);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.winner-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(216, 91, 56, 0.3);
  border-radius: 8px;
  background: rgba(216, 91, 56, 0.08);
}

.winner-box strong {
  display: block;
  font-size: 1.35rem;
}

.item-list {
  display: grid;
  gap: 10px;
}

.item-card {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.item-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.item-card h3 {
  margin: 0;
  font-size: 1rem;
}

.item-card p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-pill {
  width: fit-content;
  border-radius: 999px;
  padding: 4px 9px;
  background: rgba(17, 106, 77, 0.09);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.drawn {
  background: rgba(216, 91, 56, 0.12);
  color: var(--accent-dark);
}

.qr-frame {
  display: grid;
  place-items: center;
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.qr-frame img {
  width: min(100%, 280px);
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 700;
}

.chip:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.search-input {
  width: min(100%, 260px);
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0;
}

tr:last-child td {
  border-bottom: 0;
}

.number-column,
.participant-number {
  width: 56px;
  text-align: center;
}

.participant-number {
  color: var(--primary-dark);
  font-weight: 900;
}

.empty-state {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
}

@media (max-width: 800px) {
  .admin-layout {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .admin-header,
  .section-heading,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics-grid,
  .two-column {
    grid-template-columns: 1fr;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions > button,
  .inline-form button {
    flex: 1;
  }

  .search-input {
    width: 100%;
  }

  .toggle-row {
    flex-direction: row;
    align-items: center;
  }
}
