/* PMS counter.
   Bigger type and bigger hit targets than the admin shell: a cashier reads this
   at arm's length, under fluorescent light, while a queue watches. Bump ?v= in
   index.html on every edit. */

:root {
    --bg: #eef1f4;
    --panel: #ffffff;
    --ink: #16202a;
    --muted: #63727f;
    --line: #dfe5ea;
    --accent: #1668b3;
    --accent-ink: #ffffff;
    --ok: #17694a;
    --error: #b3261e;
    --warn-bg: #fff5e0;
    --warn-line: #e6c164;
    --rx-bg: #ede4f7;
    --rx-line: #9b7fc4;
}

* { box-sizing: border-box; }

/* The UA's [hidden] rule is display:none, but any author rule that sets display
   beats it. Several classes here set display:flex/grid, so without this `hidden`
   silently stops hiding. Learned the hard way in the admin shell. */
[hidden] { display: none !important; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
}

h1 { font-size: 20px; margin: 0 0 4px; }
.muted { color: var(--muted); }
.error { color: var(--error); }
.r { text-align: right; }

/* Keycap hints. The counter is keyboard-first: a cashier should never need the
   mouse for the common path. */
.keys {
    display: inline-block;
    padding: 0 5px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 4px;
    background: #f6f8fa;
    color: var(--muted);
    font: 600 11px/1.6 Consolas, monospace;
}
.keys.light { border-color: rgba(255,255,255,.5); background: rgba(255,255,255,.15); color: #fff; }

/* --- Login --------------------------------------------------------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 340px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 24px; }
label { display: block; margin: 12px 0 4px; font-size: 13px; font-weight: 600; }
input, select {
    width: 100%;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 5px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, button:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
    padding: 9px 14px;
    border: 0;
    border-radius: 5px;
    background: var(--accent);
    color: var(--accent-ink);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 500; }
button.danger, button.danger-text { color: var(--error); }
button.danger { background: var(--error); color: #fff; }
#login-btn { margin-top: 18px; width: 100%; }

/* --- Topbar -------------------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 14px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; }
.spacer { flex: 1; }
#terminal-select { width: auto; padding: 5px 8px; }
.whoami { text-align: right; font-size: 13px; }
.role-chip {
    display: inline-block; padding: 1px 8px; border-radius: 10px;
    background: #e7eef6; color: var(--accent); font-size: 12px; font-weight: 600;
}
.held-badge {
    padding: 3px 10px; border-radius: 10px;
    background: var(--warn-bg); border: 1px solid var(--warn-line);
    font-size: 12px; font-weight: 600;
}

/* --- Counter layout ------------------------------------------------------ */
.counter {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 14px;
    padding: 14px;
    align-items: start;
}
@media (max-width: 900px) { .counter { grid-template-columns: 1fr; } }

.cart-pane, .totals-pane {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
}

.scan-row { display: flex; gap: 8px; }
.scan-input { position: relative; flex: 1; }
#scan { width: 100%; font-size: 17px; padding: 11px 40px 11px 12px; }
/* The clear (x) button sits at the right edge of the search box and only shows
   when there is text -- toggled by pos.js. Big enough to hit with a thumb. */
.scan-clear {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
    width: 30px; height: 30px; padding: 0; margin: 0;
    display: flex; align-items: center; justify-content: center;
    border: 0; border-radius: 50%; background: transparent;
    color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer;
}
.scan-clear:hover { background: #eef2f6; color: var(--ink); }
#qty { width: 84px; font-size: 17px; padding: 11px 8px; text-align: center; }

/* Category chips under the scan bar: tap to browse a product type. */
.pos-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pos-chip {
    padding: 5px 13px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--panel); color: var(--ink);
    font-size: 13px; font-weight: 600; cursor: pointer;
}
.pos-chip:hover { border-color: var(--accent); color: var(--accent); }
.pos-chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Search results sit under the scan box like a typeahead. */
.results {
    margin-top: 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    max-height: 260px;
    overflow-y: auto;
}
.result {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px 10px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    font-weight: 500;
    text-align: left;
    cursor: pointer;
}
.result:last-child { border-bottom: 0; }
.result:hover, .result.active { background: #eef2f6; }
.result .nm { flex: 1; }
.result .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.result .pr { font-variant-numeric: tabular-nums; font-weight: 600; }

.cart { width: 100%; border-collapse: collapse; margin-top: 12px; }
.cart th, .cart td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.cart th {
    font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); text-align: left;
}
.cart td { font-size: 14px; }
.cart td.r, .cart th.r { text-align: right; font-variant-numeric: tabular-nums; }
.cart .lot { color: var(--muted); font-size: 12px; }
.cart tbody tr:last-child td { border-bottom: 0; }
.empty-note { text-align: center; padding: 34px 10px; }
.cart-qty { width: 62px; padding: 3px 6px; text-align: center; }

.pill { padding: 1px 6px; border-radius: 9px; font-size: 10px; font-weight: 700; }
.pill.rx { background: var(--rx-bg); color: #5b3a8e; }
.pill.ex { background: #e2f2ea; color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: #8a6100; }

/* Buyer attach box (device traceability). */
.buyer-box {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    padding: 8px 11px; margin-bottom: 12px;
    border: 1px solid var(--line); border-radius: 8px; background: #fafbfc;
}
.buyer-label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
#buyer-name { font-weight: 600; }
.buyer-box button { padding: 6px 11px; font-size: 12px; }

/* Serial / new-buyer forms inside the counter modal. */
.serial-form { display: grid; gap: 9px; margin-top: 12px; }
.serial-form label { display: block; margin-bottom: 3px; font-size: 13px; font-weight: 600; }

/* --- Totals -------------------------------------------------------------- */
.banner { padding: 9px 11px; border-radius: 6px; margin-bottom: 12px; font-size: 13px; }
.banner.rx { background: var(--rx-bg); border: 1px solid var(--rx-line); }

.discount-box { padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.discount-box label { margin-top: 0; }
#discount-id { margin-top: 8px; }
.form-hint { color: var(--muted); font-size: 12px; margin: 6px 0 0; }

.totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 14px 0 6px; }
.totals dt { color: var(--muted); font-size: 13px; }
.totals dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-size: 14px; }
.totals dt.grand, .totals dd.grand {
    margin-top: 8px; padding-top: 8px;
    border-top: 2px solid var(--ink);
    color: var(--ink); font-size: 22px; font-weight: 800;
}
.vat-note { font-size: 11px; margin: 0 0 12px; }

button.big { width: 100%; padding: 14px; font-size: 17px; }
.action-row { display: flex; gap: 6px; margin-top: 8px; }
.action-row button { flex: 1; padding: 7px 4px; font-size: 12px; }

/* --- Modal --------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 32, 42, .45);
    display: flex; align-items: flex-start; justify-content: center;
    padding: 40px 16px; overflow-y: auto; z-index: 50;
}
.modal { background: var(--panel); border-radius: 8px; width: 100%; max-width: 640px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-close { font-size: 20px; line-height: 1; padding: 2px 9px; }
.modal-body { padding: 18px; }
.modal-foot {
    display: flex; justify-content: flex-end; gap: 8px;
    padding: 12px 18px; border-top: 1px solid var(--line);
    background: #fafbfc; border-radius: 0 0 8px 8px;
}

/* The tender pad: the numbers a cashier actually needs, big enough to hit. */
.tender-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0 4px; }
.tender-grid button { padding: 10px 4px; font-size: 13px; }
.tender-due { font-size: 26px; font-weight: 800; text-align: right; font-variant-numeric: tabular-nums; }
.tender-change { font-size: 20px; font-weight: 700; text-align: right; color: var(--ok); font-variant-numeric: tabular-nums; }
.tender-change.short { color: var(--error); }
.pay-row { display: flex; gap: 8px; align-items: flex-end; margin-bottom: 8px; }
.pay-row select { width: 130px; }
.pay-row .rm { flex: none; }

table.plain { width: 100%; border-collapse: collapse; }
table.plain th, table.plain td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; }
table.plain th { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

/* Receipt preview: monospace, because that is what it is. */
pre.receipt {
    background: #f6f8fa;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    font: 12px/1.35 Consolas, "Courier New", monospace;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
}
