:root {
  color-scheme: light;
  --wms-bg: #f4f6f8;
  --wms-surface: #ffffff;
  --wms-surface-soft: #f9fafb;
  --wms-border: #d7dde5;
  --wms-border-strong: #c4ccd7;
  --wms-text: #172033;
  --wms-muted: #637083;
  --wms-primary: #1f6feb;
  --wms-primary-dark: #164ea6;
  --wms-primary-soft: #e8f1ff;
  --wms-success: #1f6feb;
  --wms-warning: #8a5a00;
  --wms-danger: #b42318;
  --wms-cyan: #0f766e;
  --wms-sidebar-width: 180px;
  --wms-header-height: 56px;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

body.has-app-sidebar {
  overflow: hidden;
}

body.has-mobile-nav {
  padding-bottom: 72px;
}

.wms-shell {
  display: grid;
  grid-template-columns: var(--wms-sidebar-width) minmax(0, 1fr);
  grid-template-rows: var(--wms-header-height) minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
  isolation: isolate;
}

.wms-unified-header {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: var(--wms-sidebar-width) minmax(0, 1fr);
  align-items: stretch;
  position: sticky;
  top: 0;
  z-index: 1035;
  min-height: var(--wms-header-height);
  border-bottom: 1px solid var(--wms-border);
  background: var(--wms-surface);
}

.wms-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 100%;
  padding: 0 14px;
  color: var(--wms-text);
  text-decoration: none;
}

.wms-header-brand-mark {
  flex: 0 0 auto;
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--wms-primary);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 800;
}

.wms-header-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1px;
  min-width: 0;
}

.wms-header-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 24px;
}

.wms-sidebar {
  grid-row: 2;
  grid-column: 1;
  flex: 0 0 var(--wms-sidebar-width);
  width: var(--wms-sidebar-width);
  max-width: var(--wms-sidebar-width);
  min-width: var(--wms-sidebar-width);
  height: 100%;
  min-height: 0;
  background: var(--wms-surface);
  border-right: 1px solid var(--wms-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  display: none;
}

.sidebar-brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 8px;
  background: var(--wms-primary);
  color: #fff;
  font-weight: 800;
}

.wms-header-brand strong,
.wms-header-brand small,
.sidebar-brand strong,
.sidebar-brand small {
  display: block;
  line-height: 1.1;
  white-space: nowrap;
}

.wms-header-brand strong {
  font-size: 0.92rem;
  letter-spacing: 0.01em;
}

.wms-header-brand small,
.sidebar-brand small {
  margin-top: 0;
  color: var(--wms-muted);
  font-size: 0.68rem;
}

.sidebar-nav {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 5px 12px;
}

.sidebar-section + .sidebar-section {
  margin-top: 14px;
}

.sidebar-section-title {
  padding: 0 4px 4px;
  color: #7a8596;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar-link-list {
  display: grid;
  gap: 4px;
}

.sidebar-link {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 5px 5px;
  border-radius: 7px;
  color: #344054;
  font-weight: 650;
  text-decoration: none;
}

.sidebar-link > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: #eef4ff;
  color: var(--wms-primary-dark);
}

.sidebar-link.active {
  background: #dfeeff;
  color: var(--wms-primary-dark);
}

.sidebar-link-mark {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--wms-border);
  border-radius: 6px;
  background: #fff;
  color: #526070;
  font-size: 0.72rem;
  font-weight: 800;
}

.sidebar-link.active .sidebar-link-mark {
  border-color: #9dc2ff;
  background: #fff;
  color: var(--wms-primary-dark);
}

.sidebar-backdrop {
  display: none;
}

.wms-main {
  grid-row: 2;
  grid-column: 2;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.wms-appbar {
  display: none;
}

.appbar-menu-button {
  display: none;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--wms-border);
  border-radius: 7px;
  background: #fff;
}

.appbar-menu-button span {
  display: block;
  width: 17px;
  height: 2px;
  margin: 2px auto;
  border-radius: 999px;
  background: #344054;
}

.appbar-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}

.appbar-title span {
  color: var(--wms-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.appbar-title strong {
  overflow: hidden;
  color: var(--wms-text);
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.appbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.appbar-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 4px 10px 4px 5px;
  border: 1px solid var(--wms-border);
  border-radius: 999px;
  background: #fff;
  color: #344054;
}

.appbar-user span {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 999px;
  background: #e8f1ff;
  color: var(--wms-primary-dark);
  font-size: 0.72rem;
  font-weight: 800;
}

.appbar-user strong {
  font-size: 0.82rem;
}

.appbar-logout {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--wms-border);
  border-radius: 999px;
  background: #fff;
  color: var(--wms-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.appbar-logout:hover {
  border-color: #f3b5b5;
  color: #b42318;
}

.wms-login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #eef4ff 0%, #f8fafc 45%, #eefdf5 100%);
}

.wms-login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.wms-login-panel {
  width: min(100%, 420px);
  padding: 30px;
  border: 1px solid var(--wms-border);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.12);
}

.wms-login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.wms-login-brand > span {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 8px;
  background: var(--wms-primary);
  color: #fff;
  font-weight: 900;
}

.wms-login-brand strong,
.wms-login-brand small {
  display: block;
}

.wms-login-brand small,
.wms-login-copy {
  color: var(--wms-muted);
}

.wms-login-title {
  margin: 0 0 8px;
  color: var(--wms-text);
  font-size: 1.55rem;
}

.wms-login-copy {
  margin-bottom: 22px;
}

.wms-login-form {
  display: grid;
  gap: 12px;
}

.wms-content {
  padding: 22px 24px 30px;
}

.navbar-brand {
  letter-spacing: 0;
}

.wms-topbar {
  background: var(--wms-surface);
  border-bottom: 1px solid var(--wms-border);
}

.wms-topbar .nav-link {
  color: #2d394a;
  border-radius: 6px;
  padding-inline: 0.7rem;
}

.wms-topbar .nav-link.active,
.wms-topbar .nav-link:hover {
  background: #e8f1ff;
  color: var(--wms-primary-dark);
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--wms-border);
  border-radius: 999px;
  background: #f8fafc;
}

.language-switcher button {
  min-width: 56px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: #445166;
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1;
  padding: 8px 10px;
}

.language-switcher button.active {
  background: var(--wms-primary);
  color: #fff;
}

.wms-mobile-nav {
  position: fixed;
  inset-inline: 0;
  bottom: 0;
  z-index: 1030;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--wms-surface);
  border-top: 1px solid var(--wms-border);
  box-shadow: 0 -8px 24px rgba(23, 32, 51, 0.08);
}

.wms-mobile-nav a {
  display: grid;
  min-height: 58px;
  place-items: center;
  color: #445166;
  font-size: 0.84rem;
  text-decoration: none;
}

.wms-mobile-nav a.active {
  color: var(--wms-primary);
  font-weight: 700;
}

.page-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.page-kicker {
  margin-bottom: 4px;
  color: var(--wms-muted);
  font-size: 0.9rem;
}

.page-title {
  margin: 0;
  font-size: clamp(1.45rem, 2vw, 1.9rem);
  font-weight: 750;
  letter-spacing: 0;
}

.page-subtitle {
  margin: 6px 0 0;
  color: var(--wms-muted);
}

.metric-card,
.table-wrap,
.action-panel,
.page-panel,
.filter-panel,
.form-panel,
.scan-panel,
.flow-card,
.compact-card {
  background: var(--wms-surface);
  border: 1px solid var(--wms-border);
  border-radius: 8px;
  min-height: 100%;
}

.metric-card,
.compact-card,
.flow-card {
  padding: 18px;
}

.table-wrap,
.action-panel,
.page-panel,
.filter-panel,
.form-panel,
.scan-panel {
  padding: 18px;
}

.metric-label {
  display: block;
  color: var(--wms-muted);
  font-size: 0.875rem;
  margin-bottom: 6px;
}

.metric-card strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.2;
}

.metric-card .metric-footnote {
  margin-top: 8px;
  color: var(--wms-muted);
  font-size: 0.82rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 650;
  line-height: 1;
  padding: 6px 10px;
  white-space: nowrap;
}

.status-pill.done,
.status-pill.active,
.status-pill.in {
  background: var(--wms-primary-soft);
  color: var(--wms-primary-dark);
}

.status-pill.pending,
.status-pill.hold,
.status-pill.adjust {
  background: #fff4d7;
  color: var(--wms-warning);
}

.status-pill.out,
.status-pill.danger {
  background: #feeceb;
  color: var(--wms-danger);
}

.status-pill.neutral {
  background: #edf2f7;
  color: #344054;
}

.table > :not(caption) > * > * {
  padding: 0.78rem 0.75rem;
}

.table thead th {
  color: #475467;
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: none;
  white-space: nowrap;
}

.table tbody td {
  vertical-align: middle;
}

.table-fixed-actions {
  min-width: 96px;
}

.placeholder-empty {
  color: var(--wms-muted);
  border: 1px dashed var(--wms-border);
  border-radius: 8px;
  padding: 32px;
  text-align: center;
}

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

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

.module-link {
  display: block;
  padding: 14px;
  border: 1px solid var(--wms-border);
  border-radius: 8px;
  color: var(--wms-text);
  text-decoration: none;
  background: var(--wms-surface);
}

.module-link:hover {
  border-color: #9dc2ff;
  color: var(--wms-primary-dark);
  background: #f6faff;
}

.module-link span {
  display: block;
  color: var(--wms-muted);
  font-size: 0.84rem;
  margin-top: 4px;
}

.form-label {
  color: #344054;
  font-weight: 650;
}

.form-control,
.form-select,
.btn {
  border-radius: 6px;
}

.btn-primary,
.btn-success {
  --bs-btn-bg: var(--wms-primary);
  --bs-btn-border-color: var(--wms-primary);
  --bs-btn-hover-bg: var(--wms-primary-dark);
  --bs-btn-hover-border-color: var(--wms-primary-dark);
  --bs-btn-active-bg: var(--wms-primary-dark);
  --bs-btn-active-border-color: var(--wms-primary-dark);
  --bs-btn-disabled-bg: var(--wms-primary);
  --bs-btn-disabled-border-color: var(--wms-primary);
}

.btn-outline-success {
  --bs-btn-color: var(--wms-primary);
  --bs-btn-border-color: var(--wms-primary);
  --bs-btn-hover-bg: var(--wms-primary);
  --bs-btn-hover-border-color: var(--wms-primary);
  --bs-btn-active-bg: var(--wms-primary-dark);
  --bs-btn-active-border-color: var(--wms-primary-dark);
}

.form-control:focus,
.form-select:focus {
  border-color: var(--wms-primary);
  box-shadow: 0 0 0 0.2rem rgba(31, 111, 235, 0.18);
}

.btn-icon-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.scan-camera {
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--wms-border);
  border-radius: 8px;
  background: #111827;
  color: #fff;
}

.scan-camera video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-result {
  border: 1px solid #b7d3ff;
  border-radius: 8px;
  background: #f4f8ff;
  padding: 14px;
}

.flow-steps {
  display: grid;
  gap: 10px;
}

.flow-step {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--wms-border);
  border-radius: 8px;
  background: var(--wms-surface-soft);
}

.step-number {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: #e8f1ff;
  color: var(--wms-primary-dark);
  font-weight: 800;
}

.delta-positive {
  color: var(--wms-success);
  font-weight: 700;
}

.delta-negative {
  color: var(--wms-danger);
  font-weight: 700;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.toolbar-row .form-control,
.toolbar-row .form-select {
  max-width: 260px;
}

.notice-bar {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border: 1px solid #b7d3ff;
  border-radius: 8px;
  background: #f4f8ff;
  color: #173b76;
}

@media (max-width: 991.98px) {
  body.has-mobile-nav {
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
  }

  .wms-shell {
    grid-template-columns: 1fr;
    grid-template-rows: var(--wms-header-height) minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
  }

  .wms-unified-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .wms-header-brand {
    width: auto;
    min-width: 0;
  }

  .wms-header-toolbar {
    padding: 0 14px;
  }

  .wms-sidebar {
    position: fixed;
    top: var(--wms-header-height);
    left: 0;
    bottom: 0;
    grid-row: auto;
    grid-column: auto;
    width: min(300px, 86vw);
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.18s ease;
    box-shadow: 16px 0 36px rgba(15, 23, 42, 0.12);
  }

  body.sidebar-open .wms-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1015;
    display: block;
    background: rgba(15, 23, 42, 0.34);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
  }

  body.sidebar-open .sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .wms-main {
    grid-row: 2;
    grid-column: 1;
    min-height: 0;
    height: 100%;
    overflow-y: auto;
  }

  .wms-appbar {
    display: none;
  }

  .appbar-menu-button {
    display: grid;
  }

  .appbar-user {
    display: none;
  }

  .wms-content {
    padding: 18px 14px 24px;
  }

  .page-header {
    flex-direction: column;
  }

  .page-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .toolbar-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .toolbar-row .form-control,
  .toolbar-row .form-select {
    max-width: none;
  }
}

@media (max-width: 575.98px) {
  .language-switcher button {
    min-width: 48px;
    padding-inline: 8px;
  }

  .appbar-title span {
    display: none;
  }

  .appbar-title strong {
    max-width: 44vw;
  }

  .table-wrap,
  .action-panel,
  .page-panel,
  .filter-panel,
  .form-panel,
  .scan-panel {
    padding: 16px;
  }

  .metric-card strong {
    font-size: 1.2rem;
  }

  .flow-step {
    grid-template-columns: 30px 1fr;
  }

  .flow-step .status-pill {
    grid-column: 2;
    justify-self: start;
  }
}
