/* AFFARINORO · Portale affiliati
   A private-banking passbook: ivory paper, navy ink, gold-leaf hairlines.
   Type: Plus Jakarta Sans for everything (titles, figures, text), IBM Plex Mono for codes.
   Self-hosted (SIL OFL 1.1, licences in /fonts): no third-party requests, strict CSP unchanged. */

@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: normal;
  font-display: swap;
  font-weight: 200 800;
  src: url("../fonts/plus-jakarta-sans-latin-wght-normal.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Plus Jakarta Sans";
  font-style: italic;
  font-display: swap;
  font-weight: 200 800;
  src: url("../fonts/plus-jakarta-sans-latin-wght-italic.woff2") format("woff2-variations");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "IBM Plex Mono";
  font-style: normal;
  font-display: swap;
  font-weight: 500;
  src: url("../fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
:root {
  --ink: #0f172a;
  --ink-2: #1e293b;
  --ink-soft: #475569;
  --muted: #6b7280;
  --paper: #f7f4ed;
  --paper-2: #efe9dc;
  --card: #fffdf8;
  --line: #e2d9c6;
  --line-strong: #cdbf9f;
  --gold: #d4af37;
  --gold-deep: #85680f;
  --gold-soft: #f4e9c4;
  /* The blue of the official logo, used sparingly as a second accent. */
  --brand-blue: #1d5fae;
  --ok: #2b6648;
  --ok-bg: #e2efe6;
  --warn: #855600;
  --warn-bg: #fbeed0;
  --bad: #962b2b;
  --bad-bg: #f7e0de;
  --neutral-bg: #ebe7dd;

  --display: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", sans-serif;
  --sans: "Plus Jakarta Sans", "Segoe UI", "Helvetica Neue", sans-serif;
  --mono: "IBM Plex Mono", "SF Mono", Consolas, monospace;

  --radius: 10px;
  --shadow: 0 1px 0 rgba(15, 23, 42, .04), 0 12px 32px -18px rgba(15, 23, 42, .28);
  --gutter: clamp(16px, 4vw, 40px);
}
*, *::before, *::after { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font: 15px/1.6 var(--sans);
  font-optical-sizing: auto;
  font-kerning: normal;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(212, 175, 55, .10), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(15, 23, 42, .05), transparent 60%),
    var(--paper);
}

a { color: var(--ink); text-decoration-color: var(--gold); text-underline-offset: 3px; }
a:hover { color: var(--gold-deep); }

:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 4px; }

h1, h2, h3 { font-family: var(--display); font-weight: 700; letter-spacing: -.02em; margin: 0; font-variant-numeric: lining-nums; }
h1 { font-size: clamp(28px, 3.6vw, 38px); line-height: 1.1; letter-spacing: -.03em; }
h2 { font-size: 20px; line-height: 1.25; font-weight: 650; }
h3 { font-size: 17px; }
p { margin: 0; }

.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; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 50; background: var(--gold); color: var(--ink); padding: 8px 14px; border-radius: 6px; }
.skip-link:focus { left: 8px; }

/* ---------- Header: light, so the official logo (white background) sits naturally ---------- */

.site-header {
  position: relative;
  color: var(--ink);
  background: #ffffff;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 2px 0 -1px var(--gold), 0 10px 24px -22px rgba(15, 23, 42, .5);
}

.site-header__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 10px var(--gutter);
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand { display: inline-flex; align-items: center; gap: 14px; text-decoration: none; color: inherit; white-space: nowrap; }
.brand:hover { color: inherit; }
.brand__logo { display: block; height: 48px; width: auto; }
.brand__tag {
  display: block;
  padding-left: 14px;
  border-left: 1px solid var(--gold);
  font-family: var(--sans);
  font-size: 10px;
  line-height: 1.5;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold-deep);
  font-weight: 600;
}

.nav { display: flex; align-items: center; gap: 4px; flex: 1; flex-wrap: wrap; }
.nav a {
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 12px;
  border-radius: 6px;
  position: relative;
}
.nav a:hover { color: var(--ink); background: var(--paper); }
.nav a[aria-current="page"] { color: var(--ink); font-weight: 600; }
.nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 12px; right: 12px; bottom: 1px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px;
}
.nav__sep { width: 1px; height: 18px; background: var(--line-strong); margin: 0 6px; }

.user-chip { display: flex; align-items: center; gap: 10px; margin-left: auto; font-size: 13px; color: var(--ink-soft); text-align: right; }
.user-chip__name { display: block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.user-chip__role { display: block; font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold-deep); }
.user-chip form { margin: 0; }
/* ---------- Page ---------- */

.page {
  width: 100%;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(24px, 4vw, 44px) var(--gutter) 56px;
  flex: 1;
}
.page--narrow { max-width: 920px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; flex-wrap: wrap; margin-bottom: 28px; }
/* Where the page sits (Gestione / Affiliati / 000113), above the title. */
.path { display: flex; flex-wrap: wrap; align-items: baseline; margin-bottom: 6px; font-size: 13px; color: var(--muted); }
.path a { color: var(--ink-soft); text-decoration: none; }
.path a:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gold); }
.path__sep { margin: 0 7px; color: var(--line-strong); }
.lede { color: var(--ink-soft); margin-top: 8px; max-width: 62ch; }
.lede .negative { color: var(--bad); }
.page-head__sep { margin: 0 8px; color: var(--line-strong); }

/* Sections of a page (the affiliate: registry, statement, payments), styled like the main menu. */
.tabs { display: flex; gap: 0 28px; margin: -8px 0 24px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  padding: 10px 0 9px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--ink-soft);
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--gold); }
.tabs__count { margin-left: 7px; font-weight: 500; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .tabs { gap: 0 22px; }
  .tabs__more { display: none; }
}

.site-footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.site-footer__inner { max-width: 1240px; margin: 0 auto; padding: 18px var(--gutter); display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Panels & KPIs ---------- */

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.panel__body { padding: 22px; }
.section { margin-top: 28px; }

.kpis { display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 16px; margin-bottom: 28px; }
.kpi { padding: 22px 24px; position: relative; overflow: hidden; }
.kpi__label { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.kpi__value {
  font-family: var(--display);
  font-size: clamp(26px, 2.8vw, 32px);
  font-weight: 700;
  font-variant-numeric: lining-nums tabular-nums;
  margin: 10px 0 6px;
  letter-spacing: -.02em;
}
.kpi__note { font-size: 12.5px; color: var(--ink-soft); }
.kpi--hero {
  color: #f3efe3;
  border-color: #0f172a;
  background:
    radial-gradient(circle at 110% -20%, rgba(212, 175, 55, .28), transparent 55%),
    repeating-radial-gradient(circle at 100% 100%, rgba(212, 175, 55, .07) 0 1px, transparent 1px 7px),
    linear-gradient(155deg, #13244a 0%, #0d1a36 55%, #0a1226 100%);
}
.kpi--hero .kpi__label { color: var(--gold); }
.kpi--hero .kpi__note { color: #b8bfcc; }
.kpi--hero .kpi__value { font-size: clamp(32px, 4vw, 44px); }
.kpi--hero::after {
  content: "";
  position: absolute;
  left: 24px; right: 24px; bottom: 14px;
  border-bottom: 1px solid rgba(212, 175, 55, .45);
}
.kpi--negative .kpi__value { color: #f2b8b5; }

/* ---------- Filters & forms ---------- */

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fffdf8, #fbf8f0); border-radius: var(--radius) var(--radius) 0 0; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--ink-soft); min-width: 140px; }
.field--grow { flex: 1; min-width: 180px; }
.field label, .field__label { font-weight: 600; letter-spacing: .02em; }
.field small { color: var(--muted); }

input:not([type]), input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="tel"],
input[type="number"], input[type="month"], input[type="date"], select {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 9px 11px;
  min-width: 0;
  width: 100%;
}
input:focus-visible, select:focus-visible { outline: 3px solid rgba(212, 175, 55, .55); outline-offset: 0; border-color: var(--gold-deep); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  padding: 9px 15px;
  border-radius: 7px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color .15s, border-color .15s, transform .15s;
}
.btn:hover { border-color: var(--gold-deep); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--ink); border-color: var(--ink); color: #f7f2e3; }
.btn--primary:hover { background: #1b2742; color: #fff; }
.btn--gold { background: linear-gradient(180deg, #e2c35b, #c9a22b); border-color: #b48f20; color: #1a1406; }
.btn--gold:hover { background: linear-gradient(180deg, #e8cb67, #d0a932); color: #1a1406; }
.btn--danger { color: var(--bad); border-color: #e3bcb8; }
.btn--danger:hover { border-color: var(--bad); color: var(--bad); }
.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink); padding: 7px 12px; }
.btn--ghost:hover { color: var(--ink); border-color: var(--gold-deep); background: var(--paper); }
.btn--small { font-size: 12.5px; padding: 6px 10px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline; margin: 0; }

.form-stack { display: grid; gap: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; align-items: end; }

/* ---------- Notices & states ---------- */

.notice { border-radius: 8px; padding: 12px 16px; font-size: 14px; border: 1px solid; margin-bottom: 18px; }
.notice--info { background: #f3f1ea; border-color: var(--line); color: var(--ink-soft); }
.notice--ok { background: var(--ok-bg); border-color: #bcd8c6; color: var(--ok); }
.notice--warn { background: var(--warn-bg); border-color: #ecd49a; color: var(--warn); }
.notice--bad { background: var(--bad-bg); border-color: #e6bab5; color: var(--bad); }

/* States are words, not pills: colour and weight are enough. */
.state { font-weight: 650; color: var(--ink-soft); white-space: nowrap; }
.state--ok { color: var(--ok); }
.state--warn { color: var(--warn); }
.state--bad { color: var(--bad); }
.state--gold { color: var(--gold-deep); }

/* ---------- Ledger ---------- */

/* position: relative keeps absolutely positioned children (e.g. .sr-only headers) inside the
   scroll container, otherwise they widen the whole page. */
.table-wrap { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
caption { caption-side: top; text-align: left; }
th {
  text-align: left;
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
  padding: 12px 16px;
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  background: #fbf8f1;
}
td { padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:hover td { background: #fcf9f1; }
.num { text-align: right; white-space: nowrap; font-variant-numeric: lining-nums tabular-nums; }
.nowrap { white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); font-size: 13px; }

.ledger td.num { font-family: var(--sans); }
/* The didone is for display sizes; in a column of figures the grotesk with tabular digits reads better. */
.ledger .balance { font-family: var(--sans); font-weight: 650; font-size: 15px; font-variant-numeric: lining-nums tabular-nums; }
.ledger .negative { color: var(--bad); }
.ledger__note { font-weight: 600; color: var(--ink); }
.ledger__meta { display: block; margin-top: 3px; font-size: 12.5px; color: var(--muted); }
.ledger__alert { display: block; margin-top: 3px; font-size: 12.5px; font-weight: 600; color: var(--bad); }
.ledger__kind { display: inline-block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--gold-deep); font-weight: 700; margin-right: 6px; }
.ledger__carried td { background: #f8f4e9; font-style: italic; color: var(--ink-soft); }
.ledger__carried .balance { font-style: normal; color: var(--ink); }
.ledger tfoot td { border-top: 3px double var(--gold); border-bottom: none; background: #fbf8f0; font-weight: 600; }
.ledger tfoot .balance { font-size: 17px; }

/* The affiliate code comes first, as in the ledger: 000113 Mario Rossi. */
.affiliate-code { margin-right: 8px; font-family: var(--mono); font-size: 12.5px; color: var(--gold-deep); }

/* Payments on the phone: one card per payment, who (or what) and amount on top. */
@media (max-width: 760px) {
  .ledger--cards thead { display: none; }
  .ledger--cards, .ledger--cards tbody, .ledger--cards tfoot, .ledger--cards td { display: block; width: 100%; }
  .ledger--cards tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
  }
  .ledger--cards td { border: 0; padding: 0; background: none; }
  .ledger--cards tbody tr:hover td { background: none; }
  .ledger--cards .col-main { grid-column: 1; grid-row: 1; min-width: 0; }
  .ledger--cards .col-amount { grid-column: 2; grid-row: 1; text-align: right; }
  .ledger--cards .col-date { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
  .ledger--cards .col-note, .ledger--cards .col-actions { grid-column: 1 / -1; }
  .ledger--cards .col-actions { margin-top: 6px; }
  .ledger--cards .col-actions:empty { display: none; }
  .ledger--cards tfoot tr { border-top: 3px double var(--gold); border-bottom: 0; background: #fbf8f0; }
  .ledger--cards tfoot td { border: 0; background: none; }
}

/* Nothing to show: one plain line where the table would be, with a way out when there is one. */
.empty-line { margin: 0; padding: 22px; font-size: 14px; color: var(--ink-soft); }
.empty-line a { margin-left: 4px; white-space: nowrap; }

/* Customers linked to an affiliate: the add form above the list, the unlink date beside its button. */
.link-form { padding: 18px 22px; border-bottom: 1px solid var(--line); }
.unlink-form { display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin: 0; }
.unlink-form input[type=date] { width: auto; }
.refusal__errors { margin: 4px 0 0; padding: 0; list-style: none; color: var(--ink-soft); overflow-wrap: anywhere; }
.pager { display: flex; gap: 18px; }
.pager a { font-weight: 600; white-space: nowrap; }
.table-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 14px 22px; font-size: 12px; color: var(--muted); }

/* ---------- Affiliates roster (staff list) ---------- */

.roster td { vertical-align: middle; }
.roster__who { min-width: 220px; }
.roster__name { font-weight: 650; color: var(--ink); text-decoration: none; }
.roster__name:hover { color: var(--ink); text-decoration: underline; text-decoration-color: var(--gold); }
.roster__contact { white-space: nowrap; }
/* width 0 + min-width 100%: the note fills the cell but never widens the column. */
.roster__note {
  display: block;
  width: 0;
  min-width: 100%;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-style: italic;
  color: var(--muted);
}
.roster__where { min-width: 140px; }
.roster__pct { white-space: nowrap; font-size: 13.5px; font-variant-numeric: lining-nums tabular-nums; }
/* Metals by their chemical symbol, as in the trade: Au gold, Ag silver. */
.pct__metal { margin-right: 3px; font-weight: 700; color: #64748b; }
.pct__metal--gold { color: var(--gold-deep); }
.pct__sep { margin: 0 6px; color: var(--line-strong); }
.roster__balance { font-size: 15px; }
.roster__state { min-width: 140px; }
.roster__access { display: block; margin-top: 4px; font-size: 12.5px; color: var(--muted); }
.roster__access--lockedout { color: var(--warn); }
.roster__access--blocked { color: var(--bad); }
.roster__actions .actions { justify-content: flex-end; }
.roster__off .roster__who, .roster__off .roster__where, .roster__off .roster__pct { opacity: .62; }

/* Phone and tablet: one card per affiliate, name and balance on top. The table needs about
   960 px of window to fit without scrolling sideways. */
@media (max-width: 960px) {
  .roster thead { display: none; }
  .roster, .roster tbody, .roster td { display: block; width: 100%; }
  .roster tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }
  .roster td { border: 0; padding: 0; background: none; }
  .roster tbody tr:hover td { background: none; }
  .roster__who { min-width: 0; grid-column: 1; grid-row: 1; }
  .roster__balance { grid-column: 2; grid-row: 1; text-align: right; font-size: 16px; }
  .roster__where, .roster__pct, .roster__state, .roster__actions { grid-column: 1 / -1; min-width: 0; }
  .roster__state { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
  .roster__access { display: inline; margin-top: 0; }
  .roster__actions .actions { justify-content: flex-start; }
}

/* ---------- Affiliate card ---------- */

/* Card and facts side by side, same top and same height: the facts go on two columns so they fit
   in the height of the card. */
.card-stage { display: grid; grid-template-columns: minmax(0, 500px) 1fr; gap: 36px; align-items: stretch; }
.card-stage .card-facts { margin: 0; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 28px; align-content: center; }
.card-facts__wide { grid-column: 1 / -1; }
/* The artwork comes from the approved mockup (logo, chip, white panel); name, code and barcode
   are laid over it in units of the card width (cqw), so they stay in place at any size.
   Positions are measured on the 1130x662 artwork. */
.affiliate-card {
  position: relative;
  container-type: inline-size;
  aspect-ratio: 1130 / 662;
  width: 100%;
  margin: 0;
  border-radius: 3.45% / 5.9%;
  overflow: hidden;
  color: #fff;
  background: #0b1527;
  box-shadow: 0 30px 50px -28px rgba(15, 23, 42, .7), 0 8px 18px -10px rgba(15, 23, 42, .35);
}
.affiliate-card__art { position: absolute; inset: 0; display: block; width: 100%; height: 100%; }
.affiliate-card__name {
  position: absolute;
  left: 6.6%; right: 6.6%; top: 45.4%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--sans);
  font-size: 3.4cqw;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: .17em;
  text-transform: uppercase;
  text-shadow: 0 .15cqw .4cqw rgba(0, 0, 0, .6);
}
.affiliate-card__name--long { font-size: 2.9cqw; }
.affiliate-card__name--xlong { font-size: 2.4cqw; letter-spacing: .12em; }
.affiliate-card__code {
  position: absolute;
  left: 6.8%; top: 54.4%;
  font-family: var(--sans);
  font-size: 3.17cqw;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .22em;
  color: #e4b86b;
  font-variant-numeric: lining-nums tabular-nums;
}
.affiliate-card__barcode { position: absolute; left: 8.4%; width: 83.2%; top: 68.4%; height: 16.8%; }
.affiliate-card__barcode .barcode { width: 100%; height: 100%; }
/* The panel of the artwork is a warm white: no white box behind the bars. */
.affiliate-card__barcode .barcode rect:first-child { fill: transparent; }
.affiliate-card__digits {
  position: absolute;
  left: 0; right: 0; top: 86.8%;
  text-align: center;
  font-family: var(--sans);
  font-size: 2.5cqw;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: .42em;
  text-indent: .42em;
  color: #0f172a;
  font-variant-numeric: lining-nums tabular-nums;
}
.barcode { display: block; width: 100%; height: 46px; }
.affiliate-card--off { filter: saturate(.3); }
.affiliate-card__stamp {
  position: absolute;
  top: 40%; left: -10%; right: -10%;
  transform: rotate(-12deg);
  text-align: center;
  font-family: var(--sans);
  font-weight: 650;
  letter-spacing: .4em;
  font-size: 4cqw;
  color: #fde2e1;
  background: rgba(150, 43, 43, .82);
  padding: 1.4cqw 0;
}
.card-facts { display: grid; gap: 14px; }
.card-facts dt { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.card-facts dd { margin: 2px 0 0; font-family: var(--display); font-size: 17px; font-weight: 600; font-variant-numeric: lining-nums tabular-nums; }

/* ---------- Card reader (staff) ---------- */

/* Field and camera side by side; the guide frame has the shape of the card's white barcode panel. */
.reader { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.reader__input { font-size: 22px; letter-spacing: .12em; }
.reader__result { margin: 22px 0 0; padding-top: 18px; border-top: 1px solid var(--line); }
p.reader__result { padding-top: 12px; }
.reader__who { margin: 0 0 6px; font-family: var(--display); font-size: 22px; font-weight: 600; }
.reader__who .mono { font-size: inherit; }
.reader__links { margin: 6px 0 0; display: flex; gap: 10px; flex-wrap: wrap; font-weight: 600; }
.reader__camera { overflow: hidden; }
.reader__camera-foot { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.reader__camera-foot p { margin: 0; }
.viewfinder { position: relative; background: var(--ink); aspect-ratio: 4 / 3; }
.viewfinder video { display: block; width: 100%; height: 100%; object-fit: cover; }
.viewfinder__strip {
  position: absolute; left: 12%; right: 12%; top: 36%; bottom: 36%;
  border: 2px solid var(--gold); border-radius: 6px;
  box-shadow: 0 0 0 100vmax rgba(15, 23, 42, .35);
}

/* ---------- Sign-in (modelled on the historic CORO login) ---------- */

.signin {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 16px 28px;
  background:
    radial-gradient(700px 380px at 50% -8%, rgba(212, 175, 55, .20), transparent 70%),
    repeating-radial-gradient(circle at 50% 120%, rgba(15, 23, 42, .035) 0 1px, transparent 1px 10px),
    var(--paper);
}
.signin__card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 0 rgba(15, 23, 42, .04), 0 34px 70px -38px rgba(15, 23, 42, .55);
}
.signin__banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px 24px 22px;
  /* Pure white: the logo JPG has a white background and must blend in. */
  background: #ffffff;
  border-bottom: 2px solid var(--gold);
}
.signin__banner .brand__logo { height: auto; width: 100%; max-width: 270px; }
.signin__body { padding: 26px 28px 30px; }
.signin__title { text-align: center; font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.signin__sub { text-align: center; font-size: 11px; letter-spacing: .28em; text-transform: uppercase; color: var(--gold-deep); font-weight: 600; margin: 6px 0 22px; }
.signin__text { text-align: center; color: var(--ink-soft); margin: 10px 0 20px; }
.signin__hint { text-align: center; font-size: 12px; color: var(--muted); }
.signin__done { text-align: center; margin-bottom: 18px; }
.signin__done .icon { width: 48px; height: 48px; color: var(--ok); margin-bottom: 8px; }
.signin__foot { margin-top: 22px; font-size: 12px; color: var(--muted); letter-spacing: .04em; }

.input-group { background: #fff; border: 1px solid var(--line-strong); border-radius: 12px; overflow: hidden; }
.input-group__row { display: flex; align-items: center; gap: 10px; padding: 0 12px 0 14px; transition: box-shadow .15s, background-color .15s; }
.input-group__row + .input-group__row { border-top: 1px solid var(--line); }
.input-group__row:focus-within { background: #fffcf3; box-shadow: inset 3px 0 0 var(--gold); }
.input-group .icon { width: 18px; height: 18px; flex: none; color: var(--muted); }
.input-group input { border: 0; border-radius: 0; padding: 15px 0; background: transparent; flex: 1; }
.input-group input:focus-visible { outline: none; }
.input-group__toggle { border: 0; background: transparent; color: var(--gold-deep); font: inherit; font-size: 12px; font-weight: 600; padding: 6px; cursor: pointer; border-radius: 6px; }

.btn--block { width: 100%; padding: 13px 16px; font-size: 15px; }
/* The secondary way out of a sign-in card: a touch smaller than the main button. */
.btn--block.btn--minor { padding: 10px 14px; font-size: 14px; }
.btn--outline { background: transparent; border-color: var(--ink); color: var(--ink); }
.btn--outline:hover { background: var(--ink); color: #f7f2e3; }

.password-row { display: flex; gap: 8px; }
.password-row input { flex: 1; }

/* ---------- Modal (native <dialog>, like the old back office's «Affiliato» / «Pagamento») ---------- */

.modal {
  width: min(760px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 40px 90px -30px rgba(15, 23, 42, .55);
  overflow: auto;
}
.modal--narrow { width: min(560px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(15, 23, 42, .45); backdrop-filter: blur(3px); }
.modal[open] { animation: rise .25s cubic-bezier(.2, .7, .2, 1); }
/* Without JavaScript the dialog opens in place (non-modal): keep it centred on top. */
.modal[open]:not(:modal) { position: fixed; inset: 0; margin: auto; z-index: 40; }
.modal__head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 24px;
  background: #ffffff;
  border-bottom: 2px solid var(--gold);
}
.modal__head h2 { font-size: 20px; letter-spacing: .02em; text-transform: uppercase; }
/* The × is drawn with two strokes, centred in the circle: the text glyph sat low with this font.
   The «×» stays in the markup for readers without CSS; the link's name is its aria-label. */
.modal__close {
  position: relative;
  display: inline-block;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  color: var(--ink);
  text-decoration: none;
  font-size: 0;
  background: #fff;
  cursor: pointer;
}
.modal__close::before,
.modal__close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 15px;
  height: 1.75px;
  border-radius: 1px;
  background: currentColor;
}
.modal__close::before { transform: translate(-50%, -50%) rotate(45deg); }
.modal__close::after { transform: translate(-50%, -50%) rotate(-45deg); }
.modal__close:hover { border-color: var(--gold-deep); color: var(--ink); background: var(--paper); }
.modal__body { padding: 22px 24px 8px; }
.modal__foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px 24px 22px;
  border-top: 1px solid var(--line);
  margin-top: 18px;
  background: #fbf8f0;
}

.form-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 16px 20px; }
.form-grid .field--wide { grid-column: 1 / -1; }
/* A short list of choices, all visible: plain radio buttons with their words. */
.flags { margin: 0; padding: 0; border: 0; min-width: 0; }
.flags legend { padding: 0; margin-bottom: 6px; }
.flags__options { display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 4px 0; font-size: 14px; color: var(--ink); }
.flag { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.flag input { width: 17px; height: 17px; margin: 0; accent-color: var(--ink); }
textarea {
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 9px 11px;
  width: 100%;
  min-height: 92px;
  resize: vertical;
}
textarea:focus-visible { outline: 3px solid rgba(212, 175, 55, .55); outline-offset: 0; border-color: var(--gold-deep); }
input[readonly] { background: var(--paper); color: var(--ink-soft); }
.field__error { color: var(--bad); font-size: 12.5px; font-weight: 600; }
.field--invalid input, .field--invalid select, .field--invalid textarea { border-color: var(--bad); background: #fffafa; }
.field__hint { color: var(--muted); font-size: 12px; }
.input-suffix { position: relative; }
.input-suffix input { padding-right: 34px; }
.input-suffix span { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }

.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.toolbar .btn--new { margin-left: auto; }
.balance-strip {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(90deg, var(--gold-soft), transparent 70%);
}
.balance-strip strong { font-family: var(--display); font-size: 24px; font-weight: 700; font-variant-numeric: lining-nums tabular-nums; }

/* ---------- Temporary password ---------- */

.secret {
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #fffaf0, var(--gold-soft));
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 22px;
}
.secret__title { margin: 0 0 6px; font-weight: 650; color: var(--ink); }
.secret__value { font-family: var(--mono); font-size: 20px; letter-spacing: .08em; padding: 10px 12px; background: #fff; border: 1px dashed var(--line-strong); border-radius: 6px; display: inline-block; margin: 10px 10px 10px 0; user-select: all; }

/* ---------- Detail lists ---------- */

.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px 24px; }
.facts dt { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 3px 0 0; font-size: 14.5px; overflow-wrap: anywhere; }
.facts__wide { grid-column: 1 / -1; }
.split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 20px; align-items: start; }

.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { padding: 16px 18px; }
.stat__value { font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: lining-nums tabular-nums; margin-top: 4px; }

/* ---------- Motion ---------- */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.reveal { animation: rise .55s cubic-bezier(.2, .7, .2, 1) both; }
.reveal--2 { animation-delay: .08s; }
.reveal--3 { animation-delay: .16s; }
.reveal--4 { animation-delay: .24s; }
@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; }
  .btn { transition: none; }
}

/* ---------- Responsive ---------- */

/* Staff menus are long: give the navigation room before it wraps. */
@media (max-width: 1200px) {
  .brand__tag { display: none; }
  .site-header__inner { gap: 18px; }
  .nav a { padding: 8px 9px; }
}

@media (max-width: 1080px) {
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi--hero { grid-column: 1 / -1; }
  .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* On two columns an odd last box takes the whole row instead of leaving a hole. */
  .stat-row > :last-child:nth-child(odd) { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .site-header__inner { flex-wrap: wrap; gap: 10px 16px; }
  .nav {
    order: 3;
    flex-basis: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    margin: 0 -8px;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent);
    mask-image: linear-gradient(90deg, #000 88%, transparent);
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; }
  .user-chip__name { max-width: 120px; }
  .card-stage { grid-template-columns: 1fr; }
  .reader { grid-template-columns: 1fr; }
  .form-grid, .form-grid--2 { grid-template-columns: 1fr; }
  .toolbar .btn--new { margin-left: 0; }
}

@media (max-width: 640px) {
  body { font-size: 15px; }
  .kpis { grid-template-columns: 1fr; gap: 12px; }
  .kpi { padding: 18px; }
  .filters { padding: 16px; }
  .field { min-width: 0; flex: 1 1 100%; }
  .filters .btn { flex: 1; }
  .panel__head, .panel__body { padding: 16px; }
  .facts { grid-template-columns: 1fr; }
  .stat-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px 16px; }
  .stat__value { font-size: 24px; white-space: nowrap; }
  .stat__value--wrap { white-space: normal; }
  .user-chip__role, .user-chip__name { display: none; }
  /* On the phone the logo shares its row only with «Esci»: it can be bigger than on desktop. */
  .brand__logo { height: 56px; }
  .brand__tag { display: none; }
  .site-header__inner { padding-top: 12px; padding-bottom: 8px; }

  /* The ledger becomes a list of entries: date and note on top, amounts below. */
  .ledger--stack thead { display: none; }
  .ledger--stack, .ledger--stack tbody, .ledger--stack tfoot, .ledger--stack tr, .ledger--stack td { display: block; width: 100%; }
  .ledger--stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; }
  .ledger--stack td { border: 0; padding: 0; background: none; }
  .ledger--stack tbody tr:hover td { background: none; }
  .ledger--stack td[data-label]::before { content: attr(data-label) " "; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-style: normal; }
  .ledger--stack .col-date { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }
  .ledger--stack .col-note { grid-column: 1 / -1; margin-bottom: 4px; }
  .ledger--stack .col-amount { text-align: left; }
  .ledger--stack .col-amount:empty { display: none; }
  .ledger--stack .col-balance { text-align: right; grid-column: 2; grid-row: 3; }
  .ledger--stack tfoot tr { border-top: 3px double var(--gold); background: #fbf8f0; }
  .ledger--stack tfoot td { border: 0; }
  .ledger--stack .col-filler { display: none; }
}

/* Small phones: the summary stays 2×2 so the list starts on the first screen. */
@media (max-width: 440px) {
  .stat { padding: 12px 14px; }
  .stat .kpi__label { letter-spacing: .06em; }
  .stat__value { font-size: 20px; }
}

/* ---------- Print: a clean statement on white paper ---------- */

@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .site-header, .site-footer, .filters, .actions, .no-print, .nav, .skip-link { display: none !important; }
  .print-only { display: block !important; }
  .page { padding: 0; max-width: none; }
  .panel, .kpi { box-shadow: none; border-color: #bbb; }
  .kpi--hero { background: #fff; color: #000; border: 1px solid #000; }
  .kpi--hero .kpi__label, .kpi--hero .kpi__note { color: #333; }
  .kpi--hero::after { display: none; }
  .reveal { animation: none; }
  th { background: #fff; }
  .table-wrap { overflow: visible; }
  a { text-decoration: none; }
  .affiliate-card { print-color-adjust: exact; -webkit-print-color-adjust: exact; }
}
.print-only { display: none; }
.print-only .brand__logo { height: 44px; margin-bottom: 10px; }
