:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --surface: #f9fbff;
  --border: #e5e7eb;
  --accent: #0ea5e9;
  --primary: #2563eb;
  --primary-strong: #1e3a8a;
  --text: #0f172a;
  --muted: #6b7280;
  --error: #dc2626;
  --success: #16a34a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: radial-gradient(circle at 18% 10%, rgba(14, 165, 233, 0.08), transparent 28%),
    radial-gradient(circle at 78% 0%, rgba(37, 99, 235, 0.04), transparent 24%),
    linear-gradient(180deg, #fdfefe 0%, #f4f6fb 100%);
  color: var(--text);
  min-height: 100vh;
}

.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 16px 56px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.app-header h1 {
  margin: 0;
  font-weight: 700;
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.user-area {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: #e0e7ff;
  color: #1e293b;
  padding: 8px 14px;
  border-radius: 20px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.card.compact {
  padding: 16px;
}

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

label span {
  display: block;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 4px;
}

input {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

select,
input[type='file'] {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font-size: 16px;
}

input:focus {
  outline: 2px solid rgba(37, 99, 235, 0.25);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

button {
  appearance: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  padding: 12px 14px;
  font-size: 16px;
}

button.primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #f8fafc;
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.2);
}

button.secondary {
  background: #e0ecff;
  color: #1e3a8a;
  border: 1px solid #bfdbfe;
}

button.ghost {
  background: #f8fafc;
  color: #111827;
  border: 1px solid var(--border);
}

.form-hint {
  margin: 0;
  color: var(--muted);
}

.alert {
  padding: 12px;
  border-radius: 12px;
  margin-top: 8px;
  background: #fef2f2;
  border: 1px solid #fecdd3;
  color: #b91c1c;
}

.alert.success {
  background: #ecfdf3;
  border-color: #bbf7d0;
  color: #166534;
}

.file-field small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.input-wrapper {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin: 16px 0;
}

.qr-reader {
  border: 1px dashed #bfdbfe;
  border-radius: 12px;
  padding: 8px;
  margin-bottom: 12px;
  background: #f8fafc;
}

.attendee {
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}

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

.label {
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin: 0 0 4px;
}

.attendee h3 {
  margin: 0;
}

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

.ticket-status {
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  color: #0b132b;
  background: #dbeafe;
}

.ticket-status.ok {
  background: #34d399;
}

.ticket-status.used {
  background: #fca5a5;
}

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

.actions.compact {
  margin-top: 0;
  flex-wrap: wrap;
}

.actions input[type='search'] {
  min-width: 240px;
  border-radius: 12px;
}

.app-footer {
  margin-top: 24px;
  padding: 12px 16px;
  text-align: center;
  color: #6b7280;
  font-size: 13px;
}

.import-stats {
  margin-top: 16px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

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

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

.tabs {
  display: inline-flex;
  gap: 0.5rem;
  background: #e5e7eb;
  padding: 6px;
  border-radius: 14px;
}

.tab-button {
  background: transparent;
  color: #1f2937;
  border: none;
  padding: 10px 14px;
  border-radius: 10px;
  font-weight: 600;
}

.tab-button.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
}

.admin-stack {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.admin-block {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem;
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8), 0 10px 30px rgba(15, 23, 42, 0.06);
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  max-height: 70vh;
  position: relative;
}

.cards {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

#eventsCards {
  display: none;
}

.cards .card {
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

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

table {
  width: 100%;
  border-collapse: collapse;
  color: var(--text);
  font-size: 14px;
}

table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: linear-gradient(180deg, #f8fbff, #eef2ff);
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.cell-wrap {
  white-space: normal;
}

th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 0.9rem;
}

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

tbody tr:nth-child(odd) {
  background: #f9fbff;
}

tbody tr:hover {
  background: #f0f4ff;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.panel-header.stackable {
  flex-wrap: wrap;
  gap: 0.75rem;
}

.panel-header .eyebrow {
  margin-bottom: 2px;
}

.event-detail {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  background: linear-gradient(180deg, #ffffff, #f8fbff);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 12px 32px rgba(15, 23, 42, 0.07);
}

.event-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.event-overview {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.metrics-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.75rem 0.85rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.05);
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0.5rem 0;
}

.stats .pill {
  background: #e0f2fe;
  color: #075985;
  padding: 0.4rem 0.65rem;
  border-radius: 999px;
  font-size: 0.85rem;
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.pill.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
}

.pill.available {
  background: #dcfce7;
  color: #166534;
}

.pill.unavailable {
  background: #fee2e2;
  color: #991b1b;
}

.metrics {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.metrics li {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem;
  background: #fff;
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.05);
}

.tabbed-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.6rem;
  background: #fff;
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.tab-panels {
  margin-top: 0.5rem;
}

.tab-panels .panel-header {
  margin: 0.25rem 0 0.75rem;
}

.drawer {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  background: #fff;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.drawer.floating {
  margin-top: 1rem;
  position: relative;
}

.drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.drawer h4 {
  margin: 0 0 0.5rem 0;
}

.tab-panel {
  margin-top: 0.75rem;
}

.switcher {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: space-between;
}

.switcher input[type='checkbox'] {
  width: auto;
  accent-color: var(--primary);
}

.table-actions {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.actions-cell {
  position: sticky;
  right: 0;
  background: #fff;
  box-shadow: -6px 0 12px rgba(15, 23, 42, 0.06);
}

.eyebrow {
  margin: 0 0 4px;
  letter-spacing: 0.12em;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--muted);
}

.event-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.event-meta .chip {
  background: #e0f2fe;
  color: #0f172a;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  border: 1px solid #bae6fd;
  font-size: 0.95rem;
}

.section-title {
  margin: 0;
  font-size: 1rem;
  color: #1f2937;
}

.section-hint {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

@media (max-width: 720px) {
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .app-shell {
    padding: 18px 14px 42px;
  }

  .scanner-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .input-wrapper {
    grid-template-columns: 1fr;
  }

  .panel-header.stackable .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .panel-header.stackable .actions input[type='search'] {
    width: 100%;
  }

  table.stackable {
    min-width: 720px;
  }

  th,
  td {
    white-space: nowrap;
  }

  .table-wrapper {
    max-height: 65vh;
  }
}

@media (max-width: 900px) {
  #eventsTable {
    display: none;
  }

  #eventsCards {
    display: grid;
  }

  #attendeesTable tr,
  #parkingsTable tr {
    cursor: pointer;
  }

  #attendeesTable .actions-cell,
  #attendeesTable .table-actions,
  #parkingsTable .actions-cell,
  #parkingsTable .table-actions {
    display: none;
  }

  #attendeesTable tr.show-actions .actions-cell,
  #attendeesTable tr.show-actions .table-actions,
  #parkingsTable tr.show-actions .actions-cell,
  #parkingsTable tr.show-actions .table-actions {
    display: table-cell;
  }

  #attendeesTable tr.show-actions .table-actions,
  #parkingsTable tr.show-actions .table-actions {
    display: flex;
  }

  #attendeesTable tr.show-actions,
  #parkingsTable tr.show-actions {
    background: #f1f5f9;
  }
}

.admin-stack .panel-header,
.admin-block,
.event-detail {
  gap: 0.75rem;
}

@media (min-width: 1040px) {
  .app-shell {
    max-width: 1320px;
  }
}
