:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --green: #248a3d;
  --green-soft: #e8f7ed;
  --amber: #bf6a02;
  --amber-soft: #fff4df;
  --red: #d70015;
  --red-soft: #fff1f2;
  --blue: #0071e3;
  --blue-soft: #eaf4ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(0, 113, 227, 0.08), transparent 28%),
    radial-gradient(circle at 90% 12%, rgba(52, 199, 89, 0.08), transparent 24%),
    var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

.login-card {
  display: grid;
  width: min(420px, 100%);
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.login-brand {
  margin-bottom: 4px;
}

.login-card h1 {
  margin: 0;
  font-size: 28px;
}

.login-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.login-card input {
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline-color: var(--blue);
}

.login-error {
  min-height: 20px;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}

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

.sidebar {
  padding: 24px 18px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.68);
  border-right: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
}

.brand-wrap {
  position: relative;
  margin-bottom: 28px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 0;
  border: 0;
  color: var(--ink);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  color: #ffffff;
  background: linear-gradient(145deg, #007aff, #5ac8fa);
  font-weight: 800;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.brand-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 20;
  min-width: 150px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.brand-menu button {
  width: 100%;
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  color: #ff3b30;
  background: transparent;
  text-align: left;
  font-weight: 700;
}

.brand-menu button:hover {
  background: rgba(255, 59, 48, 0.08);
}

.nav {
  display: grid;
  gap: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  text-align: left;
}

.nav-item:hover,
.nav-item.active {
  color: var(--ink);
  background: rgba(0, 113, 227, 0.1);
}

.nav-group {
  display: grid;
  gap: 6px;
}

.nav-submenu {
  display: grid;
  gap: 4px;
  margin: -2px 0 4px 34px;
}

.nav-subitem {
  min-height: 30px;
  padding: 5px 10px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
  text-align: left;
  font-size: 13px;
}

.nav-subitem:hover,
.nav-subitem.active {
  color: var(--blue);
  background: rgba(0, 113, 227, 0.08);
}

.icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: var(--blue);
  font-weight: 700;
}

.workspace {
  min-width: 0;
  padding: 30px;
}

.topbar,
.section-toolbar,
.panel-head,
.dialog-head,
.button-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

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

.toolbar-control > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.topbar {
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 6px;
  font-size: 19px;
}

h3 {
  margin-bottom: 8px;
  font-size: 16px;
}

p {
  color: var(--muted);
  line-height: 1.55;
}

.top-actions,
.button-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: min(360px, 42vw);
  height: 42px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.search-box input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn,
.file-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.primary-btn {
  color: #ffffff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(0, 113, 227, 0.22);
}

.secondary-btn {
  color: var(--ink);
  background: var(--surface);
  border-color: var(--line);
}

.ghost-btn {
  color: var(--blue);
  background: transparent;
  border-color: var(--line);
}

.icon-btn {
  width: 38px;
  padding: 0;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.metrics-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  margin-bottom: 8px;
}

.metric,
.panel,
.product-focus,
.table-wrap,
.supplier-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.metric {
  padding: 18px;
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 28px;
}

.metric small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
}

.split-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
}

.panel,
.product-focus {
  padding: 18px;
}

.action-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.action-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.status-pill,
.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.tag-button {
  border: 0;
  cursor: pointer;
}

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

.warning {
  color: var(--amber);
  background: var(--amber-soft);
}

.ok {
  color: var(--green);
  background: var(--green-soft);
}

.info {
  color: var(--blue);
  background: var(--blue-soft);
}

.product-hero {
  overflow: hidden;
  margin: -18px -18px 16px;
  aspect-ratio: 16 / 9;
  border-radius: 16px 16px 0 0;
  background: #eef2f0;
}

.product-hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
}

.focus-list {
  display: grid;
  gap: 12px;
}

.focus-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 6px 12px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
}

.focus-item + .focus-item {
  padding-top: 12px;
}

.focus-list .product-hero {
  grid-row: 1 / 5;
  width: 72px;
  height: 72px;
  margin: 0;
  aspect-ratio: auto;
  border-radius: 14px;
}

.focus-item h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.25;
}

.focus-item > p {
  margin: 0;
}

.focus-item .eyebrow {
  margin: 0;
}

.focus-item .focus-stats {
  grid-column: 2;
  margin-top: 4px;
}

.focus-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.focus-stats div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.focus-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.focus-stats strong {
  display: block;
  margin-top: 6px;
}

.section-toolbar {
  margin-bottom: 14px;
}

.section-toolbar p {
  margin-bottom: 0;
}

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
}

.segmented button {
  min-height: 32px;
  padding: 0 12px;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
  background: transparent;
}

.segmented .selected {
  color: var(--ink);
  background: rgba(0, 113, 227, 0.1);
}

.table-wrap {
  overflow: auto;
}

.inventory-table-wrap,
.packing-table-wrap,
.daily-report-table-wrap {
  max-height: calc(100vh - 230px);
  min-height: 320px;
  border-radius: 18px;
}

.sticky-table-wrap thead th,
.inventory-table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: inset 0 -1px 0 var(--line);
}

.packing-table-wrap {
  max-height: calc(100vh - 310px);
}

.daily-report-table-wrap {
  max-height: calc(100vh - 360px);
}

.hidden {
  display: none !important;
}

.records-panel {
  margin-top: 18px;
}

.packing-panel,
.inbound-panel,
.adjustment-panel,
.daily-report-panel {
  display: grid;
  gap: 14px;
}

.packing-reason,
.adjustment-form,
.filter-panel {
  display: grid;
  gap: 7px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.adjustment-form {
  grid-template-columns: repeat(4, minmax(140px, 1fr)) auto;
  align-items: end;
}

.filter-panel {
  grid-template-columns: minmax(220px, 2fr) repeat(5, minmax(130px, 1fr)) auto;
  align-items: end;
  margin-bottom: 14px;
}

.adjustment-form label,
.filter-panel label {
  display: grid;
  gap: 7px;
}

.adjustment-form .full {
  grid-column: span 2;
}

.packing-reason span,
.adjustment-form span,
.filter-panel span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.packing-reason input,
.packing-qty,
.inbound-qty,
.adjustment-form input,
.adjustment-form select,
.filter-panel input,
.filter-panel select {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline-color: var(--blue);
}

.packing-qty,
.inbound-qty {
  width: 120px;
}

.date-filter {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-filter input {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

.exchange-rate-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.exchange-rate-control span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.exchange-rate-control input {
  width: 120px;
}

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

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

th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.sku-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
}

.sku-thumb {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  background: #eef2f0;
}

img.sku-thumb {
  cursor: zoom-in;
}

.sku-cell strong,
.sku-cell span {
  display: block;
}

.sku-cell span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.split-cell {
  min-width: 120px;
}

.split-cell small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  white-space: nowrap;
}

.date-ok {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 12px;
  font-weight: 700;
}

.paid-received-sku {
  color: var(--green);
  font-weight: 800;
}

.tiny-btn {
  min-height: 30px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface-solid);
}

.danger-btn {
  color: var(--red);
  border-color: #f0c4c4;
  background: var(--red-soft);
}

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

.supplier-card {
  padding: 16px;
}

.supplier-meta {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  color: var(--muted);
  font-size: 14px;
}

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

.file-btn {
  position: relative;
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.rule-box {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 14px;
  background: var(--blue-soft);
}

.user-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}

.user-form label {
  display: grid;
  gap: 7px;
}

.user-form span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.user-form input,
.user-form select {
  height: 40px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline-color: var(--blue);
}

dialog {
  width: min(720px, calc(100vw - 28px));
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.22);
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.dialog-card {
  padding: 20px;
}

.warning-card {
  background: #fff9e8;
}

.warning-message {
  margin: 14px 0;
  padding: 12px 14px;
  border: 1px solid rgba(191, 106, 2, 0.22);
  border-radius: 14px;
  color: var(--amber);
  background: var(--amber-soft);
  font-weight: 700;
}

.warning-dialog textarea {
  min-height: 140px;
  font-size: 16px;
}

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

.field {
  display: grid;
  gap: 7px;
}

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

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  outline-color: var(--blue);
}

.field input,
.field select {
  height: 40px;
}

.field textarea {
  min-height: 180px;
  padding: 10px;
  resize: vertical;
  line-height: 1.5;
}

.image-upload-field {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--blue);
  background: var(--surface);
  cursor: pointer;
}

.file-input {
  display: none;
}

.image-preview {
  width: 96px;
  height: 96px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-strong);
}

.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.field small {
  color: var(--muted);
  line-height: 1.5;
}

.batch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.batch-table {
  display: grid;
  gap: 8px;
}

.batch-row {
  display: grid;
  grid-template-columns: minmax(180px, 2fr) minmax(90px, 1fr) minmax(100px, 1fr) minmax(110px, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.batch-row-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.batch-row input,
.batch-row select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin: 18px 0 0;
  padding: 0;
}

.dialog-actions-spacer {
  flex: 1;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  transform: translateY(18px);
  opacity: 0;
  padding: 12px 14px;
  border-radius: 14px;
  color: #ffffff;
  background: rgba(29, 29, 31, 0.9);
  box-shadow: var(--shadow);
  transition: 0.2s ease;
  pointer-events: none;
}

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

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
  background: rgba(20, 20, 22, 0.72);
  backdrop-filter: blur(12px);
}

.image-lightbox img {
  max-width: min(92vw, 1080px);
  max-height: 86vh;
  border-radius: 18px;
  object-fit: contain;
  background: #fff;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

.lightbox-close {
  position: fixed;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(255, 255, 255, 0.18);
  font-size: 24px;
  cursor: pointer;
}

@media (max-width: 1080px) {
  .app-shell {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .metrics-grid,
  .supplier-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .split-layout,
  .data-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    overflow-x: auto;
  }

  .brand-wrap {
    margin: 0;
  }

  .brand-menu {
    top: calc(100% + 10px);
    left: 0;
  }

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

  .nav-group {
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .nav-submenu {
    display: flex;
    margin: 0;
  }

  .nav-item {
    width: 44px;
    padding: 0;
    justify-content: center;
  }

  .brand div:last-child,
  .nav-item span:last-child {
    display: none;
  }

  .workspace {
    padding: 18px 14px 26px;
  }

  .topbar,
  .section-toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions,
  .search-box {
    width: 100%;
    min-width: 0;
  }

  .top-actions .primary-btn,
  .section-toolbar .secondary-btn {
    width: 100%;
  }

  .date-filter,
  .date-filter input {
    width: 100%;
  }

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

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

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

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

  .batch-row-head {
    display: none;
  }

  .adjustment-form .full {
    grid-column: auto;
  }

  h1 {
    font-size: 25px;
  }

  .metrics-grid,
  .supplier-grid,
  .form-grid,
  .focus-stats {
    grid-template-columns: 1fr;
  }
}
