/* ShopYear app: files rail + report paper. Builds on styles.css tokens. */

.topbar-actions { display: flex; gap: 10px; }
.btn-small { min-height: 40px; padding: 0 16px; font-size: .95rem; }
.btn-link { border-color: transparent; background: none; color: var(--ink-2); text-decoration: underline; padding: 0 8px; }
.btn-link:hover { color: var(--ink); }

.workspace {
  max-width: 1280px; margin: 0 auto; padding: 8px 24px 48px;
  display: grid; grid-template-columns: 340px minmax(0, 1fr); gap: 32px; align-items: start;
}

/* ---------- Files rail ---------- */
.rail { position: sticky; top: 16px; max-height: calc(100vh - 32px); overflow-y: auto; padding: 2px 2px 8px; }
.rail h1 { font-size: 1.6rem; margin-bottom: .2em; }
.rail h2 { font: 600 .95rem var(--sans); margin: 0 0 8px; color: var(--ink); }
.rail-note { color: var(--ink-2); font-size: .95rem; margin-bottom: 14px; }

.dropzone {
  position: relative; display: grid; place-content: center; gap: 4px; text-align: center;
  min-height: 140px; padding: 20px; border: 2px dashed var(--rule-strong); border-radius: var(--radius);
  background: var(--paper); cursor: pointer; transition: border-color .15s, background-color .15s;
}
.dropzone:hover, .dropzone.is-over { border-color: var(--ink); border-style: solid; background: #f6f8fb; }
.dropzone:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }
.dropzone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.dz-main { font: 700 1.15rem var(--serif); }
.dz-sub { font-size: .9rem; color: var(--ink-2); }
@media (prefers-reduced-motion: reduce) { .dropzone { transition: none; } }

.rail-buttons { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; margin: 12px 0 16px; }

.file-list { list-style: none; margin: 0 0 20px; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; }
.file {
  position: relative; background: var(--paper); border: 1px solid var(--rule); border-radius: 8px;
  padding: 8px 40px 8px 12px; font-size: .92rem;
}
.file.has-error { border-color: #e7b6a5; background: #fff8f4; }
.file-main { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; min-width: 0; }
.file-name { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: var(--mono); font-size: .85rem; }
.pill { flex: none; font-size: .78rem; font-weight: 600; border-radius: 999px; padding: 1px 9px; background: #e8edf5; color: var(--ink-2); }
.pill-bad { background: #fde3d8; color: var(--warn); }
.file-error { margin: 4px 0 0; color: var(--warn); font-size: .86rem; }
.file-detail { margin: 2px 0 0; color: var(--muted); font-size: .84rem; }
.file-remove {
  position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border: 0; border-radius: 6px;
  background: none; color: var(--muted); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.file-remove:hover { background: #eef2f7; color: var(--ink); }
.file-action { margin-top: 8px; }

.year-block { margin-bottom: 20px; }
.year-block label { display: block; font: 600 .95rem var(--sans); margin-bottom: 6px; color: var(--ink); }
.year-block select {
  width: 100%; min-height: 44px; padding: 0 10px; border-radius: 8px; border: 1.5px solid var(--ink);
  font: .95rem var(--mono); color: var(--ink); background: #fff; cursor: pointer;
}
.year-block select:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.year-detail { margin: 6px 0 0; font-size: .88rem; color: var(--ink-2); line-height: 1.45; }

.coverage-block { margin-bottom: 20px; }
.coverage { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.cov {
  display: grid; justify-items: center; gap: 0; padding: 6px 0 4px; min-height: 48px;
  border-radius: 6px; border: 1px solid var(--rule); background: var(--paper); font-size: .8rem;
}
.cov-month { font-weight: 600; color: var(--ink-2); }
.cov-state { font: 700 .95rem var(--mono); }
.cov.ok .cov-state { color: var(--ok); }
.cov.missing { border: 1px dashed #d9967e; background: #fff1e8; }
.cov.missing .cov-state, .cov.missing .cov-month { color: var(--warn); }
.coverage-summary { margin: 8px 0 0; font-size: .92rem; color: var(--ink-2); }
.coverage-summary.is-warning { color: var(--warn); font-weight: 600; }

.warnings { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.warnings li { background: #fff1e8; color: #6d2812; border-left: 3px solid var(--warn); border-radius: 4px; padding: 8px 10px; font-size: .9rem; line-height: 1.45; }

/* ---------- Report paper ---------- */
.paper {
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius);
  box-shadow: 0 1px 0 var(--rule), 0 18px 40px -18px rgba(23, 35, 63, .3);
  padding: 28px 36px 24px; min-height: 420px;
}
.empty h2 { font-size: 1.6rem; }
.downloads { padding-left: 22px; display: grid; gap: 10px; margin: 0 0 18px; color: var(--ink-2); max-width: 46em; }
.downloads strong { color: var(--ink); }
.report-error { border-left: 3px solid var(--warn); background: #fff8f4; padding: 16px 20px; border-radius: 6px; }
.report-error h2 { font-size: 1.25rem; color: var(--warn); }

.report-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; border-bottom: 2px solid var(--ink); padding-bottom: 12px; }
.report-head h2 { font-size: 1.7rem; margin: 0; }
.report-head h2:focus { outline: none; }
.report-head h2:focus-visible { outline: 2px solid var(--ink); }
.report-section { padding-top: 26px; }
.report-section h3 { font-size: 1.25rem; border-bottom: 1px solid var(--rule-strong); padding-bottom: 8px; margin-bottom: 0; }
.walk-source { margin: 8px 0 4px; font-size: .88rem; color: var(--ink-2); line-height: 1.45; max-width: 52em; }
.walk-source:empty { display: none; }
.section-note { color: var(--ink-2); font-size: .95rem; margin: 10px 0 0; max-width: 48em; }
.report-section .fine { margin-top: 8px; }

.sc-table tr.sub th, .sc-table tr.sub td { padding-top: 5px; padding-bottom: 5px; font-size: .9rem; color: var(--ink-2); border-bottom-style: dotted; }
.sc-table tr.sub th { padding-left: 16px; }
.note-cell { text-align: left !important; font-family: var(--sans) !important; color: var(--ink-2); white-space: normal !important; }

/* Lock panel */
.lock { margin-top: 26px; border: 2px solid var(--ink); border-radius: var(--radius); padding: 22px 24px; background: #f6f8fb; }
.lock h3 { font-size: 1.3rem; }
.lock p { max-width: 46em; color: var(--ink-2); }
.lock-list { margin: -6px 0 16px; padding-left: 22px; display: grid; gap: 4px; color: var(--ink); }
.lock-price strong { font: 700 1.6rem var(--serif); color: var(--ink); margin-right: 4px; }
.lock-actions { margin-bottom: 18px; }
.lock-actions .fine { margin-top: 10px; }
.license-form label, .box1a label { display: block; font-weight: 600; margin-bottom: 6px; }
.box1a label small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.license-form input, .box1a input, .cost-input {
  min-height: 44px; padding: 0 12px; border-radius: 8px; border: 1.5px solid var(--rule-strong);
  font: 1rem var(--mono); color: var(--ink); background: #fff;
}
.license-form input { flex: 1; min-width: 0; }
.license-form input:focus-visible, .box1a input:focus-visible, .cost-input:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
input[aria-invalid="true"] { border-color: var(--warn) !important; background: #fff8f4 !important; }
.field-msg { margin: 8px 0 0; padding: 8px 12px; border-radius: 6px; font-size: .93rem; font-weight: 600; }
.field-msg.is-success { background: #e3f4ea; color: var(--ok); }
.field-msg.is-warning { background: #fff1e8; color: var(--warn); }

.recover { margin-top: 14px; }
.recover > summary { cursor: pointer; color: var(--ink-2); text-decoration: underline; width: fit-content; }
.recover > summary:hover { color: var(--ink); }
.recover .license-form { margin-top: 10px; }

/* Receipt stub: shown once, right after the Stripe Payment Link redirect */
.stub { margin: 0 0 24px; padding: 18px 20px; border: 2px dashed var(--ink); border-radius: var(--radius); background: #fffdf2; }
.stub:focus { outline: none; }
.stub:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.stub h2 { font-size: 1.25rem; margin-bottom: 6px; }
.stub-status { margin: 0 0 10px; font-weight: 600; color: var(--ink-2); }
.stub-status.is-success { color: var(--ok); }
.stub-status.is-warning { color: var(--warn); }
.stub-key { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.stub-key code {
  font: 700 clamp(1.05rem, 3.6vw, 1.45rem) var(--mono); letter-spacing: .04em; color: var(--ink);
  background: var(--highlight); padding: 6px 10px; border-radius: 4px; user-select: all; overflow-wrap: anywhere;
}
.stub-note { margin: 10px 0 0; color: var(--ink-2); max-width: 46em; }

.new-note { margin: 0 0 18px; padding: 10px 14px; border-left: 3px solid var(--rule-strong); background: #f6f8fb; color: var(--ink-2); max-width: 52em; }
.new-note strong { color: var(--ink); }
.year-note { margin: 0 0 12px; padding: 10px 14px; border-left: 3px solid var(--warn); background: #fff8f4; color: #6d2812; max-width: 52em; }
.year-note strong { color: var(--warn); }

.mismatch { margin-top: 28px; border: 1px solid var(--rule); border-radius: 8px; padding: 0 16px; }
.mismatch > summary { cursor: pointer; padding: 12px 0; font-weight: 600; }
.mismatch form { display: grid; gap: 6px; padding-bottom: 16px; max-width: 40em; }
.mismatch form p { margin: 0 0 6px; color: var(--ink-2); }
.mismatch label { font-weight: 600; margin-top: 8px; }
.mismatch label small { display: block; font-weight: 400; color: var(--muted); font-size: .85rem; }
.mismatch input, .mismatch textarea {
  min-height: 44px; padding: 8px 12px; border-radius: 8px; border: 1.5px solid var(--rule-strong);
  font: 1rem var(--sans); color: var(--ink); background: #fff; width: 100%;
}
.mismatch textarea { resize: vertical; }
.mismatch #mm-sample { font: .9rem var(--mono); }
.mismatch input:focus-visible, .mismatch textarea:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; border-color: var(--ink); }
.mismatch textarea[aria-invalid="true"] { border-color: var(--warn); background: #fff8f4; }
.mismatch button { justify-self: start; margin-top: 10px; }

.box1a { margin-top: 18px; max-width: 520px; }
.box1a input { width: 220px; text-align: right; }

.monthly { margin-top: 16px; border: 1px solid var(--rule); }
.monthly .table-scroll { border: 0; margin: 0 0 14px; }
.order-diff .walk-source { margin: 4px 12px 10px; }
.diff-table tbody th small { display: block; font-size: .8rem; color: var(--muted); font-weight: 400; }
.diff-table tr.diff-group th { padding-top: 14px; font-weight: 700; color: var(--ink); white-space: normal; border-bottom: 1px solid var(--rule-strong); }
.diff-table tr.diff-group .diff-count { font-weight: 400; color: var(--muted); }
.diff-table tr.diff-more td { text-align: left; font-family: inherit; color: var(--ink-2); white-space: normal; }
.diff-table tbody td:last-child { font-weight: 600; }
.print-extra, .print-only { display: none; }

/* Grid tables (totals check, listings, monthly) */
.grid-table { width: 100%; border-collapse: collapse; }
.grid-table th, .grid-table td { padding: 9px 12px; border-bottom: 1px solid var(--rule); text-align: right; white-space: nowrap; }
.grid-table thead th { font-size: .8rem; color: var(--muted); font-weight: 600; background: #f6f8fb; vertical-align: bottom; white-space: normal; }
.grid-table th:first-child { text-align: left; }
.grid-table tbody th { font-weight: 500; }
.grid-table td { font-family: var(--mono); font-size: .9rem; }
.grid-table tfoot th, .grid-table tfoot td { border-top: 2px solid var(--ink); border-bottom: 0; font-weight: 700; }
.grid-table tr.flag td:last-child { color: var(--warn); font-weight: 700; }
#check-table { min-width: 680px; }
.check-notes { margin: 12px 0 0; padding-left: 20px; display: grid; gap: 6px; color: var(--ink-2); font-size: .95rem; }

.listings-table { min-width: 760px; }
.listings-table th, .listings-table td { padding-left: 8px; padding-right: 8px; }
.listings-table tbody th { white-space: normal; min-width: 170px; }
.listing-title { display: block; font-weight: 600; }
.listings-table tbody th small { display: block; color: var(--muted); font-size: .8rem; font-weight: 400; }
.cost-cell { padding-top: 5px !important; padding-bottom: 5px !important; }
.cost-input { width: 96px; min-height: 38px; text-align: right; font-size: .9rem; }
.listings-table tr.loss td:nth-last-child(-n+2) { color: var(--warn); font-weight: 700; }

.report-foot { margin: 28px 0 0; padding-top: 12px; border-top: 1px solid var(--rule); font-size: .85rem; color: var(--muted); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rail { position: static; max-height: none; overflow: visible; }
  .paper { padding: 22px 18px 18px; }
}
@media (max-width: 560px) {
  .app-page .topbar { padding: 12px; flex-wrap: wrap; gap: 8px; }
  .workspace { padding: 0 12px 32px; }
  .rail h1 { font-size: 1.4rem; }
  .dropzone { min-height: 104px; padding: 16px; }
  .lock { padding: 18px 16px; }
  .lock-actions .btn { width: 100%; }
  .paper { padding: 18px 14px 14px; }
  .report-head h2 { font-size: 1.4rem; }
  .box1a input { width: 100%; }
  .license-form .field-row { flex-direction: column; }
  /* Order diff: one order per block, amounts labelled, instead of a sideways-scrolling table. */
  .order-diff .table-scroll { overflow: visible; }
  .diff-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .diff-table tbody tr { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 6px; border-bottom: 1px solid var(--rule); }
  .diff-table tbody th, .diff-table tbody td { border-bottom: 0; }
  .diff-table tbody tr > th { grid-column: 1 / -1; padding-bottom: 2px; }
  .diff-table tr.diff-group, .diff-table tr.diff-more { display: block; }
  .diff-table tbody tr.print-extra { display: none; }
  .diff-table tr.diff-group th, .diff-table tr.diff-more td { display: block; }
  .diff-table tbody td[data-label] { text-align: left; padding: 2px 4px 10px; font-size: .85rem; overflow-wrap: anywhere; }
  .diff-table tbody th + td[data-label] { padding-left: 12px; }
  .diff-table tbody td[data-label]::before { content: attr(data-label); display: block; font: 600 .72rem var(--sans); color: var(--muted); }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; font-size: 11pt; }
  .topbar, .footer, .dropzone, .rail-buttons, .file-list, .rail > h1, .rail-note, .lock, .file-remove, .stub, .mismatch { display: none !important; }
  .new-note { border-left-color: #999; background: none; padding: 0 0 0 10px; }
  .year-block { display: none !important; }
  .year-note { background: none; padding: 0 0 0 10px; }
  .warnings-block { margin-bottom: 12px; }
  .warnings li { border: 1px solid #d9967e; border-left-width: 3px; background: none; }
  .cost-input::placeholder { color: transparent; }
  .workspace { display: block; padding: 0; max-width: none; }
  .rail { position: static; max-height: none; overflow: visible; margin-bottom: 12px; }
  .coverage { grid-template-columns: repeat(12, 1fr); }
  .paper { border: 0; box-shadow: none; padding: 0; min-height: 0; }
  .monthly { border: 0; }
  .monthly > summary { list-style: none; font-weight: 600; }
  .diff-table tr.print-extra { display: table-row; }
  .print-only { display: inline; }
  .screen-only { display: none; }
  .diff-table tr { break-inside: avoid; }
  .table-scroll { overflow: visible; border: 0; }
  .grid-table, #check-table, .listings-table { min-width: 0; }
  .grid-table th, .grid-table td { padding: 4px 6px; }
  /* 8 listing columns must fit 7.5in of Letter width: smaller mono figures, wrapping titles. */
  .grid-table td { font-size: 8.5pt; }
  .grid-table thead th { font-size: 7.5pt; }
  .listings-table tbody th { min-width: 0; width: 28%; font-size: 9pt; }
  .listings-table tbody th small { font-size: 7.5pt; }
  .listings-table tr { break-inside: avoid; }
  .listings-table thead { display: table-header-group; }
  .cost-input { border: 0; padding: 0; min-height: 0; width: 8ch; background: none; }
  /* An empty box 1a field would print its $0.00 placeholder as if it were the seller's figure. */
  .box1a:has(input:placeholder-shown) { display: none; }
  .report-section { break-inside: avoid-page; }
  mark { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
