/*
 * The counter.
 *
 * One stylesheet, no framework. It is a work surface rather than a page: it fills the viewport and
 * never scrolls as a whole, so the total and the pay button cannot slide out of view halfway
 * through a transaction. The basket scrolls; nothing else does.
 */

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --bg: #080e0a;
    --bg3: #111d14;
    --surface: rgba(255, 255, 255, .04);
    --border: rgba(255, 255, 255, .08);
    --lime: #b7ff64;
    --red: #ff6b6b;
    --amber: #ffc46b;
    --text: #f0f5ec;
    --muted: rgba(240, 245, 236, .55);
}

html, body { height: 100%; }

body {
    font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
}

h1, h2, h3 { font-family: 'Syne', 'DM Sans', sans-serif; }

.till-page {
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    padding: 1rem 1.25rem;
}

/* ----  Top bar  ---- */

.till-top { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.till-top h1 { font-size: 1.25rem; }
.till-top .who { font-size: .78rem; color: var(--muted); }
.till-top .who strong { color: var(--text); }
.till-top .spacer { flex: 1; }

.pending-badge {
    border-radius: 999px;
    padding: .3rem .7rem;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    cursor: pointer;
    border: 1px solid transparent;
    font-family: inherit;
}
.pending-badge.waiting {
    background: rgba(255, 196, 107, .14);
    color: var(--amber);
    border-color: rgba(255, 196, 107, .4);
}
.pending-badge.blocked {
    background: rgba(255, 107, 107, .14);
    color: var(--red);
    border-color: rgba(255, 107, 107, .4);
}

/* ----  Banners  ---- */

.banner {
    border-radius: 10px;
    padding: .6rem .85rem;
    font-size: .8rem;
    display: flex;
    gap: .6rem;
    align-items: center;
}
.banner[hidden] { display: none; }
.banner.warn {
    background: rgba(255, 196, 107, .08);
    border: 1px solid rgba(255, 196, 107, .35);
    color: var(--amber);
}
.banner.bad {
    background: rgba(255, 107, 107, .08);
    border: 1px solid rgba(255, 107, 107, .35);
    color: var(--red);
}

.blocked-box {
    border: 1px solid rgba(255, 107, 107, .4);
    background: rgba(255, 107, 107, .06);
    border-radius: 10px;
    padding: .7rem .8rem;
    font-size: .76rem;
    color: var(--red);
}
.blocked-box[hidden] { display: none; }
.blocked-box p { margin: .3rem 0; color: var(--muted); }
.blocked-box ul { margin: .4rem 0 0 1rem; color: var(--muted); }

/* ----  Two columns: the basket, and the money  ---- */

.till-body {
    flex: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: .9rem;
    min-height: 0;
}
.till-main { display: flex; flex-direction: column; gap: .75rem; min-height: 0; }
.till-side {
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-height: 0;
    overflow-y: auto;
}

/* ----  Scan  ---- */

.scan-zone {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: .85rem;
}
.scan-line { display: grid; grid-template-columns: minmax(0, 1fr) 90px; gap: .6rem; }

.scan-line input[type="text"] {
    width: 100%;
    padding: .85rem 1rem;
    font-size: 1.05rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
}
.scan-line input[type="text"]:focus { outline: 2px solid var(--lime); outline-offset: -1px; }

.scan-line input[type="number"] {
    width: 100%;
    padding: .85rem .6rem;
    font-size: 1.05rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    text-align: center;
}

.scan-hint { font-size: .72rem; color: var(--muted); margin-top: .45rem; }

.results {
    margin-top: .5rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg3);
    overflow: hidden;
    max-height: 260px;
    overflow-y: auto;
}
.results[hidden] { display: none; }

.result-row {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: .55rem .75rem;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
}
.result-row:last-child { border-bottom: none; }
.result-row:hover, .result-row:focus { background: rgba(183, 255, 100, .08); }
.result-name { font-size: .86rem; }
.result-meta { font-size: .72rem; color: var(--muted); }

/* ----  Where the stock is  ---- */

.stock-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: .7rem .85rem;
    background: var(--surface);
}
.stock-panel[hidden] { display: none; }
.stock-head { display: flex; gap: .8rem; align-items: baseline; font-size: .84rem; }
.stock-head strong { color: var(--lime); }
.stock-muted { font-size: .72rem; color: var(--muted); }
.stock-note { font-size: .72rem; color: var(--amber); margin-top: .3rem; }
.stock-loading { font-size: .76rem; color: var(--muted); }

.bin-list { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.bin-row {
    display: flex;
    gap: .45rem;
    align-items: baseline;
    font-size: .74rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .22rem .55rem;
}
.bin-code { font-variant-numeric: tabular-nums; color: var(--muted); }
.bin-qty { font-weight: 700; color: var(--text); }
.bin-tag { font-size: .64rem; color: var(--amber); text-transform: uppercase; letter-spacing: .05em; }
.bin-reserved { opacity: .7; border-style: dashed; }

/* ----  Basket  ---- */

.basket {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 14px;
}

table { width: 100%; border-collapse: collapse; }
.basket table { font-size: .88rem; }
.basket thead th {
    position: sticky;
    top: 0;
    background: var(--bg3);
    z-index: 1;
}

th {
    text-align: left;
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .09em;
    color: var(--muted);
    padding: .55rem .45rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
td { padding: .62rem .5rem; border-bottom: 1px solid rgba(255, 255, 255, .05); }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.line-meta { font-size: .7rem; color: var(--muted); margin-top: .1rem; }
.empty-row td { text-align: center; color: var(--muted); padding: 2.5rem 1rem; font-size: .84rem; }

.qty-cell { display: flex; align-items: center; gap: .3rem; }
.qty-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    font-family: inherit;
}
.qty-btn:hover { border-color: var(--lime); color: var(--lime); }

.qty-input {
    width: 52px;
    text-align: center;
    padding: .3rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-variant-numeric: tabular-nums;
}

.link-btn {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: .76rem;
    padding: 0;
    font-family: inherit;
}
.link-btn:hover { text-decoration: underline; }

/* ----  Money  ---- */

.money-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1rem;
}
.money-card h2 { font-size: .9rem; margin-bottom: .7rem; }

.total-line {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: .82rem;
    color: var(--muted);
    margin-bottom: .35rem;
}
/* `hidden` is only a user-agent rule, so any author `display` beats it. Without this the discount
   line shows "-R0.00" on every sale that has no discount. */
.total-line[hidden] { display: none; }
.total-line.grand {
    margin-top: .6rem;
    padding-top: .6rem;
    border-top: 1px solid var(--border);
    color: var(--text);
}
.total-line.grand .amount { font-family: 'Syne', sans-serif; font-size: 1.9rem; line-height: 1; }
.total-line .amount { font-variant-numeric: tabular-nums; }

.field { margin-bottom: .6rem; }
.field label { display: block; margin: .35rem 0 .25rem; font-size: .72rem; color: var(--muted); }
.field input, .field select {
    width: 100%;
    padding: .55rem .7rem;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .86rem;
}
.field input:focus, .field select:focus { outline: 1px solid var(--lime); }
.field[hidden] { display: none; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }

#cashBlock[hidden], #discountBox[hidden] { display: none; }

.change-value { font-family: 'Syne', sans-serif; font-size: 1.25rem; }
.change-value.ok { color: var(--lime); }
.change-value.short { color: var(--red); }

.pay-button {
    width: 100%;
    padding: .95rem;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    background: var(--lime);
    color: #08110a;
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: .95rem;
    letter-spacing: .02em;
}
.pay-button:disabled { opacity: .45; cursor: not-allowed; }
.pay-button:not(:disabled):hover { filter: brightness(1.08); }

.ghost-button {
    width: 100%;
    padding: .6rem;
    border-radius: 10px;
    cursor: pointer;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    font-family: inherit;
    font-size: .8rem;
}
.ghost-button:hover { border-color: var(--red); color: var(--red); }

.till-msg { border-radius: 10px; padding: .6rem .8rem; font-size: .8rem; }
.till-msg[hidden] { display: none; }
.till-msg.bad {
    background: rgba(255, 107, 107, .08);
    border: 1px solid rgba(255, 107, 107, .35);
    color: var(--red);
}
.till-msg.info { background: var(--surface); border: 1px solid var(--border); color: var(--muted); }

/* ----  Receipt  ---- */

.receipt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
}
.receipt-overlay[hidden] { display: none; }

.receipt-card {
    background: #fff;
    color: #111;
    border-radius: 12px;
    padding: 1.25rem;
    width: 340px;
    max-height: 90vh;
    overflow-y: auto;
}
.receipt-head { text-align: center; margin-bottom: .8rem; }
.receipt-shop { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.05rem; }
.receipt-meta { font-size: .72rem; color: #555; margin-top: .2rem; }
.receipt-table { width: 100%; font-size: .78rem; margin-bottom: .6rem; }
.receipt-table th {
    color: #555;
    border-bottom: 1px solid #ddd;
    padding: .3rem 0;
    font-size: .66rem;
    text-transform: uppercase;
}
.receipt-table td { padding: .28rem 0; border-bottom: 1px dashed #eee; }
.receipt-table .num { text-align: right; }
.receipt-row { display: flex; justify-content: space-between; font-size: .8rem; padding: .2rem 0; }
.receipt-row.total {
    font-family: 'Syne', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    border-top: 1px solid #ddd;
    margin-top: .4rem;
    padding-top: .5rem;
}
.receipt-warning { font-size: .7rem; color: #b45309; margin-top: .5rem; }
.receipt-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.receipt-actions button {
    flex: 1;
    padding: .65rem;
    border-radius: 9px;
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
}
.receipt-actions .print { background: #111; color: #fff; }
.receipt-actions .done { background: #e5e7eb; color: #111; }

/* ----  Sign-in gate  ---- */

.signin-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 14, 10, .94);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 250;
    padding: 1rem;
}
.signin-overlay[hidden] { display: none; }
.signin-card {
    background: var(--bg3);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.75rem;
    max-width: 420px;
    text-align: center;
}
.signin-card h2 { font-size: 1.15rem; margin-bottom: .6rem; }
.signin-card p { font-size: .84rem; color: var(--muted); margin-bottom: 1.1rem; line-height: 1.5; }
.signin-card a {
    display: inline-block;
    padding: .7rem 1.4rem;
    border-radius: 10px;
    background: var(--lime);
    color: #08110a;
    font-weight: 800;
    text-decoration: none;
    font-family: 'Syne', sans-serif;
    font-size: .88rem;
}

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

.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%) translateY(1rem);
    padding: .7rem 1.1rem;
    border-radius: 10px;
    font-size: .84rem;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity .18s, transform .18s;
    max-width: 70vw;
    text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: var(--lime); color: #08110a; font-weight: 700; }
.toast.bad { background: var(--red); color: #140404; font-weight: 700; }
.toast.warn { background: var(--amber); color: #1a1204; font-weight: 700; }
.toast.info { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }

/* Only the receipt is worth paper. */
@media print {
    body * { visibility: hidden; }
    .receipt-card, .receipt-card * { visibility: visible; }
    .receipt-card { position: absolute; left: 0; top: 0; box-shadow: none; width: 100%; }
    .receipt-actions { display: none; }
    .receipt-overlay { background: none; position: static; padding: 0; }
}

/* A till is sometimes a 10-inch tablet. The basket gets the room. */
@media (max-width: 1100px) {
    .till-body { grid-template-columns: minmax(0, 1fr) 300px; }
}
@media (max-width: 860px) {
    body { overflow: auto; }
    .till-page { height: auto; }
    .till-body { grid-template-columns: 1fr; }
    .basket { max-height: 45vh; }
}
