.portal-page {
  background:
    radial-gradient(circle at 12% 8%, rgba(250, 204, 21, 0.18), transparent 18rem),
    radial-gradient(circle at 84% 12%, rgba(20, 184, 166, 0.18), transparent 20rem),
    radial-gradient(circle at 72% 82%, rgba(96, 165, 250, 0.16), transparent 22rem),
    linear-gradient(180deg, #fffaf0 0%, #f0fbf7 48%, #eef6ff 100%);
}

.portal-auth-shell {
  min-height: calc(100vh - 66px);
  display: grid;
  place-items: center;
  padding: clamp(1rem, 5vw, 3rem);
}

.portal-auth-card,
.portal-card,
.portal-hero-panel,
.portal-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.portal-auth-card {
  width: min(520px, 100%);
  padding: clamp(1.4rem, 4vw, 2.2rem);
}

.portal-auth-card h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem);
}

.portal-muted,
.portal-card p,
.portal-hero-panel p {
  color: var(--muted);
}

.portal-form {
  display: grid;
  gap: 0.9rem;
  margin-top: 1.3rem;
}

.portal-form label {
  display: grid;
  gap: 0.35rem;
  color: var(--ink);
  font-weight: 800;
}

.portal-form input {
  min-height: 48px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.85rem;
  color: var(--ink);
  font: inherit;
}

.portal-form select,
.admin-filters select,
.admin-filters input {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  color: var(--ink);
  background: var(--white);
  font: inherit;
}

.portal-message,
.portal-status {
  min-height: 1.5rem;
  margin: 0;
  color: var(--teal-dark);
  font-weight: 800;
}

.portal-message.error,
.portal-status.error {
  color: #b42318;
}

.portal-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem clamp(1rem, 4vw, 2rem);
  border-bottom: 1px solid rgba(217, 225, 230, 0.85);
  background: rgba(255, 250, 240, 0.9);
  backdrop-filter: blur(18px);
}

.portal-account {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  color: var(--muted);
  font-weight: 800;
}

.portal-account span {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 0.75rem;
  border: 1px solid rgba(15, 118, 110, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  color: #0f766e;
}

.portal-ghost-btn {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

.portal-shell {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 1.2rem;
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem);
}

.portal-sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
  display: grid;
  gap: 0.35rem;
  padding: 0.7rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.07);
}

.portal-sidebar a {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.72rem 0.8rem;
  border-radius: 7px;
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
}

.portal-sidebar a:hover {
  background: #fff3c4;
  color: var(--ink);
}

.portal-sidebar a span {
  display: inline-grid;
  width: 1.75rem;
  height: 1.75rem;
  place-items: center;
  border-radius: 7px;
  background: rgba(20, 184, 166, 0.12);
}

.portal-content {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.portal-hero-panel,
.portal-card,
.portal-section {
  padding: clamp(1.2rem, 4vw, 2rem);
}

.portal-hero-panel {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(260px, 0.9fr);
  gap: clamp(1rem, 4vw, 2rem);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(235, 252, 246, 0.92)),
    linear-gradient(90deg, #ffffff, #ecfeff);
}

.portal-hero-panel::after {
  content: "";
  position: absolute;
  inset: auto -3rem -6rem auto;
  width: 17rem;
  height: 17rem;
  border-radius: 999px;
  background: rgba(250, 204, 21, 0.22);
}

.portal-hero-copy {
  position: relative;
  z-index: 1;
  align-self: center;
}

.portal-hero-panel h1 {
  max-width: 820px;
  font-size: clamp(2.2rem, 5vw, 4.25rem);
  line-height: 0.96;
}

.portal-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-top: 1.2rem;
}

.portal-hero-visual {
  position: relative;
  z-index: 1;
  min-height: 320px;
  align-self: stretch;
  border-radius: 8px;
  overflow: hidden;
  background: #0f172a;
  box-shadow: 0 24px 52px rgba(15, 23, 42, 0.16);
}

.portal-hero-visual img {
  width: 100%;
  height: 100%;
  min-height: 320px;
  object-fit: cover;
  opacity: 0.92;
}

.portal-float-card {
  position: absolute;
  left: 1rem;
  max-width: calc(100% - 2rem);
  padding: 0.55rem 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.9);
  color: #0f172a;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.14);
}

.portal-float-card.top {
  top: 1rem;
}

.portal-float-card.bottom {
  bottom: 1rem;
}

.portal-metrics,
.portal-download-list {
  display: grid;
  gap: 0.7rem;
}

.portal-metrics {
  position: relative;
  z-index: 1;
  grid-column: 1 / -1;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 1.2rem;
}

.portal-download-list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 1.2rem;
}

.portal-metrics span {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  text-decoration: none;
}

.portal-metrics strong {
  display: block;
  color: var(--teal-dark);
}

.portal-download-list a {
  color: var(--ink);
  font-weight: 850;
}

.portal-section-head {
  max-width: 760px;
}

.portal-section-head h2,
.portal-faq-section h2 {
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1;
}

.resource-tile {
  display: grid;
  align-content: start;
  min-height: 178px;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.resource-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 36px rgba(15, 23, 42, 0.12);
}

.resource-tile .tile-icon {
  display: grid;
  width: 3rem;
  height: 3rem;
  place-items: center;
  margin-bottom: 0.9rem;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  font-size: 1.5rem;
}

.resource-tile strong {
  display: block;
  font-size: 1.05rem;
}

.resource-tile small {
  margin-top: 0.45rem;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.tile-green {
  background: linear-gradient(160deg, #ecfdf5, #ffffff);
}

.tile-blue {
  background: linear-gradient(160deg, #eff6ff, #ffffff);
}

.tile-yellow {
  background: linear-gradient(160deg, #fffbeb, #ffffff);
}

.tile-pink {
  background: linear-gradient(160deg, #fff1f2, #ffffff);
}

.portal-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 1rem;
  align-items: center;
}

.portal-feature-card {
  background:
    linear-gradient(135deg, rgba(239, 246, 255, 0.96), rgba(255, 255, 255, 0.92));
}

.portal-support-card {
  background:
    linear-gradient(135deg, rgba(236, 253, 245, 0.96), rgba(255, 251, 235, 0.92));
}

.faq-list {
  display: grid;
  gap: 0.65rem;
  margin-top: 1rem;
}

.faq-list details {
  padding: 0.85rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.faq-list summary {
  cursor: pointer;
  font-weight: 900;
}

.portal-locked .portal-shell {
  visibility: hidden;
}

.auth-gate {
  display: none;
}

.protected-pending .reader-topbar,
.protected-pending .ebook-shell,
.protected-pending .reader-footer {
  display: none;
}

.protected-pending .auth-gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(circle at 14% 6%, rgba(59, 130, 246, 0.18), transparent 24rem),
    linear-gradient(180deg, #07121f 0%, #0d1821 100%);
  color: #f3f7fb;
}

.auth-gate-card {
  width: min(540px, 100%);
  padding: clamp(1.3rem, 5vw, 2rem);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  background: rgba(21, 35, 49, 0.92);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.32);
}

.auth-gate-card h1 {
  font-size: clamp(2rem, 7vw, 3.5rem);
}

.auth-gate-card p {
  color: #d4dde7;
}

.auth-gate-card .button.secondary {
  color: #f3f7fb;
  background: rgba(255, 255, 255, 0.1);
}

.admin-crm-shell {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.6rem);
}

.admin-pin-card,
.admin-hero,
.admin-panel,
.admin-stats span {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.admin-pin-card {
  width: min(560px, 100%);
  margin: clamp(2rem, 8vw, 5rem) auto;
  padding: clamp(1.4rem, 4vw, 2.2rem);
}

.admin-pin-card h1,
.admin-hero h1 {
  font-size: clamp(2.1rem, 4vw, 3.35rem);
  letter-spacing: 0;
}

.admin-dashboard {
  display: grid;
  gap: 0.55rem;
}

.admin-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 178px;
  padding: clamp(1.25rem, 3vw, 1.8rem);
}

.admin-hero p {
  max-width: 720px;
  color: var(--muted);
}

.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
}

.admin-stats span {
  min-height: 64px;
  padding: 0.7rem 0.9rem;
  color: var(--muted);
  font-weight: 800;
}

.admin-stats strong {
  display: block;
  color: var(--ink);
  font-size: 1.75rem;
  line-height: 1;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(280px, 330px) minmax(0, 1fr);
  gap: 0.9rem;
  margin-top: 0;
  align-items: stretch;
}

.admin-grid > .portal-form {
  margin-top: 0;
}

.admin-panel {
  display: flex;
  flex-direction: column;
  padding: clamp(1rem, 2.4vw, 1.3rem);
}

.admin-panel h2 {
  margin: 0;
  font-size: clamp(1.35rem, 2.4vw, 1.9rem);
  line-height: 1.06;
}

.admin-panel .eyebrow {
  margin-bottom: 0.45rem;
}

.admin-panel-head,
.admin-filters {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.8rem;
}

.admin-panel-head {
  margin: 0;
}

.admin-filters {
  margin: 0.7rem 0 0.65rem;
}

.admin-filters label {
  display: grid;
  flex: 1;
  gap: 0.35rem;
  color: var(--muted);
  font-weight: 850;
}

.buyer-table-wrap {
  flex: 1;
  min-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
}

.buyer-table {
  width: 100%;
  min-width: 820px;
  height: 100%;
  border-collapse: collapse;
  background: var(--white);
}


.buyer-table th,
.buyer-table td {
  padding: 0.72rem 0.78rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.buyer-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.buyer-table td strong,
.buyer-table td span {
  display: block;
}

.buyer-table td span {
  color: var(--muted);
}

.buyer-status {
  display: inline-flex !important;
  width: fit-content;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  color: var(--ink) !important;
  font-weight: 900;
}

.buyer-status.paid {
  background: #dff6eb;
  color: #116b4f !important;
}

.buyer-status.pending {
  background: #fff0c2;
  color: #8a5a00 !important;
}

.buyer-status.revoked {
  background: #ffe0dc;
  color: #a12a1f !important;
}

.buyer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.buyer-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfdfc;
  color: var(--ink);
  font-weight: 800;
  cursor: pointer;
}

@media (max-width: 820px) {
  .portal-shell,
  .portal-card,
  .portal-hero-panel,
  .admin-grid {
    grid-template-columns: 1fr;
  }

  .portal-hero-visual,
  .portal-hero-visual img {
    min-height: 240px;
  }

  .admin-hero,
  .admin-panel-head,
  .admin-filters {
    align-items: stretch;
    flex-direction: column;
  }

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

  .portal-sidebar {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portal-metrics,
  .portal-download-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .portal-topbar,
  .portal-account,
  .portal-hero-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-account {
    width: 100%;
  }

  .portal-account span,
  .portal-ghost-btn,
  .portal-hero-actions .button {
    width: 100%;
    justify-content: center;
  }

  .portal-sidebar {
    grid-template-columns: 1fr;
  }
}
