/*
 * The portal's whole stylesheet. The brand colours are copied from the dashboard's tokens rather
 * than imported: the two deploy separately, and one page's worth of values is cheaper to keep in
 * step by hand than a shared build would be.
 *
 * Every colour a tenant can choose is one of these custom properties, set on `:root` by
 * `portal.js` from the project's branding. The palette below is what an unbranded project gets.
 */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --title: #5b687c;
  --muted: #5b687c;
  --border: #e2e8f0;
  --link: #006a61;
  --primary: #00c4b4;
  --primary-fg: #003732;
  --credit: #047857;
  --refused: #93000a;
  --radius: 12px;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

/* One dark palette, applied by an explicit attribute rather than by a second media query:
   `portal.js` resolves the reader's own setting and the tenant's choice into `data-theme` before
   the first paint, so the values live in exactly one place. */
:root[data-theme="dark"] {
  --bg: #0a122a;
  --surface: #171e37;
  --text: #dbe1ff;
  --title: #bacac6;
  --muted: #bacac6;
  --border: #212942;
  --link: #43e0cf;
  --primary: #43e0cf;
  --primary-fg: #003732;
  --credit: #10b981;
  --refused: #ffb4aa;
}

* { box-sizing: border-box; }

/* An author `display` beats the UA's `[hidden] { display: none }`, so every element this page
   shows and hides — the buttons, the test badge — needs the attribute to win outright. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

.portal {
  max-width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem 4rem;
}

.portal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.meter-flow-customer { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
/* Bounded in both directions: a tenant's logo is their file, and this page cannot re-crop it. */
.meter-flow-customer__logo { max-height: 2.25rem; max-width: 10rem; object-fit: contain; }
.meter-flow-customer__name { margin: 0; font-weight: 700; font-size: 1.1rem; color: var(--title); overflow-wrap: anywhere; }

/* Test data is the one thing a reader must never mistake for their real balance. */
.portal__env {
  flex: none;
  margin: 0;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: #fff4e5;
  color: #7a4100;
  font-size: 0.8rem;
  font-weight: 600;
}

.portal__state { color: var(--muted); }
.portal__state--refused { color: var(--refused); font-weight: 600; }

.balance { margin-bottom: 0.5rem; }
.balance__label { margin: 0; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--title); }
.balance__row { display: flex; align-items: center; flex-wrap: wrap; gap: 1rem; }
.balance__figure { margin: 0.25rem 0 0; font-family: var(--mono); font-size: 2.5rem; font-weight: 700; }
.balance__note { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card__label { margin: 0; font-size: 0.85rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--title); }
.card__note { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.9rem; }

.button {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.button--primary { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
/* Beside the figure rather than under it, so the row stays one line. */
.balance__row .button { margin-top: 0.25rem; }

.ledger { width: 100%; border-collapse: collapse; margin-top: 0.75rem; font-size: 0.95rem; }
.ledger th { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.ledger td { padding: 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; text-align: start; }
.ledger__amount { text-align: right; }
.ledger td.ledger__amount { font-family: var(--mono); white-space: nowrap; }
.ledger__in { color: var(--credit); }
.ledger__when { color: var(--muted); white-space: nowrap; }
.ledger__empty-cell { color: var(--muted); }

.portal__foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
}

.portal__back { color: var(--link); }
/* The id the tenant's own system knows this reader by — what support will ask for. The page
   carries no vendor name of ours: it is the tenant's page, and the reader is their customer. */
.portal__account { margin: 0 0 0 auto; color: var(--muted); font-size: 0.75rem; font-family: var(--mono); }

@media (max-width: 34rem) {
  .balance__figure { font-size: 2rem; }
  /* Four columns do not fit a phone; the two that carry the story do. */
  .ledger th:nth-child(3), .ledger td:nth-child(3), .ledger th:nth-child(4), .ledger td:nth-child(4) { display: none; }
}

@media (min-width: 1100px) {
  .portal {
    width: 65%;
  }
}

/* The plan card: one line per allowance, each a name, a figure and — when there is a cap to show
   it against — a bar. The bar is a div with a width, because this page has no dependencies. */
.plan__name {
  margin: 0.75rem 0 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--title);
}

.plan__subhead {
  margin: 1.5rem 0 0.75rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.plan__list {
  margin: 0.75rem 0 0;
  padding: 0;
  list-style: none;
}

.feature + .feature {
  margin-top: 1rem;
}

.feature__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.feature__figure {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* The API's own refusal token, shown word for word — the same string `check()` answers with. */
.feature__reason {
  margin: 0.25rem 0 0;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--refused);
}

.allowance {
  height: 6px;
  margin-top: 0.5rem;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}

.allowance__fill {
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

/* Past the allowance the bar is full and takes the colour the page uses for a refusal. What
   happens next is the tenant's app's business — this page states the figures and nothing else. */
.allowance__fill--over {
  background: var(--refused);
}
