/* ---- App Header ---- */

.app-header {
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  padding: 0 clamp(1.5rem, 4vw, 3rem);
}

.app-header-inner {
  max-width: 68rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 3.5rem;
}

.app-header .logo {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.04em;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-header-right {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.app-header-user {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.app-header-signout {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  background: none;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  padding: 0.375rem 0.75rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.app-header-signout:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

/* ---- App Main ---- */

.app-main {
  max-width: 68rem;
  margin: 0 auto;
  padding: var(--space-lg) clamp(1.5rem, 4vw, 3rem);
}

/* ---- App Header Nav ---- */

.app-header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.app-header-nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
}

.app-header-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.app-header-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface);
}

/* ---- Admin Nav ---- */

.admin-nav {
  display: flex;
  gap: 0.25rem;
  margin-left: var(--space-md);
}

.app-header-admin {
  border-bottom-color: var(--red);
}

.admin-badge {
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-nav-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.375rem 0.625rem;
  border-radius: 0.375rem;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}

.admin-nav-link:hover {
  color: var(--text-primary);
  background: var(--bg-surface);
}

.admin-nav-link.active {
  color: var(--text-primary);
  background: var(--bg-surface);
}

/* ---- Auth Layout ---- */

.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.auth-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 2rem;
  width: 100%;
  max-width: 24rem;
}

.auth-logo {
  display: block;
  text-align: center;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.04em;
  margin-bottom: var(--space-md);
}

.auth-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  text-align: center;
  margin-bottom: var(--space-md);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.auth-footer a {
  color: var(--blue);
  font-weight: 500;
}

.auth-errors {
  background: rgba(185, 28, 28, 0.08);
  border: 1px solid rgba(185, 28, 28, 0.2);
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  margin-bottom: var(--space-sm);
  font-size: 0.8125rem;
  color: var(--red);
}

/* ---- Stat Row ---- */

.stat-row {
  display: flex;
  gap: var(--space-md);
  font-size: 0.8125rem;
}

.stat-item {
  color: var(--text-muted);
}

.stat-item strong {
  color: var(--text-primary);
}

a.stat-item {
  text-decoration: none;
}

/* ---- Filter Bar ---- */

.filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.filter-bar-left {
  display: flex;
  align-items: baseline;
  gap: var(--space-sm);
}

.filter-form {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.filter-label {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.filter-select-sm { width: 5rem; }
.filter-text-md { width: 10rem; }

/* ---- Seat Items ---- */

.seat-item {
  border-bottom: 1px solid var(--border);
}

.seat-item:last-child {
  border-bottom: none;
}

.seat-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.key-gen-form {
  display: flex;
  gap: var(--space-sm);
  align-items: end;
}

.key-gen-input {
  margin-bottom: 0;
  flex: 1;
}

/* ---- Full-Height Page ---- */

.page-full-height {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 3.5rem - 5rem);
}

.card-flex {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.card-flex-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

/* ---- Token Bar ---- */

.token-bar {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.token-bar-track {
  flex: 1;
  height: 0.5rem;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.token-bar-fill {
  height: 100%;
  background: var(--blue);
  border-radius: 2px;
}

.token-bar-col {
  min-width: 200px;
}

.token-bar-label {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 3rem;
  text-align: right;
}

/* ---- Responsive ---- */

@media (max-width: 768px) {
  .app-header-inner {
    flex-wrap: wrap;
    height: auto;
    padding: 0.75rem 0;
    gap: 0.5rem;
  }

  .app-header-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-header-right {
    gap: var(--space-sm);
  }

  .app-header-user {
    display: none;
  }

  .app-header-left {
    width: 100%;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .admin-nav {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    margin-left: 0;
    gap: 0.125rem;
  }

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

  .filter-form {
    flex-wrap: wrap;
  }

  .stat-row {
    flex-wrap: wrap;
  }

  .app-main {
    padding: var(--space-md) var(--space-sm);
  }

  .section-header-row {
    flex-direction: column;
    gap: var(--space-sm);
  }

  .danger-zone {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
  }

  .form-row {
    flex-direction: column;
  }
}
