/* Receipts: history, one receipt in full, automatic-update switches, and the setup guide
   (receipts.js, receipt-guide.js). The detail page follows the owner's reference: the source on one side,
   "What Frank changed" on the other, stacked on a phone. Pale blue is the feature's one accent; brick is
   only for something that needs a decision or went wrong. */
/* taste-gate: allow T12 because the 13px and 14px lines here are captions and table text; every button, link row and switch keeps a 44px target. */
.receipts-page, .receipt-detail, .receipt-guide { display: grid; gap: 28px; min-width: 0; }
.receipts-page h2, .receipt-detail h2, .guide-body h2 { margin: 0 0 10px; }
.receipt-back { margin: 0; }
.receipt-back a, .receipts-setup-link a { display: inline-flex; align-items: center; min-height: 44px; }

/* Automatic updates */
.receipt-auto { padding: 22px 24px; border-radius: var(--panel-radius); background: var(--blue); }
.receipt-auto-form { display: grid; gap: 12px; max-width: 64ch; }
.receipt-auto-form p { margin: 0; }
.receipt-switch { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 12px; align-items: start; min-height: 44px; margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--button-radius); background: var(--white); cursor: pointer; }
#app .receipt-switch input { width: 22px; height: 22px; min-height: 0; margin: 2px 0 0; accent-color: var(--green); }
.receipt-switch span { display: grid; gap: 2px; }
.receipt-switch small { color: var(--muted); font-size: 14px; line-height: 1.4; }
.receipt-switch:has(input:disabled) { background: transparent; cursor: default; }
.receipt-switch:has(input:checked) { border-color: var(--green); box-shadow: inset 0 0 0 1px var(--green); }
.receipt-switch:has(:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.receipt-keep { color: var(--ink); font-size: 14px; }
.receipt-auto-note { min-height: 22px; font-weight: 600; }
.receipt-paused { display: grid; gap: 10px; justify-items: start; margin: 0 0 14px; padding: 12px 14px; border-left: 4px solid var(--red); background: var(--white); max-width: 64ch; }
.receipt-paused p { margin: 0; }
.receipts-off { padding: 18px 20px; border: 1px dashed var(--line); border-radius: var(--panel-radius); }

/* History rows */
.receipt-rows { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
.receipt-row a { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 20px; align-items: center; min-height: 60px; box-sizing: border-box; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--white); color: var(--ink); text-decoration: none; }
.receipt-row a:hover { border-color: var(--green); }
.receipt-row a:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.receipt-row-main { display: grid; gap: 2px; min-width: 0; }
.receipt-row-main span { color: var(--muted); font-size: 14px; }
.receipt-row-states { display: grid; gap: 2px; font-size: 14px; text-align: right; }

/* One receipt */
.receipt-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px 24px; }
#app .receipt-head h1 { margin: 0; outline: none; }
.receipt-when { margin: 4px 0 0; color: var(--muted); font-size: 17px; }
.receipt-headline { margin: 0; padding: 6px 12px; border-radius: 6px; background: var(--sage); font-weight: 700; }
.receipt-headline.is-review { background: var(--wheat); }
.receipt-problem, .receipt-ok { display: grid; gap: 8px; justify-items: start; padding: 12px 14px; background: var(--white); outline: none; }
.receipt-problem { border-left: 4px solid var(--red); }
.receipt-ok { border-left: 4px solid var(--green); }
.receipt-problem p, .receipt-ok p { margin: 0; font-weight: 600; }
.receipt-problem ul { margin: 0; padding-left: 20px; }
.receipt-columns { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 28px; align-items: start; }
.receipt-source { padding: 18px 20px; border-radius: var(--panel-radius); background: var(--blue); }
.receipt-path { margin: 0 0 12px; font-size: 14px; color: var(--ink); }
.receipt-evidence { padding: 14px 16px; border: 1px solid var(--line); border-radius: 4px; background: var(--white); font-size: 14px; line-height: 1.5; }
.receipt-evidence p { margin: 0; }
.receipt-evidence-from { color: var(--muted); }
.receipt-evidence-subject { font-weight: 700; }
.receipt-evidence ul { margin: 10px 0 0; padding: 10px 0 0; border-top: 1px dashed var(--line); list-style: none; font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.receipt-evidence pre { margin: 10px 0 0; white-space: pre-wrap; font-size: 13px; }
.receipt-fine, .receipt-private { margin: 12px 0; font-size: 14px; line-height: 1.45; }
.receipt-effects { display: grid; gap: 18px; min-width: 0; }
.receipt-effect { min-width: 0; box-sizing: border-box; padding: 16px 18px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--white); }
.receipt-effect[data-state="pending_review"], .receipt-effect[data-state="conflict"] { border-color: var(--wheat-line); box-shadow: inset 4px 0 0 var(--ochre); }
.receipt-effect[data-state="failed"] { box-shadow: inset 4px 0 0 var(--red); }
#app .receipt-effect h3 { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; margin: 0 0 10px; font: normal 22px/1.2 Georgia, serif; color: var(--green); }
.receipt-state { font: 700 14px/1.3 system-ui, sans-serif; color: var(--ink); }
.receipt-effect[data-state="failed"] .receipt-state, .receipt-effect[data-state="conflict"] .receipt-state { color: var(--red); }
.receipt-reason { margin: 0 0 10px; font-size: 15px; }
.receipt-changes { width: 100%; border-collapse: collapse; font-size: 15px; }
/* The app's older table rules give every cell a 120px floor, a grey heading plate and no wrapping. This table sits in a narrow card, so it clears them the way the pantry table does. */
.receipt-changes th, .receipt-changes td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; min-width: 0; background: none; white-space: normal; overflow-wrap: anywhere; color: inherit; font-size: inherit; }
.receipt-changes thead th { color: var(--muted); font-size: 13px; font-weight: 700; }
.receipt-changes tbody tr:last-child th, .receipt-changes tbody tr:last-child td { border-bottom: 0; }
.receipt-changes tbody th { font-weight: 700; width: 40%; }
.receipt-changes small { display: block; color: var(--muted); font-weight: 400; font-size: 13px; }
.receipt-changes .is-out { color: var(--muted); }
.receipt-changes .receipt-shared { color: var(--muted); font-size: 14px; }
.receipt-facts { display: grid; gap: 8px; margin: 0; }
.receipt-facts div { display: grid; grid-template-columns: 132px minmax(0, 1fr); gap: 10px; }
.receipt-facts dt { color: var(--muted); font-size: 14px; }
.receipt-facts dd { margin: 0; overflow-wrap: anywhere; }
.receipt-na { color: var(--muted); font-style: italic; }
.receipt-edit { display: grid; gap: 12px; }
.receipt-edit p { margin: 0; }
.receipt-line { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 8px; margin: 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line); min-width: 0; }
#app .receipt-line label { display: grid; gap: 4px; margin: 0; font-size: 13px; font-weight: 700; }
#app .receipt-line input:not([type=checkbox]):not([type=radio]) { min-height: 44px; font-size: 16px; }
/* Where: three (or four) visible choices on their own row, drawn as the app's segmented control. No browser menu. */
.receipt-place { grid-column: 1 / -1; display: grid; gap: 4px; margin: 0; padding: 0; border: 0; min-width: 0; }
.receipt-place legend { padding: 0; font-size: 13px; font-weight: 700; }
.receipt-place-options { display: flex; flex-wrap: wrap; gap: 6px; }
#app .receipt-place-options label { position: relative; display: inline-flex; margin: 0; font-size: 15px; font-weight: 600; }
#app .receipt-place-options input { position: absolute; inset: 0; width: 100%; height: 100%; min-height: 0; margin: 0; opacity: 0; cursor: pointer; }
.receipt-place-options span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: var(--button-radius); background: var(--white); color: var(--ink); }
.receipt-place-options input:checked + span { border-color: var(--green); background: var(--sage); box-shadow: inset 0 0 0 1px var(--green); }
.receipt-place-options input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 2px; }
.receipt-line:has([name=excluded]:checked) .receipt-place-options span { opacity: .5; }
.receipt-line-problem { grid-column: 1 / -1; margin: 0; color: var(--red); font-size: 14px; font-weight: 600; }
.receipt-line-problem[hidden] { display: none; }
.receipt-evidence-total { margin: 8px 0 0; font-weight: 700; }
#app .receipt-line label.receipt-notfood { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; font-weight: 400; }
#app .receipt-notfood input { width: 20px; height: 20px; min-height: 0; margin: 0; accent-color: var(--green); }
.receipt-line:has([name=excluded]:checked) input:not([type=checkbox]):not([type=radio]) { opacity: .5; }
.receipt-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.receipt-correction { display: grid; gap: 12px; }
.receipt-correction p { margin: 0; }
.receipt-edit .form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.receipt-actions button { min-height: 44px; }
.receipt-mail { margin: 0; color: var(--muted); font-size: 14px; }
.receipt-idle { margin: 0; color: var(--muted); }
/* The floating Frank button sits at the right edge of the window on wide screens. The receipt keeps a gutter there so a
   status word or a button is never under it. */
@media (min-width: 701px) { .receipt-detail { padding-inline-end: 76px; } }
.receipt-history ol { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; font-size: 15px; }
.receipt-history li span { color: var(--muted); margin-right: 8px; }
.receipt-history small { color: var(--muted); }
.receipt-detail .visually-hidden, .receipts-page .visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

/* Setup guide: picture left, words right; picture above on a phone. */
.guide-count { margin: 0; color: var(--muted); font-size: 14px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.guide-step { display: grid; grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); gap: 32px; align-items: start; }
.guide-step.is-plain { grid-template-columns: minmax(0, 60ch); }
.guide-shot { margin: 0; padding: 14px 14px 10px; border-radius: var(--panel-radius); background: var(--blue); transform: rotate(-.6deg); }
.guide-shot svg { display: block; width: 100%; height: auto; }
.guide-shot figcaption { margin-top: 8px; color: var(--ink); font-size: 13px; }
.guide-words { display: grid; gap: 12px; min-width: 0; }
.guide-words p { margin: 0; line-height: 1.5; }
#app .guide-words h2 { margin: 0; outline: none; }
.guide-copy { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.guide-copy .forward-address { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); font-family: ui-monospace, Menlo, monospace; font-size: 15px; overflow-wrap: anywhere; }
.guide-fine, .guide-copied { color: var(--muted); font-size: 14px; }
.guide-copied { min-height: 20px; }
.guide-code { display: grid; gap: 6px; padding: 12px 14px; border-left: 4px solid var(--green); background: var(--white); }
.guide-code strong { font: 700 22px/1.2 ui-monospace, Menlo, monospace; letter-spacing: .06em; }
.guide-senders { display: grid; gap: 6px; font-weight: 700; }
#app .guide-senders textarea { min-height: 72px; font-size: 14px; resize: none; }
.guide-nav { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.guide-nav button, .guide-end a { min-height: 44px; }
.guide-end a { display: inline-flex; align-items: center; padding: 8px 18px; border-radius: var(--button-radius); background: var(--green); color: #fff; font-weight: 700; text-decoration: none; }
.guide-way-list { display: grid; gap: 10px; max-width: 560px; margin: 0; padding: 0; list-style: none; }
#app .guide-way { display: grid; grid-template-columns: 44px minmax(0, 1fr); align-items: center; gap: 14px; width: 100%; min-height: 68px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--panel-radius); background: var(--white); color: var(--ink); text-align: left; cursor: pointer; }
#app .guide-way:hover { border-color: var(--green); background: var(--sage); }
#app .guide-way:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.guide-way span:last-child { display: grid; gap: 2px; }
.guide-way small { color: var(--muted); font-size: 14px; }
.guide-way-mark, .guide-gmark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--blue); color: var(--green); font: 700 20px/1 Georgia, serif; }
.guide-way-mark.is-provider, .guide-gmark { border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.guide-way-mark img, .guide-gmark img { display: block; width: 24px; height: 24px; object-fit: contain; }
.guide-linked ul { display: grid; gap: 8px; max-width: 560px; margin: 0; padding: 0; list-style: none; }
.guide-linked li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border: 1px solid var(--green); border-radius: var(--panel-radius); background: var(--sage); }
.guide-linked li > span { display: grid; }
.guide-linked small { color: var(--muted); font-size: 14px; }
.guide-problem { min-height: 22px; margin: 10px 0 0; color: var(--red); font-weight: 600; }

/* Beside the app's sidebar the two columns are too tight for the review fields until the window is wide. */
@media (max-width: 1180px) { .receipt-columns { grid-template-columns: minmax(0, 1fr); gap: 20px; } }
@media (max-width: 860px) {
  .receipt-columns, .guide-step { grid-template-columns: minmax(0, 1fr); gap: 20px; }
  .receipt-row a { grid-template-columns: minmax(0, 1fr); }
  .receipt-row-states { text-align: left; }
  .guide-shot { max-width: 460px; }
}
@media (max-width: 560px) {
  .receipt-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .receipt-line > label:first-of-type { grid-column: 1 / -1; }
  .receipt-facts div { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .receipt-changes thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .receipt-changes tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
  .receipt-changes th, .receipt-changes td { border: 0; padding: 0; }
  .receipt-changes tbody th { grid-column: 1 / -1; }
  .receipt-changes td::before { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
  .receipt-changes td:nth-of-type(1)::before { content: "Receipt"; }
  .receipt-changes td:nth-of-type(2)::before { content: "Before"; }
  .receipt-changes td:nth-of-type(3)::before { content: "After"; }
  .receipt-changes td.is-blank::before { content: none; }
  .receipt-changes td.receipt-shared { grid-column: span 2; }
  .receipt-changes td.receipt-shared::before { content: "Before and after"; }
  .receipt-changes td.receipt-after-undo { grid-column: span 2; }
  .receipt-changes td.receipt-after-undo::before { content: "After the undo"; }
  .receipt-actions button { flex: 1 1 100%; }
  .receipt-auto { margin: 0 -16px; border-radius: 0; padding: 20px 16px; }
}
@media (prefers-reduced-motion: reduce) { .guide-shot { transform: none; } }
@media (forced-colors: active) { .receipt-effect, .receipt-source, .receipt-auto, .guide-shot { border: 1px solid CanvasText; } }
