:root {
  --color-primary: #7C3AED;
  --color-primary-hover: #6D28D9;
  --color-primary-light: #EDE9FE;
  --color-success: #10B981;
  --color-success-hover: #059669;
  --color-success-light: #D1FAE5;
  --color-warning: #F59E0B;
  --color-warning-light: #FEF3C7;
  --color-danger: #EF4444;
  --color-danger-hover: #DC2626;
  --color-danger-light: #FEE2E2;

  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  --white: #FFFFFF;
  --bg: #F8F9FC;
  --bg-card: #FFFFFF;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, monospace;

  --transition-fast: 150ms ease;
  --transition-normal: 250ms ease;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  color: var(--gray-800);
  background-color: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

button {
  cursor: pointer;
  font-family: inherit;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ===== HEADER ===== */

.app-header {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 24px;
  box-shadow: var(--shadow-sm);
}

.app-header__inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.app-header__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gray-900);
}

.app-header__subtitle {
  font-size: 0.875rem;
  color: var(--gray-500);
}

/* ===== MAIN ===== */

.app-main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* ===== METRICS ===== */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.metric-card:hover {
  box-shadow: var(--shadow-md);
}

.metric-card--confirmed {
  border-left: 4px solid var(--color-primary);
}

.metric-card--checked {
  border-left: 4px solid var(--color-success);
}

.metric-card--waitlist {
  border-left: 4px solid var(--color-warning);
}

.metric-card__value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--gray-900);
  line-height: 1.2;
}

.metric-card__label {
  display: block;
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

/* ===== TOOLBAR ===== */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  align-items: center;
}

.toolbar__search {
  flex: 1 1 280px;
}

.toolbar__filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

/* ===== INPUTS ===== */

.input {
  display: block;
  width: 100%;
  padding: 8px 12px;
  font-size: 0.875rem;
  color: var(--gray-800);
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.input:hover {
  border-color: var(--gray-400);
}

.input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.input:disabled {
  background: var(--gray-100);
  color: var(--gray-400);
  cursor: not-allowed;
}

.input--search {
  padding-left: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%239CA3AF' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 10-1.397 1.398h-.001l3.85 3.85a1 1 0 001.415-1.414l-3.85-3.85-.017.016zm-5.242.156a5 5 0 110-10 5 5 0 010 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

.input--select {
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: calc(100% - 10px) center;
  cursor: pointer;
}

.input--error {
  border-color: var(--color-danger);
}

.input--error:focus {
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

/* ===== BUTTONS ===== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  white-space: nowrap;
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--white);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--secondary {
  background: var(--white);
  color: var(--gray-700);
  border-color: var(--gray-300);
}

.btn--secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn--ghost {
  background: transparent;
  color: var(--gray-600);
}

.btn--ghost:hover:not(:disabled) {
  background: var(--gray-100);
}

.btn--danger {
  background: var(--color-danger);
  color: var(--white);
}

.btn--danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.btn--success {
  background: var(--color-success);
  color: var(--white);
}

.btn--success:hover:not(:disabled) {
  background: var(--color-success-hover);
}

.btn--link {
  background: none;
  border: none;
  color: var(--color-primary);
  padding: 0;
  text-decoration: underline;
}

.btn--link:hover {
  color: var(--color-primary-hover);
}

.btn--sm {
  padding: 4px 8px;
  font-size: 0.8125rem;
}

/* ===== TABLE ===== */

.table-wrapper {
  margin-bottom: 24px;
}

.participants-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.participants-table th,
.participants-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.875rem;
}

.participants-table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.participants-table__th {
  font-weight: 600;
  color: var(--gray-600);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  user-select: none;
}

.participants-table__th--actions {
  text-align: right;
  width: 180px;
}

.sort-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}

.participants-table__th[data-sort] {
  cursor: pointer;
}

.participants-table__th[data-sort] .sort-btn:hover {
  color: var(--color-primary);
}

.sort-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.sort-icon {
  display: inline-block;
  width: 12px;
  text-align: center;
  font-size: 0.7rem;
}

.sort-icon::after {
  content: '⇅';
}

.sort-asc .sort-icon::after {
  content: '↑';
}

.sort-desc .sort-icon::after {
  content: '↓';
}

.participants-table tbody tr {
  transition: background-color var(--transition-fast);
}

.participants-table tbody tr:hover {
  background-color: var(--gray-50);
}

.participants-table td:last-child {
  text-align: right;
}

.participants-table__actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

/* ===== STATUS BADGES ===== */

.badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 9999px;
  line-height: 1.4;
}

.badge--new {
  background: var(--gray-100);
  color: var(--gray-600);
}

.badge--confirmed {
  background: var(--color-primary-light);
  color: var(--color-primary);
}

.badge--waitlist {
  background: var(--color-warning-light);
  color: #92400E;
}

.badge--cancelled {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.badge--checked {
  background: var(--color-success-light);
  color: #065F46;
}

.badge--standard {
  background: var(--gray-100);
  color: var(--gray-700);
}

.badge--business {
  background: #EEF2FF;
  color: #3730A3;
}

.badge--vip {
  background: #FDF2F8;
  color: #9D174D;
}

/* ===== EMPTY STATE ===== */

.empty-state {
  text-align: center;
  padding: 60px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--gray-300);
  border-radius: var(--radius-lg);
}

.empty-state__icon {
  color: var(--gray-300);
  margin-bottom: 16px;
}

.empty-state__text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 4px;
}

.empty-state__hint {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-bottom: 16px;
}

.empty-state__actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== SEARCH EMPTY ===== */

.search-empty {
  text-align: center;
  padding: 24px;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.search-empty .btn {
  margin-left: 8px;
}

/* ===== LOADING ===== */

.loading-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--gray-500);
  font-size: 0.875rem;
}

.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== MODAL ===== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
}

.modal-overlay[hidden] {
  display: none;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal--wide {
  max-width: 800px;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal__title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--gray-400);
  line-height: 1;
  padding: 4px;
  transition: color var(--transition-fast);
}

.modal__close:hover {
  color: var(--gray-700);
}

.modal__body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

/* ===== FORM ===== */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 4px;
}

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

.form-error {
  display: block;
  font-size: 0.75rem;
  color: var(--color-danger);
  margin-top: 4px;
  min-height: 1em;
}

.form-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.checkbox-label input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.warning-text {
  color: var(--color-warning);
  font-weight: 500;
  margin-top: 8px;
}

/* ===== TOAST ===== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 400px;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 0.875rem;
  animation: toastIn var(--transition-normal);
}

.toast--success {
  background: var(--color-success-light);
  color: #065F46;
  border: 1px solid var(--color-success);
}

.toast--error {
  background: var(--color-danger-light);
  color: #991B1B;
  border: 1px solid var(--color-danger);
}

.toast--info {
  background: var(--gray-800);
  color: var(--white);
}

.toast__text {
  flex: 1;
}

.toast__action {
  background: none;
  border: none;
  color: inherit;
  font-weight: 600;
  font-size: 0.8125rem;
  text-decoration: underline;
  cursor: pointer;
  white-space: nowrap;
}

.toast__action:hover {
  opacity: 0.8;
}

.toast__close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.125rem;
  line-height: 1;
  padding: 2px;
  opacity: 0.6;
  cursor: pointer;
}

.toast__close:hover {
  opacity: 1;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== ACTIVITY LOG ===== */

.activity-log {
  background: var(--bg-card);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.activity-log__title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.activity-log__list {
  list-style: none;
}

.activity-log__list li {
  display: flex;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
  font-size: 0.8125rem;
  color: var(--gray-600);
}

.activity-log__list li:last-child {
  border-bottom: none;
}

.activity-log__time {
  color: var(--gray-400);
  white-space: nowrap;
  flex-shrink: 0;
}

.activity-log__empty {
  font-size: 0.8125rem;
  color: var(--gray-400);
  font-style: italic;
}

/* ===== CSV PREVIEW ===== */

.csv-summary {
  margin-bottom: 16px;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.csv-summary strong {
  color: var(--gray-900);
}

.csv-table-wrapper {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
}

.csv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.csv-table th,
.csv-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.csv-table thead {
  position: sticky;
  top: 0;
  background: var(--gray-50);
}

.csv-table .row-error {
  color: var(--color-danger);
}

.csv-table .row-ok {
  color: var(--color-success);
}

.csv-table .row-duplicate {
  color: var(--color-warning);
}

/* ===== RESPONSIVE: TABLET (768px) ===== */

@media (max-width: 768px) {
  .metrics {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar__filters {
    flex-wrap: wrap;
  }

  .toolbar__actions {
    margin-left: 0;
    justify-content: flex-start;
  }

  .app-header__inner {
    flex-direction: column;
    gap: 4px;
  }

  .participants-table {
    display: block;
    overflow-x: auto;
  }

  .toast-container {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: none;
  }

  .modal {
    max-width: 100%;
    margin: 16px;
  }

  .modal--wide {
    max-width: 100%;
  }
}

/* ===== RESPONSIVE: MOBILE (390px) ===== */

@media (max-width: 480px) {
  .metrics {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric-card {
    padding: 12px;
  }

  .metric-card__value {
    font-size: 1.5rem;
  }

  .app-main {
    padding: 16px;
  }

  .toolbar__actions {
    flex-direction: column;
  }

  .toolbar__actions .btn {
    width: 100%;
  }

  .modal__footer {
    flex-direction: column;
  }

  .modal__footer .btn {
    width: 100%;
  }

  .participants-table th,
  .participants-table td {
    padding: 8px 10px;
    font-size: 0.8125rem;
  }
}
