:root {
  --background: #0d0d0d;
  --foreground: #ffffff;
  --card: #161616;
  --card-strong: #1e1e1e;
  --muted: #b6b6b6;
  --subtle: #606060;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --accent: #1caafc;
  --accent-hover: #46b8fc;
  --accent-soft: rgba(28, 170, 252, 0.12);
  --destructive: #ff4a3d;
  --destructive-soft: rgba(255, 74, 61, 0.14);
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.topbar {
  align-items: center;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 22px 28px 18px;
}

.dashboard-nav {
  background: rgba(13, 13, 13, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding: 12px 28px;
  scrollbar-width: none;
}

.dashboard-nav::-webkit-scrollbar {
  display: none;
}

.dashboard-nav a {
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 13px;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
  white-space: nowrap;
}

.dashboard-nav a:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-strong);
  color: var(--foreground);
}

.topbar h1,
.login-shell h1,
.panel h2 {
  margin: 0;
}

.topbar h1 {
  font-size: 36px;
  font-weight: 500;
  line-height: 1.08;
}

.panel h2 {
  font-size: 18px;
  font-weight: 600;
}

.topbar p,
.panel-heading p {
  color: var(--muted);
  margin: 6px 0 0;
}

.dashboard-shell {
  display: grid;
  gap: 18px;
  padding: 20px 22px 38px;
}

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

.metric,
.panel,
.login-shell {
  background: linear-gradient(180deg, rgba(22, 22, 22, 0.98), rgba(16, 16, 16, 0.98));
  border: 1px solid var(--border);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.04),
    var(--shadow);
}

.metric {
  display: grid;
  gap: 10px;
  min-height: 112px;
  padding: 17px;
}

.metric > span,
.metric-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
}

.metric strong {
  color: var(--foreground);
  font-size: 28px;
  font-weight: 500;
  line-height: 1.1;
}

.panel {
  overflow-x: auto;
}

.waitlist-dashboard .metrics-grid > *,
.waitlist-dashboard .panel,
.waitlist-dashboard .chart-wrap {
  min-width: 0;
}

.waitlist-dashboard .dashboard-shell {
  margin: 0 auto;
  max-width: 1080px;
  width: 100%;
}

.waitlist-dashboard .panel {
  overflow: hidden;
}

.waitlist-breakdown-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.waitlist-chart-table-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 520px), 1fr));
}

.panel-heading {
  align-items: baseline;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 16px;
  justify-content: space-between;
  padding: 16px 18px;
}

.panel-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.panel-actions p {
  margin: 0;
}

.toggle-control {
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  gap: 7px;
  text-transform: uppercase;
  white-space: nowrap;
}

.toggle-control input {
  height: 1px;
  opacity: 0;
  position: absolute;
  width: 1px;
}

.toggle-switch {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  display: inline-flex;
  height: 22px;
  position: relative;
  transition:
    background-color 140ms ease,
    border-color 140ms ease;
  width: 38px;
}

.toggle-switch::after {
  background: var(--muted);
  border-radius: 50%;
  content: "";
  height: 16px;
  left: 2px;
  position: absolute;
  top: 2px;
  transition:
    background-color 140ms ease,
    transform 140ms ease;
  width: 16px;
}

.toggle-control input:checked + .toggle-switch {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.toggle-control input:checked + .toggle-switch::after {
  background: var(--accent);
  transform: translateX(16px);
}

.toggle-control input:focus-visible + .toggle-switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.help-tooltip {
  align-items: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--foreground);
  cursor: help;
  display: inline-flex;
  font-size: 11px;
  height: 17px;
  justify-content: center;
  margin-left: 5px;
  position: relative;
  text-transform: none;
  vertical-align: middle;
  width: 17px;
}

.help-tooltip::after {
  background: var(--card-strong);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow);
  color: var(--foreground);
  content: attr(aria-label);
  font-size: 12px;
  font-weight: 500;
  left: 50%;
  line-height: 1.35;
  opacity: 0;
  padding: 9px 10px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  text-transform: none;
  top: calc(100% + 8px);
  transform: translateX(-50%) translateY(-4px);
  transition:
    opacity 120ms ease,
    transform 120ms ease;
  visibility: hidden;
  width: min(260px, calc(100vw - 48px));
  z-index: 5;
}

.help-tooltip:hover::after,
.help-tooltip:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  visibility: visible;
}

.filter-form {
  align-items: end;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 18px;
}

.filter-form label {
  color: var(--muted);
  display: grid;
  font-size: 12px;
  font-weight: 700;
  gap: 7px;
  text-transform: uppercase;
}

.filter-form .toggle-control {
  display: inline-flex;
  min-height: 38px;
}

.filter-form input {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-strong);
  color: var(--foreground);
  font: inherit;
  min-height: 38px;
  padding: 8px 10px;
}

.panel-metrics {
  border-bottom: 1px solid var(--border);
  padding: 16px 20px 0;
}

.chart-wrap {
  padding: 18px;
}

.doughnut-chart-wrap {
  height: 260px;
}

.stacked-chart-wrap {
  height: 420px;
}

.stacked-chart-wrap-short {
  height: 280px;
}

.split-chart-wrap {
  padding-bottom: 22px;
}

.split-chart-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}

.split-chart-panel {
  display: grid;
  gap: 10px;
  height: 280px;
  min-width: 0;
}

.split-chart-panel h3 {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
}

table {
  border-collapse: collapse;
  min-width: 560px;
  width: 100%;
}

.table-scroll {
  overflow-x: auto;
  width: 100%;
}

.waitlist-dashboard .table-scroll table {
  min-width: 0;
  table-layout: fixed;
}

th,
td {
  border-top: 1px solid var(--border);
  overflow-wrap: anywhere;
  padding: 12px 14px;
  text-align: right;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

td {
  color: #dfdfdf;
  font-size: 14px;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.025);
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 16px;
}

.login-shell {
  display: grid;
  gap: 18px;
  padding: 28px;
  width: min(420px, calc(100vw - 32px));
}

.login-shell h1 {
  font-size: 2rem;
  font-weight: 500;
  line-height: 1.12;
}

.login-note {
  color: var(--muted);
  line-height: 1.45;
  margin: 0;
}

.primary-button,
.secondary-button {
  border-radius: 999px;
  display: inline-flex;
  font-weight: 600;
  justify-content: center;
  padding: 10px 16px;
  text-decoration: none;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease,
    transform 140ms ease;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button {
  background: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: 0 10px 24px rgba(28, 170, 252, 0.24);
  color: #000000;
}

.primary-button:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-strong);
  color: var(--muted);
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--foreground);
}

.error-message {
  background: var(--destructive-soft);
  border: 1px solid rgba(255, 74, 61, 0.34);
  color: #ffa29c;
  margin: 0;
  padding: 10px 12px;
}

@media (max-width: 720px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px 16px 16px;
  }

  .topbar h1 {
    font-size: 28px;
  }

  .dashboard-nav {
    padding: 10px 16px;
  }

  .dashboard-shell {
    padding: 16px 12px 28px;
  }

  .waitlist-breakdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .metric strong {
    font-size: 24px;
  }

  table {
    min-width: 520px;
  }

  .waitlist-dashboard th,
  .waitlist-dashboard td {
    padding: 10px 8px;
  }
}

@media (max-width: 460px) {
  .waitlist-breakdown-grid {
    grid-template-columns: 1fr;
  }
}
