/* =====================================================
   INFOSOFT STOCKSENSE — Physical Inventory System
   Theme: Clean Light Professional
   Font: Plus Jakarta Sans + JetBrains Mono
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ── TOKENS ──────────────────────────────────────────── */
:root {
  /* Brand */
  --brand:        #0057ff;
  --brand-mid:    #0047d6;
  --brand-dark:   #003ab0;
  --brand-light:  #eff4ff;
  --brand-soft:   #dce8ff;

  /* Accent / status */
  --green:        #16a34a;
  --green-bg:     #dcfce7;
  --green-border: #bbf7d0;
  --red:          #dc2626;
  --red-bg:       #fef2f2;
  --red-border:   #fecaca;
  --amber:        #d97706;
  --amber-bg:     #fffbeb;

  /* Neutrals — light theme */
  --bg:           #f4f7fb;
  --bg2:          #edf0f5;
  --surface:      #ffffff;
  --surface2:     #f8fafc;
  --border:       #e2e8f0;
  --border2:      #cbd5e1;
  --divider:      #f1f5f9;

  /* Text */
  --text:         #0f172a;
  --text2:        #334155;
  --text3:        #64748b;
  --text4:        #94a3b8;
  --text-inv:     #ffffff;

  /* Radii */
  --r-xs:  4px;
  --r-sm:  8px;
  --r:     12px;
  --r-lg:  16px;
  --r-xl:  20px;

  /* Shadows */
  --shadow-xs: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 2px 8px rgba(15,23,42,.08), 0 1px 3px rgba(15,23,42,.06);
  --shadow:    0 4px 16px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.06);
  --shadow-md: 0 8px 28px rgba(15,23,42,.12), 0 2px 8px rgba(15,23,42,.06);

  /* Layout */
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --t: .15s ease;
}

/* ── RESET ───────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ── SCROLLBAR ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

/* ── HEADER ──────────────────────────────────────────── */
header {
  position: sticky;
  top: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 24px;
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.brand-icon {
  width: 44px;
  height: 44px;
  background: var(--brand);
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.brand-icon svg {
  width: 30px;
  height: 30px;
}
.brand-names {
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.brand-company {
  font-size: 11px;
  font-weight: 700;
  color: var(--text4);
  text-transform: uppercase;
  letter-spacing: .12em;
  line-height: 1;
}
.brand-product {
  display: flex;
  align-items: baseline;
  gap: 5px;
  line-height: 1.15;
}
.brand-product-name {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.3px;
}
.brand-product-sep {
  font-size: 11px;
  color: var(--text4);
  font-weight: 400;
}
.brand-product-sub {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: .01em;
}

nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: wrap;
  flex: 1;
  justify-content: flex-end;
}

nav a {
  color: var(--text3);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--r-sm);
  transition: var(--t);
  white-space: nowrap;
}
nav a:hover { color: var(--brand); background: var(--brand-light); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  padding: 5px 10px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  white-space: nowrap;
}

nav form button {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text3);
  font-size: 13px;
  font-weight: 600;
  min-height: 32px;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  transition: var(--t);
}
nav form button:hover {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
  transform: none;
  box-shadow: none;
}

/* Company switcher */
.company-switcher {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--brand-light);
  border: 1px solid var(--brand-soft);
  padding: 4px 6px 4px 10px;
  border-radius: var(--r-sm);
}
.company-switcher span {
  font-size: 10px;
  font-weight: 700;
  color: var(--brand-mid);
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
.company-switcher select {
  width: auto;
  min-height: 26px;
  padding: 3px 24px 3px 7px;
  border-radius: var(--r-xs);
  font-size: 12.5px;
  font-family: var(--font-mono);
  background: var(--surface);
  border-color: var(--brand-soft);
  color: var(--brand-mid);
  font-weight: 600;
}

/* ── MAIN ────────────────────────────────────────────── */
main {
  padding: 22px 24px;
  max-width: 1360px;
  margin: 0 auto;
}

/* ── CARD ────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  margin: 14px 0;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  margin: 0 0 2px;
}
.card h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.1px;
  margin: 0 0 14px;
}

.page-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.subtext {
  color: var(--text3);
  font-size: 13px;
  margin-top: 4px;
  line-height: 1.6;
}
.subtext b, .subtext strong {
  color: var(--brand);
  font-weight: 600;
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ── LABELS ──────────────────────────────────────────── */
label {
  display: block;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text3);
  margin-bottom: 6px;
}

/* ── INPUTS & SELECTS ────────────────────────────────── */
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 10px 13px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--t), box-shadow var(--t), background var(--t);
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath fill='none' stroke='%2364748b' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round' d='M1 1l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 34px;
  cursor: pointer;
}
input::placeholder { color: var(--text4); }
input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,87,255,.12);
  background: var(--surface);
}
input:read-only {
  background: var(--surface2);
  color: var(--text3);
  cursor: default;
  border-style: dashed;
}
input:read-only:focus { box-shadow: none; border-color: var(--border); }
input[type="number"] {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
}
input[type="file"] {
  padding: 8px 10px;
  cursor: pointer;
  color: var(--text3);
  font-size: 13px;
}
input[type="file"]::file-selector-button {
  background: var(--brand-light);
  border: 1px solid var(--brand-soft);
  border-radius: var(--r-xs);
  padding: 5px 11px;
  color: var(--brand-mid);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-right: 10px;
  transition: var(--t);
}
input[type="file"]::file-selector-button:hover {
  background: var(--brand-soft);
}

/* Checkbox */
.checkline {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 42px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
}

.checkline input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--brand);
  flex-shrink: 0;
  transform: scale(1.15);
  opacity: 1 !important;
  visibility: visible !important;
}

.checkline input[type="radio"]:checked {
  outline: 2px solid rgba(59, 91, 219, 0.18);
  border-radius: 50%;
}

.checkline input[type="checkbox"] {
  width: 17px;
  min-height: 17px;
  height: 17px;
  padding: 0;
  border-radius: 5px;
  cursor: pointer;
  accent-color: var(--brand);
  flex-shrink: 0;
}

/* ── BUTTONS ─────────────────────────────────────────── */
button, .primary, .link-btn, .link-button, .secondary-link, .small-btn, .secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  min-height: 40px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  text-decoration: none;
  transition: var(--t);
  white-space: nowrap;
  letter-spacing: -.01em;
  background: var(--surface);
  color: var(--text2);
}

button:hover, .link-btn:hover, .link-button:hover {
  border-color: var(--border2);
  background: var(--surface2);
  color: var(--text);
}
button:active { transform: scale(.98); }

/* Primary */
button.primary, .primary {
  background: var(--brand);
  color: var(--text-inv);
  border-color: var(--brand-mid);
  font-weight: 700;
  letter-spacing: -.01em;
}
button.primary:hover, .primary:hover {
  background: var(--brand-mid);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(0,87,255,.28);
}

/* Secondary */
.secondary-btn {
  background: var(--surface);
  color: var(--text2);
  border-color: var(--border);
}
.secondary-btn:hover {
  background: var(--surface2);
  border-color: var(--border2);
  color: var(--text);
}

/* Danger */
.danger-btn {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red-border);
  min-height: 32px;
  padding: 5px 11px;
  font-size: 12px;
}
.danger-btn:hover {
  background: #fee2e2;
  border-color: #fca5a5;
}

/* Small */
.small-btn {
  min-height: 32px;
  padding: 5px 12px;
  font-size: 12.5px;
}
.edit-btn {
  background: var(--brand-light);
  color: var(--brand-mid);
  border-color: var(--brand-soft);
}
.edit-btn:hover { background: var(--brand-soft); }

/* Link button */
.link-btn, .link-button {
  min-height: 38px;
  padding: 8px 15px;
}

/* Secondary link */
.secondary-link {
  background: var(--surface2);
  color: var(--text3);
  border-color: var(--border);
  width: 100%;
  min-height: 42px;
}

/* Save button */
.save-btn { width: 100%; min-height: 44px; font-size: 14px; }

/* Disabled */
button:disabled, .small-btn:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

/* ── SCAN FORM AREA ───────────────────────────────────── */
.scanform {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.6fr .7fr .7fr 1.1fr 1fr;
  gap: 12px;
  align-items: end;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px;
  margin-top: 16px;
}
.scanform fieldset { display: contents; border: 0; padding: 0; margin: 0; min-width: 0; }
.form-field { min-width: 0; }
.scan-field { grid-column: span 2; }
.desc-field { grid-column: span 2; }

.inline-action {
  display: grid;
  grid-template-columns: 1fr 90px;
  gap: 8px;
}

/* Active doc row */
.active-doc-form {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  align-items: center;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 14px;
  margin-bottom: 16px;
}
.active-doc-form label { margin: 0; }

/* Document create form */
.doc-create-form {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 12px;
  align-items: end;
}

/* Grid forms */
.gridform {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  align-items: end;
}
.compact-form { grid-template-columns: 1fr auto auto; gap: 10px; }
.user-form { gap: 14px; }
.button-field { align-self: end; }
.checkbox-field label { text-transform: none; letter-spacing: 0; }

/* Doc actions */
.doc-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* ── TABLES ──────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--r-lg);
  background: var(--surface);
  margin-top: 6px;
}
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: transparent;
}
th {
  background: var(--surface2);
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text3);
  white-space: nowrap;
  border-bottom: 1.5px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
th:first-child { border-radius: var(--r-sm) 0 0 0; }
th:last-child  { border-radius: 0 var(--r-sm) 0 0; }
td {
  padding: 11px 14px;
  font-size: 13.5px;
  color: var(--text2);
  border-bottom: 1px solid var(--divider);
  white-space: nowrap;
  vertical-align: middle;
  transition: background var(--t);
}
td strong { color: var(--text); font-weight: 600; }
tr:hover td { background: var(--bg); }
tr:last-child td { border-bottom: 0; }
.empty-row {
  text-align: center !important;
  color: var(--text4) !important;
  padding: 40px 20px !important;
  font-size: 13px;
}
td.mono {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text2);
}
.action-col { width: 150px; }
.row-actions, .action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.inline-form { margin: 0; }

/* ── BADGES / STATUS ─────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-xs);
  padding: 3px 8px;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--font-mono);
  background: var(--brand-light);
  color: var(--brand-mid);
  letter-spacing: .02em;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  border: 1px solid transparent;
}
.status-badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
}
.status-open   { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.status-open::before { background: var(--green); }
.status-closed { background: var(--bg2); color: var(--text4); border-color: var(--border); }
.status-closed::before { background: var(--text4); }

/* Variance */
.positive-var {
  color: var(--green);
  font-weight: 700;
  font-family: var(--font-mono);
}
.negative-var {
  color: var(--red);
  font-weight: 700;
  font-family: var(--font-mono);
}

/* ── MESSAGES ────────────────────────────────────────── */
.error {
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  min-height: 18px;
}
.error-block {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  padding: 11px 14px;
  border-radius: var(--r-sm);
  margin: 10px 0;
}
.success {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  padding: 10px 14px;
  border-radius: var(--r-sm);
  margin: 10px 0;
}
#msg { min-height: 18px; margin: 8px 0 2px; }

/* ── LOGIN ───────────────────────────────────────────── */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.login-body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 30% 20%, rgba(0,87,255,.06) 0%, transparent 60%),
    radial-gradient(ellipse 60% 40% at 70% 80%, rgba(0,87,255,.04) 0%, transparent 60%);
  pointer-events: none;
}
.login {
  width: min(420px, 94vw);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-xl);
  padding: 40px 36px;
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 1;
}
.login-logo {
  width: 64px; height: 64px;
  background: var(--brand);
  border-radius: var(--r-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  box-shadow: 0 6px 20px rgba(0,87,255,.25);
}
.login-logo svg { width: 44px; height: 44px; }

/* Login brand block */
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  margin-bottom: 6px;
}
.login-company {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .16em;
  color: var(--text4);
}
.login-product-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}
.login-product {
  font-size: 26px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.5px;
}
.login-footer {
  text-align: center;
  font-size: 11px;
  color: var(--text4);
  margin-top: 20px;
}
.login h2 { display: none; }  /* replaced by .login-brand */
.hint {
  color: var(--text4);
  font-size: 13px;
  text-align: center;
  margin-bottom: 26px;
}
.login .form-group { margin-bottom: 15px; }
.login .primary { width: 100%; min-height: 46px; font-size: 15px; margin-top: 6px; }
.login .error {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--r-sm);
  text-align: center;
}

/* ── SCAN SUCCESS FLASH ──────────────────────────────── */
.scan-success-row td { animation: rowFlash .7s ease; }
@keyframes rowFlash {
  0%   { background: #dcfce7; }
  100% { background: transparent; }
}

/* ── UPLOAD META ─────────────────────────────────────── */
.upload-meta {
  font-size: 12.5px;
  color: var(--text3);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 16px 18px;
  margin-top: 18px;
}
.upload-meta h4 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text4);
  margin-bottom: 9px;
  font-weight: 700;
}
.upload-meta p { margin: 5px 0; color: var(--text2); }
.upload-meta b { color: var(--brand-mid); font-family: var(--font-mono); font-size: 11.5px; font-weight: 600; }

/* ── PAGE DIVIDER ────────────────────────────────────── */
.section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  color: var(--text4);
  padding: 6px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── RESPONSIVE — TABLET ─────────────────────────────── */
@media (max-width: 1100px) {
  .scanform { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scan-field, .desc-field { grid-column: span 1; }
  .action-field { grid-column: span 2; }
}

/* ── RESPONSIVE — MOBILE ─────────────────────────────── */

/* ════════════════════════════════════════════════════════
   MOBILE HEADER — single line: icon + name | username | ☰
   All nav links hidden behind hamburger drawer
   ════════════════════════════════════════════════════════ */

/* Hamburger button — hidden on desktop, shown on mobile */
.mob-menu-btn {
  display: none;
  width: 38px; height: 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface2);
  color: var(--text2);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  min-height: unset;
  transition: var(--t);
  font-size: 0;            /* hide any text fallback */
}
.mob-menu-btn:hover {
  background: var(--brand-light);
  border-color: var(--brand-soft);
  color: var(--brand);
  transform: none;
  box-shadow: none;
}
/* Hamburger icon — 3 lines drawn with box-shadow */
.mob-menu-btn .ham {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: 18px;
}
.mob-menu-btn .ham span {
  display: block;
  height: 2px;
  width: 100%;
  background: currentColor;
  border-radius: 2px;
  transition: var(--t);
}
/* Animate to X when open */
.mob-menu-btn.is-open .ham span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.mob-menu-btn.is-open .ham span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.mob-menu-btn.is-open .ham span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Username chip — hidden on desktop, shown on mobile */
.mob-user {
  display: none;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
  flex-shrink: 1;
}

/* ── DRAWER BACKDROP ── */
.drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 198;
  background: rgba(15,23,42,.35);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeIn .18s ease;
}
.drawer-backdrop.open { display: block; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

/* ── MOBILE NAV DRAWER ── */
.mobile-nav-drawer {
  display: none;
  position: fixed;
  top: 52px;
  left: 0; right: 0;
  z-index: 199;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  box-shadow: 0 12px 32px rgba(15,23,42,.14);
  padding: 14px;
  animation: slideDown .2s ease;
}
.mobile-nav-drawer.open { display: block; }
@keyframes slideDown {
  from { opacity:0; transform:translateY(-8px); }
  to   { opacity:1; transform:translateY(0);    }
}

/* Nav grid inside drawer — 3 per row */
.drawer-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.drawer-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 8px;
  border-radius: var(--r-sm);
  color: var(--text2);
  background: var(--surface2);
  border: 1.5px solid var(--border);
  text-decoration: none;
  transition: var(--t);
  min-height: 56px;
}
.drawer-nav a:hover, .drawer-nav a:active {
  background: var(--brand-light);
  border-color: var(--brand-soft);
  color: var(--brand);
}
.drawer-nav a .nav-icon { font-size: 18px; line-height: 1; }

/* Drawer bottom row — company switcher + sign out */
.drawer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.drawer-company {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .06em;
}
.drawer-company select {
  min-height: 36px;
  font-size: 13px;
  padding: 4px 28px 4px 9px;
  background: var(--brand-light);
  border: 1.5px solid var(--brand-soft);
  color: var(--brand-mid);
  font-weight: 700;
  font-family: var(--font-mono);
  width: auto;
  border-radius: var(--r-sm);
}
.drawer-company-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 3px;
}
.drawer-signout {
  background: var(--red-bg);
  border: 1.5px solid var(--red-border);
  color: var(--red);
  font-size: 13px;
  font-weight: 700;
  min-height: 38px;
  padding: 7px 16px;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-family: var(--font-sans);
  white-space: nowrap;
  transition: var(--t);
  display: flex;
  align-items: center;
  gap: 5px;
}
.drawer-signout:hover { background: #fee2e2; }

/* ════════════════════════════════════════════════════════
   @media (max-width: 740px)  — apply mobile overrides
   ════════════════════════════════════════════════════════ */
@media (max-width: 740px) {

  /* ── Single-line header ── */
  header {
    height: 52px;
    padding: 0 12px;
    flex-wrap: nowrap;
    gap: 8px;
    justify-content: flex-start;
    overflow: hidden;
  }

  /* Hide the full desktop nav inside header */
  header > nav { display: none !important; }

  /* Strip brand down to icon + product name only */
  .brand-company,
  .brand-product-sep,
  .brand-product-sub { display: none !important; }
  .brand-product-name { font-size: 14.5px; letter-spacing: -.2px; }
  .brand-icon { width: 32px; height: 32px; }
  .brand-icon svg { width: 22px; height: 22px; }
  .brand-names { gap: 0; }

  /* Show the mobile elements */
  .mob-user     { display: flex; margin-left: auto; }
  .mob-menu-btn { display: flex; }

  main { padding: 10px 12px; }

  .card { padding: 14px; border-radius: var(--r-lg); margin: 10px 0; }
  .card h2 { font-size: 17px; }

  .page-title-row { flex-direction: column; gap: 10px; }
  .doc-actions { flex-direction: column; width: 100%; }
  .doc-actions .link-btn,
  .doc-actions button,
  .doc-actions form { width: 100%; }

  .scanform {
    grid-template-columns: 1fr;
    gap: 11px;
    padding: 14px;
  }
  .scan-field, .desc-field, .action-field { grid-column: span 1; }

  .gridform, .compact-form { grid-template-columns: 1fr; }
  .compact-form button, .compact-form a { width: 100%; }
  .inline-action { grid-template-columns: 1fr 84px; }
  .active-doc-form { grid-template-columns: 1fr; }
  .doc-create-form { grid-template-columns: 1fr; }

  input, select { min-height: 48px; font-size: 16px !important; }
  button, .save-btn { min-height: 48px; font-size: 15px !important; }
  .small-btn { min-height: 36px; font-size: 12.5px !important; }
  .danger-btn { min-height: 36px; }

  th { padding: 9px 10px; }
  td { padding: 10px; font-size: 12.5px; }

  .login { padding: 28px 20px; }
  .login-product { font-size: 22px; }

  .user-form { grid-template-columns: 1fr; }
  .secondary-link { width: 100%; }
}

@media (max-width: 420px) {
  .drawer-nav { grid-template-columns: repeat(2, 1fr); }
  .inline-action { grid-template-columns: 1fr; }
  .card { padding: 12px; }
}

/* ── CAMERA SCANNER MODAL ─────────────────────────────── */

/* The 📷 Scan button — ALWAYS visible, no JS hide/show */
.scan-btn {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand-mid);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}
.scan-btn:hover {
  background: var(--brand-mid);
  border-color: var(--brand-dark);
  box-shadow: 0 4px 14px rgba(0,87,255,.28);
}

/* Barcode row: input + Scan button + Find button */
.barcode-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: stretch;
}
.barcode-row input { min-width: 0; }
.barcode-row .scan-btn,
.barcode-row .find-btn {
  min-height: 44px;
  padding: 0 16px;
  font-size: 13.5px;
}

/* ── MODAL OVERLAY ── */
.scanner-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0,0,0,.88);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: flex-end;   /* sheet slides up from bottom on mobile */
  justify-content: center;
  padding: 0;
}
.scanner-modal.open { display: flex; }

/* On desktop, centre it */
@media (min-width: 600px) {
  .scanner-modal { align-items: center; padding: 20px; }
}

/* ── MODAL BOX ── */
.scanner-box {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  width: 100%;
  max-width: 520px;
  overflow: hidden;
  box-shadow: 0 -8px 40px rgba(0,0,0,.4);
  display: flex;
  flex-direction: column;
  max-height: 96vh;
}
@media (min-width: 600px) {
  .scanner-box {
    border-radius: var(--r-xl);
    box-shadow: 0 24px 64px rgba(0,0,0,.5);
  }
}

/* ── MODAL HEADER ── */
.scanner-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.scanner-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.scanner-close {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: var(--t);
  padding: 0; min-height: unset;
  font-weight: 400;
}
.scanner-close:hover {
  background: var(--red-bg);
  border-color: var(--red-border);
  color: var(--red);
  transform: none; box-shadow: none;
}

/* ── VIDEO VIEWPORT ── */
.scanner-viewport {
  position: relative;
  background: #000;
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  flex-shrink: 0;
}
.scanner-viewport video {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}

/* Aim overlay */
.scanner-aim {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.scanner-aim-box {
  width: 88%;
  aspect-ratio: 5/1.35;
  position: relative;
}
.scanner-aim-box::before,
.scanner-aim-box::after,
.scanner-aim-box > span::before,
.scanner-aim-box > span::after {
  content: '';
  position: absolute;
  width: 24px; height: 24px;
  border-color: rgba(255,255,255,.95);
  border-style: solid;
}
.scanner-aim-box::before  { top:0; left:0;  border-width:3px 0 0 3px; border-radius:4px 0 0 0; }
.scanner-aim-box::after   { top:0; right:0; border-width:3px 3px 0 0; border-radius:0 4px 0 0; }
.scanner-aim-box > span::before { bottom:0; left:0;  border-width:0 0 3px 3px; border-radius:0 0 0 4px; }
.scanner-aim-box > span::after  { bottom:0; right:0; border-width:0 3px 3px 0; border-radius:0 0 4px 0; }

/* Animated laser line */
.scanner-laser {
  position: absolute;
  left: 8%; right: 8%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #00e676, #00e676, transparent);
  border-radius: 2px;
  animation: laserScan 1.8s ease-in-out infinite;
  box-shadow: 0 0 8px #00e676, 0 0 20px rgba(0,230,118,.5);
  top: 50%;
}
@keyframes laserScan {
  0%   { top:18%; opacity:.8; }
  50%  { top:82%; opacity:1;  }
  100% { top:18%; opacity:.8; }
}

/* ── STATUS BAR ── */
.scanner-status {
  padding: 11px 18px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text3);
  border-top: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
  transition: background .2s, color .2s;
}
.scanner-status.scanning { color: var(--brand); background: var(--brand-light); }
.scanner-status.success  { color: var(--green); background: var(--green-bg); font-weight:700; }
.scanner-status.error    { color: var(--red);   background: var(--red-bg); }

/* Pulsing dot when actively scanning */
.scanner-status.scanning::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand);
  animation: statusPulse 1s ease infinite;
  flex-shrink: 0;
}
@keyframes statusPulse {
  0%,100% { opacity:1; transform:scale(1); }
  50%     { opacity:.4; transform:scale(.7); }
}

/* ── CONTROL BUTTONS ── */
.scanner-controls {
  display: flex;
  gap: 10px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  justify-content: center;
  flex-shrink: 0;
}
.scanner-controls button {
  flex: 1;
  max-width: 160px;
  min-height: 42px;
  font-size: 13px;
}

/* ── ITEM NOT FOUND MESSAGE ── */
#msg {
  min-height: 0;
  margin: 10px 0 0;
  display: none;
}
#msg.visible {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
}
#msg.is-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  color: var(--red);
}
#msg.is-info {
  background: var(--brand-light);
  border: 1px solid var(--brand-soft);
  color: var(--brand-mid);
}

/* Mobile overrides */
@media (max-width: 599px) {
  .scanner-viewport { aspect-ratio: 3/4; }
  .scanner-aim-box  { width: 78%; aspect-ratio: 3/1.6; }
  .barcode-row { grid-template-columns: 1fr; gap: 8px; }
  .barcode-row .scan-btn,
  .barcode-row .find-btn { width: 100%; }
}

button.danger, .danger {
  background: #b42318 !important;
  color: #fff !important;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}
.small-btn { padding: 6px 10px !important; font-size: 12px; }
.nowrap { white-space: nowrap; }

/* Counting mode selector - clear custom radio buttons */
.counting-modes-row {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface2);
}
.counting-modes-title {
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
}
.mode-radio {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0;
  min-height: 28px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--text2);
  text-transform: none;
  letter-spacing: 0;
  white-space: nowrap;
}
.mode-radio input[type="radio"] {
  position: absolute;
  opacity: 0 !important;
  width: 1px;
  height: 1px;
  pointer-events: none;
}
.mode-radio .radio-dot {
  width: 18px;
  height: 18px;
  border: 2px solid #94a3b8;
  border-radius: 50%;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.mode-radio .radio-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}
.mode-radio input[type="radio"]:checked + .radio-dot {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(0,87,255,.12);
}
.mode-radio input[type="radio"]:checked + .radio-dot::after {
  background: var(--brand);
}
.mode-radio input[type="radio"]:focus-visible + .radio-dot {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.mode-help {
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: 9px;
  background: var(--brand-light);
  border: 1px solid var(--brand-soft);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
}
@media (max-width: 640px) {
  .counting-modes-row { gap: 12px; align-items: flex-start; }
  .counting-modes-title { width: 100%; }
  .mode-radio { width: 100%; }
}
