:root {
  color-scheme: light;
  --bg: #f3f6f8;
  --bg-soft: #eef4f3;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #111827;
  --muted: #667085;
  --line: #d9e1e7;
  --line-strong: #c5d0d8;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --accent-soft: #e5f4f1;
  --danger: #b42318;
  --danger-soft: #fff1f0;
  --warning: #8a5a00;
  --warning-soft: #fff8e5;
  --shadow: 0 14px 34px rgba(17, 24, 39, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, #eaf2f1 0, rgba(234, 242, 241, 0) 260px),
    var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 15px;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 9px 14px;
  white-space: nowrap;
  transition:
    background 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 8px 18px rgba(15, 118, 110, 0.18);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line);
}

button.secondary:hover {
  background: var(--surface-soft);
  border-color: var(--line-strong);
  box-shadow: none;
}

button.danger,
button.icon.danger {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: #ffc9c4;
}

button.danger:hover,
button.icon.danger:hover {
  background: #ffe4e0;
  box-shadow: none;
}

input,
select {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 9px 11px;
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    background 0.16s ease;
}

input::placeholder {
  color: #8a98a6;
}

input:focus,
select:focus {
  outline: 0;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

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

.auth-card {
  width: min(440px, 100%);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h1 {
  font-size: 31px;
}

.auth-form {
  display: grid;
  gap: 11px;
  margin-top: 22px;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.auth-message,
.config-notice {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.config-notice {
  border: 1px solid #f0d28a;
  border-radius: 8px;
  background: var(--warning-soft);
  color: var(--warning);
  margin-top: 16px;
  padding: 10px 12px;
}

.auth-card > .secondary {
  width: 100%;
  margin-top: 10px;
}

.app-shell {
  width: min(1320px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.app-layout {
  width: 100%;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 0;
  margin: 0;
  padding: 0;
}

.side-nav {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  background: #087cba;
  padding: 14px 10px;
}

.brand-mark {
  display: grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 800;
}

.nav-item {
  min-height: 58px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  background: transparent;
  color: #fff;
  padding: 8px 4px;
  font-weight: 700;
  white-space: normal;
}

.nav-item:hover,
.nav-item.active {
  background: #fff;
  color: #087cba;
  box-shadow: none;
}

.workspace {
  min-width: 0;
  width: min(1320px, calc(100% - 36px));
  margin: 0 auto;
  padding: 26px 0 44px;
}

.view {
  min-width: 0;
}

.topbar,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.topbar {
  padding: 2px 2px 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  margin-top: 8px;
  line-height: 1.5;
}

.actions,
.shipment-tools,
.aftersale-tools,
.data-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

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

.summary-grid article,
.panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(17, 24, 39, 0.06);
}

.summary-grid article {
  position: relative;
  overflow: hidden;
  padding: 18px;
}

.summary-grid article::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--accent);
}

.summary-grid span {
  color: var(--muted);
  display: block;
  font-size: 14px;
}

.summary-grid strong {
  display: block;
  font-size: 28px;
  line-height: 1.15;
  margin-top: 7px;
}

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

.daily-entry {
  display: grid;
  grid-template-columns: 160px 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 17px;
}

.import-panel {
  display: grid;
  gap: 10px;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 12px;
}

.import-panel textarea {
  width: 100%;
  min-height: 132px;
  resize: vertical;
}

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

.import-result {
  color: var(--muted);
  font-size: 14px;
}

.import-result p {
  margin: 0 0 8px;
}

.import-result strong {
  display: block;
  color: var(--text);
  margin-top: 8px;
}

.import-result ul {
  display: grid;
  gap: 4px;
  margin: 6px 0 0;
  padding-left: 18px;
}

.product-import-file-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
}

.product-import-file-row input[type="file"] {
  max-width: 100%;
}

.product-import-preview {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 13px;
}

.product-import-preview th,
.product-import-preview td {
  border: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
}

.product-import-preview th {
  background: var(--accent-soft);
  color: var(--text);
}

@media (max-width: 760px) {
  .product-import-file-row {
    display: grid;
  }

  .product-import-preview {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
}

.import-unmatched {
  color: var(--danger);
}

.daily-summary,
.month-summary,
.checked-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.daily-summary article {
  min-width: 154px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px 12px;
}

.daily-summary span,
.month-summary span,
.checked-summary span {
  color: var(--muted);
  font-size: 14px;
}

.daily-summary strong,
.month-summary strong,
.checked-summary strong {
  color: var(--text);
  font-size: 18px;
}

.month-summary,
.checked-summary,
.aftersale-summary {
  border-radius: 8px;
  padding: 11px 12px;
}

.month-summary,
.aftersale-summary {
  border: 1px solid var(--line);
  background: var(--surface-soft);
}

.checked-summary {
  border: 1px solid #abd4cf;
  background: var(--accent-soft);
}

.checked-summary button {
  margin-left: auto;
}

.shipment-tools input,
.aftersale-tools input,
.data-tools input {
  width: 170px;
}

.aftersale-summary {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.aftersale-summary span {
  color: var(--muted);
  font-size: 14px;
}

.aftersale-summary strong {
  color: var(--text);
  font-size: 18px;
}

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

.product-row.product-head {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  padding: 0 12px;
}

.product-row.product-head span {
  min-height: 22px;
  display: flex;
  align-items: center;
}

.product-row {
  display: grid;
  grid-template-columns: 76px minmax(220px, 1fr) 160px 140px 128px auto;
  gap: 10px;
  align-items: center;
}

.row-index {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: grab;
  user-select: none;
}

.row-index:active {
  cursor: grabbing;
}

.product-row.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.product-row.dragging {
  opacity: 0.55;
}

.product-amount {
  min-height: 40px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  font-weight: 700;
  padding: 9px 11px;
}

.product-catalog {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.catalog-filter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.catalog-search,
.catalog-search-mode {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.catalog-search input {
  width: 150px;
}

.catalog-search-mode select {
  min-width: 110px;
}

.catalog-channel-prices {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, 1fr));
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.catalog-channel-title {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.catalog-filter select {
  min-width: 150px;
}

.catalog-group {
  display: grid;
  gap: 10px;
}

.catalog-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 0 2px 8px;
}

.catalog-group-head h3 {
  margin: 0;
  font-size: 17px;
}

.catalog-group-head span,
.catalog-empty {
  color: var(--muted);
  font-size: 13px;
}

.catalog-empty {
  margin: 0;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 14px;
}

.catalog-group-list {
  display: grid;
  gap: 10px;
}

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

.product-photo {
  width: 78px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-weight: 700;
}

.product-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.catalog-fields {
  display: grid;
  grid-template-columns:
    minmax(170px, 1.25fr) 130px 120px 100px 90px 90px
    minmax(120px, 0.8fr) minmax(150px, 0.9fr);
  gap: 8px;
  align-items: end;
}

.field-group {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.field-group span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
}

.catalog-name input {
  font-weight: 700;
}

.catalog-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
  min-width: 92px;
}

.file-button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  padding: 7px 10px;
  font-size: 14px;
  font-weight: 400;
}

.catalog-actions button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 14px;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

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

.data-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 18px;
}

.data-grid span {
  display: block;
  color: var(--muted);
}

.data-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
}

.data-detail {
  margin-top: 18px;
}

.section-head h3 {
  margin: 0;
  font-size: 18px;
}

.section-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.table-wrap {
  margin-top: 16px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.aftersale-table-wrap table {
  min-width: 1180px;
}

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

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fbfcfd;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

.date-group-row td {
  background: var(--accent-soft);
  border-bottom-color: #c9dfdc;
  font-weight: 700;
}

.date-group-row td:first-child {
  display: flex;
  align-items: center;
  gap: 10px;
}

.date-group-row.is-checked td {
  background: #d7eee9;
}

.date-check {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  padding: 0;
}

.toggle-details {
  min-width: 54px;
  min-height: 34px;
  padding: 6px 10px;
  background: #fff;
  color: var(--accent);
  border: 1px solid #abd4cf;
}

.toggle-details:hover {
  background: #dff1ee;
  color: var(--accent-dark);
  box-shadow: none;
}

.shipment-detail-row td {
  background: #fff;
}

.shipment-detail-row:hover td {
  background: #fbfdfd;
}

td.amount {
  min-width: 110px;
  font-weight: 700;
}

td:nth-child(1) {
  width: 150px;
}

td:nth-child(2) {
  width: 190px;
}

td:nth-child(5),
td:nth-child(6),
td:nth-child(7) {
  width: 120px;
}

.icon {
  min-height: 36px;
  padding: 7px 10px;
}

@media (max-width: 1180px) {
  .catalog-card {
    grid-template-columns: 78px minmax(0, 1fr);
  }

  .catalog-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, max-content);
  }

  .catalog-fields {
    grid-template-columns: minmax(180px, 1.4fr) repeat(5, minmax(90px, 1fr));
  }

  .catalog-note,
  .catalog-vendor {
    grid-column: 1 / -1;
  }

  .catalog-channel-prices {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .auth-card {
    padding: 22px;
  }

  .app-layout {
    display: block;
  }

  .app-shell {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .side-nav {
    position: sticky;
    z-index: 5;
    height: auto;
    flex-direction: row;
    top: 0;
    margin: -18px -10px 14px;
    padding: 10px;
    overflow-x: auto;
  }

  .brand-mark {
    min-width: 58px;
  }

  .nav-item {
    min-width: 64px;
    min-height: 44px;
  }

  .workspace {
    width: 100%;
    padding: 0 0 28px;
  }

  .topbar,
  .panel-head {
    display: grid;
  }

  .actions,
  .panel-actions,
  .shipment-tools,
  .aftersale-tools,
  .data-tools {
    justify-content: stretch;
  }

  .actions button,
  .panel-head button,
  .daily-summary button,
  .shipment-tools button,
  .aftersale-tools button,
  .data-tools button {
    width: 100%;
  }

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

  .product-row,
  .daily-entry,
  .shipment-tools,
  .aftersale-tools,
  .data-tools {
    grid-template-columns: 1fr;
    display: grid;
  }

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

  .product-catalog,
  .data-grid {
    grid-template-columns: 1fr;
  }

  .catalog-card {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .catalog-channel-prices {
    grid-template-columns: 1fr;
  }

  .catalog-channel-title {
    grid-column: auto;
  }

  .product-photo {
    width: 72px;
  }

  .catalog-fields {
    grid-template-columns: 1fr;
  }

  .catalog-actions {
    grid-template-columns: 1fr;
  }

  .shipment-tools input,
  .aftersale-tools input,
  .data-tools input {
    width: 100%;
  }
}

@media print {
  body {
    background: #fff;
  }

  .app-shell {
    width: 100%;
    padding: 0;
  }

  .app-layout {
    display: block;
  }

  .workspace {
    width: 100%;
    padding: 0;
  }

  .panel,
  .summary-grid article {
    box-shadow: none;
  }

  .actions,
  .no-print,
  .panel:first-of-type {
    display: none !important;
  }

  input,
  select {
    border: 0;
    padding: 0;
    appearance: none;
  }
}
