:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --green: #16a34a;
  --green-hover: #15803d;
  --blue: #0284c7;
  --blue-hover: #0369a1;
  --danger: #dc2626;
  --ok: #15803d;
  --shadow: 0 10px 30px rgba(17, 24, 39, 0.08);
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body.app {
  font-family: "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

h1, h2, p { margin: 0; }

.btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: 600 14px/1 "Segoe UI", system-ui, sans-serif;
  border-radius: 10px;
  padding: 10px 16px;
  background: var(--green);
  color: #fff;
  transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:hover { background: var(--green-hover); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn.secondary {
  background: var(--blue);
}

.btn.secondary:hover { background: var(--blue-hover); }

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

.btn.ghost:hover { background: #f9fafb; }

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

.field span {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

input, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font: 15px/1.3 "Segoe UI", system-ui, sans-serif;
  outline: none;
}

input:focus, select:focus {
  border-color: #86efac;
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

/* Register */
.register-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}

.register-card {
  width: min(480px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px 24px;
  text-align: center;
}

.register-card h1 {
  font-size: 26px;
  letter-spacing: -0.03em;
}

.lede {
  margin: 8px 0 24px;
  color: var(--muted);
  font-size: 14px;
}

.register-card form {
  display: grid;
  gap: 14px;
}

.register-card .btn {
  width: 100%;
  margin-top: 6px;
  padding: 12px 16px;
  font-size: 15px;
}

.hint {
  margin-top: 16px;
  color: var(--muted);
  font-size: 13px;
}

.message {
  min-height: 20px;
  margin-top: 14px;
  font-size: 14px;
}

.message.success { color: var(--ok); font-weight: 700; }
.message.error { color: var(--danger); font-weight: 700; }

/* Admin */
.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: #111827;
  color: #fff;
}

.brand h1 {
  font-size: 18px;
  font-weight: 700;
}

.brand p {
  margin-top: 4px;
  color: #9ca3af;
  font-size: 13px;
}

.key-box {
  min-width: 240px;
}

.key-box span { color: #d1d5db; }
.key-box input {
  background: #1f2937;
  border-color: #374151;
  color: #fff;
}

.key-box input:focus {
  border-color: #4ade80;
  box-shadow: 0 0 0 3px rgba(74, 222, 128, 0.18);
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.wrap-wide {
  max-width: 1280px;
}

.toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 0 0 16px;
  padding: 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.toolbar input { flex: 1 1 240px; min-width: 200px; }
.toolbar select { flex: 0 0 180px; }

.status {
  color: var(--muted);
  font-size: 13px;
}

.table-card {
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th {
  background: #f9fafb;
  color: #4b5563;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tbody tr:hover { background: #f9fafb; }

.mosaic-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mosaic-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f3f4f6;
}

.code-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #111827;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.badge.yes {
  background: #dcfce7;
  color: #166534;
}

.badge.no {
  background: #fee2e2;
  color: #991b1b;
}

.hidden { display: none !important; }

.header-logout {
  background: transparent;
  color: #fff;
  border-color: #374151;
}

.header-logout:hover {
  background: #1f2937;
}

.pager {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
}

.pager span {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  text-align: center;
  padding: 36px 16px;
}

.guest-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}

.guest-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.guest-card.is-winner {
  border-color: #f59e0b;
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.18);
}

.guest-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: #e5e7eb;
  overflow: hidden;
}

.guest-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.guest-media-empty {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #6b7280;
  font-size: 14px;
  font-weight: 600;
}

.winner-chip {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: linear-gradient(180deg, #f8d36e 0%, #e6a23c 100%);
  color: #1a1042;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.guest-body {
  padding: 14px 14px 8px;
}

.guest-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.guest-avatar {
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: #111827;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.guest-title-row h3 {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.25;
}

.guest-code {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.guest-meta {
  display: grid;
  gap: 4px;
  color: #374151;
  font-size: 13px;
}

.guest-meta span {
  color: #6b7280;
  font-weight: 600;
}

.guest-line {
  display: flex;
  align-items: center;
  gap: 6px;
}

.guest-line .ico {
  width: 1.1em;
  text-align: center;
  opacity: 0.7;
}

.guest-footer {
  margin-top: auto;
  padding: 10px 14px 14px;
}

.btn-delete-entry {
  width: 100%;
  appearance: none;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 10px;
  padding: 10px 12px;
  font: 700 13px/1 "Segoe UI", system-ui, sans-serif;
  cursor: pointer;
}

.btn-delete-entry:hover {
  background: #fee2e2;
}

@media (max-width: 720px) {
  .admin-header,
  .brand { flex-direction: column; align-items: flex-start; }
  .key-box, .key-box input { width: 100%; min-width: 0; }
  .guest-grid { grid-template-columns: 1fr; }
}
