:root {
  --bg: #eaf4fb;
  --surface: #ffffff;
  --surface-soft: #f7fbff;
  --primary: #1f66b1;
  --primary-2: #3a97de;
  --primary-dark: #0c4f97;
  --text: #12324d;
  --muted: #5f7f99;
  --border: #d7e7f6;
  --shadow: 0 10px 28px rgba(23, 79, 138, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 10px;
  --danger-bg: #fdecec;
  --danger-text: #8a1f1f;
  --danger-border: #f4b4b4;
  --success-bg: #eaf9ef;
  --success-text: #166534;
  --success-border: #b7e4c7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background: linear-gradient(180deg, #dceefb 0%, var(--bg) 100%);
  color: var(--text);
}

body {
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
}

h1, h2, h3 {
  margin: 0;
}

.page-shell,
.page {
  width: 100%;
}

.page-shell {
  max-width: 1480px;
  margin: 0 auto;
  padding: 8px 16px 28px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 24px;
  min-height: 220px;
  padding: 28px;
  border-radius: 28px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
  color: #fff;
  box-shadow: var(--shadow);
}

.hero h1 {
  font-size: clamp(36px, 4vw, 58px);
  font-weight: 800;
  line-height: 1;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-width: 0;
  flex: 1;
}

.hero-copy-top {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.hero-copy-bottom {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-top: auto;
  flex-wrap: wrap;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-end;
  min-width: 220px;
}

.login-hero-actions .hero-toolbar-right {
  margin-top: 12px;
}

.hero-copy-bottom .hero-toolbar-right {
  margin-top: 12px;
}

.hero-logo-wrap {
  display: flex;
  justify-content: flex-end;
  width: 100%;
}

.hero-logo {
  width: 160px;
  max-width: 160px;
  height: auto;
  object-fit: contain;
  display: block;
  border-radius: 14px;
  padding: 8px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
}

.hero-toolbar {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  width: 100%;
  margin-top: auto;
}

.hero-toolbar-left {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-right: auto;
}

.hero-toolbar-right {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}

.version-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.22);
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.full-width {
  grid-column: 1 / -1;
}

.card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.stack-lg {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.row {
  display: flex;
  align-items: center;
}

.wrap {
  flex-wrap: wrap;
}

.gap-sm {
  gap: 10px;
}

label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  min-height: 96px;
  resize: vertical;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  font-weight: 700;
  white-space: nowrap;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(90deg, #1f66b1 0%, #328fe0 100%);
  color: #fff;
  box-shadow: 0 10px 18px rgba(35, 118, 188, 0.22);
}

.btn-secondary {
  background: #fff;
  color: var(--primary-dark);
  border: 1px solid rgba(16, 92, 163, 0.12);
  box-shadow: 0 8px 16px rgba(12, 79, 151, 0.10);
}

.help-btn {
  min-width: 44px;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.message,
.inline-error {
  margin-top: 10px;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.message:empty,
.inline-error:empty {
  display: none;
}

.message.server-error,
.inline-error.server-error {
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

.message.success {
  color: var(--success-text);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
}

.muted {
  color: var(--muted);
}

.hidden {
  display: none !important;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-soft);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: #eef7ff;
  color: var(--primary-dark);
  font-size: 14px;
}

tr:last-child td {
  border-bottom: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e9f4ff;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 13px;
}

.batch-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.compact-table th,
.compact-table td {
  padding: 10px 12px;
}

@media (max-width: 980px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .hero {
    flex-direction: column;
    min-height: unset;
  }

  .hero-actions,
  .hero-logo-wrap,
  .hero-toolbar {
    width: 100%;
  }

  .hero-actions {
    align-items: stretch;
  }

  .hero-logo-wrap {
    justify-content: flex-start;
  }

  .hero-toolbar {
    justify-content: space-between;
  }

  .hero-toolbar-left {
    margin-right: 0;
  }

  .batch-meta {
    grid-template-columns: 1fr;
  }
}


.hero-copy-bottom {
  margin-top: 20px;
  align-items: flex-end;
  padding-bottom: 4px;
}

.hero-toolbar {
  margin-top: auto;
  align-items: flex-end;
  padding-bottom: 4px;
}

.hero-copy-bottom > .btn,
.hero-copy-bottom > select,
.hero-toolbar-right > .btn,
.hero-toolbar-right > select {
  align-self: flex-end;
}

.help-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 37, 66, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2000;
}

.help-modal {
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #ffffff;
  border-radius: 22px;
  box-shadow: 0 24px 60px rgba(15, 58, 103, 0.28);
  border: 1px solid var(--border);
}

.help-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px 16px;
  background: linear-gradient(90deg, rgba(31,102,177,0.10) 0%, rgba(58,151,222,0.10) 100%);
  border-bottom: 1px solid var(--border);
}

.help-modal-title {
  font-size: 28px;
  color: var(--primary-dark);
  margin: 0;
}

.help-modal-subtitle {
  margin: 8px 0 0;
  color: var(--muted);
}

.help-modal-close {
  border: 0;
  background: #fff;
  color: var(--primary-dark);
  width: 42px;
  height: 42px;
  border-radius: 999px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.help-modal-body {
  padding: 22px 24px 24px;
}

.help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.help-card {
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
}

.help-card h3 {
  margin: 0 0 10px;
  color: var(--primary-dark);
  font-size: 18px;
}

.help-card p {
  margin: 0 0 10px;
  color: var(--muted);
}

.help-card ul,
.help-checklist {
  margin: 0;
  padding-left: 18px;
}

.help-card li,
.help-checklist li {
  margin: 6px 0;
}

.help-callout {
  margin-top: 18px;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(90deg, rgba(31,102,177,0.08) 0%, rgba(58,151,222,0.08) 100%);
  border: 1px solid var(--border);
}

@media (max-width: 900px) {
  .hero {
    min-height: 180px;
  }

  .help-grid {
    grid-template-columns: 1fr;
  }
}


.import-panel {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.small-text {
  font-size: 0.85rem;
}

.align-center {
  align-items: center;
}


.login-hero {
  min-height: 205px;
}

.login-hero .hero-copy {
  justify-content: flex-start;
}

.login-hero .hero-copy-top {
  align-items: center;
}

.login-hero-actions {
  justify-content: flex-start;
  gap: 18px;
}

.login-hero-toolbar {
  width: 100%;
  margin-top: 0;
  padding-bottom: 0;
}

.login-hero-toolbar .hero-toolbar-right {
  width: 100%;
  justify-content: flex-end;
}

.admin-hero .hero-copy,
.scanner-hero .hero-copy {
  justify-content: flex-start;
}

.scanner-hero .hero-copy-bottom {
  margin-top: 34px;
}

.admin-hero .hero-toolbar,
.scanner-hero .hero-toolbar {
  margin-top: 34px;
}

.admin-hero .hero-copy-bottom {
  margin-top: 60px;
}

.admin-hero .hero-toolbar-left,
.scanner-hero .hero-toolbar-left {
  min-width: 0;
}

.scanner-hero .hero-copy-bottom {
  max-width: 100%;
}

@media (max-width: 980px) {
  .login-hero-actions {
    align-items: flex-start;
  }

  .login-hero-toolbar .hero-toolbar-right {
    justify-content: flex-start;
  }

  .admin-hero .hero-copy-bottom,
  .scanner-hero .hero-copy-bottom,
  .admin-hero .hero-toolbar,
  .scanner-hero .hero-toolbar {
    margin-top: 18px;
  }
}

#companySelector{min-width:280px;}
#masterDataHint{margin:.35rem 0 .65rem 0;}


.tenant-hero .hero-toolbar {
  margin-top: 34px;
}

.tenant-hero .hero-toolbar-right {
  margin-top: 8px;
}

.import-progress {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.import-progress-bar {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: #dbeaf7;
  border: 1px solid var(--border);
}

.import-progress-fill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary-2) 100%);
  transition: width 0.25s ease;
}

.align-center {
  align-items: center;
}

.small-text {
  font-size: 12px;
}

@media (max-width: 980px) {
  .tenant-hero .hero-toolbar {
    margin-top: 18px;
  }
}


.scan-mode-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.scan-mode-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border, #d7e3f2);
  border-radius: 16px;
  background: #fff;
  min-width: 280px;
}

.scan-mode-card input[type="radio"] {
  width: auto;
  min-height: auto;
  margin-top: 3px;
}


/* ── Analytics stat cards ─────────────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border, #d7e3f2);
  border-radius: 16px;
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--fg, #1a1a2e);
  line-height: 1;
}

@media (max-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
