:root {
  --bg: #fafaf7;
  --fg: #1c1c1a;
  --muted: #6b6b66;
  --line: #deded8;
  --card: #ffffff;
  --accent: #2f5bd3;
  --bad: #b3261e;
  --bad-bg: #fdecea;
  --ok-bg: #e8f3ec;
  /* Categorical chart hues, fixed order (validated light + dark, incl. the
     wrap-around pair a donut adds). "Other" is neutral. */
  --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a;
  --cat-4: #eda100; --cat-5: #e87ba4; --cat-6: #008300;
  --cat-other: #a3a39c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151514;
    --fg: #ececea;
    --muted: #9a9a94;
    --line: #34342f;
    --card: #1e1e1c;
    --accent: #8aa8ff;
    --bad: #ff8a80;
    --bad-bg: #3a1c1a;
    --ok-bg: #1b2e22;
    --cat-1: #3987e5; --cat-2: #d95926; --cat-3: #199e70;
    --cat-4: #c98500; --cat-5: #d55181; --cat-6: #008300;
    --cat-other: #5f5f5a;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 0 16px;
}
header.top, main, .site-footer { max-width: 720px; margin: 0 auto; }
header.top { padding-block: 20px 8px; border-bottom: 1px solid var(--line); }
h1 { margin: 0; font-size: 1.5rem; }
.quota { margin: 4px 0 0; font-size: 0.95rem; }
.muted, .hint, .notice, footer, .count { color: var(--muted); }

form { display: flex; flex-direction: column; gap: 6px; padding-block: 16px; }
label { font-weight: 600; margin-top: 12px; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.hint { margin: 0; font-size: 0.875rem; }

textarea, input[type="date"] {
  width: 100%;
  font: 0.875rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: inherit;
}
input[type="date"] { font-family: inherit; font-size: 1rem; max-width: 220px; }
textarea:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.count { margin: 0; font-size: 0.85rem; text-align: right; }
.count.over { color: var(--bad); font-weight: 600; }

ol.lines { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
ol.lines:empty { display: none; }
ol.lines li {
  display: grid;
  grid-template-columns: 2.2em 4.5em 1fr;
  gap: 2px 8px;
  align-items: baseline;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 0.85rem;
}
ol.lines li.flagged { background: var(--bad-bg); }
.ln { color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.addr { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; min-width: 0; }
.note { grid-column: 3; color: var(--muted); font-size: 0.8rem; }

.badge {
  display: inline-block;
  text-align: center;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 1px 6px;
  border-radius: 999px;
  color: #fff;
}
.badge.btc { background: #c46a00; }
.badge.eth { background: #5562b8; }
.badge.sol { background: #7a3fbf; }
.badge.xrp { background: #2a2a2a; }
.badge.ada { background: #1f5fa8; }
.badge.dup { background: var(--muted); }
.badge.invalid { background: var(--bad); }
.invalid + .addr { color: var(--bad); }

.captcha {
  margin-top: 12px;
  min-height: 65px;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
button {
  font: inherit;
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
  min-height: 44px;
}
button.primary { background: var(--accent); color: #fff; border-color: transparent; font-weight: 600; }
button.secondary { background: transparent; color: inherit; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

.message { margin: 8px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--ok-bg); }
.message.error { background: var(--bad-bg); color: var(--bad); }
.notice { font-size: 0.8rem; margin-top: 12px; }
a { color: var(--accent); }



/* Results */
.results { max-width: 720px; margin: 0 auto; padding-block: 8px 24px; display: flex; flex-direction: column; gap: 8px; }
.results h2 { font-size: 1.1rem; margin: 0; }
.progress { margin: 0 0 4px; color: var(--muted); font-size: 0.875rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.card summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  list-style: none;
}
.card summary::-webkit-details-marker { display: none; }
.card .addr { font-size: 0.85rem; }
.state { font-size: 0.85rem; text-align: right; white-space: nowrap; }
.state.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.state.fetching { color: var(--accent); }
.state.error, .error-text { color: var(--bad); }
.state.warn { color: #a15c00; }
.card-body { padding: 0 12px 12px; border-top: 1px solid var(--line); }
.native { font-size: 1.25rem; margin: 10px 0 2px; font-variant-numeric: tabular-nums; }
.meta { margin: 0; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.warning { margin: 8px 0 0; padding: 8px 10px; border-radius: 6px; background: #fff4e0; color: #6b4200; font-size: 0.85rem; }
@media (prefers-color-scheme: dark) { .warning { background: #3a2c12; color: #f3cf8f; } .state.warn { color: #f3cf8f; } }
table.tokens { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 0.85rem; }
table.tokens th, table.tokens td { text-align: left; padding: 4px 0; border-bottom: 1px solid var(--line); }
table.tokens .num { text-align: right; font-variant-numeric: tabular-nums; }
button.small { min-height: 36px; padding: 6px 14px; margin-top: 8px; }

/* USD */
.grand-total { margin: 0; font-size: 1.05rem; }
.grand-total strong { font-variant-numeric: tabular-nums; }
.native .usd { color: var(--muted); font-size: 0.95rem; font-weight: 400; }
label.check.small { margin-top: 2px; font-size: 0.9rem; }
.card-body .hint { margin-top: 6px; }

/* Totals across addresses */
.summary { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.summary-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 4px 12px; }
.summary h3, .detail-head { margin: 0; font-size: 1rem; }
.detail-head { margin-top: 8px; }
.table-scroll { overflow-x: auto; }
.summary-table td:first-child { white-space: nowrap; }
.summary-table tr.native-row td { font-weight: 600; }
.badge.mini { font-size: 0.65rem; padding: 0 5px; vertical-align: 1px; }

/* Donut */
.donut { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; padding-block: 4px; }
.donut svg { width: 180px; height: 180px; flex: none; }
.donut .slice { stroke: var(--card); stroke-width: 2; stroke-linejoin: round; cursor: pointer; transition: opacity 0.12s; }
.donut .slice.dim { opacity: 0.35; }
.donut-label, .donut-value { text-anchor: middle; fill: var(--fg); }
.donut-label { font-size: 12px; fill: var(--muted); }
.donut-value { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-legend { list-style: none; margin: 0; padding: 0; flex: 1 1 220px; min-width: 0; display: grid; gap: 4px; }
.donut-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto auto; gap: 8px; align-items: center; font-size: 0.85rem; padding: 2px 4px; border-radius: 6px; }
.donut-legend li.active { background: var(--bg); }
.swatch { width: 12px; height: 12px; border-radius: 3px; }
.legend-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend-share, .legend-usd { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; }
.legend-share { color: var(--fg); }

/* Results header + PDF export */
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.results-head button { margin-top: 0; }
.print-only { display: none; }

/* A4, white, the site's light palette whatever the screen theme. */
@page { size: A4; margin: 14mm 14mm 16mm; }
@media print {
  :root {
    --bg: #ffffff; --fg: #1c1c1a; --muted: #5f5f5a; --line: #d6d6d0; --card: #ffffff;
    --accent: #2f5bd3; --bad: #b3261e; --bad-bg: #fdecea; --ok-bg: #e8f3ec;
    --cat-1: #2a78d6; --cat-2: #eb6834; --cat-3: #1baf7a;
    --cat-4: #eda100; --cat-5: #e87ba4; --cat-6: #008300; --cat-other: #a3a39c;
    color-scheme: light;
  }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  html, body { background: #ffffff !important; color: var(--fg); }
  body { padding: 0; font-size: 10.5pt; }
  header.top, main, footer, .no-print { display: none !important; }
  .print-only { display: block !important; }
  .print-head { border-bottom: 1px solid var(--line); padding-bottom: 6px; margin-bottom: 4px; }
  .print-brand { margin: 0; font-size: 15pt; font-weight: 700; }
  .print-meta, .print-foot { margin: 2px 0 0; color: var(--muted); font-size: 8.5pt; }
  .print-foot { margin-top: 10px; border-top: 1px solid var(--line); padding-top: 6px; }
  .results { max-width: none; padding: 0; gap: 6px; }
  .results h2 { font-size: 12.5pt; }
  .summary, .card { border-color: var(--line); background: #ffffff; }
  .card, .donut, tr, .warning { break-inside: avoid; }
  .card summary { cursor: default; }
  .warning { background: #fff4e0 !important; color: #6b4200 !important; }
  .state.warn { color: #a15c00 !important; }
  .donut .slice.dim { opacity: 1; }
  .donut-legend li.active { background: transparent; }
  .table-scroll { overflow: visible; }
  .addr, .meta { overflow-wrap: anywhere; }
}

#blocked-reason:empty { display: none; }

/* Long amounts (18-decimal tokens) must wrap at 360 px rather than widen the card. */
table.tokens td:nth-child(2) { overflow-wrap: anywhere; }
table.tokens td.num:not(:nth-child(2)) { white-space: nowrap; }
table.tokens th + th, table.tokens td + td { padding-left: 10px; }

/* Page end: support, disclaimer, footer line */
.site-footer { display: flex; flex-direction: column; gap: 20px; margin-top: 24px; padding-block: 20px 32px; border-top: 1px solid var(--line); }
.site-footer h2 { font-size: 1rem; margin: 0 0 6px; }
.site-footer p { margin: 0 0 8px; }
.support p, .disclaimer p { font-size: 0.875rem; color: var(--fg); }
.disclaimer p { color: var(--muted); font-size: 0.8rem; }
.support .fine { color: var(--muted); font-size: 0.8rem; }
.donations { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.donation { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.donation-chain { grid-column: 1; font-size: 0.8rem; font-weight: 600; }
.donation-address { grid-column: 1; font-size: 0.78rem; overflow-wrap: anywhere; color: var(--fg); }
.donation button { grid-column: 2; grid-row: 1 / span 2; margin: 0; }
.footer-line { border-top: 1px solid var(--line); padding-top: 12px; color: var(--muted); font-size: 0.8rem; }
.footer-line p { margin: 0 0 4px; }
.copyright { color: var(--fg); }
.tagline { margin: 2px 0 0; color: var(--muted); font-size: 0.95rem; }
