:root {
  --brand: #a93cff;
  --brand-deep: #6e00f9;
  --text: #f2f2f4;
  --muted: #a6a6ad;
  --bg: #17171b;
  --panel: #202127;
  --line: rgba(255, 255, 255, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 24px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.card {
  width: 100%;
  max-width: 420px;
  margin: min(15vh, 120px) auto 0;
  text-align: center;
}

h1 {
  margin: 0 0 10px;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.2;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
}

.spinner {
  width: 32px;
  height: 32px;
  margin: 0 auto 17px;
  border: 3px solid rgba(169, 60, 255, 0.22);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.actions {
  display: block;
}

.btn {
  display: block;
  width: 100%;
  margin: 11px 0;
  padding: 16px 20px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.btn--primary {
  border: 0;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-deep) 100%);
  box-shadow: 0 10px 26px rgba(110, 0, 249, 0.4);
  color: #fff;
  font-size: 18px;
}

.btn--secondary {
  padding: 13px 20px;
  color: #cbb2ff;
  font-size: 15px;
  font-weight: 600;
}

.channel-direct {
  display: flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  margin: 1px 0 7px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

.dashboard {
  width: 100%;
}

.dashboard-shell {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin: 8px 0 26px;
}

.dashboard-header h1 {
  margin: 2px 0 6px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.035em;
}

.eyebrow {
  margin: 0;
  color: #c58aff;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.dashboard-note,
.cohort-note,
.section-heading p,
.login-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.control-button {
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #282932;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.control-button:hover {
  border-color: rgba(197, 138, 255, 0.65);
}

.control-button:disabled {
  opacity: 0.45;
  cursor: default;
}

.control-button--primary {
  border-color: transparent;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
}

.control-button--quiet {
  background: transparent;
}

.login-panel,
.data-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.login-panel {
  max-width: 520px;
  margin: 12vh auto 0;
  padding: 26px;
}

.login-panel h2,
.section-heading h2 {
  margin: 0 0 5px;
  font-size: 20px;
}

.login-form {
  display: grid;
  gap: 13px;
  margin-top: 22px;
}

.login-form label,
.filters label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

input,
select {
  min-height: 43px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
  background: #17181d;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(169, 60, 255, 0.15);
}

.form-error,
.dashboard-status {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.form-error,
.dashboard-status--error {
  color: #ff9a9f;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(150px, 0.7fr)) minmax(240px, 1.3fr);
  gap: 10px;
  margin-bottom: 12px;
}

.cohort-note {
  margin: 0 0 17px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.metric-card {
  min-height: 112px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(145deg, #23242b, #1d1e24);
}

.metric-card span {
  display: block;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
}

.metric-card strong {
  display: block;
  margin-top: 8px;
  font-size: 32px;
  line-height: 1;
}

.metric-card--accent strong { color: #c58aff; }
.metric-card--positive strong { color: #66d69d; }
.metric-card--negative strong { color: #ff8d94; }
.metric-card--return strong { color: #70b7ff; }

.data-panel {
  margin-top: 12px;
  overflow: hidden;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  padding: 19px 20px 15px;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 13px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

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

.person-name {
  display: block;
  max-width: 230px;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
}

.person-meta,
.date-secondary {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.history-note {
  display: block;
  margin-top: 5px;
  color: #8bc8ff;
  font-size: 11px;
  font-weight: 700;
}

.state-pill {
  display: inline-block;
  padding: 5px 9px;
  border-radius: 999px;
  background: #30313a;
  font-size: 12px;
  font-weight: 800;
}

.state-pill--subscribed { background: rgba(54, 180, 112, 0.18); color: #79e3aa; }
.state-pill--unsubscribed { background: rgba(226, 79, 89, 0.18); color: #ff9da4; }
.state-pill--resubscribed { background: rgba(64, 145, 231, 0.18); color: #8bc8ff; }
.state-pill--clicked { background: rgba(169, 60, 255, 0.17); color: #d4a4ff; }

.empty-state {
  margin: 0;
  padding: 24px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  text-align: center;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 15px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 13px;
}

.dashboard-status {
  display: block;
  min-height: 20px;
  margin-top: 14px;
  text-align: right;
}

@media (max-width: 900px) {
  body { padding: 16px; }
  .summary-grid { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: repeat(2, 1fr); }
  .filter-search { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .dashboard-header { display: block; }
  .header-actions { margin-top: 16px; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 100px; }
  .filters { grid-template-columns: 1fr; }
  .filter-search { grid-column: auto; }
  .login-panel { margin-top: 6vh; padding: 20px; }

  .people-table,
  .people-table tbody,
  .people-table tr,
  .people-table td {
    display: block;
    width: 100%;
  }

  .people-table thead {
    display: none;
  }

  .people-table tr {
    padding: 12px 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
  }

  .people-table td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 10px;
    padding: 6px 0;
    border: 0;
    white-space: normal;
  }

  .people-table td:first-child {
    display: block;
    padding-bottom: 10px;
  }

  .people-table td:not(:first-child)::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.03em;
    text-transform: uppercase;
  }
}
