:root {
  --bg: #0f0f10; --surface: #161617; --surface2: #1c1c1e; --line: #2a2a2d; --line2: #36363a;
  --text: #ececee; --muted: #a3a3a8; --dim: #85858b;
  --violet: #a78bfa; --violet-bg: #1e1638; --violet-line: #4c3a8a; --on-violet: #1a1033;
  --red: #f59e8b; --red-bg: #33170f; --amber: #f2c46d; --amber-bg: #2e2410; --green: #8ee0b5; --green-bg: #0f2a1e;
  --r: 8px;
}
* { box-sizing: border-box; scrollbar-width: none; }
*::-webkit-scrollbar { display: none; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 12.5px/1.5 Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--violet); }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); } .dim { color: var(--dim); }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 17px; } h2 { font-size: 14px; } h3 { font-size: 12.5px; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px;
  padding: 10px 18px; background: rgba(15,15,16,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 13.5px; }
.brand .cup { width: 26px; height: 26px; border-radius: 7px; background: var(--violet-bg); border: 1px solid var(--violet-line);
  display: grid; place-items: center; }
.brand small { display: block; font-weight: 400; color: var(--dim); font-size: 10.5px; margin-top: -2px; }
nav { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
nav a { color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 6px; }
nav a:hover { color: var(--text); background: var(--surface2); }
nav a.on { color: var(--text); background: var(--surface2); box-shadow: inset 0 -2px 0 var(--violet); }
.topright { display: flex; align-items: center; gap: 10px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border: 1px solid var(--line2); border-radius: 999px;
  font-size: 11px; color: var(--muted); background: var(--surface); white-space: nowrap; }
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--dim); }
.pill.live { color: var(--green); border-color: #1f5a40; background: var(--green-bg); }
.pill.live .dot { background: var(--green); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .35; } }

main { max-width: 1320px; margin: 0 auto; padding: 18px; }
.pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.pagehead p { margin: 3px 0 0; color: var(--muted); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 32px; padding: 0 12px; border-radius: 6px;
  border: 1px solid var(--line2); background: var(--surface2); cursor: pointer; white-space: nowrap; }
a.btn { text-decoration: none; color: var(--text); }
.btn:hover { border-color: #4a4a50; background: #222225; }
.btn.primary { background: var(--violet); border-color: var(--violet); color: var(--on-violet); font-weight: 600; }
.btn.primary:hover { background: #c4b5fd; }
.btn.danger { color: var(--red); border-color: #5a2a20; background: var(--red-bg); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 26px; padding: 0 8px; font-size: 11.5px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: 11px; color: var(--muted); }
input[type=text], input[type=date], input[type=time], input[type=url], select, textarea {
  min-height: 32px; padding: 0 9px; border-radius: 6px; border: 1px solid var(--line2); background: var(--surface); outline: none; }
textarea { padding: 8px 9px; }
input:focus, select:focus, textarea:focus { border-color: var(--violet-line); box-shadow: 0 0 0 2px rgba(167,139,250,.15); }
input[type=date]::-webkit-calendar-picker-indicator, input[type=time]::-webkit-calendar-picker-indicator { filter: invert(.8); }
.row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; }
.seg { display: inline-flex; border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; background: var(--surface); }
.seg button { border: 0; background: transparent; padding: 6px 11px; cursor: pointer; color: var(--muted); min-height: 30px; }
.seg button + button { border-left: 1px solid var(--line2); }
.seg button.on { background: var(--violet-bg); color: var(--violet); }
.switch { position: relative; width: 36px; height: 20px; border-radius: 999px; background: var(--line2); border: 0; cursor: pointer; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #d4d4d8; transition: left .15s; }
.switch.on { background: var(--violet); } .switch.on::after { left: 19px; background: var(--on-violet); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card > .hd { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.card > .bd { padding: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

/* tables */
.tablewrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--dim);
  padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 8px 10px; border-bottom: 1px solid #222225; vertical-align: top; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--surface2); }
tr.sel td { background: var(--violet-bg); }
.tag { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 10.5px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; }
.tag.void { color: var(--red); border-color: #5a2a20; background: var(--red-bg); }
.tag.ref { color: var(--amber); border-color: #5a4518; background: var(--amber-bg); }
.tag.ok { color: var(--green); border-color: #1f5a40; background: var(--green-bg); }
.tag.vio { color: var(--violet); border-color: var(--violet-line); background: var(--violet-bg); }

/* register */
.register { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 14px; align-items: start; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cats button { border: 1px solid var(--line2); background: var(--surface); color: var(--muted); border-radius: 999px; padding: 5px 12px; cursor: pointer; min-height: 30px; }
.cats button.on { background: var(--violet-bg); border-color: var(--violet-line); color: var(--violet); }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.item { text-align: left; border: 1px solid var(--line); background: var(--surface); border-radius: var(--r); padding: 11px; cursor: pointer;
  min-height: 82px; display: flex; flex-direction: column; justify-content: space-between; gap: 8px; }
.item:hover { border-color: var(--violet-line); background: #18161f; }
.item .nm { font-weight: 500; } .item .pr { color: var(--muted); font-size: 11.5px; }
.cart { position: sticky; top: 64px; }
.cart .lines { max-height: 300px; overflow-y: auto; }
.cline { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.cline .sub { color: var(--dim); font-size: 11px; }
.qty { display: inline-flex; align-items: center; gap: 4px; }
.qty button { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line2); background: var(--surface2); cursor: pointer; padding: 0; }
.totals { display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; padding: 10px 0; }
.totals .big { font-size: 18px; font-weight: 600; }
.paygrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.paygrid button { min-height: 34px; border-radius: 6px; border: 1px solid var(--line2); background: var(--surface2); cursor: pointer; }
.paygrid button.on { background: var(--violet-bg); border-color: var(--violet-line); color: var(--violet); }
.empty { padding: 24px 10px; text-align: center; color: var(--dim); }

/* modal + drawer */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { width: min(440px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: var(--surface); border: 1px solid var(--line2); border-radius: 12px; }
.modal .hd { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.modal .bd { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.modal .ft { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.x { border: 0; background: transparent; color: var(--muted); cursor: pointer; width: 30px; height: 30px; border-radius: 6px; }
.x:hover { background: var(--surface2); color: var(--text); }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.opt { border: 1px solid var(--line2); background: var(--surface2); color: var(--muted); border-radius: 7px; padding: 7px 11px; cursor: pointer; min-height: 34px; }
.opt.on { border-color: var(--violet-line); background: var(--violet-bg); color: var(--violet); }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 40; width: min(440px, 100%); background: var(--surface); border-left: 1px solid var(--line2);
  overflow-y: auto; box-shadow: -20px 0 40px rgba(0,0,0,.4); }
.drawer .hd { position: sticky; top: 0; background: var(--surface); display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.drawer .bd { padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* receipt */
.receipt { background: #fbfaf7; color: #1b1b1b; border-radius: 6px; padding: 18px 16px; font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 11.5px; }
.receipt .c { text-align: center; } .receipt hr { border: 0; border-top: 1px dashed #999; margin: 8px 0; }
.receipt .r { display: flex; justify-content: space-between; gap: 10px; } .receipt .s { color: #555; padding-left: 10px; }
.receipt .b { font-weight: 700; font-size: 13px; }

/* z-report */
.kv { display: grid; grid-template-columns: 1fr auto; gap: 5px 14px; }
.kv .sep { grid-column: 1 / -1; border-top: 1px solid var(--line); margin: 4px 0; }
.kv .strong { font-weight: 600; }

/* setup screen + toast */
.setup { min-height: 80vh; display: grid; place-items: center; }
.setup .box { width: min(460px, 100%); text-align: center; display: flex; flex-direction: column; gap: 12px; }
.bar { height: 6px; border-radius: 999px; background: var(--line); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--violet); transition: width .4s; }
.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; padding: 9px 14px; border-radius: 8px;
  background: #26262a; border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: calc(100% - 32px); }
.toast.err { border-color: #5a2a20; color: var(--red); background: var(--red-bg); }
code, pre { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; font-size: 11.5px; }
pre { margin: 0; padding: 12px; background: #0b0b0c; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; white-space: pre; color: #d4d4d8; }
.keybox { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.keybox code { padding: 7px 9px; background: #0b0b0c; border: 1px solid var(--line); border-radius: 6px; word-break: break-all; }
ul.tips { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
ul.tips b { color: var(--text); font-weight: 500; }

@media (max-width: 640px) { #clock { display: none; } main { padding: 14px 12px; } }
@media (max-width: 980px) {
  .register { grid-template-columns: 1fr; }
  .cart { position: static; }
  .grid2 { grid-template-columns: 1fr; }
}
@media print { .top, .no-print { display: none !important; } body { background: #fff; } }

/* KPI strip (Z-Report, Sales by branch) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .lbl { color: var(--muted); font-size: 11.5px; }
.kpi .val { font-size: 17px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .sub { font-size: 11px; color: var(--muted); }
.up { color: var(--green); } .down { color: var(--red); }
/* sales by hour */
.hbars { display: flex; align-items: flex-end; gap: 3px; height: 150px; padding-top: 18px; }
.hb { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; position: relative; cursor: default; }
.hb .c { flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.hb i { display: block; width: 100%; max-width: 26px; background: var(--violet); opacity: .45; border-radius: 4px 4px 0 0; }
.hb:hover i, .hb.pk i { opacity: 1; }
.hb .h { font-size: 9.5px; color: var(--dim); margin-top: 4px; white-space: nowrap; height: 14px; }
.hb .v { position: absolute; top: -16px; font-size: 10.5px; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* share bar inside a table cell */
.share { display: inline-block; vertical-align: middle; width: 28px; height: 6px; border-radius: 3px; background: var(--surface2); margin-right: 6px; overflow: hidden; }
.share i { display: block; height: 100%; background: var(--violet); border-radius: 3px; }
/* sortable headers */
th.sort { cursor: pointer; user-select: none; }
th.sort:hover, th.sort.on { color: var(--text); }
.grid2 > *, .stack > * { min-width: 0; }
@media (max-width: 640px) { .hb .h { font-size: 9px; } .hb .h.odd { visibility: hidden; } .share { display: none; } .hbars { gap: 2px; } }

/* viewer mode (online demo) */
.pill.demo { color: var(--violet); border-color: var(--violet-line); background: var(--violet-bg); }

/* products: a line between products that have several sizes */
tr.grp td { border-top: 1px solid var(--line); }
table.ptable { table-layout: fixed; min-width: 760px; }
@media (max-width: 640px) { .topright { flex-wrap: wrap; gap: 6px; min-width: 0; } .pill.demo { font-size: 10.5px; padding-left: 7px; padding-right: 7px; } }
@media (max-width: 640px) {
  table.ptable { table-layout: auto; min-width: 0; }
  table.ptable col { width: auto !important; }
  table.ptable th { white-space: normal; }
  table.ptable th:nth-child(2), table.ptable td:nth-child(2), table.ptable th:nth-child(5), table.ptable td:nth-child(5),
  table.ptable th:nth-child(6), table.ptable td:nth-child(6) { display: none; }
}

/* compact report tables that should fit the page */
table.fit th, table.fit td { padding-left: 7px; padding-right: 7px; }
table.fit th { white-space: normal; vertical-align: bottom; }
td .sub { font-size: 11px; color: var(--dim); font-weight: 400; margin-top: 1px; }
/* fade on a table edge when there are more columns to scroll to */
.tablewrap { position: relative; }
.tablewrap.more-r { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 56px), transparent); }
.tablewrap.more-l { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 56px), transparent); }
.tablewrap.more-l.more-r { -webkit-mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(to right, transparent, #000 56px, #000 calc(100% - 56px), transparent); }

/* About page */
h2.sect { font-size: 15px; font-weight: 600; margin: 4px 0 10px; }
.realgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
ul.facts { margin: 0; padding-left: 16px; display: flex; flex-direction: column; gap: 6px; color: var(--muted); }
ul.facts li::marker { color: var(--violet); }

/* About: intro + numbers on the left, event stream on the right */
.abouttop { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); gap: 14px; align-items: stretch; margin-bottom: 14px; }
.abouttop .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 0; }
.abouttop .pagehead p { max-width: none !important; }
@media (max-width: 980px) { .abouttop { grid-template-columns: 1fr; } }
.evp { display: flex; flex-direction: column; overflow: hidden; }
.evp .hd h2 { font-family: "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; font-size: 12px; font-weight: 500; }
.evlive { display: inline-flex; align-items: center; gap: 7px; font: 11px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; color: var(--dim); }
.evlive .d { width: 7px; height: 7px; border-radius: 9px; background: var(--dim); }
.evlive.on .d { background: var(--green); box-shadow: 0 0 9px var(--green); }
.stream { font: 11.5px/1.5 "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; }
.ev { display: grid; grid-template-columns: 64px 112px minmax(0, 1fr) auto; gap: 10px; padding: 6px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.ev:first-child { background: linear-gradient(90deg, rgba(142,224,181,.08), transparent); }
.ev .t { color: var(--dim); } .ev .ok { color: var(--green); } .ev .warn { color: var(--amber); } .ev .bad { color: var(--red); }
.ev .b { color: var(--muted); overflow: hidden; text-overflow: ellipsis; } .ev .a { text-align: right; color: var(--text); font-variant-numeric: tabular-nums; }
.ev.new { animation: evin 1.4s ease-out; }
@keyframes evin { from { background: rgba(167,139,250,.22); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .ev.new { animation: none; } }
@media (max-width: 640px) { .ev { grid-template-columns: 58px minmax(0, 1fr) auto; } .ev .b { display: none; } }

/* Menu with key numbers, and the command palette (Ctrl+K) */
kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 16px; height: 16px; padding: 0 4px; border: 1px solid var(--line2);
  border-bottom-width: 2px; border-radius: 4px; font: 500 9.5px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; color: var(--dim); background: var(--surface); line-height: 1; }
nav a { display: inline-flex; align-items: center; gap: 7px; }
nav a kbd:empty { display: none; }
nav a.on kbd { color: var(--violet); border-color: var(--violet-line); }
.cmdk { display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 6px 0 10px; border: 1px solid var(--line2); border-radius: 6px;
  background: var(--surface); color: var(--dim); cursor: pointer; font: 11.5px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; }
.cmdk:hover { color: var(--muted); border-color: var(--violet-line); }
.cmdk .p { color: var(--violet); }
.overlay.cmdlayer { align-items: flex-start; padding-top: 12vh; background: rgba(0,0,0,.6); backdrop-filter: blur(2px); }
.cmd { width: min(620px, 100%); background: var(--surface); border: 1px solid var(--line2); border-radius: 10px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 1px rgba(167,139,250,.08); }
.cmdin { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.cmdin .p { color: var(--violet); font: 600 14px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; }
.cmdin input { flex: 1; min-width: 0; border: 0 !important; background: transparent !important; outline: none; padding: 2px 0 !important;
  font: 13px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; color: var(--text); box-shadow: none !important; }
.cmdlist { max-height: min(420px, 55vh); overflow-y: auto; padding: 6px; }
.cmdg { padding: 8px 8px 4px; font: 10px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; color: var(--dim); }
.cmdi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text);
  cursor: pointer; text-align: left; font-size: 12.5px; }
.cmdi .l { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdi .h { color: var(--dim); font: 11px "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace; white-space: nowrap; }
.cmdi.on { background: rgba(167,139,250,.12); box-shadow: inset 2px 0 0 var(--violet); }
.cmdi.on .h { color: var(--muted); }
.cmdempty { padding: 18px 12px; color: var(--dim); text-align: center; }
.cmdfoot { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--dim); font-size: 11px; }
.cmdfoot span { display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 980px) { nav a kbd, .cmdk .t, .cmdk kbd { display: none; } }
#branch { max-width: 170px; }
@media (max-width: 1500px) { #clock { display: none; } }
@media (max-width: 1360px) { nav a kbd { display: none; } }
nav a[hidden] { display: none !important; }
nav a kbd { display: none !important; }
