:root {
  --primary: #155dfc;
  --primary-hover: #0f4fd8;
  --primary-soft: #eff4ff;
  --bg: #f8fafc;
  --card: #ffffff;
  --border: #cbd5e1;
  --border-light: #e2e8f0;
  --text: #0f172a;
  --text-muted: #475569;
  --placeholder: #64748b; /* input placeholders, 4.8:1 on white */
  --text-faint: #5b6b82; /* small secondary text, >= 4.9:1 on all our backgrounds */
  --error: #b91c1c;
  --success: #15803d;
  --warning: #b45309;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
}

svg {
  flex-shrink: 0;
}

/* ---------- Navbar ---------- */
.navbar {
  background: var(--card);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 10;
}

.navbar-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
}

.brand-icon svg {
  width: 17px;
  height: 17px;
}

.brand-name {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.nav-link svg {
  width: 15px;
  height: 15px;
}

.nav-link:hover,
.nav-link.active {
  color: var(--text);
  background: var(--bg);
}

.nav-new {
  color: var(--primary);
}

/* ---------- Search view ---------- */
.container {
  max-width: 760px;
  margin: 0 auto;
  padding: 40px 16px 64px;
}

.hero {
  text-align: center;
  margin-bottom: 32px;
}

.hero h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.hero p {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 580px;
  margin: 0 auto;
}

.card {
  max-width: 576px;
  margin: 0 auto;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.card h2 {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  margin-bottom: 18px;
}

.field > label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}

.optional {
  color: var(--text-faint);
  font-weight: 400;
  margin-left: 4px;
}

input[type="text"],
input[type="email"],
input[type="password"],
select,
textarea {
  width: 100%;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input::placeholder,
textarea::placeholder {
  color: var(--placeholder);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21, 93, 252, 0.15);
}

.invalid {
  border-color: var(--error) !important;
}

textarea {
  resize: vertical;
  min-height: 68px;
}

.select-wrap {
  position: relative;
}

select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
}

.select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  pointer-events: none;
}

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 22px 16px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.dropzone.has-file {
  border-style: solid;
  border-color: var(--primary);
}

.upload-icon {
  width: 24px;
  height: 24px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.drop-text {
  font-size: 12px;
  color: var(--text-muted);
}

.drop-text .link {
  color: var(--primary);
}

.drop-hint {
  font-size: 10px;
  color: var(--text-faint);
}

.form-error {
  color: var(--error);
  font-size: 13px;
  margin-bottom: 8px;
}

.form-error:empty {
  display: none;
}

/* ---------- Buttons ---------- */
.btn-primary {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary svg {
  width: 16px;
  height: 16px;
}

.btn-auto {
  width: auto;
}

.btn-outline {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 14px;
  cursor: pointer;
}

.btn-outline:hover {
  border-color: var(--text-muted);
}

.btn-text {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  padding: 8px 4px;
}

.btn-text:hover:not(:disabled) {
  color: var(--primary);
}

.btn-text:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ---------- Loading view ---------- */
.loading-view {
  max-width: 620px;
  margin: 0 auto;
  padding: 72px 16px;
  text-align: center;
}

.big-spinner {
  width: 120px;
  height: 120px;
  margin: 0 auto 28px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(21, 93, 252, 0.08), transparent 70%);
  display: grid;
  place-items: center;
}

.big-spinner div {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 5px solid transparent;
  border-top-color: var(--primary);
  border-right-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-view h2 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 10px;
}

.loading-sub {
  color: var(--text-muted);
  font-size: 15px;
  margin-bottom: 36px;
}

.steps {
  list-style: none;
  display: inline-flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  margin-bottom: 24px;
}

.steps li {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 15px;
  font-weight: 500;
}

.step-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid var(--border);
}

.step-icon svg {
  width: 13px;
  height: 13px;
}

.step-done .step-icon {
  border-color: var(--success);
  color: var(--success);
}

.step-active .step-icon {
  border-color: var(--primary-soft);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}

.step-pending {
  color: var(--text-faint);
}

/* ---------- Results view ---------- */
.results-view {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.results-header {
  margin-bottom: 20px;
}

.results-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.results-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.funding-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.funding-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 4px 10px;
}

.match-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.match {
  display: grid;
  grid-template-columns: 1fr 210px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.match-main {
  padding: 22px 22px 18px;
  min-width: 0;
}

.match-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.match-name h3 {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: 1px 8px;
}

.status-badge svg {
  width: 11px;
  height: 11px;
}

.dept {
  color: var(--primary);
  font-size: 13px;
  margin-top: 2px;
}

.score {
  text-align: right;
  line-height: 1.1;
}

.score strong {
  display: block;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.score span {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 18px;
}

.tag {
  font-size: 11px;
  font-weight: 500;
  background: #f1f5f9;
  border-radius: 4px;
  padding: 3px 8px;
}

.match-main h4 {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 6px;
}

.why {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
}

.more {
  margin-top: 12px;
  font-size: 13px;
}

.more summary {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
  font-size: 12px;
  user-select: none;
}

.more summary span {
  color: var(--text-faint);
  font-weight: 400;
}

.papers {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}

.papers a {
  display: flex;
  gap: 6px;
  color: var(--text);
  text-decoration: none;
  font-weight: 500;
  line-height: 1.4;
}

.papers svg {
  width: 14px;
  height: 14px;
  margin-top: 2px;
  color: var(--text-faint);
}

.papers a:hover span {
  color: var(--primary);
  text-decoration: underline;
}

.paper-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 20px;
}

.muted {
  color: var(--text-faint);
  font-size: 12px;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  border-radius: 6px;
  padding: 4px 10px;
}

.pill svg {
  width: 13px;
  height: 13px;
}

.pill-found {
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #dbe6ff;
}

.pill-found:hover {
  border-color: var(--primary);
}

.pill-search {
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

.pill-search:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.subscores {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.subscores span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
}

.subscores strong {
  font-size: 13px;
  font-weight: 600;
}

.subscores em {
  font-style: normal;
  color: var(--text-faint);
  font-weight: 500;
}

.activity-high {
  color: var(--success);
}

.activity-medium {
  color: var(--warning);
}

.activity-low {
  color: var(--text-muted);
}

/* Right column */
.match-side {
  background: #fafbfc;
  border-left: 1px solid var(--border-light);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.side-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.side-btn svg {
  width: 14px;
  height: 14px;
}

.side-btn:hover {
  border-color: var(--text-muted);
}

.side-btn.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
  font-weight: 600;
}

.side-btn.primary:hover {
  background: var(--primary-hover);
}

.side-btn.saved {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary);
}

.side-btn.saved svg {
  fill: currentColor;
}

.contact {
  margin-top: auto;
  padding-top: 14px;
  text-align: center;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.contact > span {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.contact a {
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.contact a:hover {
  color: var(--primary);
}

.no-email {
  display: block;
  color: var(--text-muted);
  font-weight: 500;
}

.contact a.find-email {
  color: var(--primary);
  font-weight: 500;
  font-size: 11px;
}

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.disclaimer {
  margin-top: 24px;
  font-size: 11px;
  color: var(--text-faint);
  text-align: center;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: grid;
  place-items: center;
  padding: 16px;
  z-index: 50;
}

.modal {
  width: 100%;
  max-width: 640px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--card);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--border-light);
}

.modal-head h3 {
  font-size: 17px;
  font-weight: 700;
}

.modal-head p {
  font-size: 12px;
  color: var(--text-muted);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
}

.icon-btn:hover {
  background: var(--bg);
  color: var(--text);
}

.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.modal-body {
  padding: 16px 20px 0;
  overflow-y: auto;
}

/* "You've used your free search" pop-up */
.modal.upgrade-modal {
  max-width: 440px;
}

.upgrade-modal .modal-body p {
  margin: 0 0 16px;
  line-height: 1.6;
  color: var(--text-muted);
}

.upgrade-modal .modal-foot {
  display: flex;
}

/* On phones it's a small card, not a full-screen sheet like the email window. */
@media (max-width: 560px) {
  #upgradeModal {
    padding: 16px;
    place-items: center;
  }

  .modal.upgrade-modal {
    height: auto;
    border-radius: 12px;
  }

  .upgrade-modal .modal-body {
    flex: none;
  }
}

.modal-body textarea {
  line-height: 1.55;
  min-height: 280px;
}

.modal-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 20px 18px;
  border-top: 1px solid var(--border-light);
}

.modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.drafting textarea,
.drafting input {
  background: var(--bg);
}

.drafting .modal-head p::before {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border: 2px solid var(--border-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  vertical-align: -1px;
  animation: spin 0.8s linear infinite;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toast {
  position: fixed;
  left: 50%;
  top: 72px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 10px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
  z-index: 60;
}

/* ---------- Tablet & mobile ---------- */
@media (max-width: 720px) {
  .navbar-inner {
    padding: 10px 16px;
  }

  .nav-link {
    padding: 6px;
    font-size: 12px;
  }

  .nav-link svg {
    display: none;
  }

  /* 16px text stops iOS Safari zooming in when a field is tapped; taller fields are easier to hit. */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  select,
  textarea {
    font-size: 16px;
    padding: 10px 12px;
  }

  .select-arrow {
    right: 12px;
  }

  .btn-primary {
    font-size: 15px;
    padding: 13px 16px;
  }

  .btn-outline {
    font-size: 14px;
    padding: 10px 14px;
  }

  .match {
    grid-template-columns: 1fr;
  }

  .match-main {
    padding: 18px 16px 16px;
  }

  /* Actions: draft email full width, then Search | View, then Save. */
  .match-side {
    border-left: none;
    border-top: 1px solid var(--border-light);
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 14px 16px;
  }

  .side-btn {
    white-space: nowrap;
    font-size: 13px;
    padding: 10px 6px;
    gap: 6px;
  }

  .side-btn[data-action="draft"] {
    order: -1;
    grid-column: 1 / -1;
  }

  /* Save and Mark as Emailed share a row on phones. */

  .contact {
    grid-column: 1 / -1;
    padding-top: 6px;
  }

  .subscores {
    grid-template-columns: repeat(2, 1fr);
  }

  .results-view {
    padding: 24px 16px 48px;
  }

  /* Scholarship links: one swipeable row instead of a stack. */
  .funding-links {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin: 12px -16px 0;
    padding: 0 16px 4px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .funding-links::-webkit-scrollbar {
    display: none;
  }

  .funding-links > * {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .loading-view {
    padding: 48px 16px;
  }

  .loading-view h2 {
    font-size: 22px;
  }

  .loading-sub {
    font-size: 14px;
    margin-bottom: 28px;
  }

  .steps li {
    font-size: 14px;
  }
}

@media (max-width: 560px) {
  .brand-name {
    display: none;
  }

  .container {
    padding: 28px 16px 48px;
  }

  .card {
    padding: 20px 16px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .hero h1 {
    font-size: 24px;
  }

  .hero p {
    font-size: 14px;
  }

  /* Email modal becomes a full-screen sheet. */
  .modal-backdrop {
    padding: 0;
    place-items: stretch;
  }

  .modal {
    max-width: none;
    max-height: none;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }

  .modal-head {
    padding: 14px 16px 10px;
  }

  .modal-body {
    flex: 1;
    padding: 14px 16px 0;
  }

  .modal-body textarea {
    min-height: 220px;
  }

  .modal-foot {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 10px 16px calc(12px + env(safe-area-inset-bottom));
  }

  .modal-actions {
    display: contents;
  }

  .modal-foot #draftReset {
    order: 1;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px 6px;
    font-size: 14px;
  }

  .modal-foot .btn-outline {
    padding: 10px 6px;
  }
}

@media (max-width: 400px) {
  .results-view {
    padding: 20px 12px 40px;
  }

  .funding-links {
    margin: 12px -12px 0;
    padding: 0 12px 4px;
  }

  .results-header h1 {
    font-size: 22px;
  }

  .results-header p {
    font-size: 13px;
  }

  .match-name h3 {
    font-size: 16px;
  }

  .score strong {
    font-size: 22px;
  }

  .score span {
    white-space: nowrap;
    font-size: 9px;
  }

  .nav-link {
    padding: 6px 4px;
  }
}

/* ---------- Pages: universities, settings, legal ---------- */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.view {
  flex: 1 0 auto;
  width: 100%;
}

.menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-light);
  border-radius: 8px;
  color: var(--text);
  padding: 6px;
  cursor: pointer;
}

.menu-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

.avatar-sm {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
}

.avatar-sm svg {
  width: 18px;
  height: 18px;
}

.avatar-sm.has-initials {
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
}

.nav-settings-label {
  display: none;
}

.results-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.btn-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  font-size: 13px;
  padding: 7px 12px;
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

.btn-outline.btn-sm {
  color: var(--text);
}

#saveUniBtn.is-saved {
  color: var(--primary);
  background: var(--primary-soft);
  border-color: var(--primary);
}

#saveUniBtn.is-saved svg {
  fill: currentColor;
}

.page-view {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 24px 56px;
}

#settingsView,
#privacyView,
#termsView,
#aboutView {
  max-width: 760px;
}

.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-header p {
  color: var(--text-muted);
  font-size: 14px;
}

/* Universities */
.add-uni {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.add-uni input {
  flex: 1;
  min-width: 0;
}

.uni-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.uni-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.uni-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.uni-icon {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 800;
  font-size: 14px;
  display: grid;
  place-items: center;
}

.uni-title {
  flex: 1;
  min-width: 0;
}

.uni-title h3 {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.3;
}

.uni-title span {
  font-size: 12px;
  color: var(--text-muted);
}

.uni-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border-light);
}

.uni-stats strong {
  display: block;
  font-size: 15px;
}

.uni-stats span {
  font-size: 11px;
  color: var(--text-muted);
}

.uni-last {
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
}

.uni-last span {
  font-weight: 400;
  color: var(--text-muted);
}

.uni-profs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.uni-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: auto;
}

/* Settings */
.settings-card {
  max-width: none;
  margin: 0 0 16px;
}

.settings-card h2 {
  margin-bottom: 4px;
}

.card-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 16px;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--error);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 6px;
  padding: 9px 16px;
  cursor: pointer;
}

.btn-danger:hover {
  background: #fee2e2;
  border-color: var(--error);
}

.btn-danger svg {
  width: 16px;
  height: 16px;
}

.settings-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
}

.settings-links a {
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.settings-links a:hover {
  text-decoration: underline;
}

/* Log in / sign up */
.auth-card {
  max-width: none;
}

.auth-card h2 {
  margin-bottom: 4px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.auth-switch {
  margin-top: 16px;
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

.auth-switch a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  text-decoration: underline;
}

.import-summary {
  font-size: 14px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.account-actions {
  margin-bottom: 16px;
}

/* Legal / about */
.prose {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 32px;
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-muted);
}

.prose h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

.prose h2 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin: 26px 0 8px;
}

.prose p,
.prose ul,
.prose ol {
  margin-bottom: 12px;
}

.prose ul,
.prose ol {
  padding-left: 22px;
}

.prose li {
  margin-bottom: 6px;
}

.prose strong {
  color: var(--text);
}

.prose a {
  color: var(--primary);
}

.muted-date {
  font-size: 13px;
  color: var(--text-faint);
}

.placeholder {
  background: #fef9c3;
  color: #854d0e;
  border-radius: 4px;
  padding: 0 4px;
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border-light);
  background: var(--card);
}

.footer-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 18px 24px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 24px;
  font-size: 13px;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--primary);
}

/* Mobile menu: the nav collapses behind a button */
@media (max-width: 860px) {
  .navbar-inner {
    position: relative;
  }

  .menu-btn {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 2px;
    padding: 8px 12px 12px;
    background: var(--card);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.08);
  }

  .nav-links.open {
    display: flex;
  }

  .nav-link,
  .nav-links .nav-link {
    justify-content: flex-start;
    font-size: 15px;
    padding: 12px;
    border-radius: 8px;
  }

  .nav-links .nav-link svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  .nav-settings-label {
    display: inline;
  }

  .nav-settings {
    order: 10;
    border-top: 1px solid var(--border-light);
    border-radius: 0 0 8px 8px;
    margin-top: 4px;
  }
}

@media (max-width: 560px) {
  .page-view {
    padding: 24px 16px 40px;
  }

  .page-header h1,
  .prose h1 {
    font-size: 22px;
  }

  .prose {
    padding: 20px 16px;
    font-size: 14px;
  }

  .add-uni {
    flex-direction: column;
  }

  .uni-grid {
    grid-template-columns: 1fr;
  }

  .settings-actions > *,
  .btn-danger {
    width: 100%;
    justify-content: center;
  }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  }
}

/* Links live in the menu on phones, so the brand name fits again. */
@media (max-width: 560px) {
  .brand-name {
    display: inline;
  }
}

/* University cards open a detail page */
.uni-card.is-clickable {
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.uni-card.is-clickable:hover {
  border-color: #bfd0ff;
  box-shadow: 0 6px 18px rgba(21, 93, 252, 0.08);
}

.uni-card.is-clickable:focus-visible {
  outline: 3px solid rgba(21, 93, 252, 0.35);
  outline-offset: 2px;
}

.uni-card.is-clickable:active {
  transform: scale(0.995);
}

.uni-open {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: auto;
}

.uni-detail {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 4px;
  padding: 14px 16px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}

.back-link {
  align-self: flex-start;
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}

.back-link:hover {
  text-decoration: underline;
}

/* The detail header sits in the funding-links row; keep it a normal block on phones. */
.funding-links:has(.uni-detail) {
  flex-wrap: wrap;
  overflow: visible;
  margin-left: 0;
  margin-right: 0;
  padding: 0;
}

.funding-links > .uni-detail {
  flex-shrink: 1;
  min-width: 0;
  white-space: normal;
}

/* Mark as Emailed */
.side-btn.emailed {
  color: var(--success);
  background: #f0fdf4;
  border-color: #86efac;
  font-weight: 600;
}

.side-btn.emailed:hover {
  border-color: var(--success);
}

/* Emailed page: universities you've emailed someone at */
.uni-icon.is-emailed {
  background: #f0fdf4;
  color: var(--success);
}

/* Funding status (5th score) */
.subscores {
  grid-template-columns: repeat(5, 1fr);
}

.funding-available {
  color: var(--success);
}

.funding-partial {
  color: var(--warning);
}

.funding-none,
.funding-unknown {
  color: var(--text-muted);
}

.subscores [title] {
  cursor: help;
}

@media (max-width: 720px) {
  .subscores {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 360px) {
  .subscores {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Plans & billing ---------- */
.nav-plan {
  color: #fff;
  background: var(--primary);
  font-weight: 600;
}

.nav-plan:hover,
.nav-plan.active {
  color: #fff;
  background: var(--primary-hover);
}

.nav-plan.is-pro {
  color: #92400e;
  background: #fef3c7;
}

.nav-plan.is-pro:hover,
.nav-plan.is-pro.active {
  color: #92400e;
  background: #fde68a;
}

.nav-admin {
  color: var(--warning);
  font-weight: 600;
}

.plan-banner {
  max-width: 576px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text);
  background: var(--primary-soft);
  border: 1px solid #dbe6ff;
  border-radius: 10px;
}

.plan-banner.is-warning {
  background: #fffbeb;
  border-color: #fde68a;
}

.plan-banner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dev-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--warning);
  font-weight: 600;
}

.search-allowance {
  margin-top: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.search-allowance:empty {
  display: none;
}

.loading-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.loading-actions:empty {
  display: none;
}

/* Billing page */
#billingView {
  max-width: 880px;
}

.billing-current {
  margin-bottom: 18px;
}

.billing-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px 20px;
  padding: 16px 18px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 14px;
}

.billing-box.is-pro {
  border-color: #fde68a;
  background: #fffdf5;
}

.billing-box > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.billing-box span:not(.plan-pill) {
  color: var(--text-muted);
  font-size: 13px;
}

.billing-box-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.plan-pill {
  align-self: flex-start;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: #f1f5f9;
  border-radius: 999px;
  padding: 2px 10px;
}

.plan-pill.pro {
  color: #92400e;
  background: #fef3c7;
}

.plan-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

.plan-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 22px;
}

.plan-card h2 {
  font-size: 18px;
  font-weight: 700;
}

.plan-pro {
  border: 2px solid var(--primary);
  box-shadow: 0 8px 24px rgba(21, 93, 252, 0.1);
}

.plan-badge {
  position: absolute;
  top: -11px;
  right: 18px;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  border-radius: 999px;
  padding: 3px 10px;
}

.plan-badge-current {
  background: var(--success);
}

.plan-card.is-current {
  border-color: var(--success);
}

/* National / International: two cards side by side (lined up with Free / Pro), each opening like "Advanced settings".
   The payment box opens full width underneath. */
.region-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 18px;
}

@media (max-width: 720px) {
  .region-pick {
    grid-template-columns: 1fr;
  }
}

.region-row {
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.region-row.is-open {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(21, 93, 252, 0.1);
}

.region-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  padding: 20px 22px;
  cursor: pointer;
}

.region-card:hover {
  background: var(--primary-soft);
}

.region-text {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.region-text strong {
  font-size: 15px;
  font-weight: 700;
}

.region-text span {
  font-size: 13px;
  color: var(--text-muted);
}

.region-chevron {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: var(--text);
  transition: transform 0.2s;
}

.region-row.is-open .region-chevron {
  transform: rotate(90deg);
  color: var(--primary);
}

.region-row.is-open .region-card strong {
  color: var(--primary);
}

.region-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}

.region-note {
  margin: -6px 0 18px;
  padding: 14px 18px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  font-size: 14px;
  color: var(--text-muted);
}

.plan-price {
  margin: 6px 0 14px;
  color: var(--text-muted);
  font-size: 14px;
}

.plan-price strong {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
}

.plan-or strong {
  font-size: 18px;
}

.plan-features {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 14px;
}

.plan-features li {
  position: relative;
  padding-left: 24px;
  line-height: 1.45;
}

.plan-features li::before {
  position: absolute;
  left: 0;
  top: 0;
  font-weight: 700;
}

.plan-features .yes::before {
  content: "✓";
  color: var(--success);
}

.plan-features .no {
  color: var(--text-faint);
}

.plan-features .no::before {
  content: "✕";
  color: var(--text-faint);
}

.pay-card {
  max-width: none;
  margin: 0 0 16px;
}

.pay-card h2 {
  margin-bottom: 14px;
}

.pay-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  margin-bottom: 16px;
  background: #f1f5f9;
  border-radius: 10px;
}

.pay-tab {
  flex: 1;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.pay-tab.active {
  color: var(--text);
  background: var(--card);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.1);
}

.admin-tabs {
  max-width: 360px;
}

.pay-note {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 14px;
}

#payByCard svg {
  width: 18px;
  height: 18px;
}

.pay-steps {
  padding-left: 20px;
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
}

.pay-steps li {
  margin-bottom: 6px;
}

.manual-accounts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin: 4px 0 14px;
}

.manual-account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border-light);
  border-radius: 10px;
  background: var(--bg);
}

/* Easypaisa QR code to scan: its own row under the account boxes */
.pay-qr {
  grid-column: 1 / -1;
  margin: 4px 0 4px;
  text-align: left;
}

.pay-qr img {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
  margin: 0;
  border: 1px solid var(--border-light);
  border-radius: 12px;
  background: #fff;
}

.pay-qr figcaption {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

/* The wallet line (amount + network) must not be missed */
.pay-qr figcaption.pay-qr-bold {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.manual-account strong {
  display: block;
  font-size: 14px;
}

.manual-account span {
  font-size: 15px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
  overflow-wrap: anywhere; /* long wallet addresses wrap instead of overflowing */
}

/* Crypto network warning under the wallet QR */
.pay-warning {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 14px;
  font-size: 13.5px;
  color: #7a4b00;
  background: #fff7e6;
  border: 1px solid #f5d38a;
  border-radius: 10px;
}

.pending-box {
  margin-top: 6px;
  padding: 12px 14px;
  font-size: 13px;
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-radius: 10px;
}

.table-wrap {
  overflow-x: auto;
}

.pay-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.pay-table th,
.pay-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.pay-table th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.status-pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  padding: 2px 9px;
  border-radius: 999px;
  color: var(--text-muted);
  background: #f1f5f9;
}

.status-pill.approved {
  color: var(--success);
  background: #f0fdf4;
}

.status-pill.pending {
  color: #92400e;
  background: #fef3c7;
}

.status-pill.rejected {
  color: var(--error);
  background: #fef2f2;
}

.test-card {
  border-style: dashed;
  border-color: #fde68a;
}

/* Admin */
.admin-pay {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 10px;
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 10px;
}

.admin-pay-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 13px;
  min-width: 0;
}

.admin-pay-main strong {
  font-size: 14px;
  word-break: break-all;
}

.admin-pay-main code {
  font-size: 13px;
  font-weight: 600;
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
}

.admin-pay-actions {
  display: flex;
  gap: 8px;
}

/* Locked (Pro) profile links */
.side-btn.locked {
  color: var(--text-muted);
  background: #f8fafc;
  border-style: dashed;
}

.side-btn.locked:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.locked-note {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.locked-note svg {
  width: 14px;
  height: 14px;
  margin-top: 1px;
}

.locked-note a {
  color: var(--primary);
  font-weight: 600;
}

@media (max-width: 720px) {
  .plan-grid {
    grid-template-columns: 1fr;
  }

  .plan-banner {
    margin: 0 0 14px;
  }

  .billing-box-actions,
  .billing-box-actions .btn-sm {
    width: 100%;
  }
}

@media (max-width: 560px) {
  .pay-tab {
    font-size: 12px;
    padding: 9px 6px;
  }

  .admin-pay-actions {
    width: 100%;
  }

  .admin-pay-actions .btn-sm {
    flex: 1;
  }

  #manualSubmit,
  #payByCard {
    width: 100%;
  }
}


/* ---------- QA fixes ---------- */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 6px;
}

.field-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

/* CV upload is reachable and usable with the keyboard */
.dropzone:focus-visible {
  outline: 3px solid rgba(21, 93, 252, 0.45);
  outline-offset: 2px;
  border-color: var(--primary);
}

/* Visible keyboard focus everywhere */
a:focus-visible,
button:focus-visible,
summary:focus-visible,
[role="button"]:focus-visible {
  outline: 3px solid rgba(21, 93, 252, 0.45);
  outline-offset: 2px;
}

.form-success {
  font-size: 13px;
  color: var(--success);
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
}

.danger-zone {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--border-light);
}

.danger-zone summary {
  cursor: pointer;
  color: var(--error);
  font-weight: 600;
  font-size: 14px;
}

.danger-zone[open] summary {
  margin-bottom: 10px;
}

/* 404 page */
.not-found {
  max-width: 520px;
  margin: 0 auto;
  padding: 96px 24px;
  text-align: center;
}

.not-found .not-found-code {
  font-size: 56px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.03em;
}

.not-found h1 {
  font-size: 24px;
  font-weight: 800;
  margin: 6px 0 8px;
}

.not-found p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.papers .paper-title {
  display: flex;
  gap: 6px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
}


/* Until the server says who's logged in, no screen is shown (no flash of a protected page). */
body.booting .view {
  display: none !important;
}

/* App links only appear once they can be used (they'd redirect to log in / confirm otherwise). */
body[data-stage="anonymous"] .nav-link:is([data-nav="universities"], [data-nav="emailed"], [data-nav="search"], [data-nav="settings"]),
body[data-stage="unverified"] .nav-link:is([data-nav="universities"], [data-nav="emailed"], [data-nav="search"]) {
  display: none;
}

.status-pill.refunded,
.status-pill.failed {
  color: var(--error);
  background: #fef2f2;
}

.admin-pay-actions {
  align-items: center;
}

/* Admin "Users" tab */
.admin-find {
  max-width: 360px;
  margin-bottom: 12px;
}

.admin-find input {
  width: 100%;
  height: 42px;
  padding: 0 14px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.admin-find input:focus,
.admin-days:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.admin-count {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.admin-user .admin-pay-main .status-pill {
  margin-right: 4px;
}

/* Admin "Dashboard" tab: one card per number */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.admin-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border-light);
  border-radius: 12px;
}

button.admin-stat {
  cursor: pointer;
}

button.admin-stat:hover {
  border-color: var(--primary);
}

.admin-stat strong {
  font-size: 28px;
  line-height: 1.1;
}

.admin-stat span {
  font-size: 13px;
  color: var(--text-muted);
}

/* Users tab: what's stored for one account, under its row */
.admin-details {
  flex-basis: 100%;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
  font-size: 13px;
}

.admin-details h4 {
  margin: 0 0 6px;
  font-size: 13px;
}

.admin-details dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 10px;
  margin: 0;
}

.admin-details dt {
  color: var(--text-muted);
}

.admin-details dd {
  margin: 0;
  word-break: break-word;
}

.admin-details ul {
  margin: 0;
  padding-left: 18px;
  max-height: 180px;
  overflow-y: auto;
}

.admin-details p {
  margin: 0;
}

.admin-days {
  width: 72px;
  padding: 6px 8px;
  font: inherit;
  font-size: 14px;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 8px;
}

/* ---------- Log in / sign up / password / confirm: soft glass card on a blue backdrop ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.page-view.auth-stage {
  position: relative;
  isolation: isolate;
  max-width: none;
  min-height: calc(100vh - 62px);
  min-height: calc(100svh - 62px);
  display: grid;
  place-items: center;
  padding: 48px 16px 64px;
  background:
    radial-gradient(circle at 12% 18%, rgba(147, 197, 253, 0.5), transparent 38%),
    radial-gradient(circle at 88% 82%, rgba(165, 180, 252, 0.45), transparent 40%),
    linear-gradient(160deg, #eaf1ff 0%, #f4f7ff 48%, #e6edff 100%);
}

/* its own clipped layer, so the circles never make the page scroll sideways */
.auth-orbs {
  position: absolute;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.auth-orbs span {
  position: absolute;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.95), rgba(219, 234, 254, 0.7));
  box-shadow: 12px 12px 30px rgba(100, 116, 139, 0.18), -10px -10px 26px rgba(255, 255, 255, 0.85);
  animation: auth-float 9s ease-in-out infinite;
}

.auth-orbs span:nth-child(1) {
  width: 190px;
  height: 190px;
  top: 7%;
  left: 5%;
}

.auth-orbs span:nth-child(2) {
  width: 84px;
  height: 84px;
  top: 16%;
  right: 13%;
  animation-delay: -3s;
}

.auth-orbs span:nth-child(3) {
  width: 260px;
  height: 260px;
  bottom: -70px;
  right: -50px;
  animation-delay: -5s;
}

.auth-orbs span:nth-child(4) {
  width: 58px;
  height: 58px;
  bottom: 18%;
  left: 15%;
  animation-delay: -1.5s;
}

@keyframes auth-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-14px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-orbs span {
    animation: none;
  }
}

.auth-glass {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.78);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 28px;
  padding: 36px 32px 28px;
  box-shadow: 0 24px 60px rgba(30, 64, 175, 0.13), 0 2px 6px rgba(15, 23, 42, 0.05), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.auth-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 20px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, #ffffff, #e7edf8);
  box-shadow: 8px 8px 18px rgba(100, 116, 139, 0.25), -8px -8px 18px rgba(255, 255, 255, 0.95);
}

.auth-logo svg {
  width: 38px;
  height: 38px;
}

.auth-title {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: center;
  color: var(--text);
}

.auth-sub {
  margin: 6px 0 28px;
  text-align: center;
  font-size: 15px;
  color: var(--text-muted);
}

.auth-field {
  position: relative;
  margin-bottom: 14px;
}

.auth-field-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--placeholder);
  pointer-events: none;
}

#authView .auth-field input {
  height: 54px;
  padding: 0 52px 0 50px;
  font-size: 15px;
  border-radius: 16px;
  border: 1px solid #d5deeb;
  background: #f1f5fb;
  box-shadow: inset 3px 3px 7px rgba(100, 116, 139, 0.14), inset -3px -3px 7px rgba(255, 255, 255, 0.9);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

#authView .auth-field input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(21, 93, 252, 0.14);
}

#authView .auth-field input.invalid {
  border-color: var(--error);
}

.auth-field:focus-within .auth-field-icon {
  color: var(--primary);
}

.auth-eye {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--placeholder);
  cursor: pointer;
}

.auth-eye svg {
  width: 19px;
  height: 19px;
}

.auth-eye:hover {
  color: var(--primary);
  background: rgba(21, 93, 252, 0.08);
}

.auth-eye .eye-shut,
.auth-eye.shown .eye-open {
  display: none;
}

.auth-eye.shown .eye-shut {
  display: block;
}

.auth-hint {
  margin: -6px 4px 12px;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 2px 2px 18px;
  font-size: 14px;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.auth-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
  cursor: pointer;
}

.auth-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-link:hover {
  text-decoration: underline;
}

.auth-submit {
  position: relative;
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #2563eb 0%, #4f46e5 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(37, 99, 235, 0.32);
  transition: transform 0.15s, box-shadow 0.15s;
}

.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(37, 99, 235, 0.38);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-submit:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

.auth-submit-arrow {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: #2563eb;
  transition: transform 0.15s;
}

.auth-submit-arrow svg {
  width: 18px;
  height: 18px;
}

.auth-submit:hover .auth-submit-arrow {
  transform: translate(2px, -50%);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 24px 0 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, #c3cede, transparent);
}

.auth-google {
  width: 100%;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  background: linear-gradient(145deg, #ffffff, #eef2f8);
  box-shadow: 6px 6px 14px rgba(100, 116, 139, 0.2), -6px -6px 14px rgba(255, 255, 255, 0.95);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.15s;
}

.auth-google svg {
  width: 22px;
  height: 22px;
}

.auth-google:hover {
  transform: translateY(-1px);
}

.auth-google:active {
  transform: none;
  box-shadow: inset 4px 4px 10px rgba(100, 116, 139, 0.2), inset -4px -4px 10px rgba(255, 255, 255, 0.95);
}

.auth-glass .auth-switch {
  margin-top: 22px;
}

.auth-tagline {
  margin-top: 18px;
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* forgot / reset / confirm share the card; their regular inputs get the same soft look */
.auth-glass h2 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-glass .field input {
  height: 50px;
  font-size: 15px;
  border-radius: 14px;
  background: #f1f5fb;
}

.auth-glass .field input:focus {
  background: #fff;
}

/* "Back" at the top of the Confirm-email card */
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: -12px 0 14px -8px;
  padding: 6px 10px 6px 6px;
  border: 0;
  border-radius: 999px;
  background: none;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-back svg {
  width: 18px;
  height: 18px;
}

.auth-back:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.auth-back:disabled {
  opacity: 0.5;
  cursor: default;
}

/* the 6-digit confirmation code */
.auth-glass .field input.code-input {
  text-align: center;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 0.4em;
  font-variant-numeric: tabular-nums;
}

.auth-switch .link-btn {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
}

.auth-switch .link-btn:hover {
  text-decoration: underline;
}

.auth-switch .link-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.auth-glass .btn-primary {
  border-radius: 999px;
  min-height: 50px;
  background: linear-gradient(90deg, #2563eb 0%, #4f46e5 100%);
}

@media (max-width: 480px) {
  .page-view.auth-stage {
    padding: 28px 12px 44px;
    place-items: start center;
  }

  .auth-glass {
    padding: 28px 20px 22px;
    border-radius: 24px;
  }

  .auth-title {
    font-size: 25px;
  }

  .auth-sub {
    margin-bottom: 22px;
  }

  .auth-orbs span:nth-child(1) {
    width: 120px;
    height: 120px;
  }

  .auth-orbs span:nth-child(3) {
    width: 180px;
    height: 180px;
  }
}

/* Step 3 sits under the Submit button */
.pay-steps-after {
  margin-top: 16px;
}

/* "Your payments" heading with its Show / Hide button */
.payments-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.payments-head h2 {
  margin: 0;
}

#paymentsWrap {
  margin-top: 14px;
}

/* Guides (public articles) */
.guide-page {
  max-width: 760px;
}

.guide-crumb {
  font-size: 13px;
  margin-bottom: 8px;
}

.guide-meta {
  font-size: 13px;
  color: var(--text-faint);
  margin-top: 6px;
}

.guide-answer {
  color: var(--text);
  font-size: 16px;
  background: var(--primary-soft);
  border-radius: 8px;
  padding: 14px 16px;
}

.prose h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 16px 0 6px;
}

.guide-template {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  color: var(--text);
}

.guide-template p:last-child {
  margin-bottom: 0;
}

.prose .guide-list {
  list-style: none;
  padding-left: 0;
  margin-top: 20px;
}

.guide-list li {
  margin-bottom: 16px;
}

.guide-cta {
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 20px;
  margin-top: 28px;
}

.guide-cta h2 {
  margin-top: 0;
}

.prose .guide-cta .btn-primary {
  color: #fff;
  text-decoration: none;
}

.guide-related {
  margin-top: 8px;
}
