:root {
  --bg: #f4f5f7; --card: #fff; --ink: #1d2433; --muted: #6b7280; --line: #e5e7eb;
  --primary: #0b6e4f; --primary-ink: #fff; --danger: #b91c1c; --danger-bg: #fee2e2;
  --warn-bg: #fef3c7; --warn: #92400e; --ok: #0b6e4f;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
.hidden { display: none !important; }
.top { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--ink); color: #fff; }
.brand { font-weight: 700; }
.tag { font-size: 11px; background: #f59e0b; color: #000; border-radius: 4px; padding: 1px 6px; margin-left: 6px; }
.top-actions { display: flex; gap: 8px; }
.top .ghost { color: #fff; border-color: #ffffff55; }
.card { background: var(--card); border-radius: 12px; padding: 16px; margin: 12px; box-shadow: 0 1px 3px #0001; }
.narrow { max-width: 460px; margin: 24px auto; }
h1 { font-size: 22px; margin: 0 0 12px; } h2 { font-size: 18px; margin: 0 0 8px; }
.ok { color: var(--ok); }
label { display: block; margin: 8px 0 4px; font-weight: 600; }
input { width: 100%; padding: 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 8px; }
button { font: inherit; border-radius: 8px; padding: 10px 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; min-height: 44px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); font-weight: 700; }
.ghost { background: transparent; }
.big { width: 100%; font-size: 20px; padding: 16px; margin-top: 12px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, monospace; word-break: break-all; }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; }
.banner { margin: 12px; padding: 12px 14px; border-radius: 8px; background: var(--danger-bg); color: var(--danger); border: 2px solid var(--danger); font-weight: 600; white-space: pre-line; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border-color: #f59e0b; }
.pos { display: grid; grid-template-columns: 1fr; }
@media (min-width: 820px) { .pos { grid-template-columns: 3fr 2fr; align-items: start; } }
#search { margin: 8px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.product { text-align: left; padding: 12px; min-height: 92px; display: flex; flex-direction: column; gap: 4px; }
.product .name { font-weight: 700; }
.product .price { color: var(--primary); font-weight: 700; }
.product .stock { font-size: 13px; color: var(--muted); }
.product.out .stock { color: var(--danger); }
.lines { list-style: none; padding: 0; margin: 8px 0; }
.lines li { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.qty { display: flex; align-items: center; gap: 6px; }
.qty input { width: 84px; text-align: center; padding: 8px; }
.qty button { min-width: 44px; padding: 6px; }
.line-total { font-weight: 700; text-align: right; }
.line-warn { grid-column: 1 / -1; color: var(--danger); font-size: 13px; }
.total { font-size: 20px; padding: 12px 0 4px; border-top: 2px solid var(--ink); margin-top: 8px; }
.pending { margin-top: 10px; padding: 10px; background: var(--warn-bg); color: var(--warn); border-radius: 8px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spinner { width: 16px; height: 16px; border: 3px solid #f59e0b55; border-top-color: #f59e0b; border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 12px 0; }
.meta dt { color: var(--muted); } .meta dd { margin: 0; }
.foot { text-align: center; padding: 16px; }

.credit { background: #fff; color: #7c2d12; border: 2px solid #c2410c; font-weight: 700; }
.credit:not(:disabled):hover { background: #fff7ed; }
.credit-panel { margin-top: 12px; padding: 12px; border: 2px solid #c2410c; border-radius: 10px; background: #fffaf5; }
.credit-panel h3 { margin: 0 0 8px; font-size: 17px; }
.cust-list { list-style: none; padding: 0; margin: 8px 0; max-height: 260px; overflow: auto; }
.cust-list li { margin: 0 0 6px; }
.cust-list button { width: 100%; display: flex; justify-content: space-between; gap: 8px; text-align: left; }
.cust-list button.selected { border: 2px solid #c2410c; background: #ffedd5; }
.cust-list .owes { color: #9a3412; font-weight: 700; white-space: nowrap; }
.credit-confirm { margin-top: 10px; padding: 10px; background: #ffedd5; border-radius: 8px; font-weight: 600; }
#new-cust summary { cursor: pointer; color: var(--primary); font-weight: 700; padding: 8px 0; min-height: 44px; }
.owes { color: #9a3412; }
.toplink { color: #fff; text-decoration: none; align-self: center; padding: 8px 6px; font-weight: 600; }
@media (max-width: 420px) { .top { flex-wrap: wrap; gap: 6px; } .top-actions { flex-wrap: wrap; } }
