:root {
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --warn: #d97706;
  --warn-bg: #fef3c7;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 0;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar .brand {
  font-weight: 700;
  font-size: 16px;
  color: var(--text);
  text-decoration: none;
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  white-space: nowrap;
}

.topbar nav a.active { color: var(--primary); font-weight: 600; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

h1 { font-size: 20px; margin: 4px 0 16px; }
h2 { font-size: 17px; margin: 0 0 12px; }

label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="datetime-local"] {
  width: 100%;
  padding: 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 14px;
  background: #fff;
  color: var(--text);
}

button, .btn {
  display: inline-block;
  width: 100%;
  padding: 13px 16px;
  font-size: 15px;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

button:active, .btn:active { background: var(--primary-dark); }

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

.error-box {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 14px;
}

.event-list, .ticket-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.event-list li, .ticket-list li {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.event-list li:last-child, .ticket-list li:last-child { border-bottom: none; }

.event-list a {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
}

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

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

.badge-valid { background: var(--success-bg); color: var(--success); }
.badge-used { background: #f3f4f6; color: var(--muted); }

.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

#scan-region {
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}

.result-panel {
  margin-top: 16px;
  padding: 20px;
  border-radius: 12px;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

.result-valid { background: var(--success-bg); color: var(--success); }
.result-used { background: var(--warn-bg); color: var(--warn); }
.result-invalid { background: var(--danger-bg); color: var(--danger); }

.result-panel .sub {
  font-size: 14px;
  font-weight: 400;
  margin-top: 6px;
  color: inherit;
}

.manual-form {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.manual-form input { margin-bottom: 0; }
.manual-form button { width: auto; white-space: nowrap; }

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
}

.tab-btn {
  width: auto;
  white-space: nowrap;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 8px 8px 0 0;
  border-bottom: none;
  cursor: pointer;
}

.tab-btn.active {
  background: var(--card);
  color: var(--primary);
  font-weight: 600;
  border-color: var(--border);
}

.tab-panel {
  margin-top: -1px;
  border-top-left-radius: 0;
}

.sold-out-row {
  opacity: 0.6;
}
