:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --line: #dce3eb;
  --line-strong: #bcc8d6;
  --text: #1d2733;
  --muted: #687386;
  --brand: #0f766e;
  --brand-dark: #0b5f59;
  --blue: #2563eb;
  --amber: #b7791f;
  --red: #b42318;
  --green-soft: #e7f6f2;
  --blue-soft: #edf3ff;
  --amber-soft: #fff7df;
  --red-soft: #fff0ed;
  --shadow: 0 12px 32px rgba(16, 24, 40, 0.08);
  --sidebar: 236px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  overflow-x: hidden;
}

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

button {
  border: 0;
  cursor: pointer;
}

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

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

textarea {
  resize: vertical;
}

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

label {
  display: grid;
  gap: 6px;
  color: #344054;
  font-weight: 700;
}

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

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

th {
  background: #f8fafc;
  color: #475467;
  font-size: 13px;
  font-weight: 800;
}

td {
  color: #243041;
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.88), rgba(244, 246, 248, 0.95)),
    repeating-linear-gradient(
      90deg,
      rgba(15, 118, 110, 0.08) 0,
      rgba(15, 118, 110, 0.08) 1px,
      transparent 1px,
      transparent 36px
    );
}

.login-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  gap: 10px;
  margin-bottom: 22px;
}

.login-logo {
  display: block;
  width: min(260px, 100%);
  height: auto;
}

.brand-mark {
  display: inline-grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-size: 18px;
  font-weight: 900;
}

.login-brand strong,
.sidebar-brand strong {
  display: block;
  font-size: 20px;
  line-height: 1.2;
}

.login-brand span,
.sidebar-brand small {
  color: var(--muted);
  font-size: 12px;
}

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

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

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

.app-shell {
  min-height: 100vh;
  padding-bottom: 56px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 18px 12px;
  background: #111b26;
  color: #fff;
  z-index: 30;
}

.sidebar-brand {
  display: grid;
  justify-items: center;
  gap: 8px;
  padding: 0 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  text-align: center;
}

.sidebar-logo {
  display: block;
  width: min(174px, 100%);
  height: auto;
}

.sidebar-brand strong {
  color: #fff;
  font-size: 20px;
  font-weight: 900;
}

.nav-list {
  display: grid;
  gap: 5px;
  margin-top: 18px;
}

.nav-item {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 6px;
  background: transparent;
  color: #b9c5d3;
  text-align: left;
  font-weight: 800;
  white-space: nowrap;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
}

.nav-item.active {
  background: var(--green-soft);
  color: var(--brand-dark);
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-left: var(--sidebar);
  padding: 10px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.page-title {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.page-title strong {
  overflow: hidden;
  color: #111827;
  font-size: 18px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-title span {
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.mode-pill,
.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.user-chip {
  display: grid;
  min-width: 92px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.user-chip span {
  overflow: hidden;
  color: #111827;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip small {
  color: var(--muted);
  font-size: 12px;
}

.data-menu {
  position: relative;
}

.data-menu summary {
  display: inline-flex;
  min-height: 36px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 800;
  cursor: pointer;
  list-style: none;
}

.data-menu summary::-webkit-details-marker {
  display: none;
}

.data-menu[open] summary {
  border-color: #7fd0c9;
  background: var(--green-soft);
  color: var(--brand-dark);
}

.data-menu > div {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 208px;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.data-menu > div > small {
  padding: 0 3px 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.content {
  margin-left: var(--sidebar);
  padding: 22px 24px 36px;
}

.mobile-nav {
  display: none;
}

.view {
  display: none;
}

.view.active {
  display: grid;
  gap: 16px;
}

.view-actions,
.panel-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.view-actions {
  margin-bottom: -4px;
}

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

.metric {
  display: grid;
  gap: 4px;
  min-height: 104px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.metric span {
  color: var(--muted);
  font-weight: 800;
}

.metric strong {
  color: #111827;
  font-size: 30px;
  line-height: 1.15;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

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

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
  gap: 16px;
}

.panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

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

.panel-head h2 {
  margin: 0;
  color: #111827;
  font-size: 17px;
  font-weight: 900;
}

.inventory-heading {
  display: grid;
  flex: 0 0 auto;
  gap: 5px;
}

.inventory-as-of {
  display: inline-flex;
  width: fit-content;
  min-height: 26px;
  align-items: center;
  padding: 3px 9px;
  border: 1px solid #b9ddd9;
  border-radius: 999px;
  background: #f5fbfa;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

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

.inline-controls {
  display: flex;
  flex: 1 1 auto;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.inline-controls input,
.inline-controls select {
  width: auto;
  min-width: 150px;
}

.inline-controls input[type="search"] {
  min-width: 260px;
}

.history-head {
  align-items: center;
}

.history-filters {
  flex-wrap: wrap;
}

.excel-export-bar {
  display: grid;
  grid-template-columns: minmax(250px, 0.7fr) minmax(520px, 1.3fr);
  gap: 10px;
  margin: -2px 0 14px;
  padding: 12px;
  border: 1px solid #b9ddd9;
  border-radius: 8px;
  background: #f5fbfa;
}

.export-group {
  display: flex;
  min-width: 0;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.export-group strong {
  flex: 0 0 100%;
  color: var(--brand-dark);
  font-size: 14px;
}

.export-group label {
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.export-group label input {
  width: 166px;
}

.range-separator {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.range-export-group {
  padding-left: 10px;
  border-left: 1px solid #cce5e2;
}

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

.span-2 {
  grid-column: 1 / -1;
}

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

.primary,
.secondary,
.ghost,
.danger {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  padding: 0 13px;
  border-radius: 6px;
  font-weight: 900;
  white-space: nowrap;
}

.primary {
  background: var(--brand);
  color: #fff;
}

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

.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: #344054;
}

.secondary:hover {
  border-color: var(--line-strong);
  background: #f8fafc;
}

.ghost {
  background: transparent;
  color: #344054;
}

.ghost:hover {
  background: #edf2f7;
}

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

.danger:hover {
  background: #ffe2dd;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

.full {
  width: 100%;
}

.file-btn {
  position: relative;
  overflow: hidden;
}

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

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.table-wrap.compact table {
  min-width: 620px;
}

.empty-row td,
.empty-state {
  color: var(--muted);
  text-align: center;
}

.badge {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  justify-content: center;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-soft);
  color: #475467;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.badge.in {
  background: var(--green-soft);
  color: var(--brand-dark);
}

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

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

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

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.product-cell {
  display: grid;
  gap: 2px;
}

.product-cell strong {
  color: #111827;
}

.product-cell small {
  color: var(--muted);
}

.product-combobox {
  position: relative;
  width: 100%;
}

.product-combobox::after {
  position: absolute;
  top: 14px;
  right: 13px;
  width: 8px;
  height: 8px;
  border-right: 2px solid #667085;
  border-bottom: 2px solid #667085;
  content: "";
  pointer-events: none;
  transform: rotate(45deg);
}

.product-combobox input[type="search"] {
  padding-right: 34px;
}

.product-select-source {
  position: absolute;
  width: 1px;
  min-height: 0;
  height: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

.product-combobox-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  z-index: 70;
  display: grid;
  max-height: 260px;
  gap: 3px;
  overflow-y: auto;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.product-combobox-option {
  display: grid;
  width: 100%;
  min-height: 44px;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  text-align: left;
}

.product-combobox-option:hover,
.product-combobox-option.active {
  background: var(--green-soft);
  color: var(--brand-dark);
}

.product-combobox-option strong {
  overflow: hidden;
  font-size: 14px;
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-combobox-option small,
.product-combobox-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.product-combobox-option small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-combobox-empty {
  padding: 9px 10px;
}

.stock-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.stock-preview span {
  color: var(--muted);
}

.stock-preview strong {
  color: #111827;
  font-variant-numeric: tabular-nums;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.timeline-item strong {
  overflow: hidden;
  color: #111827;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item small {
  color: var(--muted);
}

.role-note {
  margin: -4px 0 12px;
  color: var(--muted);
}

.history-editor {
  border-color: #96d9d3;
  background: #fbfffe;
}

.check-line {
  display: flex;
  min-height: 38px;
  align-items: center;
  gap: 8px;
  align-self: end;
}

.check-line input {
  width: 18px;
  min-height: 18px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 80;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  pointer-events: none;
}

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

.support-footer {
  position: fixed;
  right: 0;
  bottom: 10px;
  left: var(--sidebar);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #1d2733;
  font-size: 16px;
  font-weight: 900;
  pointer-events: none;
}

.support-logo {
  display: block;
  width: 92px;
  height: auto;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1100px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .excel-export-bar {
    grid-template-columns: 1fr;
  }

  .range-export-group {
    padding-top: 10px;
    padding-left: 0;
    border-top: 1px solid #cce5e2;
    border-left: 0;
  }
}

@media (max-width: 820px) {
  body {
    background: #fff;
  }

  .sidebar {
    display: none;
  }

  .app-header {
    position: static;
    flex-direction: column;
    align-items: stretch;
    margin-left: 0;
    padding: 12px;
  }

  .header-actions {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .user-chip {
    min-width: 112px;
  }

  .mobile-nav {
    position: sticky;
    top: 0;
    z-index: 18;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 12px;
    border-bottom: 1px solid var(--line);
    background: #fff;
  }

  .mobile-nav .nav-item {
    flex: 0 0 auto;
    min-height: 36px;
    background: #f2f4f7;
    color: #344054;
    text-align: center;
  }

  .mobile-nav .nav-item.active {
    background: var(--green-soft);
    color: var(--brand-dark);
  }

  .content {
    margin-left: 0;
    padding: 12px 12px 56px;
  }

  .support-footer {
    left: 0;
    bottom: 8px;
  }

  .summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .metric {
    min-height: 92px;
    padding: 12px;
  }

  .metric strong {
    font-size: 24px;
  }

  .panel {
    padding: 12px;
    border-right: 0;
    border-left: 0;
    border-radius: 0;
    box-shadow: none;
  }

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

  .inline-controls {
    justify-content: flex-start;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  .inline-controls input,
  .inline-controls select {
    flex: 0 0 176px;
  }

  .inline-controls input[type="search"] {
    flex-basis: 240px;
    min-width: 240px;
  }

  .range-separator {
    flex: 0 0 auto;
  }

  .excel-export-bar {
    padding: 10px;
  }

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

  .span-2 {
    grid-column: auto;
  }

  .stock-preview {
    align-items: flex-start;
    flex-direction: column;
  }

  .data-menu > div {
    right: auto;
    left: 0;
  }
}

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

  .login-card {
    padding: 20px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }
}
