/* ==========================================================================
   Pemberly Payments
   Identity: a nineteenth-century acquiring house that learned to speak HTTP.
   Bottle-green ink, brass rules, greenbar accounting paper, oxblood refusals.
   ========================================================================== */

:root {
  --ink:            #101E19;
  --ink-soft:       #46574F;
  --ink-faint:      #7B8A82;

  --paper:          #F2F4EF;
  --paper-raised:   #FCFCFA;
  --greenbar:       #DEE9DA;

  --sovereign:      #1B5E43;
  --sovereign-deep: #0D3324;
  --oxblood:        #8C2F27;
  --brass:          #A8873C;
  --brass-light:    #E8C87A;

  --rule:           #C9D2C7;
  --rule-strong:    #A9B6A6;

  --display: "Bodoni Moda", "Didot", "Playfair Display", Georgia, serif;
  --body:    "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono:    "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --step-0:  0.9375rem;
  --step-1:  1.0625rem;
  --step-2:  1.375rem;
  --step-3:  2rem;
  --step-4:  clamp(2.4rem, 5vw, 3.4rem);

  --gap:     1.5rem;
  --radius:  3px;
  --shadow:  0 1px 0 var(--rule), 0 12px 28px -22px rgba(16, 30, 25, 0.55);
}

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

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--paper);
  /* Faint laid-paper texture: two near-invisible diagonal threads. */
  background-image:
    repeating-linear-gradient(90deg, rgba(16,30,25,0.018) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(0deg,  rgba(16,30,25,0.014) 0 1px, transparent 1px 4px);
  color: var(--ink);
  font-family: var(--body);
  font-size: var(--step-0);
  line-height: 1.55;
}

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

code, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

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

/* --- Masthead ------------------------------------------------------------ */

.masthead {
  background: var(--sovereign-deep);
  color: #EDF2EC;
}

.masthead__inner {
  max-width: 1180px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  text-decoration: none;
  color: inherit;
  margin-right: auto;
}

.wordmark__monogram {
  width: 2.1rem; height: 2.1rem;
  display: grid; place-items: center;
  border: 1px solid var(--brass);
  color: var(--brass-light);
  font-family: var(--display);
  font-size: 1.25rem;
  line-height: 1;
  padding-bottom: 2px;
}

.wordmark__text { display: flex; flex-direction: column; line-height: 1.05; }

.wordmark__name {
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.wordmark__suffix {
  font-size: 0.6rem;
  letter-spacing: 0.34em;
  text-transform: uppercase;
  color: var(--brass-light);
}

.masthead__nav { display: flex; gap: 0.25rem; }

.navlink {
  color: #C3D2C6;
  text-decoration: none;
  font-size: 0.8125rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  border-bottom: 2px solid transparent;
}
.navlink:hover { color: #FFF; }
.navlink.is-current { color: var(--brass-light); border-bottom-color: var(--brass); }

.chip {
  font-family: var(--mono);
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  padding: 0.3rem 0.6rem;
  border: 1px solid rgba(232, 200, 122, 0.45);
  color: var(--brass-light);
  border-radius: 999px;
  white-space: nowrap;
}

/* The engraved rule: brass hairlines over a fine repeating lathe pattern. */
.guilloche {
  height: 6px;
  background:
    linear-gradient(var(--brass), var(--brass)) 0 0 / 100% 1px no-repeat,
    linear-gradient(var(--brass), var(--brass)) 0 100% / 100% 1px no-repeat,
    repeating-linear-gradient(135deg,
      var(--sovereign) 0 3px, var(--sovereign-deep) 3px 6px);
}

/* --- Layout -------------------------------------------------------------- */

.sheet {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.counter,
.receiptpage {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: var(--gap);
  align-items: start;
}

.rail { display: grid; gap: var(--gap); }

@media (max-width: 880px) {
  .counter, .receiptpage { grid-template-columns: 1fr; }
  .sheet { padding: 1.75rem 1rem 3rem; }
}

/* --- Panels -------------------------------------------------------------- */

.panel {
  position: relative;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.panel--tight { padding: 1.25rem 1.35rem; }
.panel--notice { max-width: 44rem; margin: 0 auto; text-align: center; }

/* Torn-off receipt edge along the top of the two primary panels. */
.panel__perf {
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  border-radius: var(--radius) var(--radius) 0 0;
  background:
    linear-gradient(var(--sovereign), var(--sovereign)) 0 0 / 100% 3px no-repeat,
    repeating-linear-gradient(90deg,
      var(--rule) 0 4px, transparent 4px 9px) 0 4px / 100% 2px no-repeat;
}

.panel__head { margin-bottom: 1.75rem; }

.panel__title {
  font-family: var(--body);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 0.75rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--rule);
}

.panel__sub {
  font-size: 0.8125rem;
  color: var(--ink-faint);
  margin: 0.6rem 0 0;
}

.eyebrow {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 0.4rem;
}

.display {
  font-family: var(--display);
  font-weight: 500;
  font-size: var(--step-3);
  line-height: 1.05;
  letter-spacing: -0.01em;
  margin: 0;
}

.lede {
  color: var(--ink-soft);
  margin: 0.75rem 0 0;
  max-width: 46ch;
}

.rule { border: 0; border-top: 1px solid var(--rule); margin: 1.75rem 0; }

/* --- Form ---------------------------------------------------------------- */

.form { display: grid; gap: 1.1rem; }

.field { display: grid; gap: 0.4rem; }

.field--split {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
}

.label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.label__opt {
  font-weight: 400;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--ink-faint);
}

.input,
.amountbox__input,
.amountbox__currency {
  width: 100%;
  font-family: var(--body);
  font-size: var(--step-1);
  color: var(--ink);
  background: #FFF;
  border: 1px solid var(--rule-strong);
  border-radius: 2px;
  padding: 0.65rem 0.75rem;
}

.input--mono { font-family: var(--mono); letter-spacing: 0.03em; }

.input:focus,
.amountbox__input:focus,
.amountbox__currency:focus {
  border-color: var(--sovereign);
  outline: 2px solid rgba(27, 94, 67, 0.18);
  outline-offset: 0;
}

.hint { font-size: 0.75rem; color: var(--ink-faint); margin: 0; }

/* Amount gets the largest type on the page — it is the point of the form. */
.amountbox { display: flex; }

.amountbox__currency {
  width: auto;
  flex: 0 0 auto;
  border-right: 0;
  border-radius: 2px 0 0 2px;
  font-family: var(--mono);
  font-size: 0.875rem;
  background: var(--greenbar);
}

.amountbox__input {
  border-radius: 0 2px 2px 0;
  font-family: var(--display);
  font-size: 2rem;
  font-variant-numeric: tabular-nums;
  padding: 0.35rem 0.75rem;
}

.cardbox { position: relative; }

.cardbox__brand {
  position: absolute;
  right: 0.7rem;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--body);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sovereign);
  background: var(--greenbar);
  padding: 0.15rem 0.45rem;
  border-radius: 2px;
}

.expiry { display: flex; align-items: center; gap: 0.4rem; }
.expiry__slash { color: var(--ink-faint); font-family: var(--mono); }

/* --- Buttons ------------------------------------------------------------- */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: var(--body);
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 0.85rem 1.4rem;
  border-radius: 2px;
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.button--primary {
  background: var(--sovereign);
  color: #F4F8F3;
  border-color: var(--sovereign-deep);
  box-shadow: inset 0 0 0 1px rgba(232, 200, 122, 0.25);
  width: 100%;
}
.button--primary:hover { background: var(--sovereign-deep); }

.button__amount {
  font-family: var(--mono);
  letter-spacing: 0.02em;
  color: var(--brass-light);
  text-transform: none;
}

.button--quiet {
  background: transparent;
  color: var(--sovereign);
  border-color: var(--rule-strong);
}
.button--quiet:hover { background: var(--greenbar); }

.textlink {
  color: var(--sovereign);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  font-size: 0.875rem;
}

.smallprint {
  font-size: 0.75rem;
  color: var(--ink-faint);
  margin: 0;
  text-align: center;
}

/* --- Figures ------------------------------------------------------------- */

.figures {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem 1.25rem;
  margin: 0;
}

.figures--row { grid-template-columns: repeat(3, auto); text-align: right; }

.figures__item dt {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.figures__item dd { margin: 0; }

.figures__value {
  font-family: var(--display);
  font-size: var(--step-2);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.figures__unit { font-size: 0.875rem; color: var(--ink-faint); }

/* --- Tape (compact list) ------------------------------------------------- */

.tape { list-style: none; margin: 0; padding: 0; }

/* The <li> is only a divider. The grid lives on the row's content element --
   putting it on both meant the link was placed inside the 8px pip column and
   its own children collapsed on top of each other. */
.tape__row { border-bottom: 1px dotted var(--rule); }
.tape__row:last-child { border-bottom: 0; }

.tape__link,
.tape__row--plain {
  display: grid;
  grid-template-columns: 8px minmax(0, auto) minmax(0, 1fr) auto;
  align-items: baseline;
  column-gap: 0.6rem;
  padding: 0.5rem 0.25rem;
  text-decoration: none;
  color: inherit;
}

/* Refund rows carry no status pip, so they drop the first column. */
.tape__row--plain { grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto; }

.tape__link:hover { background: var(--greenbar); }

.tape__amount {
  font-family: var(--mono);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tape__card {
  font-size: 0.75rem;
  color: var(--ink-faint);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tape__time {
  font-size: 0.75rem;
  color: var(--ink-faint);
  font-family: var(--mono);
  text-align: right;
  white-space: nowrap;
}

.pip {
  display: block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  /* The row aligns on the text baseline; an empty box has none, so centre it
     explicitly rather than letting it drop to the bottom edge. */
  align-self: center;
}
.pip--captured, .pip--authorised { background: var(--sovereign); }
.pip--declined, .pip--failed     { background: var(--oxblood); }
.pip--refunded, .pip--partially_refunded { background: var(--brass); }

/* --- Receipt ------------------------------------------------------------- */

.panel--receipt { padding-top: 2.25rem; }

.receipt__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.receipt__amount { font-size: var(--step-4); margin-top: 0.2rem; }

.receipt__ref { font-size: 0.8125rem; color: var(--ink-faint); margin: 0.35rem 0 0; }

.receipt__verdict {
  font-family: var(--display);
  font-size: var(--step-2);
  color: var(--ink-soft);
  margin: 1.5rem 0 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--rule);
}

/* Signature element: the acquirer's rubber stamp, struck on the advice slip. */
.stamp {
  flex: 0 0 auto;
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  padding: 0.7rem 1.1rem;
  border: 3px double currentColor;
  border-radius: 4px;
  transform: rotate(-6deg);
  opacity: 0.88;
  animation: strike 320ms cubic-bezier(0.2, 1.4, 0.4, 1) both;
}

.stamp--approved { color: var(--sovereign); }
.stamp--refused  { color: var(--oxblood); transform: rotate(4deg); }

.stamp__word {
  font-family: var(--display);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  line-height: 1;
}

.stamp__code, .stamp__date {
  font-size: 0.625rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.stamp__date { opacity: 0.75; }

@keyframes strike {
  from { transform: rotate(-14deg) scale(1.45); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .stamp { animation: none; }
}

.spec { margin: 1.75rem 0 0; display: grid; }

.spec__row {
  display: grid;
  grid-template-columns: 10rem minmax(0, 1fr);
  gap: 1rem;
  padding: 0.5rem 0;
  border-bottom: 1px dotted var(--rule);
}

.spec__row dt {
  font-size: 0.6875rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-faint);
  padding-top: 0.15rem;
}

.spec__row dd { margin: 0; display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }

.meter {
  width: 90px; height: 6px;
  background: var(--greenbar);
  border: 1px solid var(--rule);
  border-radius: 999px;
  overflow: hidden;
}
.meter__fill { display: block; height: 100%; background: var(--brass); }

.receipt__actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 1.75rem;
}
.receipt__actions form { margin: 0; }

/* --- Tags ---------------------------------------------------------------- */

.tag {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.15rem 0.5rem;
  border-radius: 2px;
  border: 1px solid currentColor;
}

.tag--captured, .tag--authorised { color: var(--sovereign); background: var(--greenbar); }
.tag--declined, .tag--failed     { color: var(--oxblood); background: #F6E7E4; }
.tag--refunded, .tag--partially_refunded { color: #6B5518; background: #F5EBD6; }
.tag--pending { color: var(--ink-soft); background: var(--paper); }

/* --- Event trail --------------------------------------------------------- */

.trail { list-style: none; margin: 0; padding: 0 0 0 0.9rem; border-left: 1px solid var(--rule); }

.trail__item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0 0.75rem;
  padding: 0.45rem 0;
}

.trail__item::before {
  content: "";
  position: absolute;
  left: calc(-0.9rem - 3px);
  top: 0.85rem;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--brass);
}

.trail__type { font-size: 0.8125rem; color: var(--sovereign); }
.trail__time { font-size: 0.6875rem; color: var(--ink-faint); }
.trail__detail { grid-column: 1 / -1; font-size: 0.75rem; color: var(--ink-soft); }

.snippet {
  margin: 0;
  padding: 0.75rem;
  background: var(--sovereign-deep);
  color: #D9E6DA;
  border-radius: 2px;
  font-size: 0.75rem;
  overflow-x: auto;
}
.snippet code { font-family: var(--mono); }

/* --- Ledger -------------------------------------------------------------- */

.ledger__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
  padding-bottom: 1.25rem;
  border-bottom: 2px solid var(--sovereign);
  margin-bottom: 1.25rem;
}

.filters { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

.filters__pill {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-soft);
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
}
.filters__pill:hover { background: var(--greenbar); }
.filters__pill.is-on {
  background: var(--sovereign);
  border-color: var(--sovereign-deep);
  color: #F4F8F3;
}

.ledger__scroll {
  overflow-x: auto;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
}

/* The greenbar: alternating stripes, the way continuous-feed ledger paper
   was printed so the eye could hold a row across the width of the page. */
.greenbar {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
  min-width: 780px;
}

.greenbar thead th {
  position: sticky;
  top: 0;
  background: var(--sovereign-deep);
  color: #CFE0D2;
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-align: left;
  padding: 0.6rem 0.9rem;
  white-space: nowrap;
}

.greenbar tbody td { padding: 0.55rem 0.9rem; vertical-align: middle; }

.greenbar tbody tr:nth-child(odd)  { background: var(--paper-raised); }
.greenbar tbody tr:nth-child(even) { background: var(--greenbar); }
.greenbar tbody tr:hover { background: #CFE0CA; }

.greenbar .num     { text-align: right; }
.greenbar .strong  { font-weight: 600; }
.greenbar .dim     { color: var(--ink-faint); }
.greenbar .warn    { color: var(--oxblood); font-weight: 600; }
.greenbar .nowrap  { white-space: nowrap; }

.pager {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}
.pager__index { font-size: 0.75rem; color: var(--ink-faint); }

.empty {
  text-align: center;
  padding: 4rem 1.5rem;
  border: 1px dashed var(--rule-strong);
  border-radius: var(--radius);
  background: var(--paper-raised);
}
.empty__headline { font-family: var(--display); font-size: var(--step-2); margin: 0; }
.empty__body { color: var(--ink-faint); margin: 0.5rem 0 1.5rem; }
.empty .button { width: auto; display: inline-flex; }

/* --- Colophon ------------------------------------------------------------ */

.colophon {
  border-top: 1px solid var(--rule);
  background: rgba(222, 233, 218, 0.4);
  padding: 1.25rem 1.5rem 2rem;
}

.colophon__inner {
  max-width: 1180px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  font-size: 0.75rem;
  color: var(--ink-soft);
}

.colophon__note { margin: 0; max-width: 48ch; }

.dbstatus { margin: 0; display: flex; align-items: center; gap: 0.5rem; font-family: var(--mono); }
.dbstatus code { background: rgba(16,30,25,0.06); padding: 0 0.25rem; border-radius: 2px; }
.dbstatus__dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dbstatus--up   .dbstatus__dot { background: var(--sovereign); }
.dbstatus--down { color: var(--oxblood); }
.dbstatus--down .dbstatus__dot { background: var(--oxblood); }
