:root {
  color-scheme: light;
  --bg: #eef1f4;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --ink: #17202a;
  --muted: #667085;
  --line: #cfd7df;
  --line-strong: #aeb9c5;
  --nav: #182536;
  --nav-2: #223349;
  --primary: #245b9d;
  --primary-dark: #1a4478;
  --success: #1f7a4d;
  --danger: #b42318;
  --warning: #a15c07;
  --radius: 8px;
  --shadow: 0 14px 34px rgba(23, 32, 42, 0.10);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.55), rgba(255,255,255,0) 240px),
    var(--bg);
  color: var(--ink);
  font-family: "Avenir Next", "Helvetica Neue", "PingFang SC", "Microsoft YaHei", sans-serif;
}

.shell {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

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

h1 {
  font-size: 24px;
  font-weight: 800;
}

h2 {
  font-size: 22px;
  font-weight: 800;
}

h3 {
  font-size: 15px;
  font-weight: 800;
}

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

.login-panel {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  margin: 0;
  display: grid;
  grid-template-columns: minmax(640px, 1fr) clamp(400px, 32vw, 460px);
  overflow: hidden;
  background:
    linear-gradient(120deg, #f8fbff 0%, #eef6ff 48%, #ffffff 100%);
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.login-brand {
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-start;
  padding: clamp(46px, 6vw, 76px) clamp(44px, 6vw, 88px) clamp(34px, 5vw, 58px);
  background:
    linear-gradient(180deg, #ffffff 0%, #eef6ff 62%, #eaf4ff 100%);
  color: var(--ink);
  overflow: hidden;
}

.login-brand::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: url("assets/login-yijiawen-bg-portrait.png");
  background-size: cover;
  background-position: 54% center;
  background-repeat: no-repeat;
}

.login-brand::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(125deg, rgba(255,255,255,0.98) 0%, rgba(255,255,255,0.9) 28%, rgba(255,255,255,0.42) 54%, rgba(255,255,255,0.04) 100%),
    linear-gradient(180deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.08) 48%, rgba(238,246,255,0.18) 100%);
}

.login-brand-copy {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 12px;
  max-width: 560px;
}

.login-brand h1 {
  font-size: clamp(38px, 4vw, 56px);
  letter-spacing: 0;
}

.eyebrow {
  color: var(--primary);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.login-brand p {
  max-width: 420px;
  color: var(--muted);
}

.login-panel .form {
  align-self: center;
  justify-self: center;
  width: min(100% - 64px, 380px);
  margin: 0;
}

.login-card {
  padding: 32px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(23, 32, 42, 0.12);
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid rgba(36,91,157,0.22);
  border-radius: 8px;
  background: var(--primary);
  color: white;
  font-weight: 900;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 22px 18px;
  background: linear-gradient(180deg, var(--nav), #111a25);
  color: white;
}

.sidebar-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 4px 4px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.14);
}

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

.sidebar-brand strong {
  font-size: 17px;
}

.sidebar-brand small {
  margin-top: 3px;
  color: #94a3b8;
  font-size: 12px;
}

.sidebar-note {
  margin-top: auto;
  padding: 12px;
  color: #aab6c5;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.05);
  font-size: 12px;
}

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

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(23, 32, 42, 0.05);
}

.topbar p {
  margin-top: 4px;
}

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

.online-count {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #f7fbf8;
  font-size: 13px;
  white-space: nowrap;
}

.online-count::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
}

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

.tabs button {
  width: 100%;
  justify-content: flex-start;
  background: transparent;
  color: #d8dee7;
  border: 1px solid transparent;
}

.tabs button:hover {
  background: rgba(255,255,255,0.08);
}

.tabs button.active {
  background: #f8fafc;
  color: var(--nav);
  border-color: rgba(255,255,255,0.16);
}

.tab {
  display: none;
}

.tab.active {
  display: block;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 10px 24px rgba(23, 32, 42, 0.06);
}

.section-head,
.modal-head,
.modal-actions,
.row-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-head,
.modal-head {
  justify-content: space-between;
}

.section-head {
  margin-bottom: 16px;
}

.form {
  display: grid;
  gap: 12px;
}

.form.wide {
  max-width: 680px;
}

.inline-form,
.toolbar,
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.toolbar {
  margin: 16px 0;
}

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

.sku-context-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  padding: 14px;
  background: #f4f8fc;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.store-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.store-selector select {
  width: 260px;
  min-width: 260px;
  height: 38px;
}

.list-toolbar {
  justify-content: space-between;
  margin-top: 20px;
}

label,
.form-field {
  display: grid;
  gap: 6px;
}

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

input,
select,
textarea {
  min-height: 38px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: white;
  color: var(--ink);
  font: inherit;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(36,91,157,0.14);
}

.generate-store-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  padding: 2px 0 4px;
  color: var(--muted);
  font-size: 13px;
}

.generate-store-meta strong {
  color: var(--ink);
  font-size: 14px;
}

.generate-store-meta strong.warning {
  color: var(--danger);
}

textarea {
  resize: vertical;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 46px;
}

.text-button,
.text-link {
  min-height: auto;
  padding: 0;
  background: transparent;
  color: var(--primary);
  border: 0;
  font-size: 13px;
  font-weight: 800;
}

.text-button:hover,
.text-link:hover {
  background: transparent;
  color: var(--primary-dark);
}

.password-field .text-button {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  width: 32px;
  height: 32px;
  min-height: 32px;
  padding: 0;
  transform: translateY(-50%);
  color: var(--muted);
  background: transparent;
  border: 0;
}

.password-toggle:hover {
  color: var(--primary);
  background: #eef5fc;
}

.password-toggle svg {
  width: 18px;
  height: 18px;
}

.text-link {
  justify-self: start;
}

.form-error {
  padding: 10px 12px;
  border: 1px solid #f6c5bf;
  border-radius: 6px;
  background: #fff8f7;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.inline-error {
  margin-top: 10px;
}

button,
a.button-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  background: var(--primary);
  color: white;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
a.button-link:hover {
  background: var(--primary-dark);
}

button.ghost {
  background: white;
  color: var(--primary);
  border: 1px solid var(--line);
}

button.ghost:hover {
  background: var(--surface-2);
}

button.success {
  background: var(--success);
}

button.success:hover {
  background: #17603c;
}

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

button.danger:hover {
  background: #8f1d14;
}

button.danger-outline {
  background: #fff8f7;
  color: var(--danger);
  border: 1px solid #f6c5bf;
}

button.danger-outline:hover {
  background: #fee8e5;
}

button.small {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.split {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.split > form,
.panel-soft,
.modal-card,
.result .panel {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.inventory-summary {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.inventory-split {
  grid-template-columns: minmax(320px, 0.72fr) minmax(620px, 1.28fr);
}

.inventory-batch {
  min-width: 0;
}

.inventory-settings-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 8px 0 12px;
}

.batch-toolbar {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(180px, 220px) auto;
  gap: 10px;
  align-items: end;
}

.compact-search {
  min-width: min(420px, 100%);
}

.shipment-group-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px;
  margin-top: 12px;
  padding: 12px;
  background: white;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
}

.group-select-field,
.group-box-field {
  width: 150px;
}

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

.inventory-summary-grid > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.inventory-summary-grid strong {
  font-size: 24px;
}

.inventory-summary-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.inventory-status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 900;
}

.inventory-status.low {
  color: var(--danger);
  background: #fff8f7;
  border-color: #f6c5bf;
}

.inventory-status.high {
  color: var(--warning);
  background: #fff8ec;
  border-color: #f3d19b;
}

.inventory-status.normal {
  color: #17603c;
  background: #e8f6ee;
  border-color: #a9ddbf;
}

.inventory-alert-form input {
  width: 92px;
  min-height: 30px;
  padding: 4px 8px;
}

.inventory-setting-input {
  min-width: 110px;
  min-height: 30px;
  padding: 4px 8px;
}

.inventory-setting-input.numeric {
  width: 92px;
  min-width: 92px;
}

.inventory-row-check {
  width: 16px;
  min-height: 16px;
  height: 16px;
}

.inventory-row-quantity {
  width: 96px;
  min-height: 30px;
  padding: 4px 8px;
}

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

.import-template-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  color: var(--muted);
  background: #ffffff;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  font-size: 12px;
}

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

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

.muted-text {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.field-note {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
}

.warning-text {
  padding: 10px 12px;
  color: var(--danger);
  background: #fff8f7;
  border: 1px solid #f6c5bf;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
}

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

.list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.store-summary,
.store-action {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.store-summary {
  flex-wrap: wrap;
}

.store-state-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.store-state-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.store-action {
  flex: 0 0 auto;
}

.table-wrap {
  overflow: auto;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: white;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf1f5;
  color: #344054;
  font-size: 12px;
  font-weight: 900;
}

tr:hover td {
  background: #fbfcfd;
}

td.wrap {
  min-width: 280px;
  white-space: normal;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 800;
}

.status-badge.active {
  color: #17603c;
  background: #e8f6ee;
  border-color: #a9ddbf;
}

.status-badge.inactive {
  color: #5d6673;
  background: #f1f3f5;
  border-color: #d7dde3;
}

.search-group,
.download-links,
.pager-actions,
.pager-left,
.page-size-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-group {
  min-width: min(520px, 100%);
}

.search-group input {
  flex: 1;
}

.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 13px;
}

.pager-left {
  flex-wrap: wrap;
}

.page-size-control select {
  min-height: 32px;
  padding: 4px 8px;
}

a {
  color: var(--primary);
  font-weight: 800;
  text-decoration: none;
}

.file-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.file-chip.source {
  color: #344054;
  background: #f8fafc;
}

.file-chip.declaration {
  color: var(--primary-dark);
  background: #edf5ff;
  border-color: #b8d2f0;
}

.file-chip.logistics {
  color: #17603c;
  background: #f0faf4;
  border-color: #b7e4c7;
}

.file-chip:hover {
  filter: brightness(0.98);
}

.checkbox-list {
  display: grid;
  gap: 8px;
  max-height: 180px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: white;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-size: 14px;
}

.checkbox-row input {
  min-height: auto;
  width: 16px;
  height: 16px;
  padding: 0;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 25, 35, 0.48);
}

.modal-card {
  width: min(740px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  background: white;
  box-shadow: 0 22px 60px rgba(16, 25, 35, 0.24);
}

.modal-actions {
  justify-content: flex-end;
}

.row-actions {
  flex-wrap: nowrap;
}

.result {
  margin-top: 16px;
}

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

.monthly-report-form .grid2 {
  align-items: end;
}

.monthly-values {
  margin-top: 14px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 520px;
  padding: 12px 14px;
  border-radius: 8px;
  background: var(--nav);
  color: white;
  box-shadow: 0 16px 38px rgba(16, 25, 35, 0.24);
}

.toast.error {
  background: var(--danger);
}

.error {
  color: var(--danger);
}

@media (prefers-reduced-motion: no-preference) {
  button,
  a,
  input,
  select,
  textarea {
    transition: background-color 140ms ease, border-color 140ms ease, box-shadow 140ms ease, filter 140ms ease;
  }
}

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

  .login-brand {
    min-height: 48vh;
    min-height: 48svh;
  }

  .login-brand::before {
    background-position: center bottom;
  }

  .login-panel .form {
    width: min(100% - 56px, 420px);
    margin: 0 0 32px;
  }

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

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

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

@media (max-width: 720px) {
  .login-panel,
  .split,
  .inventory-alert-lists,
  .batch-toolbar,
  .grid2,
  .list-toolbar,
  .search-group,
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  .login-brand {
    padding: 28px;
  }

  .login-brand h1 {
    font-size: 30px;
  }

  .login-panel .form {
    width: calc(100% - 28px);
    margin: 0 0 14px;
  }

  .workspace {
    padding: 14px;
  }

  .panel {
    padding: 16px;
  }

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

  .pager {
    display: grid;
  }
}
