/* ==========================================================================
   Format library (see lib/send_invoice/invoice_formats.rb)

   Two groups of rules. The PARAMETRIC axes below (header arrangement, table
   treatment, palette) are each keyed off an attribute that is ABSENT on any
   template predating the library - so those templates keep the appearance
   defined above, and nothing here can regress them. The BESPOKE designs
   (data-format) come after, and are allowed to restyle the whole sheet.

   --invoice-tint / --invoice-ink are set inline from the chosen palette and
   fall back to the historical hairline and ink when no palette is set.
   ========================================================================== */

.template-preview {
  --invoice-tint: var(--line-soft);
  --invoice-ink: inherit;
}

/* The document wordmark. Hidden unless a format's header calls for it. */
.preview-doc-title {
  display: none;
  margin: 0 0 18px;
  color: var(--invoice-accent);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.01em;
  line-height: 1;
  text-transform: uppercase;
}

/* The accent glyph that precedes the company name (LOGO_MARKS). */
.preview-glyph {
  margin-right: 0.4em;
  color: var(--invoice-accent);
}

/* --- Axis 1: header arrangement ----------------------------------------
   split / stacked / left are the pre-existing values and are styled earlier in
   this file; right / center / band arrived with the reference set. */

.template-preview[data-header-align="right"] .preview-header {
  flex-direction: row-reverse;
}

.template-preview[data-header-align="right"] .preview-meta {
  text-align: left;
}

.template-preview[data-header-align="right"] .preview-doc-title,
.template-preview[data-header-align="center"] .preview-doc-title,
.template-preview[data-header-align="band"] .preview-doc-title {
  display: block;
}

.template-preview[data-header-align="right"] .preview-doc-title {
  text-align: right;
}

.template-preview[data-header-align="center"] .preview-header {
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.template-preview[data-header-align="center"] .preview-doc-title {
  text-align: center;
}

.template-preview[data-header-align="center"] .preview-brand {
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.template-preview[data-header-align="center"] .preview-meta {
  justify-items: center;
}

/* `band`: the wordmark sits reversed-out on a full-bleed accent bar. The
   negative margins bleed to the sheet edge, cancelling the sheet's padding -
   which is why the value tracks the three density paddings below. */
.template-preview[data-header-align="band"] .preview-doc-title {
  margin: -28px -28px 26px;
  padding: 22px 28px;
  color: #fff;
  background: var(--invoice-accent);
}

.template-preview[data-density="compact"][data-header-align="band"] .preview-doc-title {
  margin: -20px -20px 20px;
  padding: 16px 20px;
}

.template-preview[data-density="spacious"][data-header-align="band"] .preview-doc-title {
  margin: -38px -38px 30px;
  padding: 26px 38px;
}

.template-preview[data-header-align="band"] .preview-header {
  border-bottom-width: 1px;
}

/* --- Axis 2: table treatment ------------------------------------------- */

/* `filled`: reversed-out header row in the accent. */
.template-preview[data-table-style="filled"] .preview-line-items th {
  padding: 10px 8px;
  color: #fff;
  background: var(--invoice-accent);
  border-bottom: none;
}

.template-preview[data-table-style="filled"] .preview-line-items td {
  padding-left: 8px;
  padding-right: 8px;
}

/* `bordered`: every cell ruled in the palette tint. */
.template-preview[data-table-style="bordered"] .preview-line-items th,
.template-preview[data-table-style="bordered"] .preview-line-items td {
  padding: 9px 8px;
  border: 1px solid var(--invoice-tint);
}

.template-preview[data-table-style="bordered"] .preview-line-items th {
  color: var(--invoice-accent);
}

/* `striped`: alternating rows washed with the tint. */
.template-preview[data-table-style="striped"] .preview-line-items tbody tr:nth-child(even) {
  background: var(--invoice-tint);
}

.template-preview[data-table-style="striped"] .preview-line-items th {
  color: var(--invoice-accent);
  border-bottom: 1px solid var(--invoice-accent);
}

.template-preview[data-table-style="striped"] .preview-line-items td {
  padding-left: 8px;
  padding-right: 8px;
  border-bottom: none;
}

/* `minimal`: no rules at all bar a muted header underline. */
.template-preview[data-table-style="minimal"] .preview-line-items th {
  color: #888888;
  border-bottom: 2px solid #dddddd;
}

.template-preview[data-table-style="minimal"] .preview-line-items td {
  border-bottom: none;
}

/* `underline`: hairline under every row, in the palette tint. */
.template-preview[data-table-style="underline"] .preview-line-items th {
  color: var(--invoice-accent);
  border-bottom: 1px solid var(--invoice-accent);
}

.template-preview[data-table-style="underline"] .preview-line-items td {
  border-bottom: 1px solid var(--invoice-tint);
}

/* --- Axis 3: palette ---------------------------------------------------
   A palette supplies body ink and the tint. Accent stays independently
   editable (accent_color), so a merchant can keep a palette's structure and
   still brand it. Muted/label text is left alone - it reads as hierarchy, not
   palette. */

.template-preview[data-palette] {
  color: var(--invoice-ink);
}

.template-preview[data-palette] .totals-stack strong {
  color: var(--invoice-ink);
}

/* --- Bespoke designs ---------------------------------------------------
   Each is a named page from the reference set. These may restyle freely; they
   only ever apply when a merchant has explicitly picked that format. */

/* Freelancer Band: tinted logo panel, filled head, tinted grand-total row. */
.template-preview[data-format="freelancer_band"] {
  padding: 44px;
  background: #ffffff;
}

.template-preview[data-format="freelancer_band"] .preview-header {
  align-items: flex-start;
  border-bottom: none;
}

.template-preview[data-format="freelancer_band"] .preview-logo-mark {
  width: 96px;
  height: 96px;
  border-radius: 0;
  color: #3c3c3c;
  background: var(--invoice-tint, #ebe9e4);
  font-size: 24px;
}

.template-preview[data-format="freelancer_band"] .preview-line-items th {
  padding: 12px 10px;
  color: #3c3c3c;
  background: var(--invoice-tint, #ebe9e4);
  border-bottom: none;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-preview[data-format="freelancer_band"] .preview-line-items td {
  padding: 11px 10px;
  border-bottom: none;
}

.template-preview[data-format="freelancer_band"] .totals-stack span:last-child {
  padding: 8px 10px;
  background: var(--invoice-tint, #ebe9e4);
}

/* Wordmark Rule: letterspaced wordmark trailed by a long hairline. */
.template-preview[data-format="wordmark_rule"] {
  padding: 46px;
}

.template-preview[data-format="wordmark_rule"] .preview-doc-title {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-bottom: 34px;
  color: #2b2b2b;
  font-size: 44px;
  font-weight: 300;
  letter-spacing: 0.22em;
}

.template-preview[data-format="wordmark_rule"] .preview-doc-title::after {
  flex: 1;
  height: 1px;
  background: #9a9a9a;
  content: "";
}

.template-preview[data-format="wordmark_rule"] .preview-header {
  border-bottom: none;
}

.template-preview[data-format="wordmark_rule"] .preview-line-items th {
  color: #6b6b6b;
  border-bottom: 1px solid #9a9a9a;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.template-preview[data-format="wordmark_rule"] .preview-line-items td {
  border-bottom: none;
}

/* Centered Monogram: brand centered on a tinted band across the head.
   The band bleeds to the sheet edge via negative margins that cancel the
   sheet's own padding. Do NOT invert this by zeroing the sheet padding and
   re-padding each child: a table with `border-collapse: collapse` ignores its
   own padding, so the line items would bleed off the page. */
.template-preview[data-format="centered_monogram"] {
  padding: 40px;
}

.template-preview[data-format="centered_monogram"] .preview-doc-title {
  display: none;
}

.template-preview[data-format="centered_monogram"] .preview-header {
  flex-direction: column;
  align-items: center;
  margin: -40px -40px 34px;
  padding: 46px 40px;
  background: var(--invoice-tint, #e8e6e1);
  border-bottom: none;
  text-align: center;
}

.template-preview[data-format="centered_monogram"] .preview-brand {
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.template-preview[data-format="centered_monogram"] .preview-logo-mark {
  width: 78px;
  height: 78px;
  border-radius: 0;
  color: #2f2f2f;
  background: transparent;
  font-size: 34px;
}

.template-preview[data-format="centered_monogram"] .preview-meta {
  justify-items: center;
}

.template-preview[data-format="centered_monogram"] .preview-line-items th {
  border-bottom: 1px solid #6f6f6f;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Studio Neutral: quiet sheet, ruled table, nothing shouting. */
.template-preview[data-format="studio_neutral"] {
  padding: 44px;
  background: #fbfbf9;
}

.template-preview[data-format="studio_neutral"] .preview-header {
  padding-bottom: 20px;
  border-bottom: 1px solid #dcdcd6;
}

.template-preview[data-format="studio_neutral"] .preview-line-items th {
  color: #5f5f58;
  border-bottom: 1px solid #b9b9b1;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.template-preview[data-format="studio_neutral"] .preview-line-items td {
  border-bottom: 1px solid #ecece6;
}

/* Script Aesthetic: calligraphic wordmark over a warm sheet. */
.template-preview[data-format="script_aesthetic"] {
  padding: 48px;
  background: #f7f3ec;
}

.template-preview[data-format="script_aesthetic"] .preview-doc-title {
  display: block;
  margin-bottom: 30px;
  color: #2f2b26;
  font-family: "Invoice Script", "Great Vibes", cursive;
  font-size: 74px;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.template-preview[data-format="script_aesthetic"] .preview-header {
  border-bottom: none;
}

.template-preview[data-format="script_aesthetic"] .preview-logo-mark {
  color: #2f2b26;
  background: transparent;
  font-size: 20px;
}

.template-preview[data-format="script_aesthetic"] .preview-line-items th {
  color: #2f2b26;
  border-top: 1px solid #bdb5a6;
  border-bottom: 1px solid #bdb5a6;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.template-preview[data-format="script_aesthetic"] .preview-line-items td {
  border-bottom: none;
}

/* Wedding Ornament: tinted band, dotted row rules, payment panel. Column flex
   for the same reason as `gradient_header` - the band leads, the wordmark
   follows, and the DOM keeps the wordmark first. */
.template-preview[data-format="wedding_ornament"] {
  display: flex;
  flex-direction: column;
  padding: 40px;
  background: #ffffff;
}

.template-preview[data-format="wedding_ornament"] .preview-doc-title {
  display: block;
  margin: 0 0 16px;
  font-weight: 400;
  letter-spacing: 0.04em;
}

.template-preview[data-format="wedding_ornament"] .preview-header {
  flex-direction: column;
  align-items: center;
  order: -1;
  margin: -40px -40px 26px;
  padding: 30px 40px;
  background: var(--invoice-tint, #f3ece0);
  border-bottom: none;
  text-align: center;
}

.template-preview[data-format="wedding_ornament"] .preview-brand {
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.template-preview[data-format="wedding_ornament"] .preview-logo-mark {
  color: var(--invoice-accent);
  background: transparent;
  font-size: 30px;
}

.template-preview[data-format="wedding_ornament"] .preview-line-items th {
  border-bottom: 2px solid #4a4a4a;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.template-preview[data-format="wedding_ornament"] .preview-line-items td {
  border-bottom: 1px dotted #b9a98c;
}

.template-preview[data-format="wedding_ornament"] .totals-block {
  padding-top: 18px;
  background: var(--invoice-tint, #f9f4ea);
}

/* Geometric Teal: corner geometry, tinted bill-to strip, numbered rows. */
.template-preview[data-format="geometric_teal"] {
  padding: 44px;
  background: #f6f6ef;
}

.template-preview[data-format="geometric_teal"] .preview-doc-title {
  display: block;
  margin-bottom: 22px;
  font-size: 30px;
  letter-spacing: 0.06em;
  text-align: center;
}

.template-preview[data-format="geometric_teal"] .preview-header {
  border-bottom: none;
}

.template-preview[data-format="geometric_teal"] .preview-grid {
  padding: 20px 24px;
  background: var(--invoice-tint, #c3e6df);
}

.template-preview[data-format="geometric_teal"] .preview-line-items th {
  padding: 13px 10px;
  color: #2f3436;
  background: var(--invoice-accent);
  border-bottom: none;
  font-weight: 800;
}

.template-preview[data-format="geometric_teal"] .preview-line-items td {
  padding: 14px 10px;
  border-bottom: none;
}

.template-preview[data-format="geometric_teal"] .totals-block {
  border-top: 2px solid #2f3436;
}

/* Gradient Header: full-width gradient head, circular mark, gradient totals.
   Column flex so the header can `order` itself above the wordmark: in this
   design the gradient band comes first, but the wordmark precedes it in the
   DOM (where it belongs for every other format, and for screen readers). */
.template-preview[data-format="gradient_header"] {
  display: flex;
  flex-direction: column;
  padding: 44px;
  background: #ffffff;
}

.template-preview[data-format="gradient_header"] .preview-doc-title {
  display: block;
  margin: 0 0 20px;
  color: #1c1c1c;
  font-size: 52px;
}

/* The header bleeds edge-to-edge and sits ABOVE the wordmark, so it also has to
   move out of the doc-title's way - hence `order`, which the flex parent honours
   for both. */
.template-preview[data-format="gradient_header"] .preview-header {
  align-items: center;
  order: -1;
  margin: -44px -44px 26px;
  padding: 30px 44px;
  background: linear-gradient(100deg, var(--invoice-accent), color-mix(in srgb, var(--invoice-accent) 55%, white));
  border-bottom: none;
  color: #ffffff;
}

.template-preview[data-format="gradient_header"] .preview-header h2,
.template-preview[data-format="gradient_header"] .preview-header .muted,
.template-preview[data-format="gradient_header"] .preview-meta {
  color: #ffffff;
}

.template-preview[data-format="gradient_header"] .preview-logo-mark {
  width: 68px;
  height: 68px;
  border-radius: 999px;
  color: #ffffff;
  background: #1c1c1c;
}

/* The gradient goes on the ROW, not each cell: per-cell gradients restart at
   every column and read as vertical banding. */
.template-preview[data-format="gradient_header"] .preview-line-items thead tr {
  background: linear-gradient(100deg, var(--invoice-accent), color-mix(in srgb, var(--invoice-accent) 55%, white));
}

.template-preview[data-format="gradient_header"] .preview-line-items th {
  padding: 14px 10px;
  color: #ffffff;
  background: transparent;
  border-bottom: none;
}

.template-preview[data-format="gradient_header"] .preview-line-items td {
  padding: 13px 10px;
}

.template-preview[data-format="gradient_header"] .totals-stack span:last-child {
  padding: 12px 16px;
  color: #ffffff;
  background: linear-gradient(100deg, var(--invoice-accent), color-mix(in srgb, var(--invoice-accent) 55%, white));
}

.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: var(--muted);
  background: #e9edf2;
  font-size: 12px;
  font-weight: 760;
}

.step.is-active {
  color: #ffffff;
  background: var(--accent);
}

.print-body {
  padding: 24px;
  background: #f3f4f6;
  /* Printable documents keep the size they were laid out at; the app's 14px
     body is for screens, not paper. */
  font-size: 13px;
}

.print-toolbar {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 12px;
}

.print-sheet {
  max-width: 920px;
  margin: 0 auto;
  padding: 40px;
}

/* --- Packing slip preview -------------------------------------------------
   The sheet renders at its real paper size (width/height set inline in inches
   by the view, from PageSize), so A4 vs 4x6 vs a custom size all preview true
   to scale. Layout (standard/compact) is chosen via [data-layout]. */
.pack-sheet {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 0.5in;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: #24282d;
  font-family: var(--pack-font, inherit);
  font-size: 12px;
  line-height: 1.4;
}
.pack-sheet[data-layout="compact"] { padding: 0.2in; font-size: 11px; }
.pack-sheet p { margin: 0; }
.pack-muted { color: #667085; }
.pack-accent { color: var(--pack-accent); }
.pack-eyebrow {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: #667085; margin-bottom: 4px;
}

.pack-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.pack-brand { display: flex; gap: 12px; align-items: flex-start; }
.pack-brand h2 { margin: 2px 0 0; font-size: 18px; }
.pack-logo-mark {
  width: 42px; height: 42px; border-radius: 6px; flex: none;
  background: var(--pack-accent); color: #fff; font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
}
.pack-logo-img { width: 42px; height: 42px; object-fit: contain; }
.pack-meta { text-align: right; display: flex; flex-direction: column; gap: 1px; }
.pack-meta strong { font-size: 14px; }
.pack-meta span { color: #667085; font-size: 11px; }
.pack-accent-rule { height: 2px; background: var(--pack-accent); margin: 14px 0 16px; }
.pack-rule { height: 1px; background: var(--line); margin: 10px 0; }

.pack-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 18px; }
.pack-grid p { margin: 1px 0; }

.pack-items { width: 100%; border-collapse: collapse; }
.pack-items th {
  text-align: left; font-size: 10px; text-transform: uppercase; letter-spacing: 0.03em;
  background: var(--pack-accent); color: #fff; padding: 7px 8px;
}
.pack-items td { padding: 8px; border-bottom: 1px solid var(--line-soft); }
.pack-items .r { text-align: right; }

.pack-footer { margin-top: 16px; }
.pack-footer p { margin: 3px 0; }
.pack-sign { margin-top: 18px; }

/* Return-form checklists. The tick box is a drawn square in both surfaces - the PDF
   renderer uses Prawn's built-in fonts, which cannot print a "☐" at all, so a glyph
   here would have the preview and the PDF disagree. */
.pack-checklist { list-style: none; margin: 6px 0 12px; padding: 0; display: grid; gap: 7px; }
.pack-checklist.is-two-up { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 18px; }
.pack-checklist li { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.pack-tick {
  flex: 0 0 auto; width: 11px; height: 11px; margin-top: 2px;
  border: 1px solid var(--muted); border-radius: 2px;
}
.pack-sign-line { display: inline-block; width: 180px; border-bottom: 1px solid #667085; }

.pack-compact-head { display: flex; flex-direction: column; gap: 2px; }
.pack-number { font-size: 18px; font-weight: 700; }
.pack-compact-items { list-style: none; margin: 0; padding: 0; }
.pack-compact-items li { padding: 2px 0; }

/* Packing template library thumbnails (paper-shape preview at true ratio). */

.pack-thumb-paper {
  background: #fff; border: 1px solid var(--line); border-radius: 3px;
  height: 100%; max-height: 122px; padding: 8px 7px;
  display: flex; flex-direction: column; gap: 5px; box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.pack-thumb-paper.is-wide { height: auto; width: 122px; }
.pack-thumb-bar { height: 4px; border-radius: 2px; background: #e2e5e1; }
.pack-thumb-bar.accent { background: var(--accent); width: 60%; }
.pack-thumb-bar.short { width: 40%; }

/* Packing template editor.
   Shares the invoice editor's shell (.editor-topbar / .split-layout /
   .invoice-editor-shell / .acc-item): the control rail scrolls inside its own
   card so the preview stays put. It used to be a plain two-column grid whose
   left column ran ~1600px past the preview, leaving half the page as dead grey
   space and the sheet far off screen by the time you reached the last field. */
/* [hidden] must beat the display rules on .field / preview blocks. */
[data-pack-editor] [hidden] { display: none !important; }
.pack-custom-row { display: flex; align-items: center; gap: 8px; }
.pack-custom-row input[type="number"] { width: 84px; }
.pack-custom-row select { width: 68px; }
.pack-toggle-list { display: flex; flex-direction: column; gap: 8px; }

/* Layout picker: two cards, not a dropdown. The choice swaps the whole document
   (compact drops the branding), which a <select> gave no hint of. */
.pack-layout-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pack-layout-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
}
.pack-layout-card:hover { border-color: var(--line-strong); }
.pack-layout-card.is-selected { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
/* The radio drives selection; hidden so the whole card is the target, but it
   stays focusable for the keyboard. */
.pack-layout-card input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.pack-layout-card:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.pack-layout-name { font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.pack-layout-hint { font-size: 10.5px; color: var(--faint); line-height: 1.3; }

/* Miniature of each layout, drawn in CSS - a rule, a couple of text lines and a
   table band for standard; a narrow receipt for compact. */
.pack-layout-thumb {
  height: 46px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  display: block;
  position: relative;
  overflow: hidden;
}
.pack-layout-thumb::before,
.pack-layout-thumb::after { content: ""; position: absolute; background: var(--line-strong); }
.pack-layout-thumb-standard::before {
  left: 7px; right: 7px; top: 9px; height: 2px; background: var(--accent);
}
.pack-layout-thumb-standard::after {
  left: 7px; right: 7px; top: 18px; height: 12px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 2px, transparent 2px 5px);
}
.pack-layout-thumb-compact::before {
  left: 26px; right: 26px; top: 6px; bottom: 6px; background: #fff; border: 1px solid var(--line);
}
.pack-layout-thumb-compact::after {
  left: 30px; right: 30px; top: 12px; height: 20px;
  background: repeating-linear-gradient(to bottom, var(--line) 0 2px, transparent 2px 5px);
}

/* Return reasons: a picked list, not free text. Each row prints as its own
   tick-box on the return form, so they read as discrete items here too. */
.pack-reason-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.pack-reason-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px 6px 10px;
  font-size: 12.5px;
  background: var(--panel-subtle);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.pack-reason-remove {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--faint);
  font-size: 16px;
  line-height: 1;
  padding: 2px 4px;
  cursor: pointer;
  border-radius: 4px;
}
.pack-reason-remove:hover { color: var(--text); background: var(--line-soft); }
.pack-reason-remove:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pack-reason-add { display: flex; gap: 6px; margin-top: 8px; }
.pack-reason-add input { flex: 1; min-width: 0; }
.pack-reason-add button { flex: none; }
.pack-reason-add input:disabled { background: var(--line-soft); cursor: not-allowed; }

.pack-editor-preview { position: sticky; top: calc(var(--topbar-height) + 16px); display: grid; gap: 8px; align-content: start; }
.pack-preview-bar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 2px;
}
.pack-preview-dims { font-size: 11.5px; font-weight: 650; color: var(--muted); font-variant-numeric: tabular-nums; }
.pack-preview-frame {
  background: #ececea; border: 1px solid var(--line); border-radius: 12px;
  padding: 16px; display: flex; justify-content: center; align-items: flex-start;
  /* auto, not hidden: a full A4 is taller than the viewport even scaled, and
     clipping it would hide the footer the merchant just switched on. */
  overflow: auto; max-height: calc(100vh - 160px);
}
/* The sheet renders at true pixel size and the scaler shrinks it to fit, so the
   proportions stay honest - a 4x6 label must read as a label beside an A4 page. */
.pack-sheet-scaler { transform-origin: top center; flex: none; }
.pack-editor-preview .pack-sheet { box-shadow: 0 2px 8px rgba(0, 0, 0, .08); }

@media (max-width: 1023px) {
  .pack-editor-preview { position: static; }
}

/* ---- lg breakpoint: below 1024px the top bar's links become a slide-in drawer
   and the mobile top bar takes over navigation. ---- */
@media (max-width: 1023px) {
  .app-topbar { gap: 12px; padding: 0 16px; }
  .topbar-burger { display: inline-flex; }
  .topbar-brand { flex: 1; max-width: none; }

  /* The section links become the slide-in drawer. */
  .topbar-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 60;
    width: min(300px, 84vw);
    padding: 16px 12px;
    background: var(--panel);
    border-right: 1px solid var(--line);
    transform: translateX(-100%);
    visibility: hidden;
    /* Hidden only once the slide-out ends. Opening must not wait: a link
       still visibility:hidden can't take focus, and the drawer hands it one
       the moment it opens. */
    transition: transform 0.24s ease, visibility 0s linear 0.24s;
    overflow-y: auto;
  }
  html.nav-open .topbar-nav {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.24s ease, visibility 0s;
    box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.35);
  }
  .nav-stack { flex-direction: column; gap: 2px; height: auto; }
  .nav-link,
  .nav-link--util {
    width: auto;
    height: auto;
    min-height: 42px;
    padding: 0 10px;
    gap: 11px;
    margin: 0;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--muted);
    justify-content: flex-start;
    align-self: stretch;
  }
  .nav-link--util + .nav-link--util { margin-left: 0; }
  .nav-link .nav-icon { display: block; width: 18px; height: 18px; }
  .nav-link--util .nav-label { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  .nav-link:hover { background: var(--hover); color: var(--text); }
  .nav-link.is-active,
  .nav-link--util.is-active { background: var(--accent-weak); color: var(--text); font-weight: 600; }
  .nav-link.is-active .nav-icon { color: var(--accent); }
  .nav-crown { margin-left: auto; }
  .nav-count,
  .nav-link--util .nav-count { position: static; margin-left: auto; box-shadow: none; }
  .topbar-search { order: -1; margin: 0 0 10px; }
  .topbar-search-field { width: 100%; }
  .jump-results { left: 0; right: 0; width: auto; }

  .nav-scrim {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(22, 24, 26, 0.36);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.24s ease, visibility 0.24s ease;
  }

  html.nav-open .nav-scrim {
    opacity: 1;
    visibility: visible;
  }

  html.nav-open,
  html.nav-open body {
    overflow: hidden;
  }

  /* Content-level collapses retained from the previous shell breakpoint. */
  .split-layout {
    grid-template-columns: 1fr;
  }

  .split-layout > .section-card,
  .template-preview {
    position: static;
    max-height: none;
  }
}

@media (max-width: 720px) {
  .trial-banner { grid-template-columns: 1fr; justify-items: center; }
  .trial-banner > span:first-child,
  .trial-banner > .trial-banner-actions { grid-column: 1; justify-self: center; }

  .toolbar,
  .trial-banner,
  .sync-banner,
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }

  /* Phones and tablets follow the same gutter as the desktop rather than a
     hardcoded 16px, so the app bleeds consistently at every size. Cards carry
     their own padding, so their text still clears the screen edge. */
  .page-content {
    padding-left: var(--page-gutter);
    padding-right: var(--page-gutter);
  }

  .trial-banner,
  .sync-banner {
    padding-left: max(var(--page-gutter), 16px);
    padding-right: max(var(--page-gutter), 16px);
  }

  .grid-two,
  .preview-grid {
    grid-template-columns: 1fr;
  }

  .sync-request-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .sync-request-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .value {
    font-size: 24px;
  }

  .public-shell {
    padding: 16px;
  }
}

@media print {
  .app-topbar,
  .nav-scrim,
  .trial-banner,
  .sync-banner,
  .toast-region,
  .print-toolbar,
  .button,
  .button-secondary,
  .button-ghost {
    display: none !important;
  }

  .app-frame,
  .workspace,
  .page-content {
    display: block;
    padding: 0;
  }

  .template-preview,
  .print-sheet {
    position: static;
    box-shadow: none;
    border: 0;
  }
}

/* Status pill */
.dashboard .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 660;
  color: var(--muted);
  white-space: nowrap;
}

.dashboard .pill.is-ok {
  color: var(--accent);
  border-color: var(--accent-weak);
  background: var(--accent-weak);
}

/* Section card header row with trend chip */

.dashboard .delta {
  font-size: 12px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dashboard .delta.up {
  color: var(--accent);
}

.dashboard .delta.down {
  color: var(--red);
}

/* Supporting KPIs: a vertical stack that fills the rows' height so both
   columns line up top and bottom. */

.dashboard .usage {
  margin-top: 14px;
}

