:root {
  color-scheme: light;
  --navy-950: #071e30;
  --navy-900: #0b2f49;
  --navy-800: #124766;
  --blue-700: #176388;
  --blue-100: #dceef5;
  --gold-500: #c99b2f;
  --gold-300: #e8c66a;
  --silver-50: #f7f9fa;
  --silver-100: #edf1f3;
  --silver-200: #d8e0e4;
  --silver-500: #71808a;
  --ink-900: #12212b;
  --ink-700: #344a58;
  --white: #ffffff;
  --success: #13705a;
  --success-soft: #e3f5ef;
  --danger: #a83535;
  --danger-soft: #fff0f0;
  --shadow: 0 18px 50px rgb(7 30 48 / 9%);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

html {
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--silver-50);
  color: var(--ink-900);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 95% 0%, rgb(232 198 106 / 14%), transparent 28rem),
    var(--silver-50);
}

button,
input,
select {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.skip-link {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--navy-900);
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    linear-gradient(135deg, rgb(7 30 48 / 97%), rgb(18 71 102 / 94%)),
    var(--navy-950);
}

.login-card {
  width: min(100%, 29rem);
  padding: clamp(2rem, 7vw, 3.25rem);
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 28px;
  background: rgb(255 255 255 / 97%);
  box-shadow: 0 28px 80px rgb(0 0 0 / 28%);
  text-align: center;
}

.brand-mark {
  width: 4.25rem;
  height: 4.25rem;
  display: grid;
  place-items: center;
  margin: 0 auto 1.5rem;
  border-radius: 18px;
  background: var(--navy-900);
  box-shadow: inset 0 0 0 2px rgb(232 198 106 / 38%);
  color: var(--gold-300);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.brand-mark-small {
  width: 2.75rem;
  height: 2.75rem;
  margin: 0;
  border-radius: 11px;
  font-size: 0.85rem;
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--blue-700);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.login-card h1,
.page-heading h1,
.section-heading h2,
.panel-heading h2 {
  margin: 0;
  color: var(--navy-950);
  letter-spacing: -0.035em;
}

.login-card h1 {
  font-size: clamp(1.9rem, 6vw, 2.55rem);
  line-height: 1.1;
}

.login-description {
  margin: 1rem 0 1.75rem;
  color: var(--ink-700);
  font-size: 1rem;
  line-height: 1.65;
}

.security-note {
  margin: 1.3rem 0 0;
  color: var(--silver-500);
  font-size: 0.8rem;
  line-height: 1.55;
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 2.75rem;
  border-radius: var(--radius-sm);
  font-weight: 750;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.primary-button {
  border: 1px solid var(--navy-900);
  padding: 0.75rem 1.15rem;
  background: var(--navy-900);
  color: var(--white);
  box-shadow: 0 8px 18px rgb(11 47 73 / 18%);
}

.primary-button:hover {
  background: var(--navy-800);
  transform: translateY(-1px);
}

.secondary-button {
  border: 1px solid var(--silver-200);
  padding: 0.75rem 1.15rem;
  background: var(--white);
  color: var(--navy-900);
}

.secondary-button:hover {
  border-color: var(--navy-800);
}

.text-button {
  border: 0;
  padding: 0.5rem 0.75rem;
  background: transparent;
  color: var(--navy-800);
}

.text-button:hover {
  background: var(--blue-100);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold-300);
  outline-offset: 2px;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.link-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4.5rem;
  padding: 0.75rem max(1rem, calc((100vw - 84rem) / 2));
  border-bottom: 1px solid rgb(216 224 228 / 80%);
  background: rgb(255 255 255 / 92%);
  backdrop-filter: blur(14px);
}

.brand-lockup,
.account-area,
.page-heading,
.section-heading,
.panel-heading,
.filter-actions {
  display: flex;
  align-items: center;
}

.brand-lockup {
  gap: 0.8rem;
}

.product-name {
  margin: 0;
  color: var(--navy-950);
  font-size: 1rem;
  font-weight: 800;
}

.account-area {
  gap: 0.5rem;
}

.user-email {
  max-width: 20rem;
  overflow: hidden;
  color: var(--ink-700);
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-main {
  width: min(100% - 2rem, 84rem);
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}

.page-heading,
.section-heading,
.panel-heading {
  justify-content: space-between;
  gap: 1.5rem;
}

.page-heading {
  margin-bottom: 1.4rem;
}

.page-heading h1 {
  font-size: clamp(2rem, 5vw, 3.15rem);
}

.report-period,
.section-heading > p,
.dashboard-footer,
.empty-message {
  color: var(--silver-500);
}

.report-period {
  margin: 0.5rem 0 0;
  font-size: 0.95rem;
}

.status-pill {
  flex: none;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: var(--silver-100);
  color: var(--ink-700);
  font-size: 0.78rem;
  font-weight: 750;
}

.status-pill[data-state="loading"] {
  background: #fff5d6;
  color: #765b12;
}

.status-pill[data-state="success"] {
  background: var(--success-soft);
  color: var(--success);
}

.filters-panel,
.panel,
.metric-card {
  border: 1px solid var(--silver-200);
  background: var(--white);
  box-shadow: var(--shadow);
}

.filters-panel {
  margin-bottom: 2.75rem;
  padding: 1.25rem;
  border-radius: var(--radius-lg);
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.9rem;
}

.filter-grid label {
  display: grid;
  gap: 0.45rem;
}

.filter-grid label > span {
  color: var(--ink-700);
  font-size: 0.78rem;
  font-weight: 750;
}

.filter-grid input,
.filter-grid select {
  width: 100%;
  min-height: 2.75rem;
  border: 1px solid var(--silver-200);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.75rem;
  background: var(--silver-50);
  color: var(--ink-900);
  font-size: 0.9rem;
}

.filter-grid input:hover,
.filter-grid select:hover {
  border-color: #a9b7bf;
}

.filter-actions {
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1rem;
}

.error-banner,
.fatal-message {
  border: 1px solid #f0b7b7;
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
}

.error-banner {
  display: grid;
  gap: 0.25rem;
  margin: -1.5rem 0 2rem;
  padding: 1rem 1.2rem;
}

.fatal-message {
  width: min(100% - 2rem, 42rem);
  margin: 3rem auto;
  padding: 1.5rem;
}

.section-heading {
  align-items: end;
  margin: 0 0 1rem;
}

.section-heading h2,
.panel-heading h2 {
  font-size: clamp(1.35rem, 3vw, 1.8rem);
}

.section-heading > p {
  max-width: 28rem;
  margin: 0;
  font-size: 0.88rem;
  text-align: right;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1rem;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 9.25rem;
  padding: 1.2rem;
  border-radius: var(--radius-md);
}

.metric-card::after {
  content: "";
  position: absolute;
  right: -1rem;
  bottom: -1.75rem;
  width: 5rem;
  height: 5rem;
  border-radius: 50%;
  background: var(--blue-100);
}

.metric-index {
  color: var(--gold-500);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.1em;
}

.metric-value {
  display: block;
  margin: 0.65rem 0 0.25rem;
  color: var(--navy-950);
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  line-height: 1;
}

.metric-label {
  position: relative;
  z-index: 1;
  color: var(--ink-700);
  font-size: 0.85rem;
  line-height: 1.35;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 1.35rem;
}

.funnel-panel {
  margin-top: 1rem;
}

.funnel-bars,
.rate-list {
  display: grid;
  gap: 1rem;
}

.funnel-row,
.rate-row {
  display: grid;
  grid-template-columns: minmax(10rem, 1fr) minmax(12rem, 3fr) 4.5rem;
  align-items: center;
  gap: 1rem;
}

.funnel-row-label,
.rate-label {
  color: var(--ink-700);
  font-size: 0.85rem;
  font-weight: 700;
}

.bar-track {
  height: 0.72rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--silver-100);
}

.bar-fill {
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--navy-800), var(--blue-700));
}

.funnel-row:nth-child(2) .bar-fill,
.funnel-row:nth-child(4) .bar-fill {
  background: linear-gradient(90deg, var(--gold-500), var(--gold-300));
}

.bar-value,
.rate-value {
  color: var(--navy-950);
  font-variant-numeric: tabular-nums;
  font-weight: 850;
  text-align: right;
}

.two-column-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  margin: 2.75rem 0;
}

.panel-heading {
  margin-bottom: 1.35rem;
}

.unit-label {
  color: var(--gold-500);
  font-size: 1.1rem;
  font-weight: 850;
}

.rate-row {
  grid-template-columns: minmax(9rem, 1.5fr) minmax(7rem, 2fr) 4rem;
  gap: 0.75rem;
}

.email-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
}

.email-metric {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  background: var(--silver-50);
}

.email-metric-value {
  display: block;
  color: var(--navy-950);
  font-size: 1.45rem;
  font-variant-numeric: tabular-nums;
  font-weight: 850;
}

.email-metric-label {
  color: var(--silver-500);
  font-size: 0.75rem;
  line-height: 1.35;
}

.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.table-panel h3 {
  margin: 0 0 1rem;
  color: var(--navy-950);
  font-size: 1rem;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  padding: 0.7rem 0.55rem;
  border-bottom: 1px solid var(--silver-100);
  text-align: right;
  white-space: nowrap;
}

th:first-child,
td:first-child {
  text-align: left;
}

th {
  color: var(--silver-500);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

td {
  color: var(--ink-700);
  font-variant-numeric: tabular-nums;
}

.empty-message {
  margin: 0;
  padding: 1rem 0;
  font-size: 0.85rem;
}

.dashboard-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 2.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--silver-200);
  font-size: 0.78rem;
}

.dashboard-footer p {
  margin: 0;
}

@media (max-width: 72rem) {
  .filter-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 48rem) {
  .topbar {
    align-items: flex-start;
  }

  .account-area {
    align-items: flex-end;
    flex-direction: column;
  }

  .user-email {
    max-width: 11rem;
  }

  .dashboard-main {
    width: min(100% - 1.25rem, 84rem);
    padding-top: 1.5rem;
  }

  .page-heading,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .section-heading > p {
    text-align: left;
  }

  .filter-grid,
  .metric-grid,
  .two-column-section,
  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .metric-card {
    min-height: 7.5rem;
  }

  .funnel-row,
  .rate-row {
    grid-template-columns: 1fr 4rem;
  }

  .funnel-row .bar-track,
  .rate-row .bar-track {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .filter-actions {
    align-items: stretch;
    flex-direction: column-reverse;
  }

  .filter-actions button {
    width: 100%;
  }

  .dashboard-footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
