/* The referrer's area (referral programme slice 4): Commissions, the program terms and the payout details, as the
   boards Carlos approved on 2026-11-03 draw them (projects/referral-design/artboards/qs-referral.css). Colors, radii and
   type come from app.css tokens; gold only on the dark link card. Every rule carries the earn-, ref- or terms- prefix,
   since every feature stylesheet loads on every page. Nothing scrolls sideways at 375 px: the tables stack their cells
   under labels on phones. */

/* Back to commissions, on its own line at the left of the page head. */
.earn-back {
  align-self: flex-start;
}

/* The dark link card: labels in gold, the link in a box, the next payout on the right. */
.earn-label {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-400);
}

.earn-dark-text {
  margin: 0;
  color: var(--ink-300);
  font-size: 15px;
  line-height: 24px;
  max-width: 56ch;
}

.earn-dark-text a {
  color: var(--white);
}

.earn-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 40px;
}

.earn-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.earn-link {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.earn-url {
  flex: 1 1 300px;
  min-width: 0;
  display: flex;
  align-items: center;
  height: 48px;
  padding: 0 16px;
  border: 1px solid var(--white-24);
  border-radius: var(--radius-control);
  background: var(--white-8);
  font-family: var(--font-mono);
  font-size: 15px;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.earn-code {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.earn-code .figure {
  letter-spacing: 0.06em;
}

.earn-payout {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-left: 40px;
  border-left: 1px solid var(--white-16);
}

.earn-payout p {
  margin: 0;
}

/* The cards under it. */
.earn-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.earn-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 24px;
}

.earn-stats + .earn-stats {
  padding-top: 24px;
  border-top: 1px solid var(--ink-200);
}

.earn-stat {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.earn-stat p {
  margin: 0;
}

.earn-steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.earn-steps li {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  font-size: 15px;
  line-height: 22px;
  color: var(--ink-700);
}

.earn-steps b {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-control);
  background: var(--ink-100);
  color: var(--navy-800);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
}

.earn-chip-pending {
  border-color: var(--ink-300);
  background: var(--white);
  color: var(--ink-700);
}

.earn-chip-paid {
  border-color: var(--ink-900);
  background: var(--ink-900);
  color: var(--white);
}

.earn .table td .text-small {
  display: block;
}

.earn-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.earn-dl {
  margin: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 16px;
  font-size: 15px;
  line-height: 22px;
}

.earn-dl dt {
  color: var(--ink-500);
}

.earn-dl dd {
  margin: 0;
  color: var(--ink-900);
}

.earn-agree {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.earn-agree li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 4px 12px;
  padding-top: 12px;
  border-top: 1px solid var(--ink-200);
  font-size: 15px;
  line-height: 22px;
}

.earn-empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  border: 1px dashed var(--ink-300);
  border-radius: var(--radius-card);
  color: var(--ink-700);
}

.earn-empty p {
  margin: 0;
}

/* Upload invoice PDF: a label that looks like the button, the file field inside it kept for the keyboard. */
.earn-upload {
  position: relative;
  cursor: pointer;
}

.earn-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.earn-upload:focus-within {
  outline: 2px solid var(--navy-800);
  outline-offset: 2px;
}

/* The payout details form: choice cards for the type and the method, two columns of fields. */
.ref-choices {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

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

.ref-choice {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-control);
  background: var(--white);
  cursor: pointer;
}

.ref-choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ref-choice:has(input:checked) {
  border-color: var(--navy-800);
  outline: 1px solid var(--navy-800);
  outline-offset: -2px;
}

.ref-choice:has(input:focus-visible) {
  outline: 2px solid var(--navy-800);
  outline-offset: 2px;
}

.ref-choice b {
  font-weight: 500;
  color: var(--ink-900);
}

.ref-choice span {
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-500);
}

.ref-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px 24px;
}

.ref-form-wide {
  grid-column: 1 / -1;
}

/* Only the chosen method's fields. */
.ref-details:has(input[name="method"][value="wise"]:checked) .ref-sepa,
.ref-details:has(input[name="method"][value="sepa"]:checked) .ref-wise {
  display: none;
}

/* The program terms: a section per row, the lawyer's placeholders in mono, the disclosure examples in boxes. */
.terms-sec {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 16px;
  border-top: 1px solid var(--ink-200);
}

.terms-sec h3,
.terms-sec p {
  margin: 0;
}

/* The full text under each summary: the binding words, at reading size. */
.terms-text {
  font-size: 15px;
  line-height: 24px;
  color: var(--ink-700);
}

.terms-todo {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 20px;
  color: var(--ink-500);
}

.terms-say {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 16px;
  border-radius: var(--radius-control);
  background: var(--ink-50);
  border: 1px solid var(--ink-200);
}

.terms-say p {
  margin: 0;
}

@media (max-width: 960px) {
  .earn-hero,
  .earn-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .earn-payout {
    padding-left: 0;
    padding-top: 24px;
    border-left: 0;
    border-top: 1px solid var(--white-16);
  }

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

  .ref-choices,
  .ref-choices-2,
  .ref-form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Figures sit at the right of their column, under right-aligned headings, as the boards draw them. */
.earn .table .num,
.earn-statement-lines .num {
  text-align: right;
}

/* Phones: each table row stacks as a small card, the purchase first, its day under it, the figures labelled. */
@media (max-width: 767px) {
  .earn .table thead {
    display: none;
  }

  .earn .table,
  .earn .table tbody {
    display: block;
  }

  .earn .table tr {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px 12px;
    padding: 16px 0;
    border-bottom: 1px solid var(--ink-200);
  }

  .earn .table tbody td {
    display: block;
    height: auto;
    padding: 0;
    border: 0;
    text-align: left;
  }

  .earn .table .num {
    text-align: left;
    padding-right: 0;
  }

  .earn .table td[data-label]::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 2px;
    font-family: var(--font-mono);
    font-size: 11px;
    line-height: 16px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-500);
    white-space: normal;
  }

  .earn .table .earn-wide {
    grid-column: 1 / -1;
  }

  .earn .table .earn-first {
    order: -2;
    font-weight: 500;
  }

  .earn .table .earn-second {
    order: -1;
    color: var(--ink-500);
    font-size: 13px;
  }
}

/* A payout's statement: its lines and totals as two plain tables, the parties side by side, and a clean print. */
.earn-statement-lines td .text-small {
  display: block;
}

.earn-statement-parties {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
}

.earn-statement-parties p {
  margin: 4px 0 0;
}

@media (max-width: 767px) {
  .earn-statement-parties {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* The statement's brand for paper only: on screen the topbar carries it. */
.earn-print-brand {
  display: none;
}

@media print {
  /* The navy horizontal logo at the top left, as the emails' band: 24px tall and 202px wide (the kit's floor is 200px,
     BRAND-LOGO section 5), the margin under it above the clear space of 0.5467 x 24 = 13.12px. An img, so it prints
     with background graphics off. */
  .earn-print-brand {
    display: block;
    align-self: flex-start;
    width: 202px;
    height: 24px;
    margin-bottom: 16px;
  }

  body:has(.earn-statement) .topbar,
  body:has(.earn-statement) .site-footer,
  body:has(.earn-statement) .tabbar,
  .earn-noprint {
    display: none !important;
  }

  /* Browsers leave background colours out of a print by default; the Paid chip keeps its dark fill. */
  .earn-statement .chip {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}

/* Self-billing (referral programme slice 5, boards of 2026-11-12): what each invoice carries on the payout details
   form, the wait of a referrer with no registered activity, the invoice to accept, and the invoice's sheet. */
.ref-tax {
  gap: 10px;
  padding: 16px 20px;
}

.ref-tax-head {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-500);
}

.ref-tax-rows {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(0, 1fr);
  gap: 6px 24px;
  font-size: 15px;
  line-height: 22px;
}

.ref-tax-rows dt {
  color: var(--ink-500);
}

.ref-tax-rows dd {
  margin: 0;
  color: var(--ink-900);
}

.ref-tax .check {
  min-height: 0;
  padding: 6px 0 0;
}

.ref-tax .field-hint {
  margin: 0;
}

.ref-reduced-year {
  max-width: 240px;
}

.ref-wait {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 20px;
  border: 1px solid var(--ink-300);
  border-radius: var(--radius-control);
  background: var(--white);
}

.ref-wait p {
  margin: 0;
}

.ref-wait-title {
  font-weight: 500;
  color: var(--ink-900);
}

.ref-wait .text-small {
  color: var(--ink-700);
}

/* Only what matches the type chosen: the wait for 'no registered activity', the invoice panel and the agreement for
   the two that invoice. */
.ref-only-individual,
.ref-details:has(input[name="party_kind"][value="individual"]:checked) .ref-not-individual {
  display: none;
}

.ref-details:has(input[name="party_kind"][value="individual"]:checked) .ref-only-individual {
  display: flex;
}

/* Only the country's rows (the form's data-zone; Canarias, Ceuta and Melilla read as another EU country does: we
   confirm both), and within Spain the type's. */
.ref-zone-es,
.ref-zone-eu,
.ref-zone-world {
  display: none;
}

.ref-details[data-zone="es"] dl.ref-zone-es,
.ref-details[data-zone="eu"] dl.ref-zone-eu,
.ref-details[data-zone="es_other"] dl.ref-zone-eu,
.ref-details[data-zone="world"] dl.ref-zone-world {
  display: grid;
}

.ref-details[data-zone="es"] div.ref-zone-es {
  display: flex;
}

.ref-details:not(:has(input[name="party_kind"][value="self_employed"]:checked)) .ref-only-self,
.ref-details:not(:has(input[name="party_kind"][value="company"]:checked)) .ref-only-company {
  display: none !important;
}

/* The 7%: its rate in the panel, the year and the year it ends, only while it is asked for. */
.ref-irpf-reduced,
.ref-reduced-year,
.ref-reduced-back,
.ref-details:has(input[name="irpf_reduced"]:checked) .ref-irpf-full {
  display: none;
}

.ref-details:has(input[name="irpf_reduced"]:checked) .ref-irpf-reduced,
.ref-details:has(input[name="irpf_reduced"]:checked) .ref-reduced-back {
  display: inline;
}

.ref-details:has(input[name="irpf_reduced"]:checked) .ref-reduced-year {
  display: block;
}

.ref-accept {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ref-accept-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px 16px;
}

.ref-accept-head p {
  margin: 0;
}

.ref-accept-head .micro {
  color: var(--ink-500);
}

.ref-accept h2,
.ref-accept p {
  margin: 0;
}

.ref-accept-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  gap: 24px 48px;
  align-items: start;
}

.ref-accept-money {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border-radius: var(--radius-control);
  background: var(--ink-50);
}

.ref-money-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.ref-money-line dt {
  color: var(--ink-700);
}

.ref-money-line dd {
  margin: 0;
}

.ref-money-total {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--ink-200);
}

.ref-money-total dt,
.ref-money-total dd {
  font-weight: 500;
  color: var(--ink-900);
}

/*
 * 'A detail is wrong' opens its box in place; the summary is the button. Open, the box takes the card: the lines, the
 * two other ways and the money step aside (InvoiceAcceptStates 2), and Cancel reloads the page.
 */
.ref-wrong-fold summary {
  list-style: none;
}

.ref-wrong-fold[open] {
  flex: 1 1 100%;
}

.ref-wrong-fold[open] > summary {
  display: none;
}

.ref-wrong-fold[open] .ref-wrong {
  margin-top: 0;
}

.ref-accept:has(.ref-wrong-fold[open]) .ref-accept-say,
.ref-accept:has(.ref-wrong-fold[open]) .ref-accept-money {
  display: none;
}

.ref-accept:has(.ref-wrong-fold[open]) .ref-accept-grid {
  grid-template-columns: minmax(0, 1fr);
}

.ref-wrong-fold summary::-webkit-details-marker {
  display: none;
}

.ref-wrong {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

/* The self-billed invoice, A4: the statement's type and rows, the referrer as issuer. */
.inv-page {
  align-items: flex-start;
}

.inv {
  box-sizing: border-box;
  width: 794px;
  max-width: 100%;
  min-height: 1123px;
  padding: 56px 64px;
  border: 1px solid var(--ink-200);
  background: var(--white);
  display: flex;
  flex-direction: column;
  gap: 32px;
  color: var(--ink-900);
}

.inv p,
.inv h1 {
  margin: 0;
}

.inv .micro {
  color: var(--ink-500);
}

.inv-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}

.inv-id {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inv-legend {
  display: inline-block;
  align-self: flex-start;
  padding: 4px 10px;
  border: 1px solid var(--ink-900);
  border-radius: 4px;
  font-size: 14px;
  line-height: 20px;
  font-weight: 500;
}

.inv-date {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: right;
}

.inv-date dd {
  margin: 0;
  font-size: 15px;
  line-height: 22px;
}

.inv-foot .inv-date {
  text-align: left;
}

.inv-parties {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--ink-200);
}

.inv-parties section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 15px;
  line-height: 24px;
}

.inv-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 24px;
  border: 1px solid var(--ink-200);
  border-radius: var(--radius-card);
}

.inv-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 12px 0;
  border-bottom: 1px solid var(--ink-200);
  font-size: 15px;
  line-height: 23px;
}

.inv-line .text-small {
  color: var(--ink-500);
}

.inv-totals {
  margin: 0;
  display: flex;
  flex-direction: column;
}

.inv-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 10px 0;
  border-bottom: 1px solid var(--ink-200);
  font-size: 15px;
  line-height: 23px;
}

.inv-row dt {
  color: var(--ink-700);
}

.inv-row dd {
  margin: 0;
}

.inv-total {
  border-bottom: 0;
  font-weight: 600;
}

.inv-total dt {
  color: var(--ink-900);
}

.inv-foot {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: auto;
  padding-top: 24px;
  border-top: 1px solid var(--ink-200);
}

@media (max-width: 960px) {
  .ref-accept-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 767px) {
  .ref-tax-rows {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }

  .ref-tax-rows dd {
    margin-bottom: 8px;
  }

  .inv {
    padding: 24px 20px;
    min-height: 0;
  }

  .inv-head,
  .inv-parties {
    display: flex;
    flex-direction: column;
  }

  .inv-date {
    text-align: left;
  }
}

@media print {
  /* The invoice prints as its sheet alone: no topbar, no footer, no frame. */
  body:has(.inv) .topbar,
  body:has(.inv) .site-footer,
  body:has(.inv) .tabbar {
    display: none !important;
  }

  .inv {
    width: auto;
    min-height: 0;
    padding: 0;
    border: 0;
  }
}
