/* =========================================================
   Receipt Studio
   A fixed, print-ready receipt design. No external CSS deps.
   ========================================================= */

:root {
  --bg: #ede8df;
  --bg-glow: rgba(20, 108, 90, 0.09);
  --panel: #fbf9f4;
  --paper: #ffffff;
  --ink: #1d1a16;
  --ink-soft: #4e4941;
  --muted: #786f62;
  --line: #e3dbcf;
  --line-strong: #cfc5b4;
  --field: #fffefb;
  --field-soft: #f7f3eb;
  --accent: #146c5a;
  --accent-deep: #0d5546;
  --accent-soft: #e2f0eb;
  --danger: #a8472f;
  --amber: #a8741a;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --shadow-panel: 0 1px 0 rgba(255, 255, 255, 0.65) inset, 0 30px 60px -52px rgba(29, 26, 22, 0.55);
  --shadow-paper: 0 2px 4px rgba(29, 26, 22, 0.06), 0 34px 60px -30px rgba(29, 26, 22, 0.4);
  --radius-control: 10px;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

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

[hidden] {
  display: none !important;
}

html {
  min-height: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(900px 540px at 88% -8%, var(--bg-glow), transparent 62%),
    radial-gradient(760px 520px at -8% 104%, rgba(166, 128, 70, 0.09), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}

img,
svg {
  display: block;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

button,
input,
select,
textarea {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

::selection {
  background: rgba(20, 108, 90, 0.2);
}

/* ---------- Shared controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  white-space: nowrap;
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease),
    color 160ms var(--ease), transform 120ms var(--ease), box-shadow 160ms var(--ease);
}

.btn svg {
  width: 15px;
  height: 15px;
  flex: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: #fffdf8;
  box-shadow: 0 1px 2px rgba(29, 26, 22, 0.22);
}

.btn-primary:hover {
  background: #302b24;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: rgba(29, 26, 22, 0.14);
}

.btn-ghost:hover {
  background: rgba(255, 255, 255, 0.6);
  border-color: rgba(29, 26, 22, 0.24);
  color: var(--ink);
}

.btn-quiet {
  min-height: 34px;
  padding: 0 13px;
  border-radius: 9px;
  background: var(--paper);
  border-color: var(--line-strong);
  font-size: 11.5px;
  color: var(--ink-soft);
  box-shadow: 0 1px 1px rgba(29, 26, 22, 0.03);
}

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

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: rgba(133, 125, 112, 0.4);
  text-underline-offset: 3px;
}

.link-button:hover {
  color: var(--accent);
  text-decoration-color: currentColor;
}

.link-button svg {
  width: 13px;
  height: 13px;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  transition: background-color 150ms var(--ease), color 150ms var(--ease);
}

.icon-button svg {
  width: 15px;
  height: 15px;
}

.icon-button:hover {
  background: #f5eae5;
  color: var(--danger);
}

.label-short {
  display: none;
}

/* ---------- App bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid rgba(29, 26, 22, 0.08);
  background: rgba(237, 232, 223, 0.86);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  backdrop-filter: blur(16px) saturate(1.1);
}

.appbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 13px 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--ink);
  color: #fbf7ee;
  box-shadow: 0 1px 2px rgba(29, 26, 22, 0.25);
}

.brand-mark svg {
  width: 20px;
  height: 20px;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand-name {
  font-family: var(--font-serif);
  font-size: 23px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
}

.brand-tagline {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.11em;
  line-height: 1.4;
  text-transform: uppercase;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

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

.app-shell {
  display: grid;
  grid-template-columns: minmax(400px, 468px) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 72px;
}

.mobile-tabs {
  display: none;
}

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

.form-panel {
  min-width: 0;
  padding: 4px 28px 0;
  background: var(--panel);
  border: 1px solid rgba(29, 26, 22, 0.09);
  border-radius: 22px;
  box-shadow: var(--shadow-panel);
}

.form-section {
  padding: 26px 0;
  border-bottom: 1px solid var(--line);
}

.form-section:last-of-type {
  border-bottom: 0;
  padding-bottom: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 17px;
}

.section-index {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 19px;
  padding: 0 5px;
  border: 1px solid rgba(20, 108, 90, 0.22);
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.section-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-aside {
  margin-left: auto;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ---------- Fields ---------- */

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 13px 11px;
}

.field {
  min-width: 0;
}

.field-full {
  grid-column: span 2;
}

.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.optional {
  margin-left: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 400;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--field);
  color: var(--ink);
  font-size: 13px;
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease),
    background-color 150ms var(--ease);
}

.field input,
.field select {
  height: 41px;
  padding: 0 12px;
}

.field textarea {
  min-height: 58px;
  padding: 9px 12px;
  line-height: 1.5;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #948b7d;
}

.field input:hover,
.field select:hover,
.field textarea:hover {
  border-color: #bdb2a1;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.13);
}

.field select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23857d70' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  cursor: pointer;
}

.field input[type="date"] {
  color-scheme: light;
}

.field input[type="date"]::-webkit-calendar-picker-indicator {
  opacity: 0.5;
  cursor: pointer;
}

.input-group {
  display: flex;
  align-items: center;
  height: 41px;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  background: var(--field);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease),
    background-color 150ms var(--ease);
}

.input-group:hover {
  border-color: #bdb2a1;
}

.input-group:focus-within {
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.13);
}

.input-group input {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0 12px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.input-group input:hover,
.input-group input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.input-group:has(.group-prefix) input {
  padding-left: 7px;
}

.input-group:has(.group-suffix) input {
  padding-right: 7px;
}

.input-group .group-prefix,
.input-group .group-suffix {
  flex: none;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  pointer-events: none;
}

.input-group .group-prefix {
  padding-left: 12px;
}

.input-group .group-suffix {
  padding-right: 12px;
}

/* ---------- Logo ---------- */

.logo-row {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 16px;
}

.logo-preview {
  display: grid;
  place-items: center;
  flex: none;
  width: 52px;
  height: 52px;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--field-soft);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1;
}

.logo-preview img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.logo-actions {
  min-width: 0;
}

.logo-buttons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.field-hint {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 10.5px;
}

/* ---------- Items editor ---------- */

.items-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.item-row {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  transition: border-color 150ms var(--ease), box-shadow 150ms var(--ease);
}

.item-row:focus-within {
  border-color: rgba(20, 108, 90, 0.45);
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.08);
}

.item-top {
  display: flex;
  align-items: center;
  gap: 5px;
}

.item-desc {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--field-soft);
  font-size: 12.5px;
  font-weight: 500;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.item-desc::placeholder {
  color: #948b7d;
  font-weight: 400;
}

.item-desc:hover {
  background: #f3eee5;
}

.item-desc:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.item-bottom {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 8px;
  align-items: end;
  margin-top: 7px;
  padding: 0 2px;
}

.mini-field {
  display: block;
  min-width: 0;
}

.mini-field > span:first-child,
.item-amount > span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mini-field input {
  width: 100%;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--field-soft);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.mini-field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}

.mini-field input:hover {
  background: #f3eee5;
}

.rate-input-wrap {
  display: flex;
  align-items: center;
  height: 30px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--field-soft);
  transition: border-color 150ms var(--ease), background-color 150ms var(--ease);
}

.rate-input-wrap:hover {
  background: #f3eee5;
}

.rate-input-wrap:focus-within {
  border-color: var(--accent);
  background: #fff;
}

.rate-input-wrap .currency-symbol {
  flex: none;
  padding-left: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1;
  pointer-events: none;
}

.rate-input-wrap input {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 100%;
  padding: 0 7px 0 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.rate-input-wrap input:hover,
.rate-input-wrap input:focus {
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  outline: none;
}

.item-amount {
  min-width: 0;
  text-align: right;
}

.item-total {
  display: block;
  overflow: hidden;
  padding: 7px 1px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-add {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 9px;
  padding: 9px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 600;
  transition: color 150ms var(--ease), border-color 150ms var(--ease),
    background-color 150ms var(--ease);
}

.btn-add svg {
  width: 14px;
  height: 14px;
}

.btn-add:hover {
  border-color: var(--accent);
  background: rgba(226, 240, 235, 0.55);
  color: var(--accent);
}

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

.form-footer {
  padding: 18px 0 22px;
}

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

.autosave {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10.5px;
}

.save-dot {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  transition: background-color 180ms var(--ease);
}

.save-dot[data-state="saving"] {
  background: var(--amber);
}

.save-dot[data-state="error"] {
  background: var(--danger);
}

.install-link svg {
  width: 13px;
  height: 13px;
}

.privacy-note {
  margin: 7px 0 0;
  color: #7d7466;
  font-size: 10px;
  line-height: 1.45;
}

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

.preview-stage {
  min-width: 0;
  padding: 17px 22px 20px;
  border: 1px solid rgba(29, 26, 22, 0.07);
  border-radius: 24px;
  background-color: rgba(255, 255, 255, 0.32);
  background-image: radial-gradient(rgba(29, 26, 22, 0.09) 1px, transparent 1px);
  background-size: 18px 18px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
}

@media (min-height: 880px) {
  .preview-stage {
    position: sticky;
    top: 92px;
  }
}

.stage-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 4px 13px;
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.live {
  display: flex;
  align-items: center;
  gap: 7px;
}

.live i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 90, 0.12);
}

.stage-note {
  color: #9a9183;
  letter-spacing: 0.08em;
}

.paper-wrap {
  display: flex;
  justify-content: center;
  padding: 3px 0 17px;
}

/* ---------- The receipt ---------- */

.receipt {
  position: relative;
  width: min(100%, 432px);
  background: var(--paper);
  border-radius: 5px;
  box-shadow: var(--shadow-paper);
  animation: paper-in 520ms var(--ease) both;
}

@keyframes paper-in {
  from {
    opacity: 0;
    transform: translateY(9px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.receipt-inner {
  padding: 31px 30px 25px;
}

.receipt-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 15px;
}

.business-block {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 0;
}

.receipt-logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 45px;
  height: 45px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-family: var(--font-serif);
  font-size: 19px;
  line-height: 1;
}

.receipt-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.business-meta {
  min-width: 0;
}

.business-meta h1 {
  margin: 1px 0 4px;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.02;
  letter-spacing: -0.015em;
  overflow-wrap: break-word;
}

.business-contact,
.business-detail {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
  overflow-wrap: break-word;
}

.business-contact {
  color: var(--ink-soft);
  white-space: pre-line;
}

.business-detail {
  white-space: pre-line;
}

.business-detail + .business-detail {
  margin-top: 2px;
}

.receipt-ident {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  flex: none;
  gap: 4px;
  padding-top: 1px;
  text-align: right;
}

.eyebrow {
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  line-height: 1.2;
  text-transform: uppercase;
}

.receipt-no {
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  max-width: 130px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 3px;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  line-height: 1.2;
  text-transform: uppercase;
  white-space: nowrap;
}

.status-pill::before {
  content: "";
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.status-pill[data-status="paid"] {
  background: #e4f1ec;
  color: var(--accent);
}

.status-pill[data-status="pending"] {
  background: #fbf0d9;
  color: #8a5a00;
}

.status-pill[data-status="refunded"] {
  background: #f2e9e4;
  color: #824c37;
}

.receipt-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 20px;
  padding: 11px 0;
  border-top: 1px dashed var(--line-strong);
  border-bottom: 1px dashed var(--line-strong);
}

.meta-cell {
  min-width: 0;
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.13em;
  line-height: 1.3;
  text-transform: uppercase;
}

.meta-value {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.35;
  overflow-wrap: break-word;
}

.bill-to {
  margin-top: 13px;
  padding: 10px 12px;
  border-radius: 9px;
  background: #f7f4ed;
}

.billto-name {
  margin: 4px 0 0;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

.billto-detail {
  margin: 2px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: break-word;
}

.receipt-items {
  width: 100%;
  margin-top: 17px;
  border-collapse: collapse;
  table-layout: auto;
}

.receipt-items th {
  padding: 0 0 6px;
  border-bottom: 1px solid var(--ink-soft);
  color: var(--muted);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.11em;
  line-height: 1.3;
  text-align: left;
  text-transform: uppercase;
}

.receipt-items th:first-child {
  width: 100%;
}

.receipt-items th.num {
  width: 1%;
  white-space: nowrap;
}

.receipt-items th.num,
.receipt-items td.num {
  padding-left: 9px;
  text-align: right;
}

.receipt-items td {
  padding: 8px 0;
  border-bottom: 1px solid #efeae1;
  color: var(--ink);
  font-size: 10.5px;
  line-height: 1.4;
  vertical-align: top;
}

.receipt-items tbody tr:last-child td {
  border-bottom-color: var(--line-strong);
}

.receipt-items td:first-child {
  padding-right: 8px;
  font-weight: 500;
  overflow-wrap: break-word;
}

.receipt-items td.num {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.receipt-items .empty-items {
  padding: 16px 0 14px;
  border-bottom-color: var(--line-strong);
  color: var(--muted);
  font-style: italic;
  text-align: center;
}

.receipt-totals {
  width: 205px;
  margin: 12px 0 0 auto;
}

.total-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 2.5px 0;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-variant-numeric: tabular-nums;
}

.total-row > span:last-child {
  text-align: right;
  white-space: nowrap;
}

.total-row.is-total {
  margin-top: 5px;
  padding-top: 7px;
  border-top: 1px solid var(--ink);
  color: var(--ink);
  font-size: 12px;
  font-weight: 600;
}

.total-row.is-total > span:last-child {
  font-size: 15.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.receipt-note {
  margin-top: 16px;
  padding: 9px 11px;
  border-left: 2px solid var(--accent);
  border-radius: 0 7px 7px 0;
  background: #f7f4ed;
}

.receipt-note p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: break-word;
}

.receipt-footer {
  margin-top: 19px;
  padding-top: 13px;
  border-top: 1px dashed var(--line-strong);
  text-align: center;
}

.receipt-thanks {
  margin: 0 0 3px;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-style: italic;
  line-height: 1.3;
}

.receipt-footer-line {
  margin: 0;
  color: var(--muted);
  font-size: 8.5px;
  font-weight: 500;
  letter-spacing: 0.04em;
  line-height: 1.5;
  text-transform: uppercase;
  overflow-wrap: break-word;
}

.receipt-cut {
  display: none;
}

.stage-footnote {
  margin: 0;
  padding: 0 8px;
  color: #7d7466;
  font-size: 10px;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Install banner ---------- */

.install-banner {
  position: fixed;
  right: 14px;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  left: 14px;
  z-index: 60;
  display: none;
  align-items: center;
  gap: 11px;
  max-width: 500px;
  margin: 0 auto;
  padding: 10px 10px 10px 12px;
  border: 1px solid rgba(255, 253, 248, 0.13);
  border-radius: 16px;
  background: var(--ink);
  color: #fffdf8;
  box-shadow: 0 20px 50px -12px rgba(29, 26, 22, 0.55);
}

@media (max-width: 1020px) {
  .install-banner.is-visible {
    display: flex;
    animation: banner-in 360ms var(--ease) both;
  }
}

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

.install-banner-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--accent);
  color: #fffdf8;
}

.install-banner-icon svg {
  width: 19px;
  height: 19px;
}

.install-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.install-copy strong {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
}

.install-copy span {
  color: rgba(255, 253, 248, 0.62);
  font-size: 10px;
  line-height: 1.35;
}

.btn-install {
  flex: none;
  padding: 7px 12px;
  border: 0;
  border-radius: 999px;
  background: #fffdf8;
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
}

.btn-install:hover {
  background: #f1ece2;
}

.install-dismiss {
  display: grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 253, 248, 0.5);
}

.install-dismiss:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fffdf8;
}

.install-dismiss svg {
  width: 13px;
  height: 13px;
}

/* ---------- Install dialog ---------- */

.install-dialog {
  width: min(430px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
}

.install-dialog::backdrop {
  background: rgba(23, 20, 16, 0.48);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.install-dialog[open] {
  animation: dialog-in 220ms var(--ease) both;
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.dialog-body {
  padding: 23px;
  border: 1px solid rgba(29, 26, 22, 0.08);
  border-radius: 22px;
  background: var(--panel);
  box-shadow: 0 30px 80px -20px rgba(23, 20, 16, 0.45);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.dialog-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #fffdf8;
}

.dialog-icon svg {
  width: 22px;
  height: 22px;
}

.dialog-close {
  color: var(--muted);
}

.dialog-close:hover {
  background: var(--field-soft);
  color: var(--ink);
}

.install-dialog h2 {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 27px;
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.015em;
}

.dialog-lede {
  margin: 7px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 11px;
  margin: 19px 0;
  padding: 0;
  counter-reset: step;
  list-style: none;
}

.install-steps li {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.5;
  counter-increment: step;
}

.install-steps li::before {
  content: counter(step);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
}

.install-steps li strong {
  color: var(--ink);
  font-weight: 600;
}

.dialog-note {
  margin: 0 0 17px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 1.5;
}

.dialog-done {
  width: 100%;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  top: 78px;
  left: 50%;
  z-index: 70;
  max-width: min(90vw, 420px);
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--ink);
  color: #fffdf8;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -6px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ---------- Responsive ---------- */

@media (max-width: 1200px) {
  .app-shell {
    grid-template-columns: minmax(380px, 430px) minmax(0, 1fr);
    gap: 26px;
    padding-right: 24px;
    padding-left: 24px;
  }

  .appbar-inner {
    padding-right: 24px;
    padding-left: 24px;
  }

  .form-panel {
    padding-right: 24px;
    padding-left: 24px;
  }
}

@media (max-width: 1020px) {
  .appbar-inner {
    padding: 11px 16px;
  }

  .app-shell {
    display: block;
    max-width: 700px;
    padding: 16px 16px 96px;
  }

  .mobile-tabs {
    display: flex;
    gap: 3px;
    margin-bottom: 12px;
    padding: 3px;
    border: 1px solid rgba(29, 26, 22, 0.09);
    border-radius: 12px;
    background: rgba(251, 249, 244, 0.7);
  }

  .mobile-tabs button {
    flex: 1;
    padding: 8px 10px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
    transition: background-color 160ms var(--ease), color 160ms var(--ease);
  }

  .mobile-tabs button.is-active {
    background: var(--ink);
    color: #fffdf8;
    box-shadow: 0 1px 2px rgba(29, 26, 22, 0.18);
  }

  .form-panel {
    padding: 2px 22px 0;
    border-radius: 19px;
  }

  .preview-stage {
    padding: 15px 18px 18px;
    border-radius: 20px;
  }

  body[data-view="details"] .preview-stage {
    display: none;
  }

  body[data-view="preview"] .form-panel {
    display: none;
  }

  body[data-view="preview"] .mobile-tabs {
    margin-bottom: 14px;
  }

  .receipt {
    width: min(100%, 460px);
  }

  .toast {
    top: 70px;
  }

  .form-footer {
    padding-bottom: 20px;
  }
}

@media (max-width: 700px) {
  .appbar-inner {
    gap: 10px;
    padding: 10px 14px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
  }

  .brand-mark svg {
    width: 18px;
    height: 18px;
  }

  .brand-name {
    font-size: 20px;
  }

  .brand-tagline {
    display: none;
  }

  .appbar-actions {
    gap: 6px;
  }

  .appbar .btn {
    min-height: 36px;
    padding: 0 11px;
    font-size: 11.5px;
  }

  .appbar .btn svg {
    width: 14px;
    height: 14px;
  }

  .appbar .btn .label-full {
    display: none;
  }

  .appbar #new-receipt-btn {
    width: 36px;
    padding: 0;
  }

  .appbar #print-btn .label-short {
    display: inline;
  }

  .app-shell {
    padding: 12px 12px 92px;
  }

  .form-panel {
    padding: 0 17px;
    border-radius: 17px;
  }

  .form-section {
    padding: 22px 0;
  }

  .form-section:last-of-type {
    padding-bottom: 14px;
  }

  .field-grid {
    gap: 12px 9px;
  }

  .preview-stage {
    padding: 12px 12px 16px;
    border-radius: 17px;
    background-size: 16px 16px;
  }

  .stage-bar {
    padding: 0 3px 10px;
  }

  .paper-wrap {
    padding-bottom: 14px;
  }

  .receipt-inner {
    padding: 27px 22px 22px;
  }

  .business-meta h1 {
    font-size: 23px;
  }

  .receipt-logo {
    width: 40px;
    height: 40px;
    border-radius: 9px;
    font-size: 17px;
  }

  .receipt-no {
    max-width: 112px;
    font-size: 9.5px;
  }

  .status-pill {
    font-size: 8px;
  }

  .stage-footnote {
    font-size: 9.5px;
  }

  .install-banner {
    gap: 9px;
    padding-left: 10px;
  }

  .install-copy span {
    font-size: 9.5px;
  }

  .btn-install {
    padding: 7px 10px;
  }

  .toast {
    top: 64px;
  }
}

@media (max-width: 560px) {
  .field-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

  .receipt-head {
    gap: 10px;
  }

  .business-contact,
  .business-detail {
    font-size: 9.5px;
  }

  .receipt-meta {
    gap: 5px;
  }

  .meta-value {
    font-size: 10px;
  }

  .receipt-items td {
    font-size: 10px;
  }

  .form-footer-row {
    flex-wrap: wrap;
  }
}

@media (max-width: 390px) {
  .brand-name {
    font-size: 18px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
  }

  .receipt-inner {
    padding: 24px 18px 20px;
  }

  .business-block {
    gap: 8px;
  }

  .receipt-logo {
    width: 36px;
    height: 36px;
    font-size: 15px;
  }

  .business-meta h1 {
    font-size: 21px;
  }

  .receipt-ident {
    gap: 3px;
  }

  .receipt-totals {
    width: 190px;
  }

  .install-copy span {
    display: none;
  }
}

/* ---------- Very small phones ---------- */

@media (max-width: 350px) {
  .receipt-head {
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 11px;
  }

  .receipt-ident {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-top: 0;
    text-align: left;
  }

  .receipt-ident .status-pill {
    margin-top: 0;
  }

  .receipt-no {
    max-width: none;
  }

  .business-block {
    width: 100%;
  }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Print ---------- */

@media print {
  @page {
    size: A4;
    margin: 16mm;
  }

  html,
  body {
    background: #fff !important;
    min-height: 0;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .appbar,
  .mobile-tabs,
  .form-panel,
  .stage-bar,
  .stage-footnote,
  .install-banner,
  .install-dialog,
  .toast,
  .receipt-cut {
    display: none !important;
  }

  .app-shell {
    display: block !important;
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
  }

  .preview-stage {
    display: block !important;
    position: static !important;
    width: auto;
    padding: 0 !important;
    border: 0 !important;
    background: none !important;
    box-shadow: none !important;
  }

  .paper-wrap {
    display: block;
    padding: 0;
  }

  .receipt {
    width: 100% !important;
    max-width: 480px !important;
    margin: 0 auto !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    animation: none !important;
    break-inside: avoid;
    transform: scale(1.38);
    transform-origin: top center;
  }

  .receipt-inner {
    padding: 4px 6px !important;
  }

  .receipt-logo,
  .status-pill,
  .bill-to,
  .receipt-note {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .receipt-footer {
    break-inside: avoid;
  }
}
