:root {
  --brand: #0f6b4f;
  --brand-dark: #0a4f3a;
  --brand-soft: #e5f3ee;
  --bg: #f4f6f5;
  --card: #ffffff;
  --text: #1b2421;
  --muted: #66736e;
  --line: #dfe5e2;
  --danger: #b3261e;
  --danger-soft: #fbe9e7;
  --warn: #8a5a00;
  --warn-soft: #fff4dc;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Rubik, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 16px; line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.mono { font-family: ui-monospace, "SF Mono", Consolas, monospace; direction: ltr; unicode-bidi: embed; }
.ltr { direction: ltr; unicode-bidi: embed; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--brand); color: #fff;
}
.topbar .brand-logo { height: 44px; width: auto; background: #fff; border-radius: 10px; padding: 3px 8px; display: block; }
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .user { font-size: .875rem; opacity: .9; }
.topbar .btn { background: rgba(255,255,255,.15); color: #fff; border-color: transparent; }
.topbar .btn:hover { background: rgba(255,255,255,.25); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: #f0f3f2; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: .875rem; border-radius: 8px; }
.btn.big { min-height: 56px; font-size: 1.1rem; border-radius: 14px; }
.btn.block { width: 100%; }
input[type=text], input[type=password], input[type=search], input[type=number], select {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font: inherit; color: var(--text);
}
input:focus, select:focus, .btn:focus-visible { outline: 3px solid rgba(15,107,79,.3); outline-offset: 1px; border-color: var(--brand); }
label { display: block; font-weight: 600; margin: 12px 0 6px; font-size: .925rem; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 160px; }
.error-text { color: var(--danger); min-height: 1.4em; margin: 8px 0 0; font-size: .925rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .brand { text-align: center; margin-bottom: 14px; }
.login-card .login-logo { width: 100%; max-width: 300px; height: auto; display: block; margin: 4px auto 10px; }

/* ---------- scan page ---------- */
.scan-main { max-width: 560px; margin: 0 auto; padding: 14px; padding-bottom: max(24px, env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.result { text-align: center; padding: 22px 18px; min-height: 190px; display: grid; align-content: center; gap: 6px; border: 3px solid transparent; transition: border-color .2s; }
.result .price { font-size: clamp(3rem, 16vw, 4.75rem); font-weight: 800; color: var(--brand); line-height: 1; direction: ltr; }
.result .price .cur { font-size: .55em; font-weight: 700; margin-inline-end: 4px; }
.result .name { font-size: 1.35rem; font-weight: 700; }
.result .code { color: var(--muted); }
.result.found { border-color: var(--brand); }
.result.notfound { border-color: var(--danger); background: var(--danger-soft); }
.result.notfound .headline { color: var(--danger); font-size: 1.5rem; font-weight: 800; }
.result.idle .headline { font-size: 1.2rem; color: var(--muted); }
.result.flash { animation: flash .35s ease-out; }
@keyframes flash { from { transform: scale(.97); } to { transform: none; } }

.camera { position: relative; border-radius: var(--radius); overflow: hidden; background: #111; aspect-ratio: 4 / 3; }
.camera video { width: 100%; height: 100%; object-fit: cover; display: block; }
.camera .guide { position: absolute; inset: 22% 10%; border: 3px solid rgba(255,255,255,.85); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.25); pointer-events: none; }
.camera .guide::after { content: ""; position: absolute; left: 6%; right: 6%; top: 50%; height: 2px; background: #ff4d4d; box-shadow: 0 0 8px #ff4d4d; }
.camera .cam-tools { position: absolute; bottom: 10px; inset-inline-start: 10px; inset-inline-end: 10px; display: flex; gap: 8px; flex-wrap: wrap; }
.camera .cam-tools .btn { background: rgba(0,0,0,.55); color: #fff; border-color: transparent; }
.camera .cam-msg { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; text-align: center; padding: 20px; }

.manual { display: flex; gap: 8px; }
.manual input { font-size: 1.15rem; letter-spacing: .5px; direction: ltr; text-align: center; }
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.recent li:last-child { border-bottom: 0; }
.recent .r-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent .r-price { font-weight: 700; direction: ltr; }
.recent .r-miss { color: var(--danger); font-weight: 600; }

/* ---------- manager ---------- */
.mgr { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 52px); }
.side { background: var(--card); border-inline-end: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; }
.side button { text-align: start; background: none; border: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-weight: 600; color: var(--text); cursor: pointer; display: flex; justify-content: space-between; align-items: center; }
.side button:hover { background: #f0f3f2; }
.side button.active { background: var(--brand-soft); color: var(--brand-dark); }
.side .badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0 8px; font-size: .8rem; }
.content { padding: 22px; overflow: auto; }
.content > section { max-width: 1100px; }
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat .num { font-size: 2rem; font-weight: 800; color: var(--brand); }
.stat .lbl { color: var(--muted); font-size: .9rem; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 200px; }

table.grid { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
table.grid th, table.grid td { padding: 10px 12px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid th { background: #f7f9f8; font-size: .85rem; color: var(--muted); font-weight: 700; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid td.actions { white-space: nowrap; text-align: end; }
table.grid td.num { direction: ltr; text-align: end; font-weight: 700; }
table.grid col.mapped, table.grid th.mapped, table.grid td.mapped { background: var(--brand-soft); }
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 10px; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .8rem; font-weight: 700; background: #eef1f0; }
.pill.manager { background: #e7eefc; color: #2446a6; }
.pill.worker { background: var(--brand-soft); color: var(--brand-dark); }
.pill.off { background: var(--danger-soft); color: var(--danger); }
.pill.ok { background: var(--brand-soft); color: var(--brand-dark); }

.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 34px; text-align: center; background: var(--card); cursor: pointer; }
.drop.over { border-color: var(--brand); background: var(--brand-soft); }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); margin: 12px 0; }
.notice.ok { background: var(--brand-soft); color: var(--brand-dark); }
.notice.err { background: var(--danger-soft); color: var(--danger); }
.radio { display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 8px 0; cursor: pointer; }
.radio input { margin-top: 4px; }
.section-gap { margin-top: 26px; }

/* ---------- dialog & toast ---------- */
dialog { border: 0; border-radius: var(--radius); padding: 22px; width: min(440px, calc(100vw - 32px)); box-shadow: 0 10px 40px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.secret { font-size: 1.6rem; font-weight: 800; text-align: center; padding: 12px; background: var(--brand-soft); border-radius: 10px; letter-spacing: 2px; margin: 10px 0; user-select: all; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1b2421; color: #fff; padding: 10px 18px; border-radius: 10px; z-index: 100; box-shadow: var(--shadow); max-width: calc(100vw - 30px); }
.toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .mgr { grid-template-columns: 1fr; }
  .side { flex-direction: row; overflow-x: auto; border-inline-end: 0; border-bottom: 1px solid var(--line); padding: 8px; }
  .side button { white-space: nowrap; }
  .content { padding: 14px; }
  .topbar .user { display: none; }
  .topbar .brand-logo { height: 34px; padding: 2px 6px; }
}
@media (max-width: 480px) {
  .topbar { gap: 8px; padding-inline: 10px; }
  .topbar .title { visibility: hidden; }
}

/* ---------- MFA ---------- */
.center { text-align: center; }
.code-input { font-size: 1.6rem; text-align: center; letter-spacing: 4px; direction: ltr; margin: 8px 0; }
.qr { display: grid; place-items: center; margin: 6px 0 10px; min-height: 40px; }
.qr svg { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); }
ol.steps { padding-inline-start: 20px; margin: 8px 0; }
ol.steps li { margin: 6px 0; }
details { margin-top: 12px; }
details summary { cursor: pointer; }
.secret-key { letter-spacing: 1px; word-break: break-all; }
.backup-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; background: var(--brand-soft); padding: 14px; border-radius: 10px; margin: 12px 0; font-size: 1.05rem; text-align: center; }
.cam-info { margin: -6px 4px 0; text-align: center; }

/* ---------- stock count + reports on the scan page ---------- */
.actions { display: grid; gap: 10px; padding: 14px; }
.count-row { display: flex; gap: 8px; }
.count-row .qty-input { flex: 1; font-size: 1.25rem; text-align: center; direction: ltr; }
.report-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.report-btn { min-height: 48px; }
.report-btn.reported { background: var(--warn-soft); border-color: #e8c36a; color: var(--warn); }
