/*
 * IMS styles – mobile first, big tap targets (min 48px), large quantities.
 * Colours: green = stock in, orange = issue, red = low stock / waste,
 *          blue = stock view, teal = stock check.
 */
:root {
  --c-in: #15803d;      --c-in-bg: #dcfce7;
  --c-issue: #c2410c;   --c-issue-bg: #ffedd5;
  --c-waste: #dc2626;   --c-waste-bg: #fee2e2;
  --c-stock: #1d4ed8;   --c-stock-bg: #dbeafe;
  --c-adjust: #0f766e;  --c-adjust-bg: #ccfbf1;
  --c-wa: #128c7e;
  --c-text: #111827;
  --c-muted: #6b7280;
  --c-bg: #f3f4f6;
  --c-card: #ffffff;
  --c-border: #e5e7eb;
  --radius: 14px;
  --tone: #1d4ed8;      --tone-bg: #dbeafe;   /* overridden per screen */
}

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--c-bg);
  color: var(--c-text);
  font-size: 17px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
a { color: var(--c-stock); }

/* Screen tones */
.mode-in     { --tone: var(--c-in);     --tone-bg: var(--c-in-bg); }
.mode-issue  { --tone: var(--c-issue);  --tone-bg: var(--c-issue-bg); }
.mode-waste  { --tone: var(--c-waste);  --tone-bg: var(--c-waste-bg); }
.mode-adjust { --tone: var(--c-adjust); --tone-bg: var(--c-adjust-bg); }
.mode-stock  { --tone: var(--c-stock);  --tone-bg: var(--c-stock-bg); }

/* Pages use the full window width on desktop too */
.page { padding: 12px 16px 120px; }
@media (min-width: 992px) { .page { padding: 20px 32px 120px; } }

/* Long lists (stock, items, stock check) show 2 columns on wide screens */
@media (min-width: 1100px) {
  .list-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .list-grid > .stock-row, .list-grid > .sc-row {
    border-bottom: 0;
    box-shadow: 1px 0 0 var(--c-border), 0 1px 0 var(--c-border);   /* lines between cells, also when filtered */
  }
  .list-grid > .list-empty { grid-column: 1 / -1; }
}

/* Language toggle (top bar; floating on the login screen) */
.lang-toggle { display: flex; align-items: center; height: 48px; padding: 0 2px; text-decoration: none; flex: none; }
.lang-toggle span {
  padding: 5px 12px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .55); color: #fff;
  font-weight: 700; font-size: .95rem; white-space: nowrap;
}
.lang-toggle:hover span, .lang-toggle:focus span { background: rgba(255, 255, 255, .15); }
.lang-float { position: absolute; top: 10px; right: 12px; z-index: 5; }

.muted { color: var(--c-muted); }
.page-title { font-size: 1.6rem; font-weight: 800; margin: 4px 0 12px; }
.box-title { font-size: 1.25rem; font-weight: 800; margin: 0 0 10px; }
.box-subtitle { font-size: 1.05rem; font-weight: 700; margin: 14px 0 4px; }
.big-label { display: block; font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.big-alert { font-size: 1.05rem; font-weight: 600; }

.card-box {
  background: var(--c-card);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---------- Buttons ---------- */
.btn { border-radius: 12px; font-weight: 600; }
.btn-big { min-height: 56px; font-size: 1.15rem; font-weight: 700; border-radius: 14px; padding-left: 18px; padding-right: 18px; }
.btn-whatsapp { background: var(--c-wa); border-color: var(--c-wa); color: #fff; }
.btn-whatsapp:hover, .btn-whatsapp:focus { background: #0f766e; color: #fff; }
.btn-tone { background: var(--tone); border: 0; color: #fff; }
.btn-tone:hover, .btn-tone:focus { background: var(--tone); color: #fff; filter: brightness(.92); }
.btn-tone:disabled { background: var(--tone); color: #fff; opacity: .55; }
.btn-eye { min-width: 56px; font-size: 1.2rem; }
.btn-sm-tap { min-height: 48px; display: inline-flex; align-items: center; justify-content: center; }
.btn-link-plain { background: none; border: 0; color: var(--c-stock); font-weight: 700; padding: 0; min-height: 48px; }

.form-control, .form-select { border-radius: 12px; }
.form-control-lg, .form-select-lg { min-height: 56px; font-size: 1.15rem; }
.form-control:focus, .form-select:focus { border-color: var(--c-stock); box-shadow: 0 0 0 .2rem rgba(29, 78, 216, .2); }

/* ---------- Top bar & side menu ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 8px;
  height: 56px; padding: 0 8px;
  background: #1f2937; color: #fff;
}
.topbar-btn {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border: 0; border-radius: 12px; background: transparent;
  color: #fff; font-size: 1.5rem; text-decoration: none;
}
.topbar-btn:hover, .topbar-btn:focus { background: rgba(255, 255, 255, .12); color: #fff; }
.topbar-title {
  flex: 1; min-width: 0;
  color: #fff; font-weight: 800; font-size: 1.15rem; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title:hover { color: #fff; }

.side-menu {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 46;
  width: 290px; max-width: 86vw;
  background: #fff; overflow-y: auto;
  transform: translateX(-105%); visibility: hidden;   /* hidden menu is not keyboard-focusable */
  transition: transform .2s ease, visibility .2s;
  padding-bottom: 24px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, .2);
}
.menu-backdrop { position: fixed; inset: 0; z-index: 45; background: rgba(0, 0, 0, .45); display: none; }
.menu-open .side-menu { transform: none; visibility: visible; }
.menu-open .menu-backdrop { display: block; }
.side-menu-user { padding: 18px 16px; background: #1f2937; color: #fff; }
.side-menu-name { font-weight: 800; font-size: 1.15rem; }
.side-menu-role { opacity: .8; font-size: .95rem; }
.side-menu-link {
  display: flex; align-items: center; width: 100%;
  min-height: 52px; padding: 0 18px;
  color: var(--c-text); font-size: 1.1rem; font-weight: 600; text-decoration: none;
  border: 0; border-bottom: 1px solid var(--c-border); background: #fff; text-align: left;
}
.side-menu-link:hover, .side-menu-link:focus { background: var(--c-bg); color: var(--c-text); }
.side-menu-link.active { background: var(--c-stock-bg); color: var(--c-stock); }
.side-menu-logout { color: var(--c-waste); }

/* ---------- Login ---------- */
.page-login { background: #1f2937; }
.login-box {
  max-width: 440px; margin: 6vh auto 0;
  background: #fff; border-radius: 20px; padding: 24px 20px;
}
.login-logo { font-size: 3rem; text-align: center; }
.login-title { text-align: center; font-weight: 800; font-size: 1.6rem; margin: 4px 0 0; }
.login-sub { text-align: center; color: var(--c-muted); margin-bottom: 18px; }

/* ---------- Home ---------- */
.low-banner {
  background: var(--c-waste); color: #fff;
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
.low-banner-text { font-size: 1.25rem; font-weight: 800; margin-bottom: 10px; }
.low-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.low-banner-actions .btn { flex: 1 1 140px; display: flex; align-items: center; justify-content: center; }

.home-actions { display: grid; gap: 12px; }
.btn-huge {
  display: flex; align-items: center; gap: 16px;
  min-height: 100px; padding: 16px 20px;
  border-radius: 18px; color: #fff; text-decoration: none;
  font-size: 1.65rem; font-weight: 800; line-height: 1.15;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .15);
}
.btn-huge:hover, .btn-huge:focus { color: #fff; filter: brightness(.95); }
.btn-huge:active { transform: translateY(2px); box-shadow: none; }
.btn-huge-emoji { font-size: 2.3rem; width: 56px; height: 56px; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .2); border-radius: 50%; flex: none; }
.btn-huge-text small { display: block; font-size: .95rem; font-weight: 600; opacity: .92; margin-top: 4px; }
.tone-in { background: var(--c-in); }
.tone-issue { background: var(--c-issue); }
.tone-stock { background: var(--c-stock); }
.tone-waste { background: var(--c-waste); }
.tone-adjust { background: var(--c-adjust); }

.home-small { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.btn-mid {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 64px; padding: 8px; border-radius: 16px;
  color: #fff; font-size: 1.25rem; font-weight: 800; text-decoration: none;
}
.btn-mid:hover, .btn-mid:focus { color: #fff; filter: brightness(.95); }
.home-small .btn-mid:only-child { grid-column: 1 / -1; }
.home-owner { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.btn-mini {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 52px; padding: 6px; border-radius: 12px;
  background: #fff; border: 1px solid var(--c-border);
  color: var(--c-text); font-weight: 700; text-decoration: none; font-size: 1rem;
}
.btn-mini:hover { background: var(--c-bg); color: var(--c-text); }

@media (min-width: 768px) {
  .home-actions { grid-template-columns: repeat(3, 1fr); }
  .btn-huge { flex-direction: column; text-align: center; min-height: 190px; justify-content: center; }
}

.stat-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat { background: var(--c-bg); border-radius: 12px; padding: 10px 12px; }
.stat-num { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat-label { color: var(--c-muted); font-weight: 600; }

.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--c-border); }
.plain-list li:last-child { border-bottom: 0; }

/* ---------- Mode band (entry screens) ---------- */
.mode-band {
  background: var(--tone); color: #fff;
  border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px;
}
.mode-band h1 { font-size: 1.6rem; font-weight: 800; margin: 0; }
.mode-band p { margin: 2px 0 0; opacity: .92; }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-bottom: 12px; }
.search-input {
  min-height: 56px; font-size: 1.2rem; padding-left: 46px;
  border: 2px solid var(--c-border);
}
.search-icon { position: absolute; left: 14px; top: 14px; font-size: 1.2rem; pointer-events: none; }
.search-results {
  position: absolute; left: 0; right: 0; top: 60px; z-index: 20;
  background: #fff; border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  max-height: 60vh; overflow-y: auto;
}
.result-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; min-height: 58px; padding: 10px 14px;
  border: 0; border-bottom: 1px solid var(--c-border); background: #fff;
  text-align: left; font-size: 1.15rem; color: var(--c-text);
}
.result-row:hover, .result-row:focus { background: var(--tone-bg); }
.result-name { font-weight: 700; }
.result-alias { display: block; font-size: .85rem; color: var(--c-muted); font-weight: 400; }
.result-qty { white-space: nowrap; font-weight: 700; color: var(--c-muted); }
.result-qty.is-low { color: var(--c-waste); }
.result-empty { padding: 16px; color: var(--c-muted); text-align: center; }

/* ---------- Tiles (frequent items) ---------- */
.section-label { font-weight: 800; color: var(--c-muted); font-size: .95rem; text-transform: uppercase; letter-spacing: .03em; margin: 6px 0 8px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 520px) { .tiles { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.tile {
  display: flex; flex-direction: column; justify-content: space-between; gap: 4px;
  min-height: 84px; padding: 10px 12px;
  background: #fff; border: 2px solid var(--c-border); border-radius: var(--radius);
  text-align: left; color: var(--c-text);
}
.tile:active { transform: scale(.98); }
.tile-name { font-weight: 800; font-size: 1.15rem; line-height: 1.2; }
.tile-qty { font-size: .95rem; color: var(--c-muted); font-weight: 600; }
.tile.is-low .tile-qty { color: var(--c-waste); }
.tile.in-cart { border-color: var(--tone); background: var(--tone-bg); }
.tile-cart { font-size: .95rem; font-weight: 800; color: var(--tone); }

/* ---------- Cart ---------- */
.cart { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.cart-row { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 0; border-bottom: 1px solid var(--c-border); }
.cart-row:last-child { border-bottom: 0; }
.cart-main {
  flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 56px; padding: 4px 12px; border: 0; background: transparent; text-align: left; color: var(--c-text);
}
.cart-name { font-weight: 800; font-size: 1.15rem; }
.cart-sub { display: block; font-size: .9rem; color: var(--c-muted); font-weight: 600; }
.cart-sub.warn { color: var(--c-waste); }
.cart-qty { font-size: 1.35rem; font-weight: 800; color: var(--tone); white-space: nowrap; }
.cart-remove {
  flex: none; width: 48px; height: 48px; border: 0; border-radius: 12px;
  background: var(--c-bg); font-size: 1.15rem;
}
.cart-empty { padding: 22px 16px; text-align: center; color: var(--c-muted); font-weight: 600; }
.cart-count { display: inline-block; min-width: 28px; padding: 0 8px; border-radius: 999px; background: var(--tone); color: #fff; text-align: center; font-size: .95rem; }

.save-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .97); border-top: 1px solid var(--c-border);
}
@media (min-width: 992px) { .save-bar { padding-left: 32px; padding-right: 32px; } }
.save-bar .btn { width: 100%; min-height: 60px; font-size: 1.3rem; font-weight: 800; border-radius: 16px; }

/* ---------- Bottom sheet / dialog ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0, 0, 0, .5);
}
.dialog-backdrop { z-index: 60; }
.sheet {
  width: 100%; max-width: 560px; max-height: 94vh; overflow-y: auto;
  background: #fff; border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
  animation: sheet-up .16s ease-out;
}
@media (min-width: 600px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 20px; }
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
.dialog-title { font-size: 1.35rem; font-weight: 800; margin: 0 0 8px; }
.dialog-msg { font-size: 1.15rem; white-space: pre-line; margin: 0 0 14px; }
.dialog-list { font-size: 1.05rem; font-weight: 600; padding-left: 20px; margin: 0 0 14px; }
.dialog-list li { margin-bottom: 4px; }
.dialog-btns { display: grid; gap: 8px; }

.qp-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.qp-name { font-size: 1.55rem; font-weight: 800; margin: 0; line-height: 1.2; }
.qp-stock { color: var(--c-muted); font-size: 1.05rem; margin: 2px 0 12px; }
.qp-stock strong { color: var(--c-text); }
.qp-stock.is-low strong { color: var(--c-waste); }
.qp-close { flex: none; width: 48px; height: 48px; border: 0; border-radius: 12px; background: var(--c-bg); font-size: 1.3rem; }
.qp-label { font-weight: 800; margin: 10px 0 6px; }

.seg { display: flex; gap: 8px; }
.seg-btn {
  flex: 1; min-height: 52px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--c-border); border-radius: 12px; background: #fff;
  font-size: 1.15rem; font-weight: 800; color: var(--c-text); cursor: pointer;
}
.seg-btn[aria-pressed="true"], .btn-check:checked + .seg-btn {
  border-color: var(--tone); background: var(--tone-bg); color: var(--tone);
}
.btn-check:focus-visible + .seg-btn { outline: 3px solid rgba(29, 78, 216, .4); }

.stepper { display: grid; grid-template-columns: 68px 1fr 68px; gap: 8px; margin: 12px 0; }
.step-btn { height: 68px; border: 0; border-radius: 14px; background: #e5e7eb; font-size: 2.1rem; font-weight: 800; line-height: 1; }
.step-btn:active { background: #d1d5db; }
.qty-input {
  width: 100%; min-width: 0; height: 68px;
  border: 2px solid var(--c-border); border-radius: 14px;
  font-size: 2rem; font-weight: 800; text-align: center;
}
.qty-input:focus { outline: none; border-color: var(--tone); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 48px; padding: 0 16px;
  border: 2px solid var(--c-border); border-radius: 999px; background: #fff;
  font-weight: 800; font-size: 1.05rem; color: var(--c-text);
}
.chip:active, .chip.active { border-color: var(--tone); background: var(--tone-bg); color: var(--tone); }

.qp-after { margin: 10px 0 0; font-size: 1.05rem; font-weight: 600; }
.qp-after.neg { color: var(--c-waste); font-weight: 800; }
.qp-error { color: var(--c-waste); font-weight: 800; min-height: 1.4em; margin: 8px 0; }
.reason-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.reason-grid .seg-btn { font-size: 1rem; }
.qp-actions { display: grid; gap: 8px; margin-top: 6px; }
.qp-actions .btn { min-height: 60px; font-size: 1.25rem; font-weight: 800; border-radius: 14px; }

/* ---------- Toasts ---------- */
.toast-area {
  position: fixed; left: 0; right: 0; bottom: 92px; z-index: 70;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  padding: 0 12px; pointer-events: none;
}
.toast-msg {
  position: relative; overflow: hidden; pointer-events: auto;
  width: 100%; max-width: 560px;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 14px 16px 16px; border-radius: 14px;
  background: #111827; color: #fff; font-size: 1.1rem; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  animation: sheet-up .16s ease-out;
  transition: opacity .2s;
}
.toast-msg.success { background: #166534; }
.toast-msg.error { background: #b91c1c; }
.toast-msg.hide { opacity: 0; }
.toast-text { flex: 1; min-width: 0; }
.toast-action {
  flex: none; min-height: 48px; padding: 0 16px; border-radius: 12px;
  border: 2px solid #fff; background: rgba(255, 255, 255, .15); color: #fff; font-weight: 800; font-size: 1.1rem;
}
.toast-close { flex: none; width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #fff; font-size: 1.1rem; }
.toast-bar {
  position: absolute; left: 0; bottom: 0; height: 4px; width: 100%;
  background: rgba(255, 255, 255, .55); transform-origin: left;
  animation: toast-countdown linear forwards;
}
@keyframes toast-countdown { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Stock list ---------- */
.list-box { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); overflow: hidden; }
.stock-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 66px; padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text); text-decoration: none;
}
.stock-row:last-child { border-bottom: 0; }
.stock-row:hover { background: var(--c-bg); color: var(--c-text); }
.stock-name { font-weight: 800; font-size: 1.15rem; }
.stock-meta { display: block; font-size: .9rem; color: var(--c-muted); font-weight: 500; }
.stock-qty { font-size: 1.45rem; font-weight: 800; white-space: nowrap; text-align: right; }
.stock-row.is-low { background: var(--c-waste-bg); }
.stock-row.is-low .stock-qty { color: var(--c-waste); }
.stock-row.is-zero .stock-qty { color: var(--c-muted); }
.low-tag { display: block; color: var(--c-waste); font-weight: 800; font-size: .85rem; }
.list-empty { padding: 20px; text-align: center; color: var(--c-muted); font-weight: 600; }
.list-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.fchip {
  min-height: 48px; padding: 0 14px;
  border: 1px solid var(--c-border); border-radius: 999px; background: #fff;
  font-weight: 700; color: var(--c-text);
}
.fchip[aria-pressed="true"] { background: #1f2937; border-color: #1f2937; color: #fff; }
.fchip.fchip-low { color: var(--c-waste); }
.fchip.fchip-low[aria-pressed="true"] { background: var(--c-waste); border-color: var(--c-waste); color: #fff; }

/* ---------- Item detail & history ---------- */
.item-hero { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.item-hero h1 { font-size: 1.6rem; font-weight: 800; margin: 0; }
.item-hero-qty { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin: 8px 0 2px; }
.item-hero.is-low { border-color: var(--c-waste); background: var(--c-waste-bg); }
.item-hero.is-low .item-hero-qty { color: var(--c-waste); }
.item-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.item-actions .btn-mid { min-height: 56px; font-size: 1.05rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0 0; }
.kv dt { color: var(--c-muted); font-weight: 600; }
.kv dd { margin: 0; font-weight: 700; }

.mv-row { padding: 12px 14px; border-bottom: 1px solid var(--c-border); }
.mv-row:last-child { border-bottom: 0; }
.mv-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.mv-qty { font-size: 1.3rem; font-weight: 800; white-space: nowrap; }
.mv-meta { color: var(--c-muted); font-size: .92rem; margin-top: 2px; }
.mv-note { font-size: .95rem; margin-top: 2px; }
.mv-row.is-reversed .mv-qty { text-decoration: line-through; opacity: .6; }
.mv-row.is-reversal { background: #fafafa; }
.mv-actions { margin-top: 6px; }

.badge-type { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .85rem; font-weight: 800; white-space: nowrap; }
.badge-in { background: var(--c-in-bg); color: var(--c-in); }
.badge-issue { background: var(--c-issue-bg); color: var(--c-issue); }
.badge-waste { background: var(--c-waste-bg); color: var(--c-waste); }
.badge-adjust { background: var(--c-adjust-bg); color: var(--c-adjust); }
.badge-undo { background: #e5e7eb; color: #374151; }
.q-in { color: var(--c-in); }
.q-issue { color: var(--c-issue); }
.q-waste { color: var(--c-waste); }
.q-adjust { color: var(--c-adjust); }

.pager { display: flex; justify-content: space-between; gap: 8px; margin-top: 12px; }
.pager .btn { min-height: 48px; display: inline-flex; align-items: center; }

/* ---------- Forms (items, settings, users) ---------- */
.form-card { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 16px; margin-bottom: 12px; }
.form-row-gap { margin-top: 16px; }
.unit-type-btns { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.ut-label {
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  min-height: 92px; padding: 8px 4px;
  border: 2px solid var(--c-border); border-radius: var(--radius); background: #fff;
  font-weight: 800; font-size: 1.1rem; cursor: pointer;
}
.ut-label .ut-emoji { font-size: 1.8rem; }
.ut-label small { font-weight: 600; color: var(--c-muted); font-size: .85rem; }
.btn-check:checked + .ut-label { border-color: var(--c-stock); background: var(--c-stock-bg); color: var(--c-stock); }
.btn-check:disabled + .ut-label { opacity: .5; cursor: not-allowed; }
.btn-check:checked:disabled + .ut-label { opacity: 1; }
.qty-field { display: flex; gap: 8px; align-items: stretch; }
.qty-field .form-control { flex: 1; min-width: 0; }
.qty-field .seg { flex: none; }
.qty-field .seg-btn { min-width: 60px; }
.more-details { margin-top: 16px; border-top: 1px solid var(--c-border); }
.more-details > summary {
  min-height: 52px; display: flex; align-items: center; gap: 8px;
  font-weight: 800; color: var(--c-stock); cursor: pointer; list-style: none;
}
.more-details > summary::-webkit-details-marker { display: none; }
.more-details > summary::before { content: '+'; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--c-stock-bg); flex: none; }
.more-details[open] > summary::before { content: '−'; }
.danger-zone { border-color: #fecaca; }

.item-row-actions { display: flex; gap: 6px; flex: none; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--c-bg); font-size: .8rem; font-weight: 700; color: var(--c-muted); }
.pill-off { background: #fee2e2; color: #b91c1c; }

/* ---------- Stock check ---------- */
.sc-row { padding: 12px 14px; border-bottom: 1px solid var(--c-border); }
.sc-row:last-child { border-bottom: 0; }
.sc-row.changed { background: #fffbeb; }
.sc-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 6px; }
.sc-name { font-weight: 800; font-size: 1.15rem; }
.sc-sys { color: var(--c-muted); font-weight: 600; white-space: nowrap; }
.sc-sys strong { color: var(--c-text); }
.sc-input-row { display: flex; gap: 8px; align-items: center; }
.sc-input { flex: 1; min-width: 0; height: 54px; font-size: 1.3rem; font-weight: 800; text-align: center; border: 2px solid var(--c-border); border-radius: 12px; }
.sc-input:focus { outline: none; border-color: var(--tone); }
.sc-row .seg-btn { min-width: 54px; min-height: 54px; flex: none; }
.sc-diff { font-weight: 800; min-height: 1.4em; margin-top: 4px; }
.sc-diff.plus { color: var(--c-in); }
.sc-diff.minus { color: var(--c-waste); }
.sc-diff.same { color: var(--c-muted); }
.sc-diff.bad { color: var(--c-waste); }

/* ---------- Reports ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tab {
  min-height: 48px; padding: 0 14px; display: inline-flex; align-items: center;
  border-radius: 12px; background: #fff; border: 1px solid var(--c-border);
  font-weight: 700; color: var(--c-text); text-decoration: none;
}
.tab.active { background: #1f2937; border-color: #1f2937; color: #fff; }
.report-filters { background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); padding: 12px; margin-bottom: 12px; }
.report-filters .form-control, .report-filters .form-select { min-height: 48px; }
.quick-ranges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.quick-ranges .btn { min-height: 44px; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.report-actions .btn { min-height: 48px; display: inline-flex; align-items: center; }
.report-head { margin-bottom: 8px; }
.report-head h2 { font-size: 1.25rem; font-weight: 800; margin: 0; }
.report-section { margin-bottom: 18px; }
.report-section h3 { font-size: 1.1rem; font-weight: 800; margin: 0 0 6px; }
.report-table { width: 100%; background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); border-collapse: separate; border-spacing: 0; overflow: hidden; font-size: 1rem; }
.report-table th { background: #f9fafb; font-weight: 800; padding: 10px; border-bottom: 1px solid var(--c-border); text-align: left; }
.report-table td { padding: 10px; border-bottom: 1px solid var(--c-border); vertical-align: top; }
.report-table tr:last-child td { border-bottom: 0; }
.report-table .num { text-align: right; white-space: nowrap; }
.report-table tfoot td { font-weight: 800; background: #f9fafb; border-top: 2px solid var(--c-border); }
.report-table tr.is-reversed td { color: var(--c-muted); }
.report-table tr.is-reversed td.qty-cell > span { text-decoration: line-through; }
.report-empty { padding: 16px; text-align: center; color: var(--c-muted); background: #fff; border: 1px solid var(--c-border); border-radius: var(--radius); }

@media (max-width: 640px) {
  .table-stack thead { display: none; }
  .table-stack, .table-stack tbody, .table-stack tfoot, .table-stack tr { display: block; width: 100%; }
  .table-stack tr { border-bottom: 1px solid var(--c-border); padding: 6px 0; }
  .table-stack tr:last-child { border-bottom: 0; }
  .table-stack td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 4px 12px; text-align: right; }
  .table-stack td::before { content: attr(data-label); font-weight: 700; color: var(--c-muted); text-align: left; flex: none; max-width: 45%; }
  .table-stack td.num { white-space: normal; }
  .table-stack td:empty { display: none; }
}

.print-only { display: none; }

/* ---------- Error page ---------- */
.error-page { background: var(--c-bg); font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.error-box { max-width: 480px; margin: 10vh auto; background: #fff; padding: 24px; border-radius: 20px; text-align: center; }
.error-emoji { font-size: 3rem; }
.error-box h1 { font-size: 1.35rem; margin: 10px 0 18px; }
.error-details { text-align: left; font-size: .75rem; max-height: 50vh; overflow: auto; white-space: pre-wrap; margin-top: 16px; }
.btn-plain { display: inline-block; min-height: 48px; padding: 12px 20px; border-radius: 12px; background: #1f2937; color: #fff; text-decoration: none; font-weight: 700; }

/* ---------- Print ---------- */
@media print {
  .no-print, .topbar, .side-menu, .menu-backdrop, .toast-area, .save-bar, .report-filters, .tabs, .report-actions, .mv-actions { display: none !important; }
  .print-only { display: block !important; }
  body { background: #fff; font-size: 11pt; }
  .page { padding: 0; }
  .lang-float { display: none; }
  .report-table { border: 1px solid #999; font-size: 10pt; }
  .report-table th, .report-table td { padding: 4px 6px; border-bottom: 1px solid #ccc; }
  .report-table thead { display: table-header-group; }
  .report-table tr { page-break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  .stock-row.is-low, .item-hero.is-low { background: #fff; }
}
