/* Receipt generator — editor + till-style live preview + print (Till Roll 80 mm / A5). */
.rg-form { display: flex; flex-direction: column; gap: 18px; }
.rg-grp { margin: 0; padding: 0 0 18px; border: 0; border-bottom: 1px solid var(--border); min-width: 0; }
.rg-grp legend { padding: 0; margin-bottom: 12px; font-family: var(--display); font-weight: 700; font-size: 19px; letter-spacing: -.01em; }
.rg-form .actions { margin-top: 0; }
.rg-mt { margin-top: 12px; }
.rg-form .field textarea { min-height: 72px; }
.rg-form [aria-invalid="true"] { border-color: var(--bad) !important; box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
.rg-form input:focus-visible, .rg-form select:focus-visible, .rg-form textarea:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.rg-hint { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.rg-change { margin: 6px 0 0; font-weight: 700; color: var(--good); }
.rg-change:empty { display: none; }
.rg-change.due { color: var(--bad); }

/* Logo */
.rg-logo { display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap; }
.rg-logo-thumb { width: 72px; height: 56px; border: 1px dashed var(--field); border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--bg); overflow: hidden; }
.rg-logo-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; }
.rg-logo-ctl { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; flex: 1 1 200px; }
.rg-logo-ctl small { flex: 1 1 100%; color: var(--muted); font-size: 13px; }
.rg-file:focus-within { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Items */
.rg-items-head, .rg-row { display: grid; grid-template-columns: minmax(0, 1fr) 72px 110px 112px 40px; gap: 8px; align-items: center; }
.rg-items-head { padding: 0 2px 6px; color: var(--muted); font-size: 13px; font-weight: 600; }
.rg-items-head span:nth-child(n+2) { text-align: right; }
.rg-items { display: flex; flex-direction: column; gap: 8px; }
.rg-row input { width: 100%; min-width: 0; min-height: 44px; padding: 8px 10px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 15px; }
.rg-row .rg-q, .rg-row .rg-p { text-align: right; }
.rg-a { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; overflow-wrap: anywhere; }
.rg-x { width: 40px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--muted); font-size: 20px; cursor: pointer; }
.rg-x:hover { color: var(--bad); border-color: var(--bad); }
.rg-add { margin-top: 10px; }
@media (max-width: 560px) {
  .rg-items-head { display: none; }
  .rg-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) 40px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); }
  .rg-row .rg-d { grid-column: 1 / -1; }
  .rg-row .rg-a { grid-column: 1 / 3; grid-row: 3; text-align: left; }
  .rg-row .rg-x { grid-column: 3; grid-row: 2; }
}

/* Preview */
.rg-side { position: sticky; top: 12px; }
.rg-pv-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-bottom: 10px; }
.rg-pv-title { margin: 0; font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
.rg-stage { padding: 18px 12px; border-radius: 14px; background: var(--soft); }
.rg-paper { position: relative; margin: 0 auto; color: #15151A; overflow-wrap: anywhere; border-radius: 4px; }
.rg-paper.till { max-width: 320px; padding: 20px 18px 24px; font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, 'Courier New', monospace; font-size: 12.5px; line-height: 1.45; }
.rg-paper.a5 { max-width: 440px; aspect-ratio: auto; min-height: 420px; padding: 30px 28px; font-size: 13.5px; line-height: 1.5; }
.rg-pv-head { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; padding-bottom: 12px; border-bottom: 1px dashed #9A968C; }
.rg-pv-head img { max-width: 140px; max-height: 56px; object-fit: contain; margin-bottom: 6px; }
.rg-pv-head strong { font-size: 1.2em; text-transform: uppercase; letter-spacing: .02em; }
.rg-pv-head span { color: #4A4A52; font-size: .92em; }
.rg-pv-doc { margin: 10px 0 6px; text-align: center; font-weight: 800; font-size: 1.15em; letter-spacing: .3em; }
.rg-kv { display: flex; justify-content: space-between; gap: 12px; }
.rg-kv > span { color: #4A4A52; }
.rg-kv > b { text-align: right; font-variant-numeric: tabular-nums; }
.rg-pv-sec { padding: 6px 0 10px; border-bottom: 1px dashed #9A968C; }
.rg-pv-items { list-style: none; margin: 0; padding: 8px 0 10px; border-bottom: 1px dashed #9A968C; }
.rg-pv-items li + li { margin-top: 6px; }
.rg-pv-d { display: block; font-weight: 700; }
.rg-pv-items .rg-kv > span { padding-left: 1ch; }
.rg-pv-empty { text-align: center; color: #8A867C; }
.rg-pv-totals { padding-top: 8px; text-align: center; }
.rg-pv-totals .rg-kv { text-align: left; }
.rg-pv-total { margin: 2px 0; font-size: 1.15em; font-weight: 800; }
.rg-pv-total > span { color: inherit !important; text-transform: uppercase; }
.rg-stamp { display: inline-block; margin: 12px auto 4px; padding: 2px 14px; border: 3px solid #0B6E62; border-radius: 8px; color: #0B6E62; font-family: var(--display); font-weight: 800; font-size: 26px; letter-spacing: .14em; transform: rotate(-10deg); }
.rg-stamp.part { font-size: 18px; border-color: #B54708; color: #B54708; }
.rg-pv-notes { margin: 10px 0 0; text-align: center; font-size: .92em; color: #3A3A42; }
.rg-actions .btn { flex: 1 1 auto; }
.rg-recent-title { margin-top: 10px; }

/* Print: only the receipt */
@page rg-till { size: 80mm 297mm; margin: 4mm; }
@page rg-a5 { size: A5; margin: 10mm; }
@media print {
  .rg-form, .rg-actions, .rg-pv-bar, .rg-side .note, #status { display: none !important; }
  .tool-area { padding: 0 !important; margin: 0; max-width: none; }
  .rg.cols { display: block; }
  .rg-side { position: static; }
  .rg-stage { padding: 0; background: none; }
  .rg-paper { border: 0; border-radius: 0; box-shadow: none; max-width: none; min-height: 0; }
  .rg-paper.till { page: rg-till; width: 72mm; padding: 0; font-size: 9pt; }
  .rg-paper.a5 { page: rg-a5; padding: 0; font-size: 10.5pt; }
  .rg-paper, .rg-paper * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .rg-pv-items li { break-inside: avoid; }
}

/* Template button after saving: "✓ Saved as Template" (briefly), then "Update Template". */
.rg-tpl-btn.is-done { color: var(--good); border-color: var(--good); cursor: default; }
