/* Four Star — Free Thermal Receipt Generator
   Clean, tool-first UI. Live receipt IS the editor. 58mm / 80mm roll sizes. */

/* ---- chrome (screen) ---- */
.tr-btn {
  min-height: 46px; padding: 10px 18px; border-radius: 10px; font-size: 15px; font-weight: 600;
  border: 1px solid #cbd5e1; background: #fff; color: #334155; cursor: pointer; transition: all .15s;
}
.tr-btn:hover { background: #f8fafc; }
.tr-btn:disabled { opacity: .55; cursor: wait; }
.tr-btn-primary {
  border: 0; color: #0f172a; font-weight: 800;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}
.tr-btn-primary:hover { opacity: .92; }
.tr-btn-ghost { background: #fff; }
.tr-btn-sm { min-height: 38px; padding: 6px 12px; font-size: 13px; }
.tr-btn-lg { min-height: 52px; padding: 12px 22px; font-size: 16px; }

.tr-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 16px; margin-bottom: 14px;
}
.tr-toolbar-left, .tr-toolbar-right { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

.tr-size {
  display: inline-flex; padding: 3px; background: #f1f5f9; border-radius: 12px; border: 1px solid #e2e8f0;
}
.tr-size button {
  min-height: 40px; min-width: 72px; padding: 6px 14px; border: 0; border-radius: 9px;
  background: transparent; font-size: 14px; font-weight: 700; color: #64748b; cursor: pointer;
}
.tr-size button[aria-pressed="true"] {
  background: #fff; color: #0f172a; box-shadow: 0 1px 3px rgba(15,23,42,.12);
}
.tr-size-hint { font-size: 12px; color: #94a3b8; margin-left: 4px; }

.tr-cur-btn {
  min-height: 40px; padding: 6px 12px; border: 1px solid #cbd5e1; border-radius: 8px;
  background: #fff; font-size: 13px; font-weight: 600; color: #334155; cursor: pointer;
}
.tr-cur { position: relative; }
.tr-cur-pop {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 40;
  width: min(280px, 80vw); background: #fff; border: 1px solid #e2e8f0; border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,23,42,.14); padding: 8px;
}
.tr-cur-search {
  width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 14px; margin-bottom: 6px;
}
.tr-cur-list {
  list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto;
}
.tr-cur-list li {
  padding: 8px 10px; border-radius: 6px; font-size: 13px; cursor: pointer; color: #334155;
}
.tr-cur-list li:hover, .tr-cur-list li[aria-selected="true"] { background: #fff7ed; color: #0f172a; }

.tr-stage {
  background: #e8edf3;
  background-image: radial-gradient(circle at 1px 1px, rgba(148,163,184,.35) 1px, transparent 0);
  background-size: 12px 12px;
  border-radius: 16px; padding: 20px 12px 28px; overflow-x: auto;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.tr-edit-hint {
  font-size: 12px; font-weight: 600; color: #64748b; text-align: center;
}
.tr-edit-hint b { color: #0f172a; }
.tr-paper-wrap {
  /* Big on-screen editor — PDF/print still use true 58/80mm */
  width: min(440px, 94vw);
  transition: width .2s ease;
  filter: drop-shadow(0 10px 24px rgba(15,23,42,.14));
}
.tr-paper-wrap[data-size="80"] { width: min(520px, 96vw); }

.tr-export {
  margin-top: 16px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 14px; padding: 16px 18px; background: #fff; border: 1px solid #e2e8f0; border-radius: 14px;
}
.tr-export-title { font-weight: 800; font-size: 15px; color: #0f172a; }
.tr-export-sub { font-size: 12px; color: #64748b; margin-top: 2px; }
.tr-export-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.tr-more { margin-top: 12px; }
.tr-more summary {
  cursor: pointer; font-size: 13px; font-weight: 700; color: #64748b; list-style: none;
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 0;
}
.tr-more summary::-webkit-details-marker { display: none; }
.tr-more summary::before { content: "▸"; font-size: 11px; }
.tr-more[open] summary::before { content: "▾"; }
.tr-more-body {
  margin-top: 8px; padding: 12px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px;
  display: grid; gap: 10px;
}
.tr-more-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; font-size: 13px; color: #475569; }
.tr-more-row label { font-weight: 600; min-width: 90px; }
.tr-more-row input[type=number] {
  width: 100px; min-height: 38px; padding: 6px 8px; border: 1px solid #cbd5e1; border-radius: 8px;
}

.tr-file { display: none; }
.tr-saved { font-size: 12px; color: #16a34a; min-height: 1em; }
.tr-toast {
  position: fixed; bottom: 88px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: #0f172a; color: #fff; font-size: 13px; font-weight: 600;
  padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px rgba(15,23,42,.25);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.tr-toast.show { opacity: 1; }

.tr-mobilebar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  background: #fff; border-top: 1px solid #e2e8f0; padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  align-items: center; justify-content: space-between; gap: 10px;
  box-shadow: 0 -6px 20px rgba(15,23,42,.08);
}
.tr-mb-label { font-size: 13px; color: #64748b; }
.tr-mb-label b { color: #0f172a; font-size: 16px; }
.tr-mb-actions { display: flex; gap: 8px; }
.tr-mb-btn { min-height: 44px; padding: 8px 14px; font-size: 14px; }

@media (max-width: 640px) {
  .tr-mobilebar { display: flex; }
  body { padding-bottom: 76px; }
  .tr-export-actions .tr-btn-lg { display: none; }
}

/* ---- receipt paper (large edit surface) ---- */
.tr-receipt {
  box-sizing: border-box; width: 100%; background: #fff; color: #111;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 15px; line-height: 1.45; padding: 18px 16px 22px;
  border-radius: 4px;
}
.tr-receipt * { box-sizing: border-box; }

.tr-ce {
  display: inline-block; min-width: 1ch; max-width: 100%; outline: none; border-radius: 3px;
  word-break: break-word;
}
.tr-ce:empty::before { content: attr(data-ph); color: #94a3b8; }
.tr-ce:focus { background: #fff7ed; box-shadow: 0 0 0 2px rgba(245,158,11,.35); }
.tr-ce-block { display: block; width: 100%; }
.tr-ce-name {
  display: block; width: 100%; font-weight: 700; font-size: 1.05em; min-height: 1.4em;
}
.tr-inp {
  width: 100%; max-width: 5.5em; border: 0; background: transparent; text-align: center;
  font: inherit; color: inherit; padding: 2px 0; outline: none; border-radius: 3px;
}
.tr-inp:focus { background: #fff7ed; box-shadow: 0 0 0 2px rgba(245,158,11,.35); }
.tr-select {
  border: 0; background: transparent; font: inherit; color: inherit; max-width: 100%;
  outline: none; cursor: pointer;
}
.tr-select:focus { background: #fff7ed; }

.tr-center { text-align: center; }
.tr-right { text-align: right; }
.tr-muted { color: #64748b; font-size: .92em; }
.tr-strong { font-weight: 700; }
.tr-shop { font-size: 1.35em; font-weight: 800; letter-spacing: .02em; margin: 4px 0; }
.tr-dash { border: 0; border-top: 1px dashed #94a3b8; margin: 10px 0; }
.tr-meta { display: flex; justify-content: space-between; gap: 8px; margin: 3px 0; }
.tr-meta-center {
  text-align: center; line-height: 1.55; margin: 4px 0;
}
.tr-meta-center .tr-ce,
.tr-meta-center .tr-select { display: inline-block; }
.tr-logo-btn {
  display: inline-flex; margin: 0 auto 6px; padding: 0; border: 0; background: transparent; cursor: pointer;
}
.tr-logo { max-width: 64px; max-height: 64px; object-fit: contain; display: block; margin: 0 auto; }
.tr-logo-ph {
  width: 52px; height: 52px; border: 1px dashed #cbd5e1; border-radius: 6px; color: #94a3b8;
  display: flex; align-items: center; justify-content: center; font-size: 18px; margin: 0 auto;
}
.tr-logo-x {
  display: none; margin: 2px auto 0; border: 0; background: #fee2e2; color: #b91c1c;
  font-size: 11px; padding: 2px 8px; border-radius: 4px; cursor: pointer;
}
.tr-logo-btn:hover + .tr-logo-x, .tr-logo-x:hover { display: inline-block; }
.tr-has-logo .tr-logo-x { display: inline-block; }

/* Item list: name on its own full-width row (like POS preview), numbers below */
.tr-items-head {
  display: grid; grid-template-columns: 28px 1fr 1fr 1fr; gap: 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: #64748b; padding: 4px 0 6px; border-bottom: 1px solid #cbd5e1; text-align: center;
}
.tr-items-head .tr-h-sr { text-align: center; }
.tr-items-body { display: flex; flex-direction: column; }
.tr-item {
  display: grid; grid-template-columns: 28px 1fr; grid-template-rows: auto auto;
  gap: 2px 6px; padding: 8px 0; border-bottom: 1px solid #e2e8f0; position: relative;
}
.tr-item-sr {
  grid-row: 1 / span 2; align-self: center; text-align: center; font-weight: 700; color: #64748b;
}
.tr-item-name { grid-column: 2; position: relative; padding-right: 18px; }
.tr-item-nums {
  grid-column: 2; display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 4px;
  align-items: center; text-align: center; font-size: .95em; color: #334155;
}
.tr-item-nums .tr-num-lbl {
  display: block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  color: #94a3b8; letter-spacing: .03em;
}
.tr-del {
  position: absolute; right: 0; top: 0; width: 22px; height: 22px; border: 0; border-radius: 50%;
  background: #fee2e2; color: #ef4444; font-size: 14px; line-height: 1; cursor: pointer;
  opacity: 0; padding: 0;
}
.tr-item:hover .tr-del, .tr-item:focus-within .tr-del { opacity: 1; }
.tr-add {
  width: 100%; margin-top: 8px; border: 1px dashed #cbd5e1; background: #f8fafc; color: #b45309;
  font: inherit; font-weight: 700; font-size: 13px; padding: 10px; border-radius: 8px; cursor: pointer;
}
.tr-add:hover { background: #fff7ed; border-color: #f59e0b; }

.tr-tot { width: 100%; margin-top: 6px; border-collapse: collapse; }
.tr-tot td { padding: 4px 0; }
.tr-tot .tr-grand td { font-weight: 800; font-size: 1.15em; padding-top: 8px; border-top: 1px dashed #94a3b8; }
.tr-tot .tr-zero { display: none; }
.tr-foot { text-align: center; margin-top: 12px; font-size: .95em; color: #475569; }
.tr-thanks { margin-top: 10px; text-align: center; font-weight: 700; }

/* ---- print / PDF export node ---- */
.tr-print-root { position: absolute; left: -99999px; top: 0; }
.tr-print-root .tr-receipt { box-shadow: none; }
.tr-print-root .tr-del,
.tr-print-root .tr-add,
.tr-print-root .tr-logo-x,
.tr-print-root .tr-logo-ph { display: none !important; }
.tr-print-root .tr-ce:empty { display: none; }
.tr-print-root .tr-inp { appearance: textfield; }
.tr-print-root .tr-select { appearance: none; pointer-events: none; }

@media print {
  body * { visibility: hidden !important; }
  .tr-print-root, .tr-print-root * { visibility: visible !important; }
  .tr-print-root {
    position: absolute !important; left: 0 !important; top: 0 !important;
    width: 100% !important;
  }
  .tr-print-root .tr-receipt {
    width: 100% !important; max-width: none !important; margin: 0 !important;
    box-shadow: none !important; border-radius: 0 !important;
  }
  .tr-mobilebar, .tr-toast, header, footer, .print\:hidden { display: none !important; }
  @page { margin: 2mm; }
  body.tr-print-58 @page { size: 58mm auto; }
  body.tr-print-80 @page { size: 80mm auto; }
}
