/* Credits (docs/credits/UI_SPEC.md): the Credits page, its windows, the balance box of the sidebar and the Balance
   column of Settings. Loaded after the inline styles, studio.css and editor.css, whose classes these screens are
   drawn with (.st-top, .st-pane, .st-sec, .st-item, .st-banner, .st-field, .st-modal, .st-state, .st-empty).
   Owned here, and by no other file: #page-credits, #cr-side, .cr-*, and the #customers-table rules of the Balance
   column. Tokens only; the white-alpha tints have their light-theme twins at the end. */

/* ── the page: the studio's header spacing; it scrolls with #main ── */
#page-credits .page-header{margin-bottom:18px}

/* ── numbers in a top bar: the labels in one row, the numbers on one baseline, a quiet line under a number ── */
.cr-stats{display:grid;grid-auto-flow:column;grid-template-rows:auto auto auto;justify-content:start;align-items:baseline;gap:2px 32px;
  min-width:0}
.cr-stat{display:contents}
.cr-k{font-size:13px;font-weight:600;color:var(--muted)}
.cr-big{font-size:28px;font-weight:700;letter-spacing:-.025em;line-height:1.1;font-variant-numeric:tabular-nums;color:var(--text)}
.cr-mid{font-size:20px;font-weight:700;letter-spacing:-.02em;line-height:1.2;font-variant-numeric:tabular-nums;color:var(--text)}
.cr-note{font-size:12.5px;line-height:1.45;color:var(--muted2)}
.cr-note:empty{display:none}
.cr-stats .cr-note:empty{display:block}                      /* a number without a line keeps its row */
/* colour means status and nothing else: low, below zero, money in */
.cr-low{color:var(--st-miss)}
.cr-neg{color:var(--red)}
.cr-plus{color:var(--green)}

/* the quiet band under the numbers: the state, the price in words, the last top-up at the right end */
.cr-meta{font-size:13px;color:var(--muted)}
.cr-meta-end{margin:0 0 0 auto;white-space:normal}
/* the open order, between the bar and the part: its words start where the bar's do */
.st-banner.cr-order{padding:12px 16px}
/* in place of "Add credits": payments are off, or this address is not the secure one */
.cr-off{max-width:420px;margin-left:auto;font-size:13px;line-height:1.5;color:var(--muted);text-align:right}

/* a name that opens something: text colour, underlined under the pointer. An amount or an address that does (a link
   in a cell or in a sentence) is underlined from the start: nothing else there says it can be pressed */
.cr-link{color:var(--text);text-decoration:none;cursor:pointer}
button.cr-link{padding:0;border:0;background:none;font:inherit;text-align:left}
a.cr-link{text-decoration:underline;text-decoration-color:var(--muted2);text-underline-offset:3px}
.cr-link:hover{text-decoration:underline}
a.cr-link:hover{text-decoration-color:currentColor}
.cr-link:focus-visible{outline:2px solid var(--accent);outline-offset:2px;border-radius:3px}

/* ── sections ── */
.cr-hero{font-size:16px;font-weight:700;font-variant-numeric:tabular-nums;color:var(--text)}
.cr-facts{display:grid;grid-template-columns:repeat(auto-fill,minmax(190px,1fr));gap:18px 20px}
.cr-fact{min-width:0}
.cr-fact .cr-mid{margin-top:4px}
.cr-levels{display:flex;flex-wrap:wrap;gap:10px}
.cr-level{display:inline-flex;align-items:baseline;gap:8px;padding:10px 14px;border:1px solid var(--border-hover);border-radius:10px;
  font-size:14px;color:var(--text)}
.cr-level b{font-size:16px;font-weight:700;font-variant-numeric:tabular-nums}
.cr-levels + .st-help{margin-top:-6px}
.cr-sec-plain{padding-top:24px}                              /* a section without a head (the empty state) */

/* ── tables: the page's own table, set on the section's edges ── */
.cr-table th{font-weight:600;white-space:nowrap}
.cr-table td{vertical-align:top}
.cr-table th:first-child,.cr-table td:first-child{padding-left:0}
.cr-table th:last-child,.cr-table td:last-child{padding-right:0}
.cr-table tr:hover td{background:none}
.cr-table .r{text-align:right}
.cr-table td .cr-note{margin-top:2px}
.cr-table tfoot td{border-bottom:0;font-weight:600}
.cr-table tfoot td .cr-note{font-weight:400}
.cr-table .cr-name{font-size:14px;font-weight:600}
.cr-table .cr-name + .cr-mono{white-space:nowrap}
.cr-mono{font-family:var(--font-mono);font-size:12px;color:var(--muted2)}
.cr-mono.cr-full{color:var(--text);overflow-wrap:anywhere;user-select:all}
.cr-what .cr-mono{white-space:nowrap}                        /* a short transaction id is never cut in two */
.cr-none{color:var(--muted)}
.cr-m{display:none}                                          /* what a row says on a phone only */
/* History: the date and the two amounts keep their width, "What" takes the rest */
.cr-hist{table-layout:fixed}
.cr-hist .cr-c-date{width:96px}
.cr-hist .cr-c-amt{width:110px}
.cr-hist .cr-what{font-size:14px;overflow-wrap:anywhere}
.cr-hist.cr-end tbody tr:last-child td{border-bottom:0}       /* nothing under the last line: no rule either */
.cr-bal{font-variant-numeric:tabular-nums}
.cr-foot{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap;margin-top:12px;font-size:12.5px;
  color:var(--muted2)}
.cr-foot-acts{display:flex;gap:8px;margin-left:auto}
.cr-scroll{overflow-x:auto}
.cr-scroll > table{min-width:720px}
.cr-scroll th,.cr-scroll td{white-space:nowrap}
.st-item-body .cr-table tbody tr:last-child td{border-bottom:0}

/* ── Payments (the admin) ── */
.cr-group{display:flex;flex-direction:column;min-width:0}
.cr-group > .st-banner{margin-bottom:10px}
.cr-group > .st-banner:last-child{margin-bottom:0}
.cr-sub-h{margin:4px 0 10px;font-size:14px;font-weight:600;color:var(--text)}
.cr-line{font-size:13px;line-height:1.5;color:var(--muted)}
.cr-line b{font-weight:600;color:var(--text)}
.st-mark.cr-count{padding:0 6px}
/* a line that needs a look: an item that is always open, its name in the strip where a fold has its button */
.cr-item-head{padding-left:14px}
.cr-item-head .st-item-title{font:600 14px/1.3 var(--font-ui);color:var(--text)}
.cr-item-k{font-size:12.5px;color:var(--muted)}
.cr-item-body{gap:8px}
.cr-coin{display:flex;flex-direction:column;gap:4px;min-width:0}
.cr-coin + .cr-coin{padding-top:14px;border-top:1px solid var(--border)}
.cr-coin-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;font-size:14px;font-weight:600;color:var(--text)}
.cr-more{align-self:flex-start;margin-top:12px}

/* ── windows ── */
.cr-modal.cr-narrow{max-width:440px}
.cr-modal .cr-err{margin-top:14px;font-size:12.5px;line-height:1.45;color:var(--red)}
.cr-modal .cr-err:empty{display:none}
.cr-modal .st-field + .st-field,.cr-modal .st-row + .st-field,.cr-modal .st-field + .st-row{margin-top:14px}
.cr-modal .st-row > .st-field{margin-top:0}
.cr-modal .st-modal-text b{font-weight:600;color:var(--text)}
.cr-load{font-size:13px;color:var(--muted)}
.cr-say{font-size:14px;line-height:1.5;color:var(--text)}
.cr-say + .cr-say{margin-top:6px}
/* a field with a $ before it, or ¢ / % after it */
.cr-unit{display:grid;grid-template-columns:auto minmax(0,1fr);align-items:center;gap:8px}
.cr-unit.cr-after{grid-template-columns:minmax(0,1fr) auto}
.cr-unit > span{font-size:14px;color:var(--muted)}
/* money is typed: the browser's one-cent stepper is not offered */
.cr-unit input::-webkit-outer-spin-button,.cr-unit input::-webkit-inner-spin-button{margin:0;-webkit-appearance:none}
.cr-unit input[type=number]{-moz-appearance:textfield;appearance:textfield}
.cr-copy-field{position:fixed;top:0;left:0;width:1px;height:1px;opacity:0}

/* Add credits, the amount: five quick amounts, each with the bonus it gets; the picked one wears the studio's ring */
.cr-amts{display:flex;gap:8px;flex-wrap:wrap;margin-bottom:16px}
.cr-amt{display:flex;flex:1 1 0;flex-direction:column;align-items:center;justify-content:center;gap:1px;min-width:0;height:52px;padding:0 6px;
  border:1px solid var(--border-hover);border-radius:8px;background:var(--bg);color:var(--text);font:600 14px/1.2 var(--font-ui);
  font-variant-numeric:tabular-nums;cursor:pointer}
.cr-amt:hover:not(:disabled){border-color:rgba(255,255,255,.28)}
.cr-amt[aria-checked="true"],.cr-amt[aria-checked="true"]:hover{border-color:var(--accent);box-shadow:0 0 0 1px var(--accent)}
.cr-amt:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.cr-amt-b{font-size:11.5px;font-weight:500;line-height:1.2;color:var(--muted2)}
.cr-amt-b:empty{display:none}
.cr-sum{margin-top:16px;font-size:13.5px;line-height:1.5;color:var(--text)}
.cr-sum .st-err,.cr-sum .cr-note{margin-top:0}

/* the pay screen: what to send and where, the QR beside it */
.cr-pay-sum{font-size:13.5px;line-height:1.5;color:var(--muted)}
.cr-pay-sum b{font-weight:600;color:var(--text)}
.cr-pay-state{display:flex;flex-direction:column;align-items:flex-start;gap:6px;margin:10px 0 16px}
.cr-pay-state .cr-line,.cr-pay-state .st-help{margin:0}
.cr-pay{display:grid;grid-template-columns:minmax(0,1fr) 168px;gap:16px 20px;align-items:start}
.cr-pay-main{display:flex;flex-direction:column;gap:14px;min-width:0}
.cr-pay-k{margin-bottom:5px;font-size:13px;font-weight:600;color:var(--text)}
.cr-pay-amount{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
.cr-pay-amount + .cr-note{margin-top:6px}
.cr-pay-coin{font-size:20px;font-weight:700;letter-spacing:-.02em;line-height:1.2;font-variant-numeric:tabular-nums;color:var(--text)}
.cr-addr{padding:9px 12px;border:1px solid var(--border-hover);border-radius:8px;background:var(--bg);font-family:var(--font-mono);
  font-size:13px;line-height:1.45;color:var(--text);word-break:break-all;user-select:all}
.cr-addr + .btn{margin-top:8px}
.cr-qr{display:block;width:168px;height:168px;padding:8px;border-radius:10px;background:#fff}
/* the one warning, under the network it is about: left-aligned (the banner's own layout centres a line that wraps) */
.st-banner.cr-warn{justify-content:flex-start;margin:0;padding:9px 12px;font-size:13px;line-height:1.45}

/* Edit pricing: the price is a few digits, so its ¢ stands at a short field, well before the next field's $ */
.cr-modal .st-row3 .cr-unit.cr-after{grid-template-columns:96px auto;justify-content:start}
/* one row per bonus level */
.cr-lv-k{margin:18px 0 7px;font-size:13px;font-weight:600;color:var(--text)}
.cr-lv{display:grid;grid-template-columns:190px 110px 28px;align-items:center;gap:8px 12px}
.cr-lv + .cr-lv{margin-top:8px}
.cr-lv .cr-unit > span{white-space:nowrap}

/* ── the balance box of the sidebar (customers, every page) ── */
.cr-side{--cr-low:var(--accent);display:flex;flex-direction:column;gap:2px;width:100%;margin-bottom:8px;padding:10px 12px;
  border:1px solid var(--border);border-radius:10px;background:transparent;font-family:var(--font-ui);text-align:left;cursor:pointer}
.cr-side[hidden]{display:none}
.cr-side:hover{border-color:var(--border-hover)}
.cr-side:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.cr-side-k{font-size:12.5px;font-weight:600;color:var(--muted2)}
.cr-side-v{font-size:16px;font-weight:700;line-height:1.25;font-variant-numeric:tabular-nums;color:var(--text)}
.cr-side-v.cr-low{color:var(--cr-low)}
.cr-side-v.cr-neg{color:var(--red)}
.cr-side-s{overflow:hidden;font-size:12.5px;color:var(--muted);white-space:nowrap;text-overflow:ellipsis}

/* ── Settings, the Balance column (added by credits.js to the admin's customers table) ── */
#customers-table .cr-set-bal,.cr-set-h{text-align:right}
/* as narrow as a balance: every pixel of it is taken from Models (a right-aligned cell needs no room at its left) */
.cr-set-col{width:86px}
#customers-table .cr-set-bal,.cr-set-h{padding-left:0}
#customers-table .cr-set-bal{font-variant-numeric:tabular-nums;white-space:nowrap}
#customers-table .cr-set-bal .cr-low{color:var(--accent)}
#customers-table .cr-set-none{color:var(--muted2)}
@media (min-width:769px){ #customers-table .cr-set-k{display:none} }

/* ── the admin's customers: six columns down to 1000px wide (closer together under 1128px, where a long name takes
   two lines); narrower, a customer becomes a stacked row, as Settings does on a phone: the name and the balance,
   what they have left and paid, the last top-up ── */
@media (min-width:1001px){ .cr-cust td .cr-note{white-space:nowrap} }
@media (min-width:1001px) and (max-width:1127px){
  .cr-cust th,.cr-cust td{padding-left:8px;padding-right:8px}
  .cr-cust th:first-child,.cr-cust td:first-child{padding-left:0}
  .cr-cust th:last-child,.cr-cust td:last-child{padding-right:0}
}
@media (max-width:1000px){
  .cr-cust,.cr-cust tbody,.cr-cust tfoot{display:block}
  .cr-cust thead,.cr-cust td.cr-d{display:none}
  .cr-cust tr{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:start;gap:6px 10px;padding:12px 0;border-bottom:1px solid var(--border)}
  .cr-cust td{display:block;padding:0;border:0}
  .cr-cust td.cr-m{display:block;grid-column:1/-1;font-size:12.5px;line-height:1.5;color:var(--muted)}
  .cr-cust td[colspan]{grid-column:1/-1}
  .cr-cust tfoot tr{border-bottom:0}
  .cr-cust td:empty{display:none}
}

/* ── a phone ── */
@media (max-width:768px){
  #page-credits .page-header{margin-bottom:14px}
  #page-credits .page-sub{display:none}
  .cr-stats{flex:1 1 100%;gap:2px 24px}
  .cr-off{flex:1 1 100%;max-width:none;margin-left:0;text-align:left}
  .cr-meta-end{flex-basis:100%;margin-left:0}
  .cr-facts{grid-template-columns:repeat(2,minmax(0,1fr))}
  .cr-amts{gap:8px}
  .cr-amt{flex:1 1 28%}
  .cr-pay{grid-template-columns:minmax(0,1fr)}
  .cr-qr{display:none}                                        /* a phone cannot scan its own screen: the address is copied */
  .cr-lv{grid-template-columns:minmax(0,1fr) minmax(0,1fr) 28px}
  /* History: no Date column, the date leads the line under "What"; no Balance column (the bar has the balance);
     the coin amount and the transaction on a line of their own */
  .cr-hist .cr-c-date,.cr-hist td.cr-date,.cr-hist .cr-bal{display:none}
  .cr-hist .cr-c-amt{width:92px}
  .cr-hist .cr-rest{display:block}
  .cr-hist .cr-sep{display:none}
  .cr-hist td.cr-what{padding-left:0}
  .cr-hist th.cr-c-what{padding-left:0}
  .cr-m{display:inline}
  div.cr-m,td.cr-m{display:block}
  .cr-item-head{flex-wrap:wrap;padding:8px 8px 8px 14px}
  .cr-item-head .st-item-title{flex:1 1 100%;white-space:normal}
  /* Settings: the balance is the fourth line of a customer's row, Save keeps its place beside the name */
  #customers-table tr.cr-set-row td:nth-child(4){grid-column:1/-1;grid-row:4;font-size:12.5px;color:var(--muted);text-align:left}
  #customers-table tr.cr-set-row td:nth-child(5){grid-column:2;grid-row:1}
}

/* ── light theme: the twins of the tints above, and the amber that reads on white ── */
html[data-theme="light"] .cr-table tr:hover td{background:none}
html[data-theme="light"] .cr-amt:hover:not(:disabled){border-color:rgba(16,17,22,.34)}
html[data-theme="light"] .cr-amt[aria-checked="true"]:hover{border-color:var(--accent)}
html[data-theme="light"] .cr-side{--cr-low:#8a5a06}
html[data-theme="light"] #customers-table .cr-set-bal .cr-low{color:#8a5a06}
