:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --line: #d9dee5;
  --text: #17202a;
  --muted: #657282;
  --accent: #0f766e;
  --accent-2: #b45309;
  --soft: #e8f3f1;
  --shadow: 0 14px 28px rgba(23, 32, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

.app {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 0 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0;
}

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

#periodText {
  margin: 8px 0 0;
}

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

.logout-form {
  margin: 0;
}

.icon-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
}

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

.login-shell {
  width: min(420px, 100%);
}

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

.login-panel h1 {
  margin-bottom: 10px;
}

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

.login-error {
  margin: 16px 0 0;
}

.login-submit {
  width: 100%;
  justify-content: center;
}

.status {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #f1c27d;
  border-radius: 8px;
  background: #fff7ed;
  color: #7c2d12;
}

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

.metric {
  min-height: 96px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

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

.metric strong {
  display: block;
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  margin: 6px 0 14px;
  overflow-x: auto;
}

.tab {
  min-width: 92px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.tab.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

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

input[type="search"] {
  width: min(420px, 100%);
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: var(--panel);
  color: var(--text);
  font-size: 14px;
}

.option-button {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 14px;
  background: var(--panel);
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.option-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.currency-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.currency-button {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
}

.currency-button.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
  font-weight: 800;
}

.currency-controls small {
  margin-left: 4px;
  color: var(--muted);
}

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

.table-wrap {
  width: 100%;
  overflow: auto;
  max-height: calc(100vh - 320px);
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f9fafb;
  color: #334155;
  font-size: 12px;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.sort-button span {
  min-width: 12px;
  color: var(--muted);
  font-size: 11px;
}

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

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

td.wrap {
  min-width: 260px;
  max-width: 420px;
  white-space: normal;
}

.thumb-cell {
  width: 72px;
  min-width: 72px;
}

.product-thumb,
.thumb-placeholder {
  display: block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f9;
}

.product-thumb {
  object-fit: cover;
}

.product-thumb.large,
.thumb-placeholder.large {
  width: 64px;
  height: 64px;
  line-height: 62px;
}

.thumb-placeholder {
  color: var(--muted);
  font-size: 12px;
  line-height: 46px;
  text-align: center;
}

.subtext {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  white-space: normal;
}

.warehouse-table {
  min-width: 1260px;
}

.warehouse-subnav {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 6px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.subtab {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fbfcfd;
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.subtab.active {
  border-color: var(--accent);
  background: var(--soft);
  color: var(--accent);
}

.ads-subnav {
  align-items: center;
}

.subnav-note {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.ads-table {
  min-width: 1380px;
}

.ads-detail-table {
  min-width: 1580px;
}

.money-dual {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font-weight: 800;
  line-height: 1.2;
}

.money-dual small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.service-provider-layout {
  display: grid;
  gap: 14px;
  min-width: 980px;
  padding: 14px;
}

.service-provider-form {
  display: block;
}

.service-provider-editor {
  background: #fbfcfd;
}

.service-provider-table {
  min-width: 980px;
}

.selected-row {
  background: #eef8f7;
}

.checkbox-field {
  display: flex;
  align-items: center;
  grid-template-columns: unset;
  gap: 8px;
  margin-top: 12px;
}

.checkbox-field input {
  width: auto;
  min-height: unset;
}

.provider-preview {
  margin-top: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.ok {
  border-color: #b7d8d4;
  background: #eef8f7;
  color: #0f766e;
}

.status-pill.warn {
  border-color: #f1c27d;
  background: #fff7ed;
  color: #b45309;
}

.status-pill.missing {
  border-color: #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.empty {
  padding: 36px;
  color: var(--muted);
  text-align: center;
}

.order-list {
  display: grid;
  gap: 0;
  min-width: 1180px;
}

.order-card {
  display: grid;
  grid-template-columns: 84px 56px minmax(300px, 1fr) 64px 150px 150px 92px;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.order-status {
  width: fit-content;
  border-radius: 6px;
  padding: 4px 8px;
  background: var(--soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.order-thumb {
  display: block;
  width: 48px;
  height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f1f5f9;
  object-fit: cover;
}

.order-thumb.placeholder {
  color: var(--muted);
  font-size: 12px;
  line-height: 46px;
  text-align: center;
}

.order-main {
  min-width: 0;
}

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

.order-title strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-title span,
.order-subline {
  color: var(--muted);
  font-size: 12px;
}

.order-subline {
  margin-top: 5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.order-qty {
  color: #dc2626;
  font-size: 20px;
  font-weight: 800;
  text-align: center;
}

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

.order-money strong {
  display: block;
  margin-top: 5px;
  font-size: 15px;
}

.detail-link {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: var(--panel);
  color: var(--accent);
  font-weight: 800;
  cursor: pointer;
}

.detail-panel[hidden] {
  display: none;
}

.detail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.18);
}

.detail-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 21;
  width: min(920px, 100%);
  overflow: auto;
  border-left: 1px solid var(--line);
  background: var(--panel);
  box-shadow: -18px 0 36px rgba(15, 23, 42, 0.16);
}

.warehouse-drawer {
  width: min(980px, 100%);
}

.detail-header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.detail-header h2 {
  margin: 0;
  font-size: 22px;
}

.detail-products {
  display: grid;
  gap: 10px;
  padding: 18px 24px 0;
}

.detail-item {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.detail-item p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 24px 28px;
}

.detail-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.detail-block h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.money-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid #eef1f4;
}

.money-line:first-of-type {
  border-top: 0;
}

.money-line span {
  color: var(--muted);
}

.money-line small {
  display: block;
  margin-top: 3px;
  color: #8a95a3;
  font-size: 11px;
}

.money-line strong {
  text-align: right;
  white-space: nowrap;
}

.money-line.highlight strong {
  color: #dc2626;
  font-size: 17px;
}

.profit-block {
  grid-column: 1 / -1;
}

.profit-form {
  display: grid;
  gap: 0;
}

.profit-input-line strong {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.profit-input-line select {
  width: 160px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.profit-input-line input {
  width: 120px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  text-align: right;
  font: inherit;
}

.warehouse-fee-line {
  align-items: center;
}

.file-list {
  display: grid;
  gap: 10px;
  padding: 16px;
}

.file-row {
  display: grid;
  grid-template-columns: 150px 1fr 100px 210px;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  font-size: 13px;
}

.file-row strong {
  color: var(--accent-2);
}

.editor-form {
  display: grid;
  gap: 14px;
  padding: 18px 24px 28px;
}

.editor-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: var(--panel);
}

.editor-section h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

.product-summary {
  display: grid;
  grid-template-columns: 76px 1fr;
  align-items: center;
  gap: 12px;
  background: #fbfcfd;
}

.product-summary p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

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

.field.full {
  margin-top: 12px;
}

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

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

.checkbox-field input[type="checkbox"] {
  width: auto;
  min-height: unset;
}

.field textarea {
  resize: vertical;
}

.hint {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.segmented-control {
  display: inline-flex;
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  background: #fbfcfd;
}

.segmented-control label {
  min-width: 92px;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.segmented-control label:has(input:checked) {
  background: var(--soft);
  color: var(--accent);
}

.segmented-control input {
  margin-right: 6px;
}

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

.section-title-row h3 {
  margin: 0;
}

.bundle-table {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.bundle-table-head,
.bundle-row {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 96px 140px 130px 86px;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.bundle-table-head {
  background: #f9fafb;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.bundle-row {
  border-top: 1px solid var(--line);
}

.bundle-row select,
.bundle-row input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.cost-preview {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.cost-preview div {
  min-height: 72px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.cost-preview span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.cost-preview strong {
  display: block;
  margin-top: 8px;
  font-size: 18px;
}

.editor-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 0 0;
  background: var(--panel);
}

.save-button {
  height: 40px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.save-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

@media (max-width: 980px) {
  .app {
    padding: 16px;
  }

  .topbar {
    align-items: flex-start;
  }

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

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

  .currency-controls {
    flex-wrap: wrap;
  }

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

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

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