:root { --shadow: 0 6px 18px rgba(0,0,0,.18); --overlay: rgba(0,0,0,.45); }
[data-theme="dark"] { --shadow: 0 6px 18px rgba(0,0,0,.5); --overlay: rgba(0,0,0,.6); }
/* colours of each theme: themes.css (generated by tools/themes.py) */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: "Sarabun", "Noto Sans Thai", Tahoma, sans-serif; font-size: 16px; color: var(--text); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { padding: 12px 16px; }
h1, h2, h3 { margin: 0 0 10px; }
input, select, textarea, button { font: inherit; }
input, select, textarea { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: var(--input, var(--surface)); color: var(--text); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: -1px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .warn { color: var(--warn); } .bad { color: var(--bad); } .good { color: var(--ok); } .center { text-align: center; }
.big { font-size: 20px; } .huge { font-size: 44px; font-weight: bold; margin: 8px 0; }
.n { text-align: right; white-space: nowrap; }
main > h2, main > h3, main > .page-title, main > p.muted, main > p > .muted { color: var(--bg-text); }

/* top bar */
.topbar { display: flex; align-items: center; gap: 14px; padding: 0 12px; height: 52px; background: var(--topbar); color: var(--topbar-text); }
.topbar .brand { font-weight: bold; font-size: 18px; color: var(--topbar-text); }
.topbar nav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.topbar nav a { color: var(--topbar-text); padding: 14px 11px; white-space: nowrap; }
.topbar nav a.on, .topbar nav a:hover { color: #fff; background: var(--topbar-on); text-decoration: none; }
.topbar .who { display: flex; align-items: center; gap: 8px; font-size: 14px; white-space: nowrap; }
.topbar .who a { color: var(--topbar-text); }
.topbar select.theme { padding: 3px 6px; font-size: 13px; background: var(--topbar-on); color: var(--topbar-text); border-color: transparent; }
.avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex: none; display: inline-flex; align-items: center; justify-content: center; font-weight: bold; color: var(--muted); border: 2px solid rgba(255,255,255,.6); }
.avatar.lg { width: 72px; height: 72px; font-size: 28px; }
.avatar.xl { width: 140px; height: 140px; font-size: 54px; border-radius: 12px; }

.btn { display: inline-block; padding: 8px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--text); cursor: pointer; }
.btn:hover { background: var(--hover); text-decoration: none; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { background: #9b1c1c; border-color: #9b1c1c; color: #fff; }
.btn.big { width: 100%; padding: 14px; font-size: 20px; font-weight: bold; }
.btn.small { padding: 4px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 16px; margin-bottom: 12px; }
.card.narrow { max-width: 380px; margin: 40px auto; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 12px; background: var(--on); color: var(--ok); border: 1px solid var(--line); }
.flash.bad, .err { color: var(--bad); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; }
.cols-2 { display: grid; grid-template-columns: minmax(260px, 1fr) 2fr; gap: 12px; align-items: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; }
.stat b { display: block; font-size: 24px; }
.stat span { color: var(--muted); font-size: 14px; }

.form { max-width: 720px; }
.form label { display: block; margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.form label input:not([type=checkbox]), .form label select, .form label textarea { display: block; width: 100%; margin-top: 3px; color: var(--text); font-size: 16px; }
.form label.check { color: var(--text); }
.login label { display: block; margin-bottom: 12px; }
.login label input { display: block; width: 100%; margin-top: 4px; }
.login .btn { width: 100%; }

.toolbar { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.filters { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.filters label { color: var(--muted); font-size: 14px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tabs a { padding: 8px 14px; border-radius: 6px 6px 0 0; background: var(--surface-2); color: var(--text); border: 1px solid var(--line); border-bottom: 0; }
.tabs a.on { background: var(--surface); font-weight: bold; }
.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); }
.grid th, .grid td { padding: 7px 9px; border-bottom: 1px solid var(--line); text-align: left; }
.grid th { background: var(--surface-2); font-weight: 600; font-size: 14px; }
.grid th.n, .grid td.n { text-align: right; }
.grid tr.dim td { color: var(--muted); }
.grid tr.void td { color: var(--muted); text-decoration: line-through; }
.grid tr.on td { background: var(--on); }
.grid tfoot td { font-weight: bold; background: var(--surface-2); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin: 12px 0; }
.pager span { color: var(--bg-text); }

/* sales screen */
.page-sell main { padding: 8px; }
.sell { display: grid; grid-template-columns: 1fr 360px; gap: 8px; height: calc(100vh - 68px); }
.sell-left { display: flex; flex-direction: column; min-height: 0; }
.scan { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.scan input { flex: 1; font-size: 24px; padding: 10px 12px; }
.scan .keys { color: var(--muted); font-size: 13px; white-space: nowrap; }
.scan .keys { color: var(--bg-text); }
.cart-wrap { flex: 1; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.cart { width: 100%; border-collapse: collapse; }
.cart th { position: sticky; top: 0; background: var(--surface-2); padding: 8px; text-align: left; font-size: 14px; }
.cart th.n { text-align: right; }
.cart td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.cart tr.last td { background: var(--last); }
.cart .name { font-size: 18px; }
.cart input.qty { width: 80px; text-align: right; }
.cart input.price { width: 100px; text-align: right; }
.cart .del { border: 0; background: none; color: var(--bad); font-size: 18px; cursor: pointer; }
.sell-right { display: flex; flex-direction: column; gap: 8px; overflow: auto; }
.box { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 12px; position: relative; }
.cashier { display: flex; gap: 12px; align-items: center; }
.cashier .who-name { font-size: 20px; font-weight: bold; }
.member .row input { flex: 1; }
#memberInfo { margin-top: 6px; }
.totals .line { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.totals .line input { width: 150px; text-align: right; font-size: 20px; }
.totals .line #redeem { width: 90px; }
.totals .line b { font-size: 22px; }
.totals .grand b { font-size: 34px; color: var(--accent); }
.totals .change b { font-size: 30px; color: var(--ok); }
.totals .change b.bad { color: var(--bad); }
.totals .credit { display: block; margin: 8px 0; }
.totals .row { margin-top: 8px; }
.totals .row .btn { flex: 1; }
.msg { min-height: 1.4em; margin: 6px 0 0; }
.msg.bad { color: var(--bad); font-weight: bold; }
.picklist { list-style: none; margin: 4px 0 0; padding: 0; max-height: 50vh; overflow: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.member .picklist { position: absolute; left: 12px; right: 12px; z-index: 5; box-shadow: var(--shadow); }
.picklist li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; }
.picklist li:hover, .picklist li.on { background: var(--on); }
.picklist.big li { font-size: 18px; }
.modal { position: fixed; inset: 0; background: var(--overlay); display: flex; align-items: center; justify-content: center; z-index: 20; }
.modal-box { background: var(--surface); border-radius: 10px; padding: 20px; width: min(720px, 94vw); max-height: 86vh; overflow: auto; }

/* price check / stock count */
.pricecheck { display: flex; gap: 8px; margin-bottom: 12px; }
.pricecheck input { flex: 1; font-size: 26px; padding: 10px; }
.pricebox { text-align: center; padding: 30px; }
.pricebox .pname { font-size: 30px; }
.pricebox .pprice { font-size: 80px; font-weight: bold; color: var(--accent); }
.pricebox .pprice small { font-size: 30px; }
.countbox input[name=counted] { font-size: 34px; width: 200px; text-align: right; }

.credit-bill .row { margin-top: 8px; }
.credit-bill input[name=amount] { width: 130px; text-align: right; }
.user-photo-form { display: flex; gap: 16px; align-items: center; }

@media (max-width: 900px) {
  .sell { grid-template-columns: 1fr; height: auto; }
  .cart-wrap { max-height: 50vh; }
  .cols-2 { grid-template-columns: 1fr; }
  .scan .keys { display: none; }
  .topbar { height: auto; flex-wrap: wrap; padding: 6px 12px; }
}

/* theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.tp { border-radius: 10px; overflow: hidden; background: var(--bg); border: 3px solid transparent; box-shadow: var(--shadow); }
.tp.current { border-color: #f5d76e; }
.tp .tp-top { background: var(--topbar); color: var(--topbar-text); padding: 8px 10px; display: flex; justify-content: space-between; font-size: 14px; }
.tp .tp-top b { color: #fff; }
.tp .tp-body { display: grid; grid-template-columns: 1fr 120px; gap: 6px; padding: 8px; }
.tp .tp-scan { grid-column: 1 / -1; background: var(--input); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; color: var(--muted); font-size: 13px; }
.tp table { width: 100%; border-collapse: collapse; background: var(--surface); color: var(--text); font-size: 13px; border-radius: 5px; overflow: hidden; }
.tp th { background: var(--surface-2); text-align: left; padding: 3px 6px; font-weight: 600; }
.tp td { padding: 4px 6px; border-top: 1px solid var(--line); }
.tp tr.last td { background: var(--last); }
.tp .tp-tot { background: var(--surface); border-radius: 5px; padding: 6px; color: var(--text); font-size: 13px; display: flex; flex-direction: column; gap: 3px; }
.tp .tp-tot .g { font-size: 22px; font-weight: bold; color: var(--accent); text-align: right; }
.tp .tp-tot .btn { padding: 5px; font-size: 13px; text-align: center; }
.tp .tp-foot { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px 10px; color: var(--bg-text); }
.tp .tp-foot .name { font-size: 18px; font-weight: bold; }

/* quick buttons panel (sales screen, F9) - sits over the cart, totals stay visible */
.qb-open { white-space: nowrap; font-weight: bold; }
.qb-open small { opacity: .7; font-weight: normal; }
.cart-area { position: relative; flex: 1; display: flex; flex-direction: column; min-height: 0; }
.qb { position: absolute; inset: 0; z-index: 4; display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; }
.qb[data-mode="see"] { background: color-mix(in srgb, var(--bg) 30%, transparent); }        /* cart shows faintly behind */
.qb[data-mode="see"] .qb-btn { opacity: .95; }
.qb[data-mode="see"] .qb-last { display: none; }
.qb[data-mode="last"] { background: var(--surface-2); border: 1px solid var(--line); }
.qb-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px; background: var(--topbar); color: var(--topbar-text); }
.qb-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.qb-tabs button { border: 0; border-radius: 6px; padding: 7px 14px; font-size: 16px; background: var(--topbar-on); color: var(--topbar-text); cursor: pointer; }
.qb-tabs button.on { background: var(--surface); color: var(--text); font-weight: bold; }
.qb-tools { display: flex; gap: 10px; align-items: center; font-size: 13px; white-space: nowrap; }
.qb-tools a { color: var(--topbar-text); font-size: 18px; text-decoration: none; }
.qb-tools select { padding: 3px; font-size: 13px; }
.qb-close { border: 0; background: #9b1c1c; color: #fff; font-size: 20px; width: 40px; height: 36px; border-radius: 6px; cursor: pointer; }
.qb-last { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; background: var(--last); color: var(--text); font-size: 17px; border-bottom: 1px solid var(--line); }
.qb-grid { flex: 1; overflow: auto; padding: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); grid-auto-rows: 96px; gap: 10px; align-content: start; }
.qb-btn { border: 1px solid rgba(0,0,0,.18); border-radius: 12px; color: #141a1e; cursor: pointer; display: flex; flex-direction: column; justify-content: space-between; text-align: left; padding: 9px 11px; box-shadow: 0 2px 0 rgba(0,0,0,.18); transition: transform .08s, box-shadow .08s, filter .08s; }
.qb-btn .l { font-size: 18px; font-weight: 600; line-height: 1.2; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.qb-btn .pr { font-size: 16px; text-align: right; opacity: .8; }
.qb-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 10px rgba(0,0,0,.25); filter: brightness(1.04); opacity: 1 !important; }
.qb-btn.hit { transform: scale(.94); filter: brightness(.92); }
.c-g { background: #9ccaa9; } .c-b { background: #a7bedb; } .c-t { background: #96c7c2; } .c-y { background: #dccf8f; }
.c-o { background: #e0b88e; } .c-r { background: #dba8a3; } .c-p { background: #bfaedb; } .c-n { background: #c3c8cc; }
[data-theme="dark"] .qb-btn { filter: brightness(.78); }
[data-theme="dark"] .qb-btn:hover { filter: brightness(.88); }
.swatch { display: inline-block; width: 22px; height: 22px; border-radius: 5px; vertical-align: middle; border: 1px solid rgba(0,0,0,.25); }

/* clock in the top bar: layout.php picks full Thai date -> short date -> time only -> hidden,
   whichever is the most detailed that still leaves the menu room */
.clock { white-space: nowrap; font-size: 19px; color: var(--topbar-text); font-variant-numeric: tabular-nums; }
.clock .clk-time { font-size: 23px; font-weight: bold; color: #fff; letter-spacing: .5px; }
.clock .clk-short { display: none; }
.clock[data-fit="short"] .clk-full { display: none; }
.clock[data-fit="short"] .clk-short { display: inline; }
.clock[data-fit="time"] .clk-full { display: none; }
.clock[data-fit="none"] { display: none; }

/* vivid "blood red" highlights (same in every theme): time, net total, pay button.
   Red is the background with white text - red text on the muted cards would be hard to read. */
:root { --hot: #d0101e; --hot-hover: #e0182a; }
.clock .clk-time { background: var(--hot); color: #fff; padding: 2px 10px; border-radius: 6px; margin-left: 6px; }
.totals .grand b { background: var(--hot); color: #fff; padding: 2px 12px; border-radius: 8px; min-width: 150px; text-align: right; }
#save.btn.primary { background: var(--hot); border-color: var(--hot); color: #fff; }
#save.btn.primary:hover { background: var(--hot-hover); filter: none; }
.tp .tp-tot .g { background: var(--hot); color: #fff; border-radius: 6px; padding: 0 6px; }
.tp .tp-tot .btn.primary { background: var(--hot); border-color: var(--hot); }

.install-app { background: var(--hot); border-color: var(--hot); color: #fff; font-weight: bold; white-space: nowrap; }
.install-app:hover { background: var(--hot-hover); }
