:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d9dee7;
  --panel: #ffffff;
  --page: #f5f6f8;
  --teal: #276fae;
  --teal-dark: #164f82;
  --red: #c0352b;
  --blue: #276fae;
  --black: #101114;
  --shadow: 0 14px 34px rgba(16, 17, 20, 0.07);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

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

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #eef1f5;
}

.login-card {
  width: min(430px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.login-logo {
  width: 190px;
  max-width: 76%;
  height: auto;
  display: block;
  margin: 0 auto 14px;
  border-radius: 4px;
}

.brand-logo {
  width: 176px;
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

.login-card h1,
.login-card p {
  margin: 12px 0;
}

.login-card p {
  color: var(--muted);
}

.demo-accounts {
  display: grid;
  gap: 5px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 13px;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  color: #f8fafc;
  background: var(--black);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  text-align: center;
  padding: 2px 0 6px;
}

.brand h1,
.brand p,
.toolbar h2,
.toolbar p,
.panel h3,
.form-head h3,
.form-head p {
  margin: 0;
}

.brand h1 {
  width: 176px;
  max-width: 100%;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0;
}

.brand p,
.user-card span {
  color: #b9c0ca;
  font-size: 13px;
  margin-top: 3px;
}

.user-card {
  display: grid;
  gap: 4px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px;
}

.nav-tabs {
  display: grid;
  gap: 10px;
}

.nav-tab,
.ghost {
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e8edf3;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
  font-weight: 700;
}

.nav-tab.active,
.nav-tab:hover {
  background: #f8fafc;
  color: var(--black);
}

.ghost {
  text-align: center;
}

.sync-panel {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #d7dde5;
  font-size: 14px;
}

.pulse {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--blue);
  box-shadow: 0 0 0 6px rgba(39, 111, 174, 0.16);
}

.content {
  padding: 26px;
  min-width: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}

.eyebrow {
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.toolbar h2 {
  font-size: 28px;
  margin-top: 3px;
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search-box,
.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  padding: 8px 10px;
}

.search-box span,
.toggle span {
  color: var(--muted);
  font-size: 13px;
}

.search-box input {
  width: 260px;
  border: 0;
  outline: 0;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.stat strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 0.8fr);
  gap: 16px;
  margin-bottom: 16px;
}

.panel,
.form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel {
  padding: 18px;
}

.inventory-panel,
.inventory-entry-panel,
.import-panel {
  margin-bottom: 16px;
}

.panel-head,
.form-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 16px;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.compact-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}

.compact-select select {
  width: 76px;
  height: 34px;
}

.panel-head h3,
.form-head h3 {
  font-size: 18px;
}

.panel-head span,
.form-head p {
  color: var(--muted);
  font-size: 13px;
}

.bar-chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(90px, 150px) minmax(0, 1fr) 70px;
  align-items: center;
  gap: 12px;
  min-height: 28px;
}

.bar-label,
.bar-value {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label {
  font-weight: 700;
}

.bar-track {
  height: 12px;
  border-radius: 999px;
  background: #edf2f2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #111827, #276fae);
}

.bar-value {
  text-align: right;
  color: var(--muted);
}

.warning-list,
.movement-list,
.pending-list,
.user-list {
  display: grid;
  gap: 10px;
  max-height: 430px;
  overflow: auto;
}

.movement-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.movement-tools .search-box {
  flex: 1;
  max-width: 560px;
}

.movement-tools .search-box input {
  width: 100%;
}

.movement-tools > span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.warning-item,
.movement-item,
.pending-item,
.selected-product,
.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfc;
}

.warning-item strong,
.movement-item strong,
.pending-item strong {
  display: block;
}

.warning-item span,
.movement-item span,
.pending-item span,
.user-row span {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  overflow: auto;
  max-height: 52vh;
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

th,
td {
  padding: 11px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef1f5;
  font-size: 13px;
}

.sort-button {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  text-align: left;
  padding: 0;
}

.sort-button.active {
  color: var(--blue);
}

td {
  font-size: 14px;
}

.qty {
  font-weight: 800;
}

.low {
  color: var(--red);
}

tr.low-stock {
  background: #fff7ed;
}

.stock-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 800;
}

.stock-status.warn {
  color: var(--red);
  background: #fee4df;
}

.stock-status.ok {
  color: var(--teal-dark);
  background: #d7f5ea;
}

.stock-status.off {
  color: var(--muted);
  background: #edf2f2;
}

.warning-edit {
  display: grid;
  grid-template-columns: 78px 56px 56px;
  gap: 6px;
  align-items: center;
}

.warning-edit input {
  width: 100%;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
}

.form-panel {
  padding: 22px;
  max-width: 980px;
}

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

.entry-mode {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f4f7f6;
}

.entry-mode label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--ink);
  cursor: pointer;
}

.entry-mode input {
  margin: 0;
}

.inbound-detail-grid {
  margin-top: 16px;
}

label {
  color: var(--muted);
  font-size: 13px;
}

label input,
select,
textarea,
.inline-form input,
.inline-form select,
.movement-edit input,
.user-row input,
.user-row select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: 0;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 150px;
  padding: 10px 12px;
  resize: vertical;
}

label input {
  margin-top: 6px;
}

label select {
  margin-top: 6px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.required-field,
.required-input {
  color: var(--teal-dark);
  font-weight: 800;
}

.required-field input,
.required-input {
  border-color: #9fd3c8;
  background: #fbfffd;
}

.full,
.full-width {
  width: 100%;
}

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

.primary,
.danger,
.secondary {
  height: 42px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  padding: 0 16px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  background: var(--teal);
}

.primary:hover {
  background: var(--teal-dark);
}

.danger {
  background: var(--red);
}

.danger:hover {
  background: #912018;
}

.secondary {
  color: var(--teal-dark);
  border: 1px solid #9fd3c8;
  background: #e7f7f3;
}

.compact {
  height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.form-panel .primary,
.form-panel .danger {
  margin-top: 18px;
}

.selected-product {
  margin-top: 14px;
  color: var(--muted);
}

.duplicate-panel {
  display: grid;
  gap: 8px;
  margin-top: 14px;
  border: 1px solid #fed7aa;
  border-radius: 8px;
  background: #fff7ed;
  padding: 12px;
}

.duplicate-choice {
  width: 100%;
  text-align: left;
}

.movement-item {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.movement-main {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.movement-edit {
  display: grid;
  grid-template-columns: 0.9fr 0.8fr 1.3fr;
  gap: 8px;
}

.movement-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.badge {
  width: 54px;
  border-radius: 999px;
  padding: 5px 8px;
  text-align: center;
  font-weight: 800;
  font-size: 12px;
}

.badge.in {
  color: var(--teal-dark);
  background: #d7f5ea;
}

.badge.out {
  color: var(--red);
  background: #fee4df;
}

.inline-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 120px;
  gap: 10px;
  margin-bottom: 16px;
}

.user-row {
  display: grid;
  grid-template-columns: 1.1fr 1fr 150px 1fr 90px 88px 104px;
  gap: 10px;
  align-items: center;
}

.row-check {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.row-check input {
  width: auto;
  height: auto;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 240px;
  max-width: 420px;
  transform: translateY(90px);
  opacity: 0;
  transition: 160ms ease;
  border-radius: 8px;
  background: #17343b;
  color: #fff;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  z-index: 20;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@media (max-width: 1120px) {
  .stats-grid,
  .dashboard-grid,
  .form-grid,
  .inline-form,
  .user-row {
    grid-template-columns: 1fr;
  }
}

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

  .sidebar {
    position: static;
    height: auto;
  }

  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .search-box input {
    width: 100%;
  }

  .movement-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .movement-tools .search-box {
    max-width: none;
  }

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

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

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