:root {
  color-scheme: light;
  --ink: #18201b;
  --muted: #68736d;
  --line: #dce2de;
  --paper: #f7f5f0;
  --panel: #ffffff;
  --soft: #edf1ed;
  --accent: #1f6b4f;
  --accent-dark: #174d39;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 14px clamp(18px, 5vw, 64px);
  background: rgba(247, 245, 240, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 38px;
  height: 38px;
}

.brand strong {
  display: block;
  font-size: 18px;
}

.brand span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

nav {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  flex-wrap: wrap;
  justify-content: flex-end;
}

nav a,
nav button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 8px 10px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--muted);
}

nav a:hover,
nav button:hover {
  color: var(--ink);
}

.navLink.active {
  color: var(--ink);
}

main {
  min-height: 100vh;
}

.pageView {
  min-height: calc(100vh - 68px);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 380px);
  gap: 64px;
  align-items: start;
  max-width: 1100px;
  margin-inline: auto;
  padding: clamp(44px, 7vw, 82px) clamp(18px, 5vw, 64px);
}

.eyebrow {
  color: var(--accent);
  font-weight: 700;
  margin: 0 0 12px;
}

h1 {
  max-width: 640px;
  margin: 0 0 20px;
  font-size: clamp(36px, 4.5vw, 56px);
  line-height: 1.12;
  letter-spacing: 0;
}

h2 {
  margin: 0 0 16px;
  font-size: 24px;
  letter-spacing: 0;
}

h3 {
  margin: 0 0 14px;
  font-size: 19px;
}

.lead {
  max-width: 520px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.7;
  margin: 0 0 28px;
}

.heroActions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

button,
.primary,
.secondary,
.ghost {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 15px;
  font: inherit;
  cursor: pointer;
  background: var(--panel);
  min-height: 42px;
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary,
.ghost {
  color: var(--ink);
}

.smallLink {
  color: var(--accent);
  font-weight: 700;
}

.heroSteps {
  display: grid;
  gap: 0;
}

.heroSteps div {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 8px 14px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}

.heroSteps div:last-child {
  border-bottom: 0;
}

.heroSteps em {
  color: var(--accent);
  font-size: 22px;
  font-style: normal;
  font-weight: 800;
  line-height: 1;
  grid-row: span 2;
}

.heroSteps strong {
  font-size: 17px;
}

.heroSteps span {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
  grid-column: 2;
}

.heroSteps b {
  color: var(--ink);
}

.serviceBox,
.panel,
.authPanel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
}

.portalSection .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  margin-bottom: 24px;
}
.portalSection .panel h3 {
  font-size: 16px;
  color: var(--ink);
  margin: 0 0 14px 0;
  font-weight: 700;
}


.section {
  padding: 42px clamp(18px, 5vw, 64px);
}

.sectionHead {
  max-width: 1100px;
  margin-inline: auto;
  margin-bottom: 20px;
  text-align: center;
}

.sectionHead p,
.muted {
  color: var(--muted);
  line-height: 1.6;
}

.plansTableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  max-width: 1100px;
  margin-inline: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.plansTable th,
.plansTable td {
  padding: 14px 16px;
  font-size: 15px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.accountLayout {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 760px;
  margin-inline: auto;
  min-height: calc(100vh - 68px);
}

.authPanel {
  width: min(440px, 100%);
  padding: 26px;
}

.tabs {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  padding: 4px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  overflow: hidden;
}

.tabs::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: calc(50% - 4px);
  border-radius: 999px;
  background: var(--accent);
  transition: transform 0.18s ease;
}

.tabs.loginMode::before {
  transform: translateX(100%);
}

.tab {
  position: relative;
  z-index: 1;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.tab.active {
  color: white;
}

.form {
  display: grid;
  gap: 13px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 14px;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 11px 12px;
  font: inherit;
  color: var(--ink);
  background: white;
  min-width: 0;
}

.inlineFields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
}

.inlineFields .secondary {
  min-width: 116px;
  padding-inline: 12px;
  white-space: nowrap;
}

.portalSection {
  max-width: 1100px;
  margin-inline: auto;
}

.dashboardCards {
  display: flex;
  gap: 20px;
  max-width: 1100px;
  margin-inline: auto;
  margin-bottom: 32px;
}

.dashCard--primary {
  flex: 0 0 260px;
}

.dashCard:not(.dashCard--primary) {
  flex: 1 1 auto;
}

.dashCard--referral {
  flex: 1.2 1 300px;
}

.dashCard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dashCard--primary {
  border-left: 4px solid var(--accent);
}

.statRow {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.statValue {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.1;
}

.statUnit {
  color: var(--muted);
  font-size: 14px;
}

.infoLine {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.infoLine strong {
  font-size: 15px;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.infoLine .ghost {
  padding: 3px 10px;
  font-size: 12px;
  min-height: auto;
  margin-left: auto;
}

.infoLine--top {
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 4px;
}

.emailsBox {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 10px;
}

.emailLine {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.emailLine strong {
  font-size: 14px;
  color: var(--ink);
  word-break: break-all;
}

.emailBadge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--soft);
  color: var(--muted);
  flex-shrink: 0;
}

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

.referralCodeRow {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.referralCodeRow strong {
  font-size: 22px;
  letter-spacing: 0;
  color: var(--accent);
  overflow-wrap: anywhere;
}

.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 12px;
}

.referralHint {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.referredUsersBox {
  display: grid;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.referredUserLine {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.referredUserLine strong {
  color: var(--ink);
  font-size: 14px;
}

.metricBox {
  padding: 0;
  border-bottom: none;
}
.metricBox span,
.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}
.metricBox strong {
  display: block;
  font-size: 22px;
  overflow-wrap: anywhere;
}

.recordLine {
  padding: 10px 0;
}
.recordLine + .recordLine {
  border-top: 1px solid var(--line);
}
.recordLine strong,
.recordLine span {
  display: block;
}
.recordLine span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.tableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.dataTable th,
.dataTable td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.dataTable th {
  background: #f4f7f5;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
}

.dataTable td {
  color: var(--ink);
}

.dataTable tr:last-child td {
  border-bottom: none;
}

.dataTable .statusBadge {
  font-size: 11px;
  padding: 2px 8px;
}

.dataTable td:first-child {
  white-space: normal;
  min-width: 180px;
}

.dataTable td strong {
  font-size: 14px;
  color: var(--ink);
}

.statusBadge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  vertical-align: middle;
  flex-shrink: 0;
}
.statusBadge--success {
  background: #d1fae5;
  color: #065f46;
}
.statusBadge--warning {
  background: #fef3c7;
  color: #92400e;
}
.statusBadge--danger {
  background: #fee2e2;
  color: #991b1b;
}
.statusBadge--info {
  background: #dbeafe;
  color: #1e40af;
}
.statusBadge--accent {
  background: var(--soft);
  color: var(--accent-dark);
}

.historyBox {
  margin-top: 16px;
}

.historyBox h4 {
  margin: 0 0 10px;
}

.userChip {
  color: var(--muted);
  font-weight: 400;
}

.siteFooter {
  padding: 24px clamp(18px, 5vw, 64px);
  border-top: 1px solid var(--line);
  text-align: center;
}

.siteFooter p {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.siteFooter a {
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.siteFooter a:hover {
  color: var(--ink);
}

.hidden {
  display: none !important;
}

dialog {
  width: min(1180px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 24px;
}

.dialogForm {
  margin-bottom: 20px;
}

.adminBox {
  max-height: 72vh;
  overflow: auto;
}

.adminGrid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.metric {
  background: #f4f7f5;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.metric strong {
  display: block;
  font-size: 28px;
  overflow-wrap: anywhere;
}

.adminGrantForm {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) 120px minmax(220px, 1fr) auto;
  gap: 12px;
  align-items: end;
  padding: 16px 0 22px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.adminTableWrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 22px;
  background: white;
}

.adminTableWrap table {
  min-width: 900px;
}

.adminTableWrap th {
  background: #f4f7f5;
  white-space: nowrap;
}

.adminTableWrap td {
  vertical-align: top;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 360px;
  padding: 12px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: white;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.modalOverlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modalOverlay.hidden { display: none; }
.modalBox {
  background: white;
  border-radius: 12px;
  padding: 28px;
  max-width: 480px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 40px rgba(0,0,0,0.2);
}
.modalBox h3 { margin-top: 0; }

.paymentFallback {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(24,32,27,0.48);
}

.paymentFallbackBox {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  text-align: center;
}

.paymentFallbackBox p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 980px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 36px;
    max-width: 720px;
  }

  .heroText,
  .lead,
  h1 {
    max-width: none;
  }

  .dashboardCards {
    flex-direction: column;
  }

  .dashCard--primary {
    flex: 1 1 auto;
  }

  .dashCard .primary {
    align-self: flex-start;
  }

  .adminGrid,
  .adminGrantForm {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .pageView {
    min-height: auto;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 12px 18px;
  }

  .brand img {
    width: 34px;
    height: 34px;
  }

  .brand strong {
    font-size: 17px;
  }

  nav {
    width: 100%;
    justify-content: flex-start;
    gap: 6px 10px;
  }

  nav a,
  nav button {
    min-height: 34px;
    padding: 6px 8px;
  }

  h1 {
    font-size: 34px;
    line-height: 1.16;
    overflow-wrap: normal;
    word-break: keep-all;
  }

  .lead {
    font-size: 16px;
    line-height: 1.65;
  }

  .hero {
    padding: 34px 20px 28px;
    gap: 28px;
  }

  .eyebrow {
    font-size: 14px;
    line-height: 1.5;
  }

  .heroActions .primary {
    width: 100%;
  }

  .heroSteps {
    border-top: 1px solid var(--line);
  }

  .heroSteps div {
    grid-template-columns: 42px 1fr;
    gap: 6px 12px;
    padding: 15px 0;
  }

  .heroSteps em {
    font-size: 20px;
  }

  .section {
    padding: 30px 20px;
  }

  .sectionHead {
    text-align: left;
  }

  .plansTable th,
  .plansTable td {
    padding: 12px 10px;
    font-size: 14px;
  }

  .plansTable th:nth-child(3),
  .plansTable td:nth-child(3) {
    display: none;
  }

  .accountLayout {
    align-items: flex-start;
    min-height: auto;
    padding-top: 22px;
  }

  .authPanel,
  .panel,
  .dashCard {
    padding: 20px;
  }

  .portalSection .panel {
    padding: 20px;
  }

  .dataTable th,
  .dataTable td {
    padding: 11px 10px;
    font-size: 13px;
  }

  .dataTable td:first-child {
    min-width: 140px;
  }

  .inlineFields {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .inlineFields .secondary {
    min-width: 104px;
    padding-inline: 9px;
    font-size: 14px;
  }

  .modalOverlay {
    align-items: flex-end;
  }

  .modalBox {
    width: 100%;
    max-width: none;
    max-height: calc(100vh - 24px);
    border-radius: 12px 12px 0 0;
    padding: 24px 20px;
  }

  .toast {
    left: 18px;
    right: 18px;
    max-width: none;
  }
}
