/* Theme follows ansuran.flexpc.com.my */
@font-face { font-family: "Inter"; src: url("/fonts/inter.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Inter Tight"; src: url("/fonts/inter-tight.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
  --ink: #1d1d1f;
  --ink-2: #6e6e73;
  --line: rgba(0, 0, 0, 0.09);
  --line-strong: rgba(0, 0, 0, 0.2);
  --bg: #f5f5f7;
  --surface: #fff;
  --accent: #e11d2a;
  --accent-dark: #c01622;
  --accent-ink: #fff;
  --accent-soft: #fdecee;
  --ok: #0a7d4f;
  --ok-soft: #e4f5ee;
  --warn: #8a4b08;
  --warn-soft: #fdf3dc;
  --danger: #c01622;
  --danger-soft: #fdecee;
  --radius: 18px;
  --radius-lg: 22px;
  --shadow: 0 6px 20px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.05);
  --display: "Inter Tight", Inter, system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.4 Inter, -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.006em;
  overscroll-behavior-y: none;
}
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.015em; font-weight: 700; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
h1, h2, h3, p { margin: 0; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* App frame */
.topbar {
  background: rgba(251, 251, 253, 0.9);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wordmark { font-family: var(--display); font-weight: 800; font-size: 20px; letter-spacing: 0.01em; line-height: 1; color: var(--ink); }
.wordmark b { color: var(--accent); font-weight: 800; }
.brand-block { min-width: 0; }
.topbar .sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }
.link-btn { background: none; border: 0; color: var(--ink-2); font-size: 14px; padding: 8px 0 8px 12px; white-space: nowrap; }
.progress { height: 6px; background: rgba(0, 0, 0, 0.09); border-radius: 3px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: var(--accent); transition: width 0.2s; }
.progress.light { margin-top: 6px; }
.progress.light.done > i { background: var(--ok); }

.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }
.stack > * + * { margin-top: 14px; }
.card { background: var(--surface); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow); }
.card h2 { font-size: 18px; margin-bottom: 10px; }

/* Buttons and fields */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 20px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-weight: 600;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:active { background: var(--accent-dark); }
.btn.danger { color: var(--danger); border-color: rgba(192, 22, 34, 0.35); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.4; cursor: default; }
.btn.small-btn { min-height: 38px; padding: 0 14px; font-size: 14px; }
.field {
  width: 100%; min-height: 48px; padding: 0 14px; border-radius: 14px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 16px;
}
label.lbl { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.err { color: var(--danger); font-size: 14px; min-height: 20px; margin-top: 8px; }

/* Login */
.login { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px 20px; }
.login { background: var(--surface); }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box form { text-align: left; }
.login .wordmark { font-size: 28px; display: block; margin-bottom: 28px; }
.login .eyebrow { color: var(--accent); font-weight: 600; font-size: 15px; margin-bottom: 8px; }
.login h1 { font-size: 42px; line-height: 1.05; letter-spacing: -0.03em; margin-bottom: 12px; }
.login .g-slot { min-height: 44px; margin-top: 24px; display: flex; justify-content: center; }
.login-sep { margin: 28px 0 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.text-btn { background: none; border: 0; padding: 6px 0; color: var(--ink-2); font-size: 14px; text-decoration: underline; }

/* Counter screen */
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border-bottom: 1px solid var(--line); }
.tab {
  min-height: 46px; padding: 0 2px; background: none; border: 0; border-bottom: 2px solid transparent;
  font-weight: 600; font-size: 14.5px; color: var(--ink-2);
}
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.filters {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  padding: 10px 12px; display: grid; gap: 8px; border-bottom: 1px solid var(--line);
}
.search { position: relative; }
.search .field { padding-right: 44px; }
.search-clear {
  position: absolute; top: 0; right: 0; width: 44px; height: 46px;
  background: none; border: 0; font-size: 20px; color: var(--ink-2);
}
.item-list { list-style: none; margin: 0; padding: 8px 12px calc(96px + var(--safe-b)); max-width: 720px; margin-inline: auto; }
.item-list li + li { margin-top: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: 0; border-radius: var(--radius);
  padding: 13px 16px; min-height: 64px; box-shadow: var(--shadow);
}
.item:active { background: var(--accent-soft); }
.item-main { flex: 1; min-width: 0; }
.item-name { font-size: 15px; line-height: 1.35; overflow-wrap: anywhere; }
.item-meta { font-size: 12.5px; color: var(--ink-2); margin-top: 4px; overflow-wrap: anywhere; }
.item-qty { font-family: var(--display); font-size: 26px; font-weight: 700; min-width: 44px; text-align: right; }
.cat { font-weight: 650; letter-spacing: 0.02em; }
.empty { text-align: center; color: var(--ink-2); padding: 48px 20px; }
.status-chip { font-size: 12.5px; color: var(--warn); background: var(--warn-soft); padding: 8px 12px; text-align: center; }

.submit-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  background: var(--surface); border-top: 1px solid var(--line);
  padding: 12px 16px calc(12px + var(--safe-b));
}
.submit-bar .btn { display: flex; max-width: 688px; margin: 0 auto; width: 100%; }

.center-screen { padding: 56px 24px; text-align: center; max-width: 420px; margin: 0 auto; }
.center-screen h2 { font-size: 21px; margin-bottom: 8px; }
.big-tick { width: 60px; height: 60px; margin: 0 auto 16px; border-radius: 50%; background: var(--ok-soft); color: var(--ok); display: grid; place-items: center; font-size: 30px; font-weight: 700; }

/* Bottom sheet and numpad */
.scrim {
  position: fixed; inset: 0; z-index: 20; background: rgba(15, 18, 24, 0.55);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px; background: var(--surface);
  border-radius: 28px 28px 0 0; padding: 18px 16px calc(16px + var(--safe-b));
  max-height: 100dvh; overflow-y: auto;
}
.sheet-head { display: flex; align-items: flex-start; gap: 8px; }
.sheet-name { flex: 1; font-size: 15px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.sheet-close { flex: none; width: 40px; height: 40px; margin: -6px -4px 0 0; border: 0; background: none; font-size: 24px; color: var(--ink-2); }
.qty-field {
  margin: 12px 0; height: 68px; border: 2px solid var(--accent); border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-size: 40px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.qty-field.placeholder { color: #a5adb9; font-weight: 500; font-size: 18px; }
.qty-field.replace span { background: var(--accent-soft); border-radius: 6px; padding: 0 8px; }
.numpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  height: 62px; border-radius: 18px; border: 0; background: var(--bg);
  font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; user-select: none;
}
.key:active { background: #e3e3e8; }
.key.enter { background: var(--accent); color: #fff; font-size: 18px; }
.key.enter:active { background: var(--accent-dark); }
.key.enter[disabled] { background: #ececf0; color: #a1a1a6; }
.key.back svg { display: block; margin: auto; }

.dialog { width: 100%; max-width: 420px; background: var(--surface); border-radius: 28px 28px 0 0; padding: 24px 20px calc(18px + var(--safe-b)); }
.dialog h2 { font-size: 21px; margin-bottom: 8px; }
.dialog .actions { display: grid; gap: 8px; margin-top: 18px; }

/* Serial scanner */
.scan-tag { display: inline-block; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 2px 8px; border-radius: 999px; }
.scanner {
  position: fixed; inset: 0; z-index: 20; background: var(--surface);
  display: flex; flex-direction: column; height: 100dvh;
}
.scan-head { display: flex; gap: 8px; padding: 12px 14px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.scan-title { flex: 1; min-width: 0; }
.scan-head .sheet-name { font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.scan-view { position: relative; flex: 0 0 32dvh; background: #000; overflow: hidden; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; left: 8%; right: 8%; top: 28%; bottom: 28%; border: 2px solid rgba(255, 255, 255, 0.8); border-radius: 10px; transition: border-color 0.1s; }
.scan-view.hit .scan-guide { border-color: #33d17a; box-shadow: 0 0 0 2000px rgba(51, 209, 122, 0.18); }
.scan-msg { position: absolute; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; color: #fff; font-size: 14px; background: rgba(0, 0, 0, 0.6); }
.scan-status { padding: 8px 14px; font-size: 13.5px; background: var(--bg); color: var(--ink-2); border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.scan-status.ok { background: var(--ok-soft); color: var(--ok); }
.scan-status.warn { background: var(--warn-soft); color: var(--warn); }
.scan-body { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 14px; }
.scan-pending { background: var(--warn-soft); border-radius: 14px; padding: 10px 12px; margin-bottom: 8px; font-size: 13.5px; overflow-wrap: anywhere; }
.scan-pending .grid-2 { margin-top: 8px; }
.scan-manual { display: flex; gap: 8px; }
.scan-manual .field { flex: 1; min-width: 0; }
.scan-count { font-size: 14px; margin: 12px 0 2px; }
.scan-list { list-style: none; margin: 0; padding: 0; }
.scan-row { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--line); min-height: 44px; }
.scan-row:first-child { border-top: 0; }
.scan-serial { font-family: ui-monospace, Consolas, monospace; font-size: 13.5px; overflow-wrap: anywhere; }
.scan-row .scan-serial { flex: 1; min-width: 0; }
.scan-remove { flex: none; width: 40px; height: 40px; border: 0; background: none; font-size: 20px; color: var(--ink-2); }
.scan-foot { padding: 10px 14px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); }
.serial-diff { margin-top: 8px; border-left: 3px solid var(--danger); padding-left: 10px; }
.serial-diff.extra { border-left-color: var(--warn); }
.serial-diff-head { font-size: 13px; font-weight: 650; }
.serial-diff-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 10px; padding: 3px 0; }

/* Toast */
#toast {
  position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%);
  z-index: 40; max-width: calc(100vw - 32px); width: max-content;
  background: var(--ink); color: #fff; font-size: 14px; padding: 10px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity 0.15s;
}
#toast.show { opacity: 1; }

/* Admin */
.admin-nav { display: grid; grid-template-columns: repeat(4, auto); justify-content: space-between; gap: 4px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-nav .tab { font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--bg); border-radius: 14px; padding: 10px 12px; }
.stat b { display: block; font-family: var(--display); font-size: 24px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12.5px; color: var(--ink-2); }
.notice { border-radius: 14px; padding: 10px 12px; font-size: 14px; margin-top: 10px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12.5px; background: var(--bg); border-radius: 999px; padding: 4px 10px; }
.check-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 2px; min-height: 52px;
  border-top: 1px solid var(--line); cursor: pointer;
}
.check-row:first-of-type { border-top: 0; }
.check-row input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check-row .who { min-width: 0; overflow-wrap: anywhere; }
.cat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; border-top: 1px solid var(--line); padding-top: 4px; }
.cat-option { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; }
.cat-option input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; padding: 4px; background: var(--bg); border-radius: 999px; }
.seg button { min-height: 42px; border: 0; border-radius: 999px; background: none; font-weight: 600; color: var(--ink-2); }
.seg button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.alloc { border-top: 1px solid var(--line); padding: 12px 0; }
.alloc:first-of-type { border-top: 0; }
.alloc-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 8px; font-weight: 600; overflow-wrap: anywhere; }
.counter-row { padding: 12px 0; border-top: 1px solid var(--line); }
.counter-row:first-of-type { border-top: 0; }
.counter-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.badge { font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--bg); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Report */
.report-row { border-top: 1px solid var(--line); padding: 12px 0; }
.report-row:first-of-type { border-top: 0; }
.report-name { font-size: 14.5px; line-height: 1.35; overflow-wrap: anywhere; }
.report-nums { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.report-num { background: var(--bg); border-radius: 8px; padding: 5px 9px; font-size: 13px; }
.report-num b { font-size: 15px; font-variant-numeric: tabular-nums; }
.report-num.bad { background: var(--danger-soft); color: var(--danger); }
.report-num.good { background: var(--ok-soft); color: var(--ok); }
.history-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  text-align: left; background: none; border: 0; border-top: 1px solid var(--line); padding: 12px 0;
}
.history-row:first-of-type { border-top: 0; }
.history-row[disabled] { cursor: default; }
