:root {
  --bg: #0d0f12; --card: #16191e; --line: #262a31; --text: #e8eaed; --muted: #8b929c;
  --accent: #3fd8c2; --accent-text: #062b26; --bad: #ff6b6b; --ok: #43d17a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
h1, h2, h3 { margin: 0 0 .6rem; } h2 { font-size: 1.1rem; } h3 { font-size: .9rem; color: var(--muted); margin-top: 1rem; }
code { background: var(--line); padding: .1rem .35rem; border-radius: 4px; }
button, input, select { font: inherit; color: inherit; background: #1f232a; border: 1px solid var(--line); border-radius: 8px; padding: .45rem .7rem; }
button { cursor: pointer; } button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input[type=checkbox] { width: 1.1rem; height: 1.1rem; accent-color: var(--accent); }

.muted { color: var(--muted); }
.center { max-width: 420px; margin: 15vh auto; text-align: center; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1rem; margin-bottom: 1rem; }
.login button { width: 100%; margin-top: 1rem; }
.error { color: var(--bad); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.check { display: flex; gap: .4rem; align-items: center; }
.pill { font-size: .75rem; padding: .1rem .45rem; border-radius: 99px; background: var(--line); white-space: nowrap; }
.pill.ok { background: #143823; color: var(--ok); } .pill.bad { background: #3a1717; color: var(--bad); }
.w4 { width: 4.5rem; } .w8 { width: 7rem; }

header { display: flex; align-items: center; gap: .75rem; padding: .6rem 1rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { color: var(--accent); font-size: 1.1rem; }
nav { display: flex; gap: .25rem; flex-wrap: wrap; }
nav a { color: var(--muted); text-decoration: none; padding: .35rem .7rem; border-radius: 8px; }
nav a.active, nav a:hover { color: var(--text); background: var(--line); }
#clock.on { border-color: var(--ok); color: var(--ok); } #clock.off { border-color: var(--bad); color: var(--bad); }
main { padding: 1rem; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 500; font-size: .8rem; }
.num { text-align: right; }
tr.clickable { cursor: pointer; } tr.clickable:hover { background: #1b1f25; }
tr.detail td { background: #12151a; } tr.detail button { margin-top: .5rem; }
table.edit input:not([type=checkbox]), table.edit select { width: 100%; min-width: 5rem; }
table.edit .w4 { width: 4.5rem; min-width: 0; } table.edit .w8 { width: 7rem; }

.pos { display: grid; grid-template-columns: 220px 1fr 340px; gap: 1rem; align-items: start; }
.pos .card { margin: 0; }
.products { min-height: 70vh; } .products > input { width: 100%; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.product { display: flex; flex-direction: column; align-items: flex-start; gap: .2rem; text-align: left; padding: .7rem; min-height: 90px; }
.product img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 6px; }
.product b { color: var(--accent); }
.tag { font-size: .7rem; color: var(--muted); }
.pending-bill { width: 100%; text-align: left; margin-bottom: .4rem; }
.pending #hold { width: 100%; }
.cart { position: sticky; top: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.lines { max-height: 40vh; overflow: auto; }
.line { display: grid; grid-template-columns: 1fr auto auto; gap: .5rem; align-items: center; padding: .4rem 0; border-bottom: 1px solid var(--line); }
.qty { display: flex; gap: .3rem; align-items: center; } .qty button { padding: .1rem .5rem; }
.totals > div { display: flex; justify-content: space-between; }
.totals .total { font-size: 1.2rem; font-weight: 700; }
.cart .row button { flex: 1; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .75rem; margin-top: .75rem; }
.stats div { background: #1f232a; border-radius: 10px; padding: .75rem; display: flex; flex-direction: column; }
.stats b { font-size: 1.3rem; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.discount .rules { margin-top: .6rem; display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }

#toast { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: #1f232a; border: 1px solid var(--accent);
  padding: .6rem 1rem; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; } #toast.bad { border-color: var(--bad); }

@media (max-width: 1000px) { .pos, .two { grid-template-columns: 1fr; } .cart { position: static; } }
