:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --primary: #0f766e;
  --border: #d0d5dd;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #111827;
  color: white;
  padding: 12px 16px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.brand {
  font-weight: 800;
  text-decoration: none;
}

nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

nav a {
  color: white;
  text-decoration: none;
  font-size: 14px;
  opacity: .95;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px;
}

.hero, .panel, .detail, .empty {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
}

.hero h1, h1 {
  margin-top: 0;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  background: white;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  cursor: pointer;
}

.button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  text-decoration: none;
  color: var(--text);
}

.card img, .placeholder {
  width: 100%;
  height: 160px;
  object-fit: cover;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #e5e7eb;
  color: var(--muted);
}

.card-body {
  padding: 14px;
}

.card h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

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

.form {
  display: grid;
  gap: 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.form.compact {
  background: transparent;
  border: 0;
  padding: 0;
}

label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

input, textarea, select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  font: inherit;
  background: white;
}

.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.preview {
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  background: #e5e7eb;
  border-radius: 18px;
  margin-bottom: 14px;
}

.stock {
  font-size: 20px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 6px 14px;
}

.search {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search input, .search select {
  flex: 1;
  min-width: 220px;
}

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

table {
  border-collapse: collapse;
  width: 100%;
  min-width: 760px;
}

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

th {
  background: #f9fafb;
}

pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #f9fafb;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .container {
    padding: 12px;
  }

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

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

  .button {
    width: 100%;
  }

  .search {
    flex-direction: column;
  }
}


.userbadge {
  color: #d1d5db;
  font-size: 13px;
  white-space: nowrap;
}

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #111827;
  padding: 18px;
}

.login-card {
  width: min(460px, 100%);
  background: white;
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-card h1 {
  margin-bottom: 4px;
}

.login-form {
  border: 0;
  padding: 0;
}

.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  margin: 12px 0;
}

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

.small {
  font-size: 13px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox input {
  width: auto;
}


.brand-with-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.site-logo {
  width: auto;
  height: 34px;
  max-width: 140px;
  object-fit: contain;
  background: white;
  border-radius: 8px;
  padding: 3px;
}

.logo-preview-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 16px;
  display: inline-flex;
}

.logo-preview {
  max-width: 320px;
  max-height: 160px;
  object-fit: contain;
}

.delete-logo-form {
  margin-top: 12px;
}

.button.danger {
  color: #991b1b;
  border-color: #fecaca;
  background: #fef2f2;
}

.report-header {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.report-header h1 {
  margin: 0 0 4px;
}

.report-logo {
  max-width: 220px;
  max-height: 90px;
  object-fit: contain;
}

@media print {
  .topbar,
  .search,
  .button {
    display: none !important;
  }

  body {
    background: white;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .report-header,
  .table-wrap {
    border: 0;
  }

  table {
    font-size: 11px;
  }

  th, td {
    padding: 6px;
  }
}

.error-list {
  margin: 0;
  padding-left: 20px;
  color: #991b1b;
}

.error-list li {
  margin-bottom: 6px;
}


.main-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.nav-dropdown {
  position: relative;
  display: inline-flex;
}

.nav-dropbtn {
  border: 0;
  background: transparent;
  color: white;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 0;
}

.nav-dropdown-content {
  display: none;
  position: absolute;
  top: 24px;
  right: 0;
  min-width: 210px;
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,.18);
  overflow: hidden;
  z-index: 100;
}

.nav-dropdown:hover .nav-dropdown-content,
.nav-dropdown:focus-within .nav-dropdown-content {
  display: grid;
}

.nav-dropdown-content a {
  color: var(--text);
  padding: 12px 14px;
  text-decoration: none;
}

.nav-dropdown-content a:hover {
  background: #f3f4f6;
}

@media (max-width: 680px) {
  .main-nav {
    width: 100%;
  }

  .nav-dropdown {
    width: 100%;
  }

  .nav-dropbtn {
    width: 100%;
    text-align: left;
    padding: 8px 0;
  }

  .nav-dropdown-content {
    position: static;
    width: 100%;
    margin-top: 6px;
  }
}


.incoming-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.2fr);
  gap: 16px;
  align-items: start;
}

.scanner-box {
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 14px;
}

.barcode-video {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  background: #111827;
  border-radius: 14px;
  display: block;
  margin-bottom: 10px;
}

.scanner-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.result-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  margin: 12px 0;
  background: #ffffff;
}

.success-box {
  border: 1px solid #bbf7d0;
  background: #f0fdf4;
  color: #166534;
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 14px;
}

.manual-details {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px;
  background: #ffffff;
}

.manual-details summary {
  cursor: pointer;
  font-weight: 750;
  margin-bottom: 12px;
}

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form input {
  width: 90px;
}

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

.positions-table select,
.positions-table input {
  min-width: 180px;
}

.small-button {
  padding: 8px 10px;
  font-size: 13px;
}

.row-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.success-message {
  margin-bottom: 18px;
}

.ocr-editor {
  position: relative;
  display: inline-block;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: #111827;
  touch-action: none;
}

.ocr-editor img {
  display: block;
  max-width: min(100%, 980px);
  height: auto;
}

.ocr-editor canvas {
  position: absolute;
  left: 0;
  top: 0;
  cursor: crosshair;
  touch-action: none;
}

.editor-toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.panel.nested {
  margin-top: 14px;
  padding: 12px;
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  cursor: pointer;
  text-decoration: underline;
  font: inherit;
}

.sub-row td {
  background: #f9fafb;
}

.inline-move-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-move-form select {
  max-width: 340px;
}

.image-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.image-card {
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  background: white;
}

.image-card img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
  background: #e5e7eb;
}

.image-card-body {
  padding: 12px;
}

.image-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}


/* Mobile-friendly navigation */
.topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.mobile-menu-button {
  display: none;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
  color: white;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.main-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.main-nav a,
.nav-dropbtn {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border-radius: 10px;
  padding: 8px 10px;
}

.main-nav a:hover,
.nav-dropbtn:hover {
  background: rgba(255,255,255,.09);
}

.nav-primary {
  font-weight: 800;
}

.mobile-bottom-nav {
  display: none;
}

.nav-dropdown-content.open {
  display: grid;
}

@media (min-width: 761px) {
  .nav-dropdown:hover .nav-dropdown-content {
    display: grid;
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 76px;
  }

  .topbar {
    position: sticky;
    top: 0;
    padding: 10px 12px;
  }

  .mobile-menu-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .main-nav {
    display: none;
    width: 100%;
    background: #1f2937;
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 16px;
    padding: 10px;
    gap: 8px;
  }

  .main-nav.open {
    display: grid;
  }

  .main-nav a,
  .nav-dropbtn {
    width: 100%;
    justify-content: flex-start;
    min-height: 46px;
    padding: 12px 14px;
    background: rgba(255,255,255,.06);
  }

  .nav-dropdown {
    width: 100%;
    display: grid;
  }

  .nav-dropbtn {
    font-weight: 800;
  }

  .nav-dropdown-content {
    position: static;
    display: none;
    width: 100%;
    margin-top: 8px;
    border-radius: 14px;
    box-shadow: none;
    overflow: hidden;
  }

  .nav-dropdown-content.open {
    display: grid;
  }

  .nav-dropdown-content a {
    min-height: 44px;
    color: var(--text);
    background: white;
    border-radius: 0;
  }

  .userbadge {
    font-size: 12px;
    color: #d1d5db;
  }

  .mobile-bottom-nav {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: 10px;
    z-index: 200;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    background: #111827;
    border: 1px solid rgba(255,255,255,.14);
    border-radius: 20px;
    padding: 8px;
    box-shadow: 0 12px 28px rgba(0,0,0,.28);
  }

  .mobile-bottom-nav a,
  .mobile-bottom-nav button {
    border: 0;
    border-radius: 14px;
    background: rgba(255,255,255,.08);
    color: white;
    text-decoration: none;
    display: grid;
    place-items: center;
    gap: 2px;
    padding: 8px 4px;
    font: inherit;
    cursor: pointer;
  }

  .mobile-bottom-nav span {
    font-size: 20px;
    line-height: 1;
  }

  .mobile-bottom-nav small {
    font-size: 11px;
  }
}


/* Clean user-menu navigation: primary actions + user dropdown */
.clean-topbar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 10px 14px;
}

.clean-topbar-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quick-action-nav {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr) minmax(0, .8fr);
  gap: 8px;
  width: 100%;
}

.quick-action {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(255,255,255,.08);
  color: white;
  text-decoration: none;
  font-weight: 750;
  border: 1px solid rgba(255,255,255,.10);
}

.quick-action:hover {
  background: rgba(255,255,255,.14);
}

.primary-action {
  background: #0f766e;
  border-color: #0f766e;
}

.primary-action:hover {
  background: #115e59;
}

.user-menu {
  position: relative;
  flex: 0 0 auto;
}

.user-menu-button {
  min-height: 42px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.08);
  color: white;
  border-radius: 999px;
  padding: 7px 10px 7px 13px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "name arrow"
    "role arrow";
  column-gap: 8px;
  align-items: center;
  cursor: pointer;
  text-align: left;
  max-width: 210px;
}

.user-menu-name {
  grid-area: name;
  font-size: 14px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-role {
  grid-area: role;
  font-size: 11px;
  color: #d1d5db;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-arrow {
  grid-area: arrow;
  font-size: 13px;
}

.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 250px;
  max-width: min(92vw, 340px);
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 18px 45px rgba(0,0,0,.24);
  overflow: hidden;
  z-index: 300;
}

.user-menu-dropdown.open {
  display: grid;
}

.user-menu-dropdown a {
  color: var(--text);
  text-decoration: none;
  padding: 13px 15px;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 650;
}

.user-menu-dropdown a:hover {
  background: #f3f4f6;
}

.dropdown-section-title {
  padding: 12px 15px 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  font-weight: 800;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.logout-link {
  color: #991b1b !important;
}

.mobile-bottom-nav,
.mobile-menu-button,
.main-nav,
.nav-dropdown,
.nav-dropdown-content,
.userbadge {
  display: none !important;
}

@media (max-width: 760px) {
  body {
    padding-bottom: 0;
  }

  .clean-topbar {
    gap: 9px;
    padding: 9px 10px;
  }

  .brand-with-logo span {
    font-size: 16px;
  }

  .site-logo {
    height: 30px;
    max-width: 110px;
  }

  .user-menu-button {
    max-width: 155px;
    min-height: 40px;
    padding: 6px 9px 6px 11px;
  }

  .user-menu-name {
    font-size: 13px;
  }

  .user-menu-role {
    font-size: 10px;
  }

  .user-menu-dropdown {
    top: calc(100% + 9px);
    right: 0;
    min-width: min(88vw, 310px);
  }

  .quick-action-nav {
    grid-template-columns: 1fr 1fr 0.72fr;
    gap: 7px;
  }

  .quick-action {
    min-height: 44px;
    padding: 8px 7px;
    border-radius: 13px;
    font-size: 14px;
  }
}

@media (max-width: 390px) {
  .brand-with-logo span {
    display: none;
  }

  .quick-action {
    font-size: 13px;
  }

  .user-menu-button {
    max-width: 145px;
  }
}

.app-footer {
  max-width: 1100px;
  margin: 18px auto;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}
