/* Cuts — Phase 8: ticket entry split-pane (items left, receipt right). */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #fafafa; color: #1a1a1a;
  padding-bottom: env(safe-area-inset-bottom);
}
header.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .75rem 1rem; background: #1a1a1a; color: #fff;
  position: sticky; top: 0; z-index: 30;
}
header.topbar h1 {
  font-size: 1.05rem; font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  flex-grow: 1;
  flex-shrink: 1;
  flex-basis: 0;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
header.topbar #menu-btn { flex: 0 0 auto; }
header.topbar .back-btn { flex: 0 0 auto; }
/* When back is hidden, balance the layout with a transparent spacer of equal width to the menu. */
header.topbar .back-btn[hidden] {
  display: inline-flex; visibility: hidden; pointer-events: none;
  /* Match menu button width (~36px) so h1 centers between two equal-sized ends */
  width: 36px; height: 36px; padding: 0; border-color: transparent;
}
header.topbar .back-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: none; border: 1px solid #555; color: #fff;
  padding: .35rem .6rem; border-radius: 6px; font-size: .85rem;
  -webkit-tap-highlight-color: rgba(255,255,255,0.15);
  touch-action: manipulation; cursor: pointer;
}
header.topbar .back-btn:active { background: rgba(255,255,255,0.1); }
header.topbar .back-icon {
  display: inline-block; width: 10px; height: 10px;
  border-left: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(45deg); margin-left: 2px;
}
header.topbar #menu-btn {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 36px; height: 36px; padding: .35rem .5rem;
  background: none; border: 1px solid #555; border-radius: 6px; color: #fff;
  -webkit-tap-highlight-color: rgba(255,255,255,0.15);
  touch-action: manipulation;
}
header.topbar #menu-btn .hbg {
  display: block; height: 2px; width: 100%; background: currentColor; border-radius: 1px;
}
main { padding: 0; max-width: 100%; margin: 0; }

button, input, select { font: inherit; }

#menu-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: none; z-index: 50;
}
#menu-backdrop.open { display: block; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
  background: #fff; border-top-left-radius: 14px; border-top-right-radius: 14px;
  padding: .75rem 1rem; max-height: 70vh; overflow-y: auto;
  display: none; box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
}
.sheet.open { display: block; }
.sheet-handle {
  width: 36px; height: 4px; border-radius: 2px; background: #ddd;
  margin: .25rem auto .75rem;
}
.sheet-title {
  text-align: center; font-size: .8rem; color: #888;
  text-transform: uppercase; letter-spacing: .04em; margin-bottom: .5rem;
}
.sheet-item {
  padding: .85rem .5rem; border-radius: 8px; cursor: pointer;
  -webkit-tap-highlight-color: rgba(26,26,26,0.1);
  touch-action: manipulation;
}
.sheet-item:active { background: #f0f0f0; }

input, select {
  width: 100%;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus { outline: 2px solid #1a1a1a; outline-offset: 1px; }

.toast {
  position: fixed; top: 1rem; left: 50%; transform: translate(-50%, -1rem);
  background: #1f1f1f; color: #fff; padding: .55rem .9rem; border-radius: 6px;
  font-size: .875rem; z-index: 200; opacity: 0;
  transition: opacity .2s ease, transform .2s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25); pointer-events: none;
  max-width: calc(100vw - 2rem); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.toast-ok   { background: #166534; }
.toast.toast-warn { background: #92400e; }
.toast.toast-err  { background: #991b1b; }

/* ===== Ticket entry split-pane ===== */
.ticket-stage {
  display: flex; gap: 0;
  height: calc(100dvh - 56px); /* header */
  overflow-x: auto; overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.items-pane, .receipt-pane {
  flex: 0 0 100%;
  min-width: 100%;
  scroll-snap-align: start;
  display: flex; flex-direction: column;
  background: #fafafa;
  padding: 1rem;
  overflow-y: auto;
}
@media (min-width: 768px) {
  .items-pane, .receipt-pane { flex: 0 0 50%; min-width: 50%; }
}

/* Items pane */
.items-pane h2 {
  font-size: .95rem; text-transform: uppercase; letter-spacing: .04em;
  color: #666; margin-bottom: .75rem;
}
.items-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem;
}
.item-btn {
  background: #fff; border: 1px solid #ddd; border-radius: 8px;
  padding: .85rem .5rem; cursor: pointer; text-align: center;
  position: relative;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
  touch-action: manipulation;
  transition: transform .08s ease, background .12s ease;
}
.item-btn:active { transform: scale(0.97); background: #f5f5f5; }
.item-btn .item-name { font-weight: 600; font-size: .95rem; }
.item-btn .item-price { color: #666; font-size: .8rem; margin-top: .15rem; }
.item-btn .item-badge {
  position: absolute; top: -.4rem; right: -.4rem;
  min-width: 22px; height: 22px; padding: 0 .5rem;
  background: #1a1a1a; color: #fff; font-size: .75rem; font-weight: 700;
  border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
}
.items-pane-hint {
  margin-top: auto; padding-top: 1rem;
  font-size: .75rem; color: #888; text-align: center;
}

/* Receipt pane */
.receipt-pane {
  background: #f4f1ea;
}
.receipt {
  background: #fff; border: 1px dashed #c0b8a8;
  border-radius: 4px; padding: 1rem;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: .85rem; line-height: 1.45;
  color: #1a1a1a;
  max-width: 360px; width: 100%; margin: 0 auto;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.receipt .r-header { text-align: center; }
.receipt .r-shop   { font-weight: 700; font-size: .95rem; }
.receipt .r-meta   { color: #555; font-size: .75rem; }
.receipt .r-divider { border: none; border-top: 1px dashed #c0b8a8; margin: .6rem 0; }
.receipt .r-line {
  display: flex; justify-content: space-between; align-items: baseline; gap: .5rem;
}
.receipt .r-line .r-line-name { flex: 1; min-width: 0; }
.receipt .r-line .r-line-amt  { white-space: nowrap; }
.receipt .r-line .r-line-qty  { color: #888; margin-right: .35rem; }
.receipt .r-empty { color: #888; text-align: center; padding: .5rem 0; }
.receipt .r-totals { font-weight: 700; }
.receipt .r-footer { text-align: center; color: #888; font-size: .7rem; margin-top: .5rem; }
.receipt .r-draft  { color: #b45309; font-weight: 700; }
.receipt .r-tnum   { font-weight: 700; }

.receipt-controls {
  display: flex; gap: .5rem; justify-content: center; margin-top: .75rem;
  flex-wrap: wrap;
}
.receipt-controls button {
  padding: .55rem .85rem; border-radius: 6px; font-size: .85rem;
  border: 1px solid #ccc; background: #fff; cursor: pointer;
  touch-action: manipulation; -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.receipt-controls button.danger { color: #991b1b; border-color: #fca5a5; }
.receipt-controls button.primary {
  background: #16a34a; color: #fff; border-color: #16a34a; font-weight: 600;
  padding: .7rem 1.25rem; font-size: .95rem;
}
.receipt-controls button:disabled { opacity: .5; cursor: not-allowed; }

.receipt-row-controls {
  display: inline-flex; gap: .25rem; margin-left: .25rem;
}
.receipt-row-controls button {
  width: 22px; height: 22px; padding: 0;
  border: 1px solid #ddd; background: #fff; border-radius: 4px;
  font-size: .8rem; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05);
}
.receipt-row-controls button:active { background: #f0f0f0; }

/* Receipt pane chrome */
.receipt-pane h2 {
  font-size: .95rem; text-transform: uppercase; letter-spacing: .04em;
  color: #666; margin-bottom: .75rem; text-align: center;
}
.receipt-wrap { flex: 1; display: flex; flex-direction: column; }
.receipt-wrap .receipt { flex: 0 0 auto; }

/* Other views still get padding */
#app > section, #app > form, #app > h2, #app > p, #app > div { }
#app > .padded { padding: 1rem; max-width: 720px; margin: 0 auto; }
/* ===== Calendar picker (reports) ===== */
.cal-wrap {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: .5rem;
}
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: .25rem .25rem .5rem;
  border-bottom: 1px solid #eee;
  margin-bottom: .35rem;
}
.cal-title { font-weight: 600; font-size: .9rem; }
.cal-nav {
  width: 32px; height: 32px; border: 1px solid #ddd; background: #fff;
  border-radius: 6px; font-size: 1.1rem; line-height: 1; cursor: pointer;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05); touch-action: manipulation;
}
.cal-nav:active { background: #f0f0f0; }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px;
}
.cal-dow {
  text-align: center; font-size: .7rem; color: #888;
  padding: .25rem 0; font-weight: 600;
}
.cal-cell {
  appearance: none; -webkit-appearance: none;
  width: 100%; aspect-ratio: 1 / 1;
  border: 1px solid transparent; background: transparent;
  border-radius: 4px;
  font-size: .85rem; cursor: pointer; padding: 0;
  color: #ccc;
  -webkit-tap-highlight-color: rgba(0,0,0,0.05); touch-action: manipulation;
}
.cal-cell.cal-empty { cursor: default; }
.cal-cell.cal-has {
  background: #f0f7ff; border-color: #cfe2ff; color: #1a1a1a;
  font-weight: 500;
}
.cal-cell.cal-has:active { background: #d6e7ff; }
.cal-cell.cal-has.cal-selected {
  background: #1a1a1a; color: #fff; border-color: #1a1a1a;
}
.cal-cell:disabled, .cal-cell[aria-disabled="true"] {
  color: #ddd; background: transparent; cursor: not-allowed;
}
