body{font-family:Arial,sans-serif;transition:background .3s,color .3s;overflow-x:hidden}
body[data-theme="light"]{background:#f5f6f8;color:#212529}
body[data-theme="dark"]{background:#121212;color:#f1f1f1}
body[data-theme="dark"] .card,body[data-theme="dark"] .table,body[data-theme="dark"] .form-control,body[data-theme="dark"] .form-select,body[data-theme="dark"] .form-check-input{background:#1e1e1e;color:#f1f1f1;border-color:#333}
body[data-theme="dark"] .table{--bs-table-bg:#1e1e1e;--bs-table-color:#f1f1f1;--bs-table-border-color:#333}
.container{max-width:1200px}
.topbar{display:flex;justify-content:space-between;align-items:flex-start;gap:12px;margin-bottom:20px;flex-wrap:wrap}
.topbar h1,.topbar h2,.topbar h3,.topbar h4,.topbar h5{margin:0}
.topbar > div:last-child{display:flex;flex-wrap:wrap;gap:8px}
.auth-card{max-width:520px;margin:40px auto;border-radius:14px}
.theme-btn,.lang-links a{text-decoration:none;margin-inline-start:10px}
.small-note{font-size:14px;opacity:.9;word-break:break-word}
.stock-toolbar .form-control,.stock-toolbar .btn{min-height:44px}
.scan-box{max-width:420px;margin:0 auto}
#reader{width:100%;max-width:400px;margin:0 auto}
.product-hit{border:1px solid #198754;background:rgba(25,135,84,.08);border-radius:10px;padding:12px;margin-top:12px}
.product-miss{border:1px solid #dc3545;background:rgba(220,53,69,.08);border-radius:10px;padding:12px;margin-top:12px}
.card{border-radius:14px}.card-body{overflow-wrap:anywhere}
img{max-width:100%;height:auto}
.table-responsive{overflow-x:auto;-webkit-overflow-scrolling:touch}
@media (max-width: 991.98px){.container{padding-left:14px;padding-right:14px}.topbar > div:last-child{width:100%}}
@media (max-width: 767.98px){body{font-size:14px}.container{padding-left:10px;padding-right:10px}.auth-card{margin:20px auto}.topbar{align-items:stretch}.topbar > div:first-child,.topbar > div:last-child{width:100%}.topbar > div:last-child .btn,.topbar > div:last-child a.btn{flex:1 1 calc(50% - 8px);min-width:130px}.card-body{padding:1rem}.table{white-space:nowrap}.row>[class*=col-]{margin-bottom:.5rem}}
@media (max-width: 575.98px){h2{font-size:1.35rem}.btn-sm{padding:.45rem .6rem;font-size:.82rem}.topbar > div:last-child .btn,.topbar > div:last-child a.btn{flex:1 1 100%}.table td,.table th{padding:.55rem}}
/* ===== GLOBAL ACTION BUTTONS ===== */
.page-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
}

.page-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

/* ===== MOBILE CARDS ===== */
.mobile-info-grid .label {
    font-size: 14px;
    opacity: 0.8;
}

.mobile-info-grid .value {
    font-size: 17px;
    font-weight: 700;
}

/* ===== RESPONSIVE TABLE ===== */
.table-responsive {
    overflow-x: auto;
}

/* ===== TOPBAR FIX ===== */
.topbar {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
}


/* ===== READABLE TYPOGRAPHY v10 =====
   Improves legibility without changing the grid, card widths or scanner geometry. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { font-size: 16px; line-height: 1.45; }
.form-label, label { font-size: 15px; line-height: 1.35; }
.form-control, .form-select, .input-group-text { font-size: 16px; }
.btn { font-size: 15px; line-height: 1.35; }
.btn-sm { font-size: 14px; }
.small, small, .small-note, .text-muted { font-size: 14px; }
.card-title { font-size: 18px; }
.table { font-size: 15px; }
.dropdown-menu { font-size: 15px; }

@media (max-width: 767.98px) {
  body { font-size: clamp(15.5px, 4vw, 16px); line-height: 1.45; }
  .form-label, label { font-size: clamp(14.5px, 3.7vw, 15px); }
  .form-control, .form-select, .input-group-text { font-size: 16px; }
  .btn { font-size: clamp(14px, 3.6vw, 15px); }
  .btn-sm { font-size: 14px; }
  .small, small, .small-note, .text-muted { font-size: 14px; }
  .mobile-info-grid .label { font-size: 14px; }
  .mobile-info-grid .value { font-size: 17px; }
  .table { font-size: 14.5px; }
}


/* ===== APP RENDERING STABILITY v11 ===== */
html, body {
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
  font-family: Arial, Tahoma, Helvetica, sans-serif !important;
  font-synthesis: none;
}
button, input, select, textarea, .btn, .form-control, .form-select, .dropdown-menu {
  font-family: Arial, Tahoma, Helvetica, sans-serif !important;
  -webkit-text-size-adjust: 100% !important;
  text-size-adjust: 100% !important;
}
svg.app-icon, .app-icon svg {
  width: 1.25em;
  height: 1.25em;
  display: block;
  flex: 0 0 auto;
}
.notranslate { translate: no; }

/* PWA install control: remains available when a browser does not show an address-bar badge. */
.stocktake-install-btn {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 1080;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(127,127,127,.35);
  border-radius: 999px;
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  box-shadow: 0 4px 18px rgba(0,0,0,.18);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
}
.stocktake-install-btn svg { width: 19px; height: 19px; display:block; fill:currentColor; flex:0 0 19px; }
.stocktake-install-btn.ready { border-color: currentColor; }
.stocktake-install-help { position:fixed; inset:0; z-index:1090; display:none; align-items:flex-end; justify-content:center; padding:16px; background:rgba(0,0,0,.48); }
.stocktake-install-help.show { display:flex; }
.stocktake-install-help-card { position:relative; width:min(100%,440px); padding:20px 44px 20px 20px; border-radius:18px; background:var(--bs-body-bg,#fff); color:var(--bs-body-color,#212529); box-shadow:0 12px 40px rgba(0,0,0,.28); }
.stocktake-install-help-title { font-size:18px; font-weight:800; margin-bottom:8px; }
.stocktake-install-help-text { font-size:15px; line-height:1.55; }
.stocktake-install-help-close { position:absolute; top:9px; right:11px; width:34px; height:34px; border:0; border-radius:50%; background:transparent; color:inherit; font-size:26px; line-height:1; }
@media (display-mode: standalone), (display-mode: fullscreen) { .stocktake-install-btn { display:none !important; } }


/* ===== PUBLIC AUTH LANGUAGE + THEME TOOLBAR v13 =====
   Login/Register: language selector and theme toggle are equal-size controls on one row. */
.auth-controls {
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
}
.auth-controls-login,
.auth-controls-register { max-width: 520px; margin-inline: auto; }
.auth-language-wrap {
  width: 100% !important;
  min-width: 0 !important;
  max-width: none !important;
}
.auth-language-select,
.auth-theme-btn {
  box-sizing: border-box;
  width: 100% !important;
  min-width: 0 !important;
  height: 46px !important;
  min-height: 46px !important;
  margin: 0 !important;
  padding: 8px 12px;
  font-size: 14px;
  line-height: 1.2;
}
.auth-language-select {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-theme-btn {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
@media (max-width: 575.98px) {
  .auth-controls {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) !important;
    gap: 6px;
  }
  .auth-language-select,
  .auth-theme-btn {
    height: 44px !important;
    min-height: 44px !important;
    padding-inline: 8px;
    font-size: clamp(11px, 3.45vw, 14px);
  }
}
