:root {
  --ink: #0f172a;
  --muted: #475569;
  --bg: #f1f5f9;
  --card: #ffffff;
  --line: #cbd5e1;
  --line-strong: #94a3b8;
  --brand: #1e293b;
  --green: #16A34A;
  --green-dark: #15803d;
  --green-soft: #dcfce7;
  --blue: #2563EB;
  --blue-dark: #1d4ed8;
  --blue-soft: #dbeafe;
  --orange: #EA580C;
  --orange-dark: #c2410c;
  --orange-soft: #ffedd5;
  --red: #DC2626;
  --red-dark: #b91c1c;
  --red-soft: #fee2e2;
  --ok: #16A34A;
  --warn: #EA580C;
  --bad: #DC2626;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font: 17px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.hidden { display: none !important; }

/* ---------- Sticky Compact Top Header ---------- */
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 14px;
  background: var(--brand);
  color: #fff;
}
.brand { font-weight: 800; font-size: 1.05rem; letter-spacing: .3px; }
.ver { font-weight: 600; opacity: .8; font-size: .82em; background: #ffffff22; padding: 2px 6px; border-radius: 6px; }
.top .badge {
  font-size: .9rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green);
  color: #fff;
  border: 2px solid #ffffff55;
}
.top .badge.bad { background: var(--red); }

.banner { padding: 12px 16px; font-weight: 800; font-size: 1.05rem; text-align: center; }
.banner.danger { background: var(--red); color: #fff; }
.banner.warn { background: #fef3c7; color: #92400e; border-bottom: 2px solid #f59e0b; }

.bar {
  position: sticky;
  top: 0;
  z-index: 15;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 10px;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 2px solid var(--line);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}
.bar .wh {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  background: var(--blue-soft);
  border: 2px solid var(--blue);
  border-radius: 999px;
  padding: 4px 12px;
  font-weight: 800;
  color: var(--ink);
  flex: 1 1 200px;
  max-width: 360px;
}
.bar .wh-icon { font-size: 1.2rem; }
.bar .wh select {
  width: 100%;
  margin: 0;
  padding: 6px 4px;
  min-height: 40px;
  border: 0;
  background: transparent;
  font-size: 17px;
  font-weight: 800;
  color: var(--ink);
}
.bar .wh select:focus { outline: none; }

.who-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .95rem;
}
.who-badge strong { font-weight: 800; }

.btn-logout {
  min-height: 44px !important;
  padding: 8px 14px !important;
  font-size: 16px !important;
  font-weight: 800 !important;
  border-radius: 999px !important;
  background: var(--red) !important;
  border: 2px solid var(--red-dark) !important;
  color: #fff !important;
  white-space: nowrap;
}

/* ---------- Cards & Base Typography ---------- */
.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin: 12px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.04);
}
.narrow { max-width: 420px; margin: 24px auto; }
.login-card h1 { font-size: 1.5rem; text-align: center; margin-bottom: 16px; }
.login-card button[type="submit"] { width: 100%; margin-top: 14px; min-height: 62px; font-size: 20px; }

h1 { font-size: 1.4rem; font-weight: 800; margin: 0 0 12px; color: var(--ink); }
h2 { font-size: 1.2rem; font-weight: 800; margin: 16px 0 10px; color: var(--ink); }
h3 { font-size: 1.05rem; font-weight: 800; margin: 14px 0 8px; color: var(--ink); }

label {
  display: block;
  margin: 10px 0;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
}

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  min-height: 52px;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
  border: 2px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}
input:disabled, select:disabled {
  background: #f1f5f9;
  color: var(--muted);
  border-color: var(--line);
}
input[type=checkbox] {
  display: inline-block;
  width: 24px;
  height: 24px;
  min-height: 24px;
  margin: 0 10px 0 0;
  vertical-align: middle;
  accent-color: var(--green);
}

/* ---------- Touch Buttons & Strict Action Color Coding ---------- */
button {
  font: inherit;
  font-size: 18px;
  font-weight: 800;
  min-height: 56px;
  padding: 12px 18px;
  border-radius: 12px;
  border: 2px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.06s ease, opacity 0.15s ease;
}
button:active:not(:disabled) { transform: scale(0.98); }
button:disabled { opacity: .45; cursor: not-allowed; }

/* GREEN (#16A34A): Selling, Receiving Stock, Confirming */
button.primary, button.btn-green {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
  min-height: 58px;
  font-size: 19px;
  font-weight: 800;
}

/* BLUE (#2563EB): Counting & Scanning Stock, Viewing Statements/Reports, Online Sale */
button.btn-blue, .big-btn.online {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
  min-height: 58px;
  font-size: 19px;
  font-weight: 800;
}

/* ORANGE (#EA580C): Sending Stock Out (Transfers), Customer Returns/Exchanges */
button.btn-orange {
  background: var(--orange);
  border-color: var(--orange-dark);
  color: #fff;
  min-height: 58px;
  font-size: 19px;
  font-weight: 800;
}

/* RED (#DC2626): Refunds Paid Out, Cancel, Hold/Disable User, Log Out */
button.danger, button.btn-red {
  background: var(--red);
  border-color: var(--red-dark);
  color: #fff;
  min-height: 56px;
  font-size: 18px;
  font-weight: 800;
}

/* Touch-friendly pill buttons for inline/row actions */
button.link, td a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 14px;
  margin: 3px 4px 3px 0;
  border-radius: 10px;
  border: 2px solid var(--blue);
  background: var(--blue-soft);
  color: var(--blue-dark);
  font-size: 16px;
  font-weight: 800;
  text-decoration: none;
}
button.link.danger, button.link.btn-red {
  border-color: var(--red);
  background: var(--red-soft);
  color: var(--red-dark);
}
button.link.btn-green {
  border-color: var(--green);
  background: var(--green-soft);
  color: var(--green-dark);
}
button.link.btn-orange {
  border-color: var(--orange);
  background: var(--orange-soft);
  color: var(--orange-dark);
}

.error { color: var(--red); font-weight: 800; }
.muted { color: var(--muted); }
.ok { color: var(--green); font-weight: 800; }
.warn { color: var(--orange); font-weight: 800; }

/* ---------- Sticky Navigation Bar & Persistent HOME Button ---------- */
.tabs {
  position: sticky;
  top: 58px;
  z-index: 14;
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  padding: 10px 12px;
  background: #e2e8f0;
  border-bottom: 2px solid var(--line);
}
.tabs.home-mode { display: none; }
.tabs button {
  white-space: nowrap;
  min-height: 48px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 2px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  font-size: 16px;
  font-weight: 800;
}
.tabs button.btn-home {
  background: var(--brand);
  border-color: #0f172a;
  color: #fff;
  font-size: 17px;
  padding: 10px 18px;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
  flex-shrink: 0;
}
.tabs button.active {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
}

/* ---------- Role-Based Picture Launchpad ---------- */
.launchpad-wrap { padding: 4px 12px 16px; }
.launchpad-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin: 12px 0;
}
button.launch-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 128px;
  padding: 18px 14px;
  border-radius: 16px;
  border: 3px solid var(--line-strong);
  background: #fff;
  color: var(--ink);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.08);
  gap: 8px;
}
button.launch-tile .tile-icon {
  font-size: 2.6rem;
  line-height: 1.1;
}
button.launch-tile .tile-label {
  font-size: 1.15rem;
  font-weight: 900;
  letter-spacing: 0.3px;
  line-height: 1.2;
}
button.launch-tile .tile-sub {
  font-size: 0.88rem;
  font-weight: 700;
  opacity: 0.9;
}

button.launch-tile.tile-green {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
}
button.launch-tile.tile-blue {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
}
button.launch-tile.tile-orange {
  background: var(--orange);
  border-color: var(--orange-dark);
  color: #fff;
}
button.launch-tile.tile-red {
  background: var(--red);
  border-color: var(--red-dark);
  color: #fff;
}

.wh-picker-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-top: 10px;
}

.screen { padding: 0 0 56px; }

/* ---------- Tables & Responsive Mobile Cards ---------- */
table { width: 100%; border-collapse: collapse; background: #fff; font-size: 1rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #e2e8f0; font-weight: 800; color: var(--ink); }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.stat { background: #f8fafc; border: 2px solid var(--line); border-radius: 12px; padding: 14px; }
.stat .k { color: var(--muted); font-size: .92rem; font-weight: 700; }
.stat .v { font-size: 1.5rem; font-weight: 900; margin-top: 4px; }

/* ---------- Permission Switchboard & Checkboxes ---------- */
.checks {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin: 8px 0 16px;
}
.checks label {
  font-weight: 700;
  font-size: 1rem;
  display: flex;
  align-items: center;
  min-height: 52px;
  padding: 10px 14px;
  margin: 0;
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: 12px;
  cursor: pointer;
  user-select: none;
}
.checks label:has(input:checked) {
  background: var(--green-soft);
  border-color: var(--green);
  color: #064e3b;
}

.preset-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 10px 0 16px;
  padding: 12px;
  background: #f8fafc;
  border: 2px dashed var(--line-strong);
  border-radius: 12px;
}
.preset-bar button {
  flex: 1 1 150px;
  min-height: 50px;
  font-size: 16px;
}

/* ---------- User Cards & Status Badges ---------- */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
}
.status-active { background: var(--green-soft); color: var(--green-dark); border: 2px solid var(--green); }
.status-hold { background: var(--orange-soft); color: var(--orange-dark); border: 2px solid var(--orange); }
.status-disabled { background: var(--red-soft); color: var(--red-dark); border: 2px solid var(--red); }

.user-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  margin-top: 12px;
}
.user-card {
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}
.user-card-actions button {
  flex: 1 1 120px;
  min-height: 48px;
  font-size: 16px;
  padding: 8px 12px;
}

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 8px 0; }
.row > * { flex: 1 1 160px; }

.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: 16px;
  padding: 16px 20px;
  border-radius: 14px;
  background: var(--ink);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 800;
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
  text-align: center;
}
.toast.bad { background: var(--red); }
.toast.good { background: var(--green); }

/* ---------- Scanning ---------- */
.scan-box { margin: 10px 0; }
.mode-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--blue);
  color: #fff;
  font-weight: 900;
  font-size: 1.1rem;
}
.mode-banner.mode-green { background: var(--green); }
.mode-banner.mode-orange { background: var(--orange); }
.mode-banner .mode { letter-spacing: .6px; }
.mode-banner .wh { font-weight: 700; opacity: 0.95; }

.scan-row { margin: 10px 0; align-items: stretch; }
.scan-row .scan-input { font-size: 1.2rem; font-weight: 800; flex: 3 1 200px; min-height: 58px; }
.scan-row button { flex: 1 0 auto; min-height: 58px; background: var(--blue); border-color: var(--blue-dark); color: #fff; }

.scan-result { padding: 14px; border-radius: 12px; font-weight: 800; font-size: 1.05rem; background: #e2e8f0; margin: 8px 0; }
.scan-result.ok { background: var(--green-soft); color: var(--green-dark); border: 2px solid var(--green); }
.scan-result.error { background: var(--red-soft); color: var(--red-dark); border: 2px solid var(--red); }
.scan-result.warn { background: var(--orange-soft); color: var(--orange-dark); border: 2px solid var(--orange); }

.scan-count { margin: 10px 0; font-size: 1.05rem; }
.scan-items { max-height: 45vh; overflow: auto; border: 2px solid var(--line); border-radius: 12px; background: #fff; }
.scan-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 1rem; }
.scan-item .bc { font-family: ui-monospace, monospace; font-weight: 800; min-width: 120px; font-size: 1.05rem; }
.scan-item .msg { flex: 1; font-weight: 600; }
.scan-item.bad { background: var(--red-soft); }
.scan-item.bad .msg { color: var(--red-dark); font-weight: 800; }
.scan-item.pending .msg { color: var(--muted); }
tr.sel td { background: var(--blue-soft); }

/* ---------- Camera ---------- */
.cam { position: fixed; inset: 0; background: #000; z-index: 40; display: flex; flex-direction: column; }
.cam video { flex: 1; width: 100%; object-fit: cover; }
.cam .aim { position: absolute; left: 10%; right: 10%; top: 40%; height: 20%; border: 4px solid #22c55ecc; border-radius: 14px; pointer-events: none; }
.cam-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px; background: #111; color: #fff; font-weight: 800; }
.cam-bar button { background: var(--red); border-color: var(--red-dark); color: #fff; }

/* ---------- Labels: invisible on screen, the only thing printed ---------- */
#labels { display: none; }
@media print {
  body > *:not(.print-target) { display: none !important; }
  #labels.print-target { display: grid !important; grid-template-columns: repeat(var(--cols,3),1fr); gap: 0; }
  .label { border: 1px dashed #bbb; padding: 6px 6px 4px; text-align: center; break-inside: avoid; height: var(--h,34mm); overflow: hidden; }
  .label .p { font-size: 20px; font-weight: 900; line-height: 1; } .label .n { font-size: 10px; }
  .label svg { width: 100%; height: 14mm; } .label .c { font: 12px monospace; font-weight: 700; }
  @page { margin: 5mm; }
}

.line-card { border: 2px solid var(--line); border-radius: 12px; padding: 14px; margin: 10px 0; background: #fff; }
.line-card.sel { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25); }
.line-nums { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0; font-size: 1rem; font-weight: 600; }
.line-card .row button { flex: 1 1 140px; }

@media print { body { background: #fff !important; } }

/* ---------- Counter & Billing ---------- */
table.bill input.amt {
  width: 84px;
  min-height: 48px;
  padding: 8px;
  margin: 0;
  text-align: right;
  font-size: 18px;
  font-weight: 800;
}
.qty-step {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.qty-step button.step-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 4px 10px;
  font-size: 20px;
  font-weight: 900;
  border-radius: 10px;
}
.btn-remove-line {
  min-height: 48px !important;
  min-width: 52px !important;
  padding: 8px 14px !important;
  background: var(--red) !important;
  border: 2px solid var(--red-dark) !important;
  color: #fff !important;
  font-weight: 800 !important;
  border-radius: 10px !important;
}
.bill-totals {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  margin: 12px 0;
  background: #f8fafc;
  border: 2px solid var(--line-strong);
  border-radius: 12px;
}
.big { font-size: 1.7rem; font-weight: 900; color: var(--ink); }
.pay-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 14px 0;
}
.big-btn {
  min-height: 68px;
  font-size: 1.25rem;
  padding: 16px 12px;
  font-weight: 900;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.12);
}
.big-btn.cash {
  background: var(--green);
  border-color: var(--green-dark);
  color: #fff;
}
.big-btn.online {
  background: var(--blue);
  border-color: var(--blue-dark);
  color: #fff;
}
.split-toggle-row {
  margin: 8px 0 12px;
}
.split-toggle-row button {
  width: 100%;
  min-height: 52px;
}
.split {
  padding: 12px;
  background: #f8fafc;
  border: 2px solid var(--line);
  border-radius: 12px;
  margin: 10px 0;
}
details {
  margin: 12px 0;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}
summary {
  cursor: pointer;
  color: var(--blue-dark);
  font-weight: 800;
  font-size: 1.05rem;
  padding: 6px 0;
}
.summary .pay-row { grid-template-columns: 1fr 1fr; }
.receipt { max-width: 520px; }
.r-head { margin-bottom: 8px; }
.r-total { display: flex; justify-content: space-between; padding: 10px 0; font-size: 1.2rem; }
tr.returned td { color: var(--muted); text-decoration: line-through; }

@media print {
  #receipt-print.print-target { display: block !important; font: 12px/1.3 system-ui, sans-serif; max-width: 80mm; }
  #receipt-print table { font-size: 11px; }
}

/* ---------- Statements ---------- */
.tabs-inline { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.tabs-inline button { flex: 1 1 130px; min-height: 52px; }
.tabs-inline button.active { background: var(--blue); color: #fff; border-color: var(--blue-dark); }
table.kv td:first-child { color: var(--ink); font-weight: 600; }
table.kv tr.strong td { font-weight: 900; font-size: 1.05rem; background: #f8fafc; }
table.kv tr.warn td { color: var(--orange-dark); font-weight: 800; }
table.kv tr.ok td:last-child { color: var(--green); font-weight: 800; }
table.kv tr.error td:last-child { color: var(--red); font-weight: 800; }
td.num.error { color: var(--red); font-weight: 800; }
td.num.ok { color: var(--green); font-weight: 800; }

@media print {
  #statement-print.print-target { display: block !important; font: 11px/1.3 system-ui, sans-serif; }
  #statement-print .card { border: 0; margin: 0 0 8px; padding: 0; }
}

/* ---------- Mobile Responsive Tables to Cards ---------- */
@media screen and (max-width: 768px) {
  .card { margin: 10px 8px; padding: 14px 12px; }
  .bar { padding: 8px 10px; }
  .bar .wh { flex: 1 1 100%; max-width: none; order: -1; }
  .tabs { top: 108px; }
  .pay-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .big-btn { font-size: 1.12rem; min-height: 64px; padding: 14px 8px; }

  .table-wrap { overflow-x: visible; }
  table:not(.kv),
  table:not(.kv) tbody {
    display: block;
    width: 100%;
  }
  table:not(.kv) thead {
    display: none;
  }
  table:not(.kv) tbody tr {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 12px;
    background: #fff;
    border: 2px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 10px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.04);
  }
  table:not(.kv) tbody td {
    border-bottom: 0;
    padding: 4px 2px;
    text-align: left !important;
    white-space: normal !important;
  }
  table:not(.kv) tbody td:first-child {
    flex: 1 1 100%;
    font-weight: 800;
    font-size: 1.05rem;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
    margin-bottom: 2px;
  }
  table:not(.kv) tbody td[data-label]::before {
    content: attr(data-label) ": ";
    font-weight: 700;
    color: var(--muted);
    font-size: 0.9rem;
  }
  table:not(.kv) tbody td:last-child:has(button, a) {
    flex: 1 1 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 6px;
    border-top: 1px dashed var(--line);
  }
  table:not(.kv) tbody td:last-child button,
  table:not(.kv) tbody td:last-child a {
    flex: 1 1 120px;
    margin: 0;
  }
}

/* ---------- View as (System Admin preview) ---------- */
.banner.viewas { position: sticky; top: 0; z-index: 15; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; background: #fde68a; color: #422006; border-bottom: 3px solid #b45309; }
.banner.viewas button { background: #422006; color: #fff; border-color: #422006; font-weight: 800; }
body.viewing-as .top { background: #b45309; }
.btn-view-as { background: #fef3c7; border-color: #b45309; color: #422006; font-weight: 700; }
.viewas-pick { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); margin-top: 8px; }
.viewas-pick button { text-align: left; }
.perm-groups { columns: 2 240px; } .perm-groups h3 { break-after: avoid; } .perm-groups ul { margin: 0 0 10px; padding-left: 20px; break-inside: avoid; }
.perm-no { color: var(--muted); text-decoration: line-through; }
.viewas-pick button { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; text-align: left; }
/* PIN show/hide */
.pin-wrap { position: relative; display: block; }
.pin-wrap input { padding-right: 56px; }
.pin-wrap .eye { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); margin-top: 2px; min-height: 0; height: 40px; width: 46px; padding: 0; border: 0; background: transparent; font-size: 1.3rem; box-shadow: none; }

/* Opening count result (like the old scanner: big green / orange / red card) */
.big-result { padding: 14px; border-radius: 10px; }
.big-result .r-title { font-size: 1.35rem; font-weight: 900; letter-spacing: .3px; }
.big-result .r-item { font-size: 1.15rem; font-weight: 800; margin-top: 4px; }
.big-result .r-msg { font-size: .9rem; font-weight: 600; margin-top: 4px; opacity: .9; }
.big-result.ok { background: #15803d; color: #fff; }
.big-result.dup { background: #ea580c; color: #fff; }
.big-result.error { background: #b91c1c; color: #fff; }
.scan-item.ok .msg { color: #15803d; } .scan-item.dup { background: #fff1e6; } .scan-item.dup .msg { color: #9a3412; }

/* camera: keep the bottom bar above the phone's own buttons, show results on top of the picture */
.cam { height: 100vh; height: 100dvh; }
.cam-bar { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px) + 24px); font-size: 1rem; font-weight: 700; }
.cam .aim.ok { border-color: #22c55e; box-shadow: 0 0 0 4000px rgba(21,128,61,.25); }
.cam .aim.dup { border-color: #fb923c; box-shadow: 0 0 0 4000px rgba(234,88,12,.3); }
.cam .aim.bad { border-color: #ef4444; box-shadow: 0 0 0 4000px rgba(185,28,28,.3); }
.cam-result { position: absolute; left: 12px; right: 12px; top: 12px; padding: 14px 16px; border-radius: 12px; color: #fff; z-index: 2; transition: opacity .4s; }
.cam-result .r-title { font-size: 1.4rem; font-weight: 900; }
.cam-result .r-item { font-size: 1.05rem; font-weight: 700; margin-top: 4px; }
.cam-result.ok { background: #15803d; } .cam-result.dup { background: #ea580c; } .cam-result.bad { background: #b91c1c; } .cam-result.wait { background: #334155; }
.cam-result.fade { opacity: .55; }

.upload-line { margin: 8px 0; padding: 8px 10px; border-radius: 8px; font-weight: 700; }
.upload-line.waiting { background: #fef3c7; color: #78350f; } .upload-line.clear { background: #dcfce7; color: #14532d; }
.problem-line { margin: 8px 0; padding: 8px 10px; border-radius: 8px; font-weight: 800; background: #fee2e2; color: #7f1d1d; }

/* Home: Mother Hub stock */
.home-stock .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 8px 0; }
.home-stock .stat { padding: 8px; } .home-stock .stat .k { font-size: .75rem; } .home-stock .stat .v { font-size: 1.05rem; }

/* opening: decide many */
.bulk-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; margin-bottom: 10px; border-radius: 10px; background: #eef2f7; position: sticky; top: 0; z-index: 5; }
.bulk-bar select { width: auto; flex: 1 1 200px; margin: 0; }
.bulk-bar .bulk-all { display: flex; align-items: center; gap: 6px; margin: 0; font-weight: 800; }
.bulk-bar input[type=checkbox], table input[type=checkbox] { width: 22px; height: 22px; }

/* challan + send from list */
.challan-head { margin-bottom: 8px; } .challan-no { font-size: 1.3rem; font-weight: 900; }
.challan-total td { border-top: 2px solid var(--ink); }
.challan-group { margin: 8px 0; } .challan-bc { font-family: ui-monospace, monospace; font-size: .85rem; word-break: break-word; }
.send-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; padding: 10px; border-radius: 10px; background: #eef2f7; position: sticky; top: 0; z-index: 5; margin: 8px 0; }
.send-bar label { flex: 1 1 180px; margin: 0; } .send-bar strong { flex: 1 1 160px; }
.qty-row { display: flex; gap: 6px; align-items: center; } .qty-row .qty-in { width: 80px; margin: 0; } .qty-row button { padding: 8px 10px; }
.bc-pick { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; } .bc-item { display: flex; align-items: center; gap: 4px; font: 600 .85rem ui-monospace, monospace; margin: 0; }
@media print { #challan-print.print-target { display: block !important; font: 11px/1.3 system-ui, sans-serif; } #challan-print table { font-size: 11px; } }

.bulk-all { display: flex; align-items: center; gap: 8px; font-weight: 800; } .bulk-all input { width: 22px; height: 22px; }

.origin-line { margin-top: 8px; padding: 10px 12px; border-radius: 10px; background: #eef2f7; border-left: 6px solid #64748b; }
.origin-line .k { display: block; font-size: .8rem; font-weight: 800; text-transform: uppercase; color: var(--muted); }
.origin-line strong { font-size: 1.15rem; } .origin-line.supplier { border-left-color: #2563eb; } .origin-line.opening { border-left-color: #b45309; }

/* no-tag sale */
.notag-chip { display: inline-block; margin-top: 2px; padding: 1px 8px; border-radius: 999px; background: #ffedd5; color: #9a3412; font-weight: 800; font-size: .8rem; }
.notag-box { margin: 8px 0; padding: 10px; border: 2px solid #ea580c; border-radius: 10px; background: #fff7ed; }
.notag-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.notag-list { display: grid; gap: 6px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); max-height: 50vh; overflow: auto; margin: 8px 0; }
.notag-item { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }

/* daily report */
.daily-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; margin-bottom: 8px; }
.daily-head label { flex: 1 1 220px; margin: 0; }
.daily-time { padding: 8px 12px; border-radius: 10px; background: #e0ecff; text-align: right; } .daily-time .k { font-size: .8rem; color: var(--muted); }
table.daily tr.grand td { background: #dbeafe; border-top: 2px solid var(--brand); }
.formula { margin: 8px 0; padding: 8px 12px; border-radius: 10px; background: #ede9fe; font-weight: 700; text-align: center; }
.formula.yellow { background: #fef9c3; }
.daily-paper h1 { margin: 12px 16px 0; }
@media print { #daily-print.print-target { display: block !important; font: 11px/1.3 system-ui, sans-serif; } #daily-print .card { border: 0; margin: 0 0 8px; padding: 0; } #daily-print input { border: 0; } }

/* Daily Report print: portrait, everything fits (owner, 2 Nov 2026) */
.print-only { display: none; }
table.daily th { white-space: normal; line-height: 1.15; vertical-align: bottom; }
@media print {
  #daily-print .no-print { display: none !important; }
  #daily-print .print-only { display: block !important; }
  #daily-print h1 { font-size: 14px; margin: 0 0 4px; }
  #daily-print h2 { font-size: 12px; margin: 8px 0 4px; }
  #daily-print .daily-head { margin: 0 0 4px; } #daily-print .daily-time { padding: 2px 6px; font-size: 9px; }
  #daily-print .table-wrap { overflow: visible !important; }
  #daily-print table.daily { width: 100% !important; table-layout: fixed; border-collapse: collapse; font-size: 8.5px; }
  #daily-print table.daily th, #daily-print table.daily td {
    white-space: normal !important; overflow-wrap: anywhere; word-break: break-word;
    padding: 2px 3px !important; border: 0.5px solid #999 !important; line-height: 1.2;
  }
  #daily-print table.daily th { background: #e5e7eb !important; font-size: 8px; vertical-align: bottom; }
  #daily-print table.daily th:first-child, #daily-print table.daily td:first-child { width: 24%; }
  #daily-print table.daily th:nth-child(2), #daily-print table.daily td:nth-child(2) { width: 8%; }
  #daily-print table.daily tr { break-inside: avoid; }
  #daily-print table.daily thead { display: table-header-group; }
  #daily-print .formula { font-size: 9px; padding: 3px 6px; margin: 4px 0; }
  #daily-print p { font-size: 8.5px; margin: 3px 0; }
  #daily-print .notag-chip { font-size: 7px; padding: 0 4px; }
}

/* Daily Report: borders + highlighted key columns (screen and print) */
table.daily { border-collapse: collapse; width: 100%; }
table.daily th, table.daily td { border: 1px solid #94a3b8; padding: 6px 6px; }
table.daily th { background: #1e3a8a; color: #fff; font-size: .82rem; text-align: center; }
table.daily td.num { font-size: .9rem; }
table.daily td.hl-sale { background: #dcfce7; color: #14532d; font-size: 1rem; }
table.daily th.hl-sale { background: #15803d; }
table.daily td.hl-close { background: #fef3c7; color: #78350f; font-size: 1rem; }
table.daily th.hl-close { background: #b45309; }
table.daily tr.grand td { background: #dbeafe; font-weight: 800; border-top: 2px solid #1e3a8a; }
table.daily tr.grand td.hl-sale { background: #bbf7d0; } table.daily tr.grand td.hl-close { background: #fde68a; }
@media print {
  #daily-print table.daily th { background: #1e3a8a !important; color: #fff !important; text-align: center; }
  #daily-print table.daily th.hl-sale { background: #15803d !important; } #daily-print table.daily th.hl-close { background: #b45309 !important; }
  #daily-print table.daily td.hl-sale { background: #dcfce7 !important; font-size: 9.5px; } #daily-print table.daily td.hl-close { background: #fef3c7 !important; font-size: 9.5px; }
  #daily-print table.daily tr.grand td { background: #dbeafe !important; }
  #daily-print table.daily th, #daily-print table.daily td { border: 0.6pt solid #64748b !important; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
@media screen and (max-width: 768px) {
  table.daily td.hl-sale, table.daily td.hl-close { border-radius: 6px; padding: 4px 8px; }
}
@media print {
  #daily-print table.daily td, #daily-print table.daily td.num { font-size: 8.5px !important; }
  #daily-print table.daily td.hl-sale, #daily-print table.daily td.hl-close { font-size: 10px !important; font-weight: 900; }
  #daily-print table.daily tr.grand td { font-size: 9.5px !important; }
}
@media screen and (max-width: 768px) {
  table.daily td { border: 0 !important; }
  table.daily tr { border: 1px solid #94a3b8; }
  table.daily tr.grand td { border-top: 0 !important; }
}
/* Overall (bill) discount */
.overall-disc { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 10px 0 4px; padding: 8px 10px; border: 2px dashed #f59e0b; border-radius: 10px; background: #fffbeb; }
.overall-disc label { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.overall-disc input.amt { width: 110px; font-size: 1.1rem; }
.overall-chip { margin-top: 3px; font-size: .78rem; font-weight: 800; color: #92400e; }
.corr-line { border-left: 4px solid #f59e0b; background: #fffbeb; }
.corr-line > div:first-child { font-weight: 800; }
.challan-head { margin: 10px 0 4px; padding: 6px 10px; border-radius: 8px; font-size: 1.05rem; }
.challan-head.open { background: #fff4d6; color: #92400e; }
.challan-head.done { background: #e7f6ec; color: #166534; }
.rev-top { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; justify-content: space-between; padding: 10px; border: 2px solid #f59e0b; border-radius: 12px; background: #fffbeb; margin-bottom: 8px; }
.rev-top input.big-price { font-size: 1.6rem; font-weight: 800; width: 160px; }
.rev-count { font-size: 1.3rem; }
.rev-count strong { font-size: 1.8rem; color: #166534; }
.price-line { border-left-color: #f59e0b !important; }
