/* Referral program pages. Mobile first; no external fonts or assets. */

:root {
  --bg: #0b1622;
  --bg-raised: #132233;
  --bg-input: #0e1b29;
  --text: #e8f1f8;
  --muted: #a6b8c8;
  --line: #2a3f55;
  --accent: #6cc4ff;
  --accent-text: #04121f;
  --focus: #ffd166;
  --ok: #5fd39a;
  --warn: #ffcc66;
  --bad: #ff8a80;
  --info: #8fd0ff;
  --radius: 12px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f7fb;
    --bg-raised: #ffffff;
    --bg-input: #ffffff;
    --text: #0d1b2a;
    --muted: #4a5d70;
    --line: #c9d6e2;
    --accent: #005a9e;
    --accent-text: #ffffff;
    --focus: #b35c00;
    --ok: #146c43;
    --warn: #8a5300;
    --bad: #b3261e;
    --info: #00558f;
    color-scheme: light;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
  padding-top: 8px;
  padding-bottom: 32px;
}

main:focus {
  outline: none;
}

.wrap {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

h1 {
  font-size: 1.6rem;
  line-height: 1.25;
  margin: 16px 0 8px;
}

h2 {
  font-size: 1.2rem;
  margin: 0 0 12px;
}

h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
}

.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 10;
  background: var(--bg-raised);
  padding: 8px 12px;
  border-radius: 8px;
}

.offscreen {
  position: fixed;
  left: -9999px;
  top: 0;
  opacity: 0;
}

/* ------------------------------------------------------------- chrome */
.site-header {
  border-bottom: 1px solid var(--line);
  background: var(--bg-raised);
}

.header-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 56px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.site-header nav {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.site-footer {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.875rem;
  padding: 16px 0;
}

.test-banner {
  background: var(--warn);
  color: #1d1300;
  text-align: center;
  font-weight: 700;
  font-size: 0.875rem;
  padding: 6px 16px;
  letter-spacing: 0.02em;
}

/* -------------------------------------------------------------- blocks */
.lead {
  color: var(--muted);
  font-size: 1.05rem;
  margin: 0 0 16px;
}

.card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}

.hint {
  color: var(--muted);
  font-size: 0.875rem;
  margin: 4px 0 0;
}

.notice {
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
  border-left: 4px solid var(--info);
  background: color-mix(in srgb, var(--info) 12%, transparent);
}

.notice.error {
  border-left-color: var(--bad);
  background: color-mix(in srgb, var(--bad) 12%, transparent);
}

.notice.warning {
  border-left-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
}

.notice.success {
  border-left-color: var(--ok);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}

.prewrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 16px 0 8px;
}

.steps,
.points {
  margin: 0;
  padding-left: 1.4em;
}

.steps li,
.points li {
  margin: 6px 0;
}

/* ------------------------------------------------------------- buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button.primary {
  background: var(--accent);
  color: var(--accent-text);
}

.button.small {
  min-height: 36px;
  padding: 6px 12px;
  font-size: 0.9rem;
}

.button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link-button {
  background: none;
  border: 0;
  padding: 8px 0;
  color: var(--accent);
  font: inherit;
  text-decoration: underline;
  cursor: pointer;
}

/* --------------------------------------------------------------- forms */
form .field,
fieldset.field {
  margin: 0 0 16px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-width: 0;
}

legend {
  font-weight: 600;
  padding: 0 4px;
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
}

input[type="text"],
input[type="password"],
input[type="url"],
input[type="date"],
select,
textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--line);
  border-radius: 8px;
}

textarea {
  resize: vertical;
}

[aria-invalid="true"] {
  border-color: var(--bad);
  box-shadow: 0 0 0 1px var(--bad);
}

.field-error {
  color: var(--bad);
  font-size: 0.9rem;
  font-weight: 600;
  margin: 4px 0 0;
}

.field.checkbox {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  align-items: start;
}

.field.checkbox input {
  width: 22px;
  height: 22px;
  margin: 2px 0 0;
}

.field.checkbox label {
  font-weight: 400;
}

.field.checkbox .field-error {
  grid-column: 1 / -1;
}

.row {
  display: flex;
  flex-direction: column;
  gap: 0 12px;
}

.channels {
  list-style: none;
  margin: 12px 0;
  padding: 0;
}

.channel {
  border: 1px dashed var(--line);
  border-radius: 10px;
  padding: 12px;
  margin: 0 0 12px;
}

.channel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.counter {
  text-align: right;
}

/* -------------------------------------------------------- referral page */
.hero {
  padding: 8px 0;
}

.code-box {
  background: var(--bg-raised);
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  text-align: center;
}

.code-label {
  margin: 0;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: clamp(1.6rem, 9vw, 2.6rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  margin: 8px 0;
  overflow-wrap: anywhere;
  user-select: all;
}

.copy-status {
  display: inline-block;
  margin-left: 8px;
  color: var(--ok);
  font-size: 0.9rem;
}

/* ------------------------------------------------------------ dashboard */
.share-grid {
  display: grid;
  gap: 16px;
}

.share .code {
  font-size: 2rem;
  margin-top: 0;
}

.qr-box {
  justify-self: center;
  width: 100%;
  max-width: 240px;
}

.qr {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

.balances {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.balance-card {
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-top: 4px solid var(--info);
  border-radius: var(--radius);
  padding: 12px;
}

.balance-card.available {
  border-top-color: var(--ok);
}

.balance-card.paid {
  border-top-color: var(--accent);
}

.balance-card.negative {
  border-top-color: var(--bad);
}

.balance-card .amount {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 2px 0;
  font-variant-numeric: tabular-nums;
}

.filters {
  display: grid;
  gap: 0 12px;
  align-items: end;
}

.filters .field {
  margin-bottom: 12px;
}

.filters .button {
  margin-bottom: 12px;
}

.badge,
.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 10px;
  font-weight: 700;
  font-size: 0.85rem;
  border: 1px solid currentColor;
}

.badge {
  font-size: 1rem;
  padding: 4px 14px;
}

.status-submitted,
.status-pending,
.status-processing {
  color: var(--info);
}

.status-needs_info {
  color: var(--warn);
}

.status-approved,
.status-available,
.status-paid {
  color: var(--ok);
}

.status-rejected,
.status-reversed,
.status-failed,
.status-void {
  color: var(--bad);
}

.staff-message {
  border-left: 4px solid var(--warn);
  padding: 4px 12px;
  margin: 12px 0;
}

.empty {
  color: var(--muted);
}

/* Tables are stacked cards on small screens (labels from data-label). */
.table-wrap {
  width: 100%;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

table.data thead {
  position: absolute;
  left: -9999px;
}

table.data tr {
  display: block;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  margin: 0 0 10px;
}

table.data td {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0;
  text-align: right;
  overflow-wrap: anywhere;
}

table.data td::before {
  content: attr(data-label);
  color: var(--muted);
  text-align: left;
  font-weight: 600;
}

.terms section {
  margin: 20px 0;
}

.draft-badge {
  display: inline-block;
  vertical-align: middle;
  background: var(--warn);
  color: #1d1300;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 6px;
  padding: 2px 8px;
}

.draft-note {
  border: 2px dashed var(--warn);
  border-radius: var(--radius);
  padding: 4px 16px;
  margin: 12px 0 20px;
}

/* ------------------------------------------------------- wider screens */
@media (min-width: 600px) {
  h1 {
    font-size: 2rem;
  }

  .row {
    flex-direction: row;
  }

  .row .grow {
    flex: 1;
  }

  .balances {
    grid-template-columns: repeat(4, 1fr);
  }

  .filters {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

@media (min-width: 760px) {
  .share-grid {
    grid-template-columns: 1fr 220px;
    align-items: start;
  }

  table.data thead {
    position: static;
  }

  table.data tr {
    display: table-row;
    border: 0;
    padding: 0;
  }

  table.data th,
  table.data td {
    display: table-cell;
    padding: 8px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
  }

  table.data th {
    color: var(--muted);
    font-size: 0.85rem;
  }

  table.data .num {
    text-align: right;
  }

  table.data td::before {
    content: none;
  }
}
