/* ============================================================
   E-Provision Receipt Generator — plain CSS
   ============================================================ */

:root {
  --ink: #191817;
  --cream: #efebe2;
  --panel: #f7f4ee;
  --preview: #e5e0d4;
  --light: #f6f3ec;
  --rule: rgba(25, 24, 23, 0.2);
  --muted: rgba(25, 24, 23, 0.55);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

h1, p { margin: 0; }

/* ---------- page shell ---------- */

.app-shell {
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
}

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 20px;
}

@media (min-width: 640px) {
  .container { padding: 32px; }
}

@media (min-width: 1024px) {
  .container { padding: 48px; }
}

.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(25, 24, 23, 0.15);
  padding-bottom: 28px;
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: rgba(25, 24, 23, 0.4);
}

.page-head h1 {
  margin-top: 12px;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.02em;
  font-weight: 700;
}

@media (min-width: 640px) {
  .page-head h1 { font-size: 2.6rem; line-height: 1; }
}

.lede {
  margin-top: 12px;
  max-width: 28rem;
  font-size: 14px;
  line-height: 1.65;
  color: var(--muted);
}

/* ---------- buttons ---------- */

.actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}

@media (min-width: 640px) {
  .actions { width: auto; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1 1 auto;
  border: 1px solid var(--rule);
  background: none;
  padding: 12px 16px;
  font-family: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: rgba(25, 24, 23, 0.7);
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

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

.btn:hover {
  border-color: rgba(25, 24, 23, 0.45);
  color: var(--ink);
}

@media (min-width: 640px) {
  .btn { flex: 0 0 auto; }
}

.btn-dark {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--light);
  padding: 12px 20px;
}

.btn-dark:hover {
  background: rgba(25, 24, 23, 0.85);
  color: var(--light);
}

/* ---------- workbench ---------- */

.workbench {
  margin-top: 32px;
  display: grid;
  gap: 32px;
}

@media (min-width: 1024px) {
  .workbench {
    margin-top: 40px;
    grid-template-columns: minmax(300px, 340px) 1fr;
    gap: 48px;
  }

  .rail {
    position: sticky;
    top: 32px;
    align-self: start;
  }
}

.panel {
  background: var(--panel);
  padding: 24px;
  box-shadow: 0 0 0 1px rgba(25, 24, 23, 0.1);
}

.panel + .panel { margin-top: 20px; }

.panel-title {
  margin-bottom: 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: rgba(25, 24, 23, 0.35);
}

.panel-block-divider {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid rgba(25, 24, 23, 0.1);
}

/* ---------- form fields ---------- */

.fields > * + * { margin-top: 16px; }

.field { display: block; }

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: rgba(25, 24, 23, 0.45);
}

.field input {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  padding: 0 0 6px;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease;
}

.field input::placeholder { color: rgba(25, 24, 23, 0.25); }

.field input:focus { border-color: var(--ink); }

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

.field-row .field { margin-top: 0; }

.amount-value {
  margin-top: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid transparent;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.btn-add {
  width: 100%;
  margin-top: 16px;
  background: var(--ink);
  border-color: var(--ink);
  color: var(--light);
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.22em;
}

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

.btn-add:hover { background: rgba(25, 24, 23, 0.85); color: var(--light); }

.btn-add:disabled,
.btn-add:disabled:hover {
  background: rgba(25, 24, 23, 0.15);
  border-color: transparent;
  color: rgba(25, 24, 23, 0.4);
  cursor: not-allowed;
}

/* ---------- preview ---------- */

.preview-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: rgba(25, 24, 23, 0.35);
}

.preview-bar .mono {
  font-family: "Courier New", ui-monospace, monospace;
  text-transform: none;
  letter-spacing: 0;
}

.preview-frame {
  background: var(--preview);
  padding: 12px;
  overflow-x: auto;
}

@media (min-width: 640px) {
  .preview-frame { padding: 24px; }
}

@media (min-width: 1024px) {
  .preview-frame { padding: 40px; }
}

/* ---------- receipt sheet ---------- */

.receipt-paper {
  font-family: "Courier New", Courier, "Consolas", monospace;
  font-size: 12.5px;
  line-height: 1.3;
  letter-spacing: 0.01em;
  font-weight: 700;
  color: #000;
  width: 8.5in;
  background: #fff;
  box-sizing: border-box;
  margin: 0 auto;
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px -24px rgba(25, 24, 23, 0.45);
}

@media (min-width: 640px) {
  .receipt-paper { padding: 40px; }
}

.receipt-paper p { margin: 0; white-space: pre-wrap; }

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

.shop-block { flex: 0 0 auto; }

.meta-block { min-width: 56%; }

.rcpt-shop {
  font-family: "Arial Black", Arial, sans-serif;
  font-weight: 700;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.rcpt-table {
  width: 100%;
  height: 3.0375in;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12.5px;
  margin: 16px auto 0;
  border-left: 1px solid #000;
  border-right: 1px solid #000;
}

.rcpt-table th,
.rcpt-table td {
  padding: 1px 4px;
  vertical-align: top;
  text-align: left;
  font-weight: 700;
  word-break: break-word;
  border-top: 0;
  border-bottom: 0;
}

.rcpt-table th {
  font-family: "Arial Black", Arial, sans-serif;
  border: 1px solid #000;
  font-weight: 800;
  font-size: 15px;
  white-space: nowrap;
}

.rcpt-table tbody td {
  border-left: 1px solid #000;
  border-bottom: 0;
}

.rcpt-table tbody .rcpt-filler td {
  padding: 0;
  height: 100%;
}

.rcpt-table tbody .rcpt-row { height: 1px; }

.rcpt-table tfoot td {
  border-top: 1px solid #000;
  border-left: 1px solid #000;
  border-bottom: 1px solid #000;
  font-weight: 700;
}

.rcpt-table tfoot .rcpt-total td {
  font-family: "Arial Black", Arial, sans-serif;
  font-weight: 800;
}

.rcpt-total .label { text-align: right; }

.rcpt-remove {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: auto;
  padding: 0;
  background: none;
  color: rgba(25, 24, 23, 0.35);
  border: 1px solid rgba(25, 24, 23, 0.15);
  cursor: pointer;
  transition: color 0.2s ease, border-color 0.2s ease;
}

.rcpt-remove:hover {
  color: #191817;
  border-color: rgba(25, 24, 23, 0.6);
}

.rcpt-remove svg { width: 12px; height: 12px; }

.rcpt-footer { margin-top: 2px; }

.rcpt-signatures {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin: 10px 0 18px;
}

.rcpt-signature { flex: 1 1 0; }

.rcpt-sign-line { margin-top: 2px; }

.rcpt-summary { margin: 0; line-height: 1.12; }

.summary-row { display: grid; }

.cols-2 { grid-template-columns: 38% 62%; }

.cols-3 { grid-template-columns: 38% 36% 26%; }

.nowrap { white-space: nowrap; }

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 340px;
}

.toast {
  background: var(--ink);
  color: var(--light);
  padding: 12px 16px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28);
  animation: toast-in 0.2s ease-out;
}

.toast strong {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
}

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

/* ============================================================
   PRINT — the sheet is the only thing on the page
   ============================================================ */

@media print {
  @page {
    size: 8.5in 11in;
    margin: 0;
  }

  html,
  body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 8.5in !important;
    height: 11in !important;
    overflow: hidden !important;
  }

  body * { visibility: hidden; }

  .print-sheet,
  .print-sheet * { visibility: visible; }

  .no-print { display: none !important; }

  .app-shell {
    height: 0 !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .print-sheet {
    position: absolute;
    left: 0;
    top: 0;
    width: 8in !important;
    max-width: none !important;
    margin: 0 !important;
    box-sizing: border-box;
    height: 9.4in !important;
    overflow: hidden !important;
    padding: 0.3in 0.25in !important;
    border: none !important;
    box-shadow: none !important;
    background: #fff !important;
    font-size: 11pt;
    line-height: 1.1;
    transform: none !important;
    page-break-after: avoid !important;
    page-break-inside: avoid !important;
  }

  .rcpt-table,
  .rcpt-table th,
  .rcpt-table td { font-size: 11pt; }

  .rcpt-table th,
  .rcpt-table td { padding: 0.5pt 3pt; }

  .rcpt-table tr { page-break-inside: avoid; }

  .rcpt-signatures { margin: 4pt 0 6pt; }
}