/* ============================================================
   Fuel Bill Generator — Premium industrial toolkit aesthetic
   ============================================================ */

:root {
  --ink: #12151a;
  --ink-soft: #1c2129;
  --panel: #161a21;
  --panel-2: #1e2430;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #e8eaed;
  --muted: #8b939e;
  --faint: #5c6570;
  --accent: #e8a317;
  --accent-dim: rgba(232, 163, 23, 0.14);
  --accent-text: #1a1408;
  --ok: #3dba7a;
  --err: #e85d5d;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
  --font-ui: "Sora", system-ui, sans-serif;
  /* Thermal receipt — matched to docs/reference_site.html (NOOBius) */
  --receipt-font: 'pixFueler-A', 'Courier New', Courier, monospace;
  --receipt-font-weight: 600;
  --receipt-width: 302px;
  --receipt-pad-top: 24px;
  --receipt-pad-x: 20px;
  --receipt-pad-bottom: 22px;
  --receipt-font-size: 13px;
  --receipt-logo-width: 76px;
  --receipt-line-height: 1.12;
  --ink-photo: rgba(55, 55, 57, 0.82);
  --paper: #ececec;
  --photo-blur: 0.72px;
  --photo-contrast: 0.96;
  --photo-brightness: 1.02;
  --photo-saturate: 0.9;
  --preview-bg: #0d1014;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 163, 23, 0.09), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(60, 90, 120, 0.18), transparent 50%),
    linear-gradient(165deg, #0a0c10 0%, #12161d 45%, #0e1116 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px;
  mix-blend-mode: overlay;
  z-index: 0;
}

/* ---- Layout ---- */

.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 40px;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.95fr);
  gap: 16px 24px;
  align-items: start;
  box-sizing: border-box;
}

.workspace {
  grid-column: 1 / -1;
  display: grid;
  /* Form slightly wider than preview — receipt itself stays ~302px centered */
  grid-template-columns: minmax(400px, 1.2fr) minmax(340px, 0.9fr);
  gap: 24px;
  align-items: stretch;
}

.workspace[hidden] {
  display: none !important;
}

.bulk-preview-workspace {
  grid-template-columns: 1fr;
}

/* Single / bulk editor + preview share one viewport height */
#workspace-single,
#workspace-bulk {
  --panel-h: calc(100vh - 148px);
}

#workspace-single .controls,
#workspace-single .preview-pane,
#workspace-bulk .controls,
#workspace-bulk .preview-pane {
  height: var(--panel-h);
  max-height: var(--panel-h);
  min-height: var(--panel-h);
  box-sizing: border-box;
}

#workspace-bulk .bulk-side {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#workspace-bulk .bulk-summary-card {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

#workspace-bulk .bulk-panel-actions {
  flex-shrink: 0;
  margin-top: auto;
}

@media (max-width: 960px) {
  .app,
  .workspace {
    grid-template-columns: 1fr;
    padding-left: 16px;
    padding-right: 16px;
  }

  .app {
    padding: 20px 16px 40px;
  }

  #workspace-single .controls,
  #workspace-single .preview-pane,
  #workspace-bulk .controls,
  #workspace-bulk .preview-pane {
    height: auto;
    max-height: none;
    min-height: 0;
  }

  #workspace-single .controls,
  #workspace-bulk .controls {
    max-height: min(70vh, 640px);
  }

  #workspace-single .preview-pane,
  #workspace-bulk .preview-pane {
    min-height: 480px;
  }

  .preview-pane {
    position: static !important;
    order: -1;
  }

  .chrome-hidden {
    display: none !important;
  }
}

/* ---- Brand header ---- */

.brand {
  grid-column: 1 / -1;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 8px;
  animation: rise 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(145deg, var(--accent), #c4780a);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(232, 163, 23, 0.28);
}

.brand-icon svg,
.brand-logo {
  width: 28px;
  height: 28px;
  display: block;
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.4vw, 2rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.brand h1 span {
  color: var(--accent);
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 400;
}

.badge {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-dim);
  border: 1px solid rgba(232, 163, 23, 0.25);
  padding: 6px 12px;
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- Panels ---- */

.panel {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: rise 0.75s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.controls {
  padding: 16px 14px 14px;
  animation-delay: 0.06s;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.panel-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  position: sticky;
  bottom: 0;
  background: linear-gradient(to top, var(--panel) 70%, transparent);
  padding-bottom: 4px;
}

.btn-block {
  width: 100%;
  min-width: 0;
}

.preview-pane {
  position: relative;
  top: auto;
  padding: 16px;
  animation-delay: 0.14s;
  background:
    linear-gradient(180deg, var(--panel) 0%, var(--ink-soft) 100%);
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.preview-pane .panel-head {
  flex-shrink: 0;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.icon-btn:hover {
  color: var(--text);
  border-color: var(--accent);
  background: var(--accent-dim);
}

/* ---- Form ---- */

.section {
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section:last-of-type {
  border-bottom: none;
  margin-bottom: 12px;
}

.section-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 10px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field-grid .full {
  grid-column: 1 / -1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field[hidden],
[hidden] {
  display: none !important;
}

.field label {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 500;
}

.field input,
.field select {
  appearance: none;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.field input[type='checkbox'] {
  appearance: auto;
  -webkit-appearance: checkbox;
  width: 1.05rem;
  height: 1.05rem;
  min-width: 1.05rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.field input:focus,
.field select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%238b939e' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
}

.field-input-wrap {
  position: relative;
  display: flex;
  align-items: stretch;
}

.field-input-wrap input {
  width: 100%;
  padding-right: 36px;
}

.field-rand {
  appearance: none;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.field-rand:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.field input[type='datetime-local'] {
  min-height: 42px;
}

.ghost-btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--panel-2);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  height: 34px;
}

.ghost-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.ghost-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hint {
  margin: 8px 0 0;
  font-size: 0.75rem;
  color: var(--faint);
}

.range-value {
  float: right;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.field-action .ghost-btn-block {
  width: 100%;
  height: 40px;
  justify-content: center;
}

/* Segmented control */

.seg-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  border: 1px solid var(--line-strong);
}

.seg-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.seg-btn:hover {
  color: var(--text);
}

.seg-btn.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.address-panel {
  margin-top: 2px;
}

.address-list {
  margin-top: 10px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--ink);
}

.address-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-align: left;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s;
}

.address-item:last-child {
  border-bottom: none;
}

.address-item:hover {
  background: rgba(255, 255, 255, 0.04);
}

.address-item.active {
  background: var(--accent-dim);
}

.addr-title {
  font-size: 0.84rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.addr-sub {
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.35;
}

.addr-badge {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid rgba(232, 163, 23, 0.35);
  border-radius: 999px;
  padding: 1px 6px;
}

.address-empty {
  padding: 16px 12px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.chip-group {
  display: grid;
  gap: 8px;
}

.chip-group.papers {
  grid-template-columns: 1fr 1fr;
}

.chip {
  position: relative;
  display: block;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.chip:hover {
  border-color: rgba(232, 163, 23, 0.4);
}

.chip.active {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-title {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.chip-desc {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: var(--muted);
}

.chip-sm {
  padding: 10px 12px;
  text-align: center;
}

.chip-sm .chip-title {
  font-size: 0.8rem;
}

/* Toggle */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle span {
  position: absolute;
  inset: 0;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: 0.2s;
}

.toggle span::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: 0.2s;
}

.toggle input:checked + span {
  background: var(--accent-dim);
  border-color: var(--accent);
}

.toggle input:checked + span::after {
  transform: translateX(18px);
  background: var(--accent);
}

#bulk-panel {
  margin-top: 14px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  border: 1px dashed var(--line-strong);
}

#bulk-panel[hidden] {
  display: none;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: auto;
  accent-color: var(--accent);
  pointer-events: auto;
}

/* Actions */

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-sm);
  padding: 13px 16px;
  font-family: var(--font-ui);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, opacity 0.2s;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.btn-primary {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #f0b429, #d4890a);
  color: var(--accent-text);
  box-shadow: 0 8px 24px rgba(232, 163, 23, 0.28);
}

.btn-primary:not(:disabled):hover {
  box-shadow: 0 12px 28px rgba(232, 163, 23, 0.38);
}

.btn-secondary {
  background: var(--ink);
  color: var(--text);
  border: 1px solid var(--line-strong);
}

.btn-secondary:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent);
}

.status {
  min-height: 1.2em;
  margin-top: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--err);
}

.disclaimer {
  margin: 14px 0 0;
  font-size: 0.7rem;
  line-height: 1.45;
  color: var(--faint);
  text-align: center;
}

/* ---- Preview ---- */

.preview-stage {
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 163, 23, 0.06), transparent 60%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 11px,
      rgba(255, 255, 255, 0.015) 11px,
      rgba(255, 255, 255, 0.015) 12px
    ),
    var(--preview-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 28px 16px;
}

#receipt-preview {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* ---- Receipt (Noobius-style thermal slip) ---- */

.receipt-wrapper {
  width: 100%;
  max-width: calc(var(--receipt-width) + 24px);
  margin-inline: auto;
  padding: 22px 0 28px;
  filter:
    drop-shadow(0 10px 28px rgba(15, 23, 42, 0.18))
    contrast(var(--photo-contrast))
    brightness(var(--photo-brightness))
    saturate(var(--photo-saturate));
}

.receipt-wrapper.wrapper-flat {
  padding: 14px 0;
}

.receipt-wrapper.has-photo-blur {
  filter:
    drop-shadow(0 10px 28px rgba(15, 23, 42, 0.18))
    contrast(var(--photo-contrast))
    brightness(var(--photo-brightness))
    saturate(var(--photo-saturate))
    blur(var(--photo-blur));
}

.receipt-wrapper.is-live .receipt,
.receipt.is-live {
  animation: none !important;
}

.receipt,
.receipt-wrapper .receipt,
.receipt-wrapper .receipt * {
  font-family: var(--receipt-font);
}

.receipt {
  width: var(--receipt-width);
  position: relative;
  background-color: var(--paper);
  background-image: var(--paper-texture);
  background-repeat: var(--paper-repeat, no-repeat);
  background-size: var(--paper-size, cover);
  background-position: var(--paper-position, center center);
  padding: var(--receipt-pad-top) var(--receipt-pad-x) var(--receipt-pad-bottom);
  font-family: var(--receipt-font);
  font-size: var(--receipt-font-size);
  font-weight: var(--receipt-font-weight);
  line-height: var(--receipt-line-height);
  color: var(--ink-photo);
  letter-spacing: 0.01em;
  -webkit-font-smoothing: grayscale;
  -moz-osx-font-smoothing: grayscale;
  filter: contrast(1.06) brightness(1.01) saturate(0.92);
  box-shadow: none;
  animation: slip-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) both;
  overflow: visible;
  text-transform: none;
}

.receipt-content {
  position: relative;
  z-index: 1;
}

.receipt-grain {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: none;
  opacity: 0.07;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='1.1' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
}

.receipt.has-grain .receipt-grain {
  display: block;
}

.receipt-header,
.receipt-body,
.receipt-footer,
.welcome,
.station-name,
.company-name,
.receipt-line,
.stars,
.thank-you {
  color: var(--ink-photo);
  font-weight: var(--receipt-font-weight);
  text-shadow:
    0 0 0.55px rgba(55, 55, 57, 0.45),
    0.35px 0 0.45px rgba(55, 55, 57, 0.28);
  opacity: 0.98;
}

/* Torn thermal-paper edges */
.receipt.has-tears::before,
.receipt.has-tears::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  z-index: 3;
  background-color: var(--paper);
  background-image: var(--paper-texture);
  background-repeat: var(--paper-repeat, no-repeat);
  background-size: var(--paper-size, cover);
  background-position: var(--paper-position, center center);
}

.receipt.has-tears::before {
  top: -18px;
  clip-path: polygon(
    0% 100%, 1.5% 35%, 3% 92%, 4.5% 18%, 6% 88%, 7.5% 28%, 9% 95%, 10.5% 12%,
    12% 82%, 13.5% 42%, 15% 90%, 16.5% 22%, 18% 78%, 19.5% 48%, 21% 94%,
    22.5% 15%, 24% 85%, 25.5% 38%, 27% 92%, 28.5% 25%, 30% 80%, 31.5% 55%,
    33% 96%, 34.5% 18%, 36% 88%, 37.5% 32%, 39% 90%, 40.5% 12%, 42% 82%,
    43.5% 45%, 45% 94%, 46.5% 20%, 48% 76%, 49.5% 50%, 51% 92%, 52.5% 28%,
    54% 86%, 55.5% 38%, 57% 95%, 58.5% 15%, 60% 84%, 61.5% 52%, 63% 90%,
    64.5% 22%, 66% 78%, 67.5% 42%, 69% 94%, 70.5% 18%, 72% 88%, 73.5% 35%,
    75% 92%, 76.5% 25%, 78% 82%, 79.5% 48%, 81% 96%, 82.5% 12%, 84% 86%,
    85.5% 38%, 87% 90%, 88.5% 20%, 90% 78%, 91.5% 55%, 93% 94%, 94.5% 28%,
    96% 84%, 97.5% 42%, 99% 92%, 100% 100%
  );
}

.receipt.has-tears::after {
  bottom: -18px;
  clip-path: polygon(
    0% 0%, 1.5% 65%, 3% 8%, 4.5% 82%, 6% 12%, 7.5% 72%, 9% 5%, 10.5% 88%,
    12% 18%, 13.5% 58%, 15% 10%, 16.5% 78%, 18% 22%, 19.5% 52%, 21% 6%,
    22.5% 85%, 24% 15%, 25.5% 62%, 27% 8%, 28.5% 75%, 30% 20%, 31.5% 45%,
    33% 4%, 34.5% 82%, 36% 12%, 37.5% 68%, 39% 10%, 40.5% 88%, 42% 18%,
    43.5% 55%, 45% 6%, 46.5% 80%, 48% 24%, 49.5% 50%, 51% 8%, 52.5% 72%,
    54% 14%, 55.5% 62%, 57% 5%, 58.5% 85%, 60% 16%, 61.5% 48%, 63% 10%,
    64.5% 78%, 66% 22%, 67.5% 58%, 69% 6%, 70.5% 82%, 72% 12%, 73.5% 65%,
    75% 8%, 76.5% 78%, 78% 18%, 79.5% 52%, 81% 4%, 82.5% 88%, 84% 14%,
    85.5% 62%, 87% 10%, 88.5% 80%, 90% 22%, 91.5% 45%, 93% 6%, 94.5% 72%,
    96% 16%, 97.5% 58%, 99% 8%, 100% 0%
  );
}

.receipt-header {
  text-align: center;
  margin-bottom: 14px;
}

.bp-logo {
  display: inline-block;
  margin-bottom: 8px;
}

.bp-logo img {
  display: block;
  width: var(--receipt-logo-width);
  height: auto;
  margin: 0 auto;
  opacity: 0.88;
  filter: contrast(0.88) brightness(1.08) grayscale(1) blur(0.2px);
}

.company-name {
  font-family: var(--receipt-font);
  font-size: calc(var(--receipt-font-size) + 1px);
  font-weight: 700;
  line-height: 1.15;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
}

.welcome,
.station-name,
.receipt-line,
.stars,
.thank-you {
  font-family: var(--receipt-font);
  font-size: var(--receipt-font-size);
  line-height: var(--receipt-line-height);
  margin: 0;
}

.receipt-body {
  margin-top: 0;
  text-align: left;
}

.receipt-section + .receipt-section {
  margin-top: 14px;
}

.receipt-line {
  white-space: pre;
  margin: 0;
  padding: 0;
}

.receipt-footer {
  text-align: center;
  margin-top: 16px;
}

.receipt.no-bg {
  background-image: none !important;
}

/* Plain-paper templates — faded ink so the slip looks aged */
.receipt.paper-plain {
  --ink-photo: rgba(78, 74, 68, 0.58);
  color: var(--ink-photo);
}

.receipt.paper-plain .receipt-header,
.receipt.paper-plain .receipt-body,
.receipt.paper-plain .receipt-footer,
.receipt.paper-plain .welcome,
.receipt.paper-plain .station-name,
.receipt.paper-plain .company-name,
.receipt.paper-plain .receipt-line,
.receipt.paper-plain .stars,
.receipt.paper-plain .thank-you {
  color: var(--ink-photo);
  text-shadow:
    0 0 0.45px rgba(78, 74, 68, 0.28),
    0.25px 0 0.35px rgba(78, 74, 68, 0.18);
  opacity: 0.92;
}

.receipt.paper-plain .bp-logo img {
  filter: contrast(0.88) brightness(1.08) grayscale(1) opacity(0.72);
}

.receipt.font-courier,
.receipt.font-courier * {
  font-family: 'Courier New', Courier, monospace !important;
  font-weight: 600;
  letter-spacing: 0.03em;
}

.receipt.layout-basic {
  padding: calc(var(--receipt-pad-top) - 2px) var(--receipt-pad-x) calc(var(--receipt-pad-bottom) - 8px);
  filter: contrast(0.98) brightness(1.01) saturate(0.95);
}

.receipt.layout-basic .receipt-header {
  text-align: left;
  margin-bottom: 10px;
}

.receipt.layout-basic .bp-logo img {
  width: 64px;
  margin-left: 0;
}

.receipt.layout-basic .welcome {
  display: none;
}

.receipt.layout-basic .company-name {
  font-size: var(--receipt-font-size);
  margin-bottom: 2px;
}

.receipt.layout-basic .station-name {
  letter-spacing: 0.04em;
}

.receipt.layout-basic .receipt-line {
  letter-spacing: 0.02em;
}

/* Capture offscreen — keep in layout for reliable html2canvas */
.capture-host {
  position: fixed;
  left: 0;
  top: 0;
  transform: translate(-120vw, 0);
  z-index: 0;
  pointer-events: none;
  opacity: 1;
}

.capture-host .receipt {
  animation: none !important;
}

.capture-host .receipt-wrapper {
  filter: none !important;
  padding: 0 !important;
}

/* Animations */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slip-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---- Brand actions / theme ---- */

.brand-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
  min-height: 40px;
}

/* Keep header width stable when Random fill is toggled per product */
#btn-random-fill[hidden] {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}

/* ---- Mode tabs ---- */

.mode-tabs {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  width: fit-content;
  max-width: 100%;
  overflow-x: auto;
}

.mode-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.active {
  background: var(--accent-dim);
  color: var(--accent);
}

.chrome-tabs {
  display: none;
  gap: 6px;
  margin-bottom: 14px;
}

@media (max-width: 960px) {
  .chrome-tabs {
    display: flex;
  }
}

.chrome-tab {
  flex: 1;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.chrome-tab.active {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* ---- Collapsible folds ---- */

.fold {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  margin-bottom: 10px;
  overflow: hidden;
}

.fold-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  user-select: none;
}

.fold-summary::-webkit-details-marker {
  display: none;
}

.fold-summary::after {
  content: "";
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-top: -4px;
}

.fold[open] > .fold-summary::after {
  transform: rotate(-135deg);
  margin-top: 4px;
}

.fold-title {
  display: block;
  font-weight: 650;
  font-size: 0.95rem;
  color: var(--text);
}

.fold-desc {
  display: block;
  margin-top: 2px;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 400;
}

.fold-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.field.full {
  grid-column: 1 / -1;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-row input {
  flex: 1;
  min-width: 0;
}

.ghost-btn-block {
  width: 100%;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  user-select: none;
}

.check input {
  width: auto !important;
  height: auto !important;
  min-width: 1.05rem;
  accent-color: var(--accent);
  pointer-events: auto;
}

/* ---- Sticky actions ---- */

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(10, 12, 16, 0.96), rgba(10, 12, 16, 0.88) 70%, transparent);
  pointer-events: none;
}

.sticky-actions[hidden] {
  display: none !important;
}

.sticky-actions .btn {
  pointer-events: auto;
  position: relative;
  z-index: 41;
  min-width: 160px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

html[data-theme="light"] .sticky-actions {
  background: linear-gradient(to top, rgba(245, 242, 236, 0.96), rgba(245, 242, 236, 0.88) 70%, transparent);
}

/* ---- Preview watermark ---- */

.preview-watermark {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  font-family: var(--font-ui);
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: rgba(180, 40, 40, 0.18);
  transform: rotate(-28deg);
  z-index: 5;
  text-transform: uppercase;
}

.preview-watermark.sample-disclaimer {
  font-size: clamp(0.55rem, 2.8vw, 0.78rem);
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-align: center;
  padding: 12%;
  color: rgba(160, 24, 24, 0.34);
  text-transform: none;
  font-weight: 800;
}

.receipt {
  position: relative;
}

.capture-host .preview-watermark:not(.sample-disclaimer) {
  display: none !important;
}

.capture-host .preview-watermark.sample-disclaimer {
  display: grid !important;
}

/* ---- Bulk UI ---- */

.bulk-summary-card {
  padding: 8px 4px 16px;
}

.summary-dl {
  margin: 0;
  display: grid;
  gap: 10px;
}

.summary-dl > div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.88rem;
}

.summary-dl dt {
  margin: 0;
  color: var(--muted);
}

.summary-dl dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
}

.bulk-month-table {
  width: 100%;
  border-collapse: collapse;
  margin: 14px 0 8px;
  font-size: 0.75rem;
}

.bulk-month-table th,
.bulk-month-table td {
  padding: 6px 4px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.bulk-month-table th {
  color: var(--muted);
  font-weight: 600;
}

.bulk-warnings {
  margin: 10px 0 0;
  padding-left: 1.1rem;
  color: #c45c2a;
  font-size: 0.8rem;
}

.bulk-sample-note,
.bulk-sample-banner {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px dashed rgba(180, 40, 40, 0.45);
  color: #b42828;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.bulk-sample-banner {
  margin: 0 0 12px;
  text-align: center;
}

.bulk-preview-totals {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
}

.bulk-preview-total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 1rem;
}

.bulk-preview-total-row strong {
  font-size: 1.25rem;
}

.bulk-preview-total-meta {
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
}

.bulk-preview-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bulk-report-panel {
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  max-height: 280px;
  overflow: auto;
}

.bulk-preview-panel {
  padding: 18px;
}

.bulk-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.bulk-preview-toolbar h2 {
  margin: 0;
  font-size: 1.05rem;
}

.bulk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.bulk-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bulk-card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--line);
}

.bulk-card-body {
  padding: 10px 12px;
  font-size: 0.82rem;
  display: grid;
  gap: 4px;
}

.bulk-card-body .muted {
  color: var(--muted);
}

.bulk-card-stats {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  min-height: 1.2em;
}

.bulk-card-tag {
  flex: 0 0 4.5rem;
  text-align: right;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.bulk-card-tag.is-empty {
  visibility: hidden;
}

.bulk-card-thumb {
  --thumb-scale: 0.5;
  background: #1a1d22;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12px 8px 14px;
  overflow: hidden;
  /* Height set in JS to scaled receipt height so nothing is clipped */
  min-height: 120px;
}

.bulk-card-thumb .receipt-wrapper {
  pointer-events: none;
  width: var(--receipt-width);
  max-width: none;
  margin: 0;
  padding: 0;
  filter: none;
  transform: scale(var(--thumb-scale));
  transform-origin: top center;
  flex-shrink: 0;
}

.bulk-card-thumb .preview-watermark {
  font-size: 1.2rem;
}

.bulk-card-thumb .preview-watermark.sample-disclaimer {
  font-size: 0.55rem;
  letter-spacing: 0.02em;
}

/* ---- Light theme ---- */

html[data-theme="light"] {
  --ink: #f7f4ef;
  --ink-soft: #efeae2;
  --panel: #ffffff;
  --panel-2: #f4f1eb;
  --line: rgba(20, 24, 30, 0.1);
  --line-strong: rgba(20, 24, 30, 0.16);
  --text: #1a1f27;
  --muted: #5c6570;
  --faint: #8b939e;
  --accent: #b8790a;
  --accent-dim: rgba(184, 121, 10, 0.12);
  --accent-text: #fff8e8;
  --preview-bg: #e8e4dc;
  --shadow: 0 18px 40px rgba(30, 24, 16, 0.12);
}

html[data-theme="light"] body {
  background:
    radial-gradient(1100px 520px at 8% -8%, rgba(184, 121, 10, 0.12), transparent 55%),
    radial-gradient(800px 420px at 100% 0%, rgba(90, 120, 150, 0.12), transparent 50%),
    linear-gradient(165deg, #f3efe7 0%, #ebe6dc 45%, #f7f4ef 100%);
}

html[data-theme="light"] body::before {
  opacity: 0.18;
  mix-blend-mode: multiply;
}
