:root {
  --bg: #f4f6f4; --panel: #ffffff; --text: #1b211d; --muted: #66706a; --line: #dfe4e0;
  --accent: #1f7a4d; --accent-ink: #ffffff; --danger: #b3261e; --warn: #9a6700; --ok: #1f7a4d;
  --soft: #eaf3ee; --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --panel: #1b201d; --text: #e6ebe7; --muted: #95a199; --line: #2c3430;
    --accent: #3fae78; --accent-ink: #0b130e; --danger: #ef6b62; --warn: #e0b04a; --ok: #3fae78; --soft: #1f2d25; }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); min-height: 44px; }
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
label > input, label > select, label > textarea { margin-top: 4px; }
button { min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.big { min-height: 64px; font-size: 18px; width: 100%; }
h1, h2, h3 { margin: 0 0 12px; } h2 { font-size: 20px; } h3 { font-size: 16px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
header .brand { font-weight: 700; margin-right: 8px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
nav a { padding: 10px 14px; border-radius: 8px; color: var(--text); text-decoration: none; }
nav a.active { background: var(--soft); color: var(--accent); font-weight: 600; }
.scalechip { display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-radius: 999px; }
.scalechip .w { font-variant-numeric: tabular-nums; font-weight: 700; min-width: 80px; text-align: right; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); } .dot.moving { background: var(--warn); } .dot.err { background: var(--danger); }
.scalechip button { min-height: 34px; border-radius: 999px; }

main { padding: 16px; max-width: 1280px; margin: 0 auto; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.counter { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.3fr); gap: 16px; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 860px) { .counter, .grid2, .form2 { grid-template-columns: 1fr; } }

.list { max-height: 360px; overflow: auto; }
.list button { display: flex; justify-content: space-between; width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; background: none; }
.list button:hover, .list button.sel { background: var(--soft); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: var(--soft); color: var(--accent); font-weight: 600; }
.badge.bad { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.badge.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }

.meter { margin: 8px 0 14px; }
.meter .bar { height: 10px; background: var(--line); border-radius: 999px; overflow: hidden; }
.meter .fill { height: 100%; background: var(--accent); }
.meter .fill.high { background: var(--warn); } .meter .fill.full { background: var(--danger); }
.meter .lbl { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }

.products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.products button { height: auto; padding: 12px; text-align: left; display: block; }
.products button.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent) inset; }
.products .n { font-weight: 600; display: block; }
.products .s { font-size: 13px; color: var(--muted); }

.weigh { display: flex; gap: 10px; align-items: stretch; margin: 14px 0; }
.weigh input { font-size: 28px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.weigh .unit { align-self: center; font-size: 22px; color: var(--muted); }
.problems { color: var(--danger); margin: 8px 0; padding-left: 18px; }
.total { font-size: 22px; font-weight: 700; }

.login { max-width: 380px; margin: 10vh auto; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--text); padding: 20px; width: min(560px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); padding: 12px 18px; border-radius: 8px; background: var(--text); color: var(--bg); opacity: 0; transition: opacity .2s; pointer-events: none; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; } #toast.err { background: var(--danger); color: #fff; }
.scroll { overflow-x: auto; }

/* buy-in, vault and refill */
.row.nowrap { flex-wrap: nowrap; gap: 6px; }
input.num { text-align: right; font-variant-numeric: tabular-nums; }
table.lines td { vertical-align: middle; } table.lines input { min-width: 90px; } table.lines select { min-width: 160px; }
tfoot td { border-bottom: 0; font-weight: 700; }
a[data-trace] { color: var(--accent); font-weight: 600; font-variant-numeric: tabular-nums; }
dialog.wide { width: min(820px, calc(100vw - 32px)); }
.scroll.tall { max-height: 220px; overflow: auto; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.chips button { min-height: 40px; padding: 0 12px; font-variant-numeric: tabular-nums; }
.group { padding: 12px 0; border-bottom: 1px solid var(--line); } .group:last-child { border-bottom: 0; }
label.check { display: flex; gap: 10px; align-items: center; color: var(--text); font-size: 15px; }
label.check input { width: auto; min-height: 0; margin: 0; }

/* labels: always black on white, sized for a 62 mm label roll or an A4 sheet */
#labels { position: fixed; inset: 0; z-index: 50; overflow: auto; background: var(--bg); }
.labelbar { position: sticky; top: 0; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.sheet { display: flex; flex-wrap: wrap; gap: 4mm; padding: 16px; }
.label { width: 62mm; padding: 3mm; background: #fff; color: #000; border: 1px solid #bbb; border-radius: 2mm; text-align: center; break-inside: avoid; }
.label .ln { font-weight: 700; font-size: 13pt; line-height: 1.15; overflow-wrap: anywhere; }
.label .lw { font-size: 16pt; font-weight: 700; }
.label .ls { font-size: 7.5pt; margin-bottom: 1.5mm; }
.label svg { max-width: 100%; height: auto; }
@media print {
  body { background: #fff; }
  body > :not(#labels) { display: none !important; }
  #labels { position: static; overflow: visible; background: #fff; }
  .labelbar { display: none; } .sheet { padding: 0; }
}

/* Product name */
.product-name { font-weight: 800; font-size: 1.4rem; letter-spacing: .02em; margin-bottom: 4px; }
header .scs { font-weight: 800; font-size: .75rem; letter-spacing: .08em; padding: 2px 6px; border-radius: 4px; border: 1px solid currentColor; opacity: .7; margin-right: 6px; }

/* operator console */
:root { --info: #2f5fb3; }
@media (prefers-color-scheme: dark) { :root { --info: #7ea6ef; } }
a { color: var(--accent); }
a.btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); text-decoration: none; }
button.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.badge.info { background: color-mix(in srgb, var(--info) 15%, transparent); color: var(--info); }
.small { font-size: 12px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .tl { font-size: 13px; color: var(--muted); }
.tile .tv { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; font-variant-numeric: tabular-nums; margin: 2px 0; }
.tile .ts { font-size: 13px; color: var(--muted); }
.tile.warn { border-color: var(--warn); } .tile.warn .tv { color: var(--warn); }
.tile.bad { border-color: var(--danger); } .tile.bad .tv { color: var(--danger); }
.filters { margin-bottom: 8px; } .filters input { flex: 2 1 220px; width: auto; } .filters select { flex: 1 1 150px; width: auto; }
table.clubs tbody tr { cursor: pointer; } table.clubs tbody tr:hover { background: var(--soft); }
table.clubs td.num { white-space: nowrap; } table.clubs td:first-child { min-width: 170px; }
body.op main { max-width: 1600px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-bottom: 18px; }
.bars .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.bars .bar span { display: block; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.bars .bar em { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; font-size: 11px; font-style: normal; color: var(--muted); }
ul.alerts { margin: 12px 0; padding-left: 18px; } ul.alerts li.bad { color: var(--danger); } ul.alerts li.warn { color: var(--warn); }
.licbar { padding: 10px 16px; background: color-mix(in srgb, var(--warn) 18%, var(--panel)); color: var(--text); border-bottom: 1px solid var(--line); text-align: center; font-weight: 600; }
.licbar.bad { background: color-mix(in srgb, var(--danger) 18%, var(--panel)); }
.pre { white-space: pre-wrap; margin: 0; }
code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; overflow-wrap: anywhere; }
code.big { font-size: 20px; font-weight: 700; }
textarea { min-height: 80px; }

/* v7: header with a folding menu on phones and small laptops */
.menubtn { display: none; margin-left: auto; }
.navbox { display: flex; align-items: center; gap: 12px; flex: 1; flex-wrap: wrap; }
.userbox { display: flex; align-items: center; gap: 8px; }
nav a { padding: 10px 12px; }
@media (min-width: 861px) { nav { flex-wrap: nowrap; } }
@media (max-width: 1500px) and (min-width: 861px) {
  nav a { padding: 8px 8px; } header { gap: 8px; } .userbox button { padding: 0 10px; } .userbox .muted { display: none; }
  header .brand { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .scalechip .w { min-width: 64px; } .scalechip button { padding: 0 10px; }
}
.filters label.check { white-space: nowrap; }
.dlgerr:empty { display: none; }
@media (max-width: 860px) {
  header { padding: 8px 12px; gap: 8px; }
  header .brand { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-right: 0; }
  .menubtn { display: inline-block; min-height: 40px; padding: 0 12px; font-weight: 600; color: var(--accent); white-space: nowrap; }
  .navbox { display: none; order: 10; flex-basis: 100%; flex-direction: column; align-items: stretch; }
  header.open .navbox { display: flex; }
  nav { flex-direction: column; } nav a { padding: 12px; border-bottom: 1px solid var(--line); border-radius: 0; }
  .userbox { justify-content: flex-end; flex-wrap: wrap; }
  .scalechip { order: 5; flex-basis: 100%; justify-content: space-between; padding: 2px 2px 2px 12px; }
  .scalechip button { min-height: 32px; }
  .scalechip .w { min-width: 0; }
  main { padding: 12px; }
  .panel { padding: 12px; }
  /* operator clubs list and member list as cards on a phone */
  table.clubs thead, table.members thead { display: none; }
  table.clubs, table.clubs tbody, table.clubs tr, table.clubs td,
  table.members, table.members tbody, table.members tr, table.members td { display: block; width: 100%; }
  table.clubs tr, table.members tr { border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; padding: 6px 10px; }
  table.clubs td, table.members td { border: 0; padding: 4px 0; text-align: left !important; }
  table.clubs td.num, table.members td.num { text-align: left; }
  table.clubs td:nth-child(n+5)::before { content: attr(data-l) ': '; color: var(--muted); font-size: 13px; }
}
td.acts { text-align: right; white-space: normal; }
td.acts button { margin: 2px 0; }
.scalechip.sim { border-style: dashed; }
.scalechip.sim .w::after { content: ' demo'; font-size: 11px; font-weight: 400; color: var(--warn); }
td.neg { color: var(--danger); }
.problems.big { font-weight: 600; }
.notice { padding: 10px 12px; border-radius: 8px; background: color-mix(in srgb, var(--warn) 15%, var(--panel)); }
.warnpanel { border-color: var(--warn); }
