/* Core stylesheet: fonts, tokens, base type and the shared components (buttons, fields, cards,
   tables, badges, notices). The shells add css/site.css (public pages) or css/shell.css (the
   affiliate and admin areas). Fonts are self-hosted: no third-party call. */
@font-face {
  font-family: "Inter";
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  src: url("/assets/fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("/assets/fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  src: url("/assets/fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Geist Mono";
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  src: url("/assets/fonts/geist-mono-500.woff2") format("woff2");
}

:root {
  /* Neutrals: surfaces, lines and text. */
  --white: #ffffff;
  --bg-muted: #fafafa;
  --bg-subtle: #f5f5f5;
  --bg-emphasis: #e5e5e5;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;
  --line-emphasis: #a3a3a3;
  --text-emphasis: #171717;
  --text-strong: #262626;
  --text: #404040;
  --text-soft: #525252;
  --muted: #6b6b6b; /* secondary text; >= 4.5:1 on white, --bg-muted and --bg-subtle */
  --placeholder: #a3a3a3;
  --hover: rgba(23, 23, 23, 0.05);
  --pressed: rgba(23, 23, 23, 0.1);
  /* VGC brand: navy for primary actions and the active nav, orange as the accent. */
  --navy: #1c3a55;
  --navy-dark: #16304a;
  --navy-tint: rgba(28, 58, 85, 0.08);
  --accent: #df9a57; /* fills, lines and rings only, never text */
  --accent-ring: rgba(223, 154, 87, 0.2);
  --accent-text: #a35a14; /* the accent as text (>= 4.5:1 on white and --bg-muted) */
  /* Status tints: a pale fill with a dark text of the same hue (>= 4.5:1). */
  --info-bg: #dbeafe;
  --info: #1d4ed8;
  --success-bg: #dcfce7;
  --success: #15803d;
  --attention-bg: #ffedd5;
  --attention: #c2410c;
  --warning-bg: #fef9c3;
  --warning: #a16207;
  --error-bg: #fee2e2;
  --error: #b91c1c;
  --error-line: #fca5a5;
  --neutral-bg: #ececec;
  --neutral: #525252;
  --radius-s: 6px;
  --radius-m: 8px;
  --radius-l: 12px;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  color: var(--text-emphasis);
  font-weight: 600;
  line-height: 1.3;
}
h1 {
  font-size: 24px;
  letter-spacing: -0.02em;
}
h2 {
  margin-top: 32px;
  font-size: 16px;
}
h3 {
  font-size: 14px;
}
p {
  margin: 0 0 12px;
}
ul,
ol {
  margin: 0 0 12px;
  padding-left: 20px;
}
li + li {
  margin-top: 4px;
}
a {
  color: var(--text-emphasis);
  text-decoration-color: var(--line-emphasis);
  text-underline-offset: 3px;
}
a:hover {
  text-decoration-color: currentColor;
}
:focus-visible {
  outline: 2px solid var(--navy);
  outline-offset: 2px;
}
code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-strong);
  font-family: var(--mono);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 24px;
  margin: 0 0 12px;
}
dt {
  color: var(--muted);
}
dd {
  margin: 0;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.muted {
  color: var(--muted);
  font-size: 13px;
}
.money,
.num {
  font-variant-numeric: tabular-nums;
}
.money {
  color: var(--text-emphasis);
  font-weight: 500;
}
/* Read by screen readers only, such as the copy button's "Copied" status. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.icon {
  flex: none;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icon chips: a soft square behind a line icon. */
.icon-20 {
  width: 20px;
  height: 20px;
}
.icon-chip {
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: linear-gradient(to bottom, var(--white), var(--bg-subtle));
  color: var(--text);
}
.icon-chip-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-s);
}
/* An information card with its icon chip on top. */
.info-card > .icon-chip {
  margin-bottom: 14px;
}

/* Buttons: 40px by default, 32px in bars and rows. Primary is navy; the hover adds a ring. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--white);
  color: var(--text-emphasis);
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s,
    box-shadow 0.15s;
}
.btn:hover {
  background: var(--bg-muted);
  color: var(--text-emphasis);
}
.btn:focus-visible {
  outline: none;
  border-color: var(--line-emphasis);
  box-shadow: 0 0 0 4px var(--bg-emphasis);
}
.btn-primary {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover {
  border-color: var(--navy-dark);
  background: var(--navy-dark);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--bg-emphasis);
}
.btn-primary:focus-visible {
  border-color: var(--navy-dark);
  box-shadow: 0 0 0 4px var(--accent-ring);
}
.btn-quiet {
  border-color: transparent;
  background: var(--bg-subtle);
  color: var(--text-strong);
}
.btn-quiet:hover {
  background: var(--bg-emphasis);
}
.btn-danger {
  border-color: #dc2626;
  background: #dc2626;
  color: var(--white);
}
.btn-danger:hover {
  background: var(--error);
  color: var(--white);
  box-shadow: 0 0 0 4px var(--error-bg);
}
.btn-sm {
  min-height: 32px;
  padding: 0 12px;
}
.btn-xs {
  min-height: 28px;
  padding: 0 10px;
  font-size: 12px;
}
.btn-block {
  width: 100%;
}
.btn[disabled] {
  border-color: var(--line);
  background: var(--bg-subtle);
  color: var(--muted);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-link {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}
.nav-form {
  display: inline;
  margin: 0;
}
p.no-print:has(.btn) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
/* The Print button shows only once print.js has run; .btn would otherwise override [hidden]. */
.btn[data-print][hidden] {
  display: none;
}

/* Fields: label above (14px/500), 6px-radius inputs with a soft ring on focus. */
.field {
  display: block;
  margin: 0 0 20px;
}
.field label,
fieldset.field legend {
  display: block;
  padding: 0;
  margin-bottom: 8px;
  color: var(--text-emphasis);
  font-size: 14px;
  font-weight: 500;
}
.field input:not([type="checkbox"], [type="radio"]),
.field select,
.field textarea,
.input {
  display: block;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-s);
  background: var(--white);
  color: var(--text-emphasis);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}
.field textarea {
  resize: vertical;
}
.field select {
  appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23737373' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-position: right 12px center;
  background-repeat: no-repeat;
  background-size: 16px;
}
.field input::placeholder,
.field textarea::placeholder {
  color: var(--placeholder);
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--text-soft);
  outline: none;
  box-shadow: 0 0 0 1px var(--text-soft);
}
.field input[readonly] {
  background: var(--bg-subtle);
  color: var(--muted);
}
.field .hint {
  display: block;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}
fieldset.field .hint {
  margin: 0 0 12px;
}
.field .field-error {
  margin: 8px 0 0;
  color: var(--error);
  font-size: 12px;
  font-weight: 500;
}
.field input[aria-invalid="true"],
.field select[aria-invalid="true"],
.field textarea[aria-invalid="true"] {
  border-color: var(--error-line);
  color: #7f1d1d;
}
.field input[aria-invalid="true"]:focus,
.field select[aria-invalid="true"]:focus,
.field textarea[aria-invalid="true"]:focus {
  border-color: var(--error);
  box-shadow: 0 0 0 1px var(--error);
}
fieldset.field {
  margin-inline: 0;
  padding: 0;
  border: 0;
}
fieldset.field input + label {
  margin-top: 12px;
}
fieldset.field label {
  color: var(--text-soft);
  font-size: 13px;
}
/* A checkbox beside its label, with the field's error under both. */
.field-check {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
}
.field.field-check input,
.field input[type="checkbox"],
.check {
  appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  min-height: 16px;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: var(--white) center / 12px no-repeat;
  cursor: pointer;
}
.field.field-check input:checked,
.field input[type="checkbox"]:checked,
.check:checked {
  border-color: var(--accent);
  background-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2.5 6.2 2.3 2.3 4.7-4.9'/%3E%3C/svg%3E");
}
.field.field-check input:focus-visible,
.field input[type="checkbox"]:focus-visible,
.check:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}
.field.field-check label {
  display: inline;
  margin: 0;
  color: var(--text-strong);
  font-weight: 400;
}
.field label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--text-strong);
  font-weight: 400;
}
.field label > input[type="checkbox"] {
  margin-top: 2px;
}
.field-check a {
  color: var(--accent-text);
  text-decoration-color: currentColor;
}
.field-check .field-error {
  flex-basis: 100%;
}
.chip-required {
  display: inline-flex;
  align-items: center;
  min-height: 16px;
  margin-left: 6px;
  padding: 0 4px;
  border-radius: var(--radius-s);
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  vertical-align: 1px;
}
.chip-required {
  background: var(--attention-bg);
  color: var(--attention);
}

/* A row of filters with its button, wrapping to one column on a phone. */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0 12px;
}
.filters .field {
  flex: 1 1 11rem;
  margin-bottom: 0;
}
.filters .btn {
  margin-bottom: 0;
}

/* Cards: a 1px line and a 12px radius do the work; no shadow. */
.card {
  margin: 0 0 20px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
}
.card > :first-child,
.card > form > :first-child {
  margin-top: 0;
}
.card > :last-child,
.card > form > :last-child {
  margin-bottom: 0;
}
.card > form + form {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.card h2 {
  margin: 0 0 12px;
  color: var(--text-strong);
  font-size: 16px;
  letter-spacing: -0.01em;
}
.card.filters {
  padding: 16px;
}

/* Stat tiles (admin pages): label above a 20px number. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
}
.stat .label {
  color: var(--text-soft);
  font-size: 14px;
  font-weight: 500;
}
.stat .value {
  color: var(--text-emphasis);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.stat .muted {
  font-size: 12px;
}

/* Tables: 14px rows, light vertical rules between columns, row hover. A phone stacks rows. */
.table-wrap {
  margin-bottom: 20px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
}
.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
}
.table th,
.table td {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line);
  color: var(--text);
  line-height: 24px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
.table th:first-child,
.table td:first-child {
  border-left-color: transparent;
}
.table th {
  color: var(--text-emphasis);
  font-weight: 500;
  background: var(--white);
}
.table tbody tr:last-child td {
  border-bottom: 0;
}
.table tbody tr {
  transition: background-color 75ms;
}
.table tbody tr:hover td {
  background: var(--bg-muted);
}
.table td .muted {
  font-size: 12px;
}
.table .num {
  text-align: right;
}
.table a {
  font-weight: 500;
}
.table tr.empty td,
.table tr.empty:hover td {
  padding: 48px 16px;
  background: var(--white);
  color: var(--muted);
  text-align: center;
  white-space: normal;
}

/* Status badges: a pale tint with its own dark text; the label is always the text. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: var(--radius-s);
  background: var(--neutral-bg);
  color: var(--neutral);
  font-size: 12px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
}
.badge-pending {
  background: var(--attention-bg);
  color: var(--attention);
}
.badge-payable,
.badge-approved {
  background: var(--info-bg);
  color: var(--info);
}
.badge-paid {
  background: var(--success-bg);
  color: var(--success);
}
.badge-void,
.badge-reversed,
.badge-cancelled {
  background: var(--neutral-bg);
  color: var(--neutral);
}
.badge-failed,
.badge-rejected {
  background: var(--error-bg);
  color: var(--error);
}
.badge-review {
  background: var(--warning-bg);
  color: var(--warning);
}

/* Notices: neutral by default, red for an error, each with its own icon. */
.notice {
  position: relative;
  margin: 0 0 20px;
  padding: 12px 14px 12px 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  background: var(--bg-muted);
  color: var(--text-strong);
}
.notice::before {
  content: "";
  position: absolute;
  top: 14px;
  left: 14px;
  width: 16px;
  height: 16px;
  background:
    center / 16px no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23525252' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 7.5v3.5M8 5h.01'/%3E%3C/svg%3E");
}
.notice ul {
  margin: 6px 0 0;
}
.notice-error {
  border-color: #fecaca;
  background: #fef2f2;
  color: var(--error);
}
.notice-error::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23b91c1c' stroke-width='1.5' stroke-linecap='round'%3E%3Ccircle cx='8' cy='8' r='6.25'/%3E%3Cpath d='M8 4.75v3.75M8 11h.01'/%3E%3C/svg%3E");
}
.notice-success {
  border-color: #bbf7d0;
  background: #f0fdf4;
  color: var(--success);
}

/* In-page tabs: a segmented control with the current option raised. */
main .site-nav,
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 20px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
}
main .site-nav a,
.segmented label {
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  color: var(--text-soft);
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
}
main .site-nav a:hover,
.segmented label:hover {
  color: var(--text-emphasis);
}
main .site-nav a[aria-current="page"] {
  border-color: var(--line);
  background: var(--bg-muted);
  color: var(--text-emphasis);
  font-weight: 500;
}

/* The copy field: the link as quiet text in a muted panel, with a small copy button. */
.copy-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding: 6px 6px 6px 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--bg-muted);
}
.copy-favicon {
  display: grid;
  flex: none;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  color: var(--text-soft);
}
.copy-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 4px 2px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-emphasis);
  font: 500 14px / 1.4 var(--sans);
  text-overflow: ellipsis;
}
.field input.copy-input {
  min-height: 0;
  padding: 4px 2px;
  border: 0;
  background: transparent;
  color: var(--text-emphasis);
  font-weight: 500;
}
.copy-input:focus-visible {
  outline: 2px solid var(--navy);
}
.copy-row .btn {
  min-height: 32px;
  padding: 0 12px;
}
.copy-row .icon-done,
.copy-row .is-copied .icon-copy {
  display: none;
}
.copy-row .is-copied .icon-done {
  display: block;
}

/* Statements (P6, A7): a page that prints cleanly, with every field an invoice needs. */
.statement {
  margin-bottom: 20px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: var(--radius-l);
  background: var(--white);
}
.statement h1 {
  margin-top: 0;
  font-size: 20px;
}
.statement h2 {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.statement-parties {
  display: grid;
  gap: 16px;
  margin: 20px 0;
}
.statement-line {
  margin: 0 0 4px;
}
.statement-meta {
  gap: 4px 16px;
  margin: 0 0 16px;
}
.statement-status {
  font-weight: 600;
}
.statement-net {
  border-top: 2px solid var(--text-emphasis);
  color: var(--text-emphasis);
  font-weight: 600;
}
.statement-tax {
  color: var(--muted);
  font-size: 13px;
}
.statement .table-wrap {
  border-radius: var(--radius-m);
}

@media (min-width: 640px) {
  .statement {
    padding: 32px;
  }
  .statement-parties {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 639px) {
  .table-wrap {
    border: 0;
    background: transparent;
    overflow: visible;
  }
  .table,
  .table tbody,
  .table tr,
  .table td {
    display: block;
    width: 100%;
  }
  .table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
  }
  .table tr {
    margin-bottom: 12px;
    padding: 4px 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-l);
    background: var(--white);
  }
  .table td,
  .table td:first-child {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 0;
    border-left: 0;
    border-bottom: 1px solid var(--line);
    text-align: right;
    white-space: normal;
  }
  .table tbody tr:last-child td {
    border-bottom: 1px solid var(--line);
  }
  .table tr td:last-child {
    border-bottom: 0;
  }
  .table tbody tr:hover td {
    background: transparent;
  }
  .table td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
  }
  .table tr.empty td {
    justify-content: center;
  }
  .btn {
    white-space: normal;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}

@media print {
  .site-header,
  .footer,
  .no-print {
    display: none;
  }
  body,
  .page {
    background: var(--white);
    padding: 0;
  }
  .statement {
    border: 0;
    padding: 0;
  }
  .statement-parties {
    grid-template-columns: 1fr 1fr;
  }
  .table-wrap {
    overflow: visible;
    border: 0;
  }
  .statement-rows tr {
    break-inside: avoid;
  }
}
