:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #d9e1ec;
  --line-strong: #b9c6d7;
  --text: #162033;
  --muted: #647188;
  --soft: #eef3f8;
  --brand: #1967d2;
  --brand-dark: #0f4fa8;
  --accent: #11845b;
  --warn: #b54708;
  --danger: #b42318;
  --shadow: 0 8px 24px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  font-size: 14px;
}

button,
input {
  font: inherit;
}

button {
  min-height: 36px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

button:hover:not(:disabled),
.file-button:hover {
  background: var(--brand-dark);
  border-color: var(--brand-dark);
}

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

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

button.ghost:hover:not(:disabled) {
  background: var(--soft);
  border-color: var(--line-strong);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 22px;
  line-height: 1.2;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--brand);
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

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

main {
  max-width: 1760px;
  margin: 0 auto;
  padding: 18px 24px 36px;
}

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

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

.metric span {
  display: block;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric strong {
  display: block;
  font-size: 24px;
  line-height: 1.2;
}

.metric.accent strong {
  color: var(--accent);
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 320px) minmax(540px, 1fr) minmax(300px, auto) auto;
  align-items: end;
  gap: 14px;
  margin: 14px 0;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-wrap label,
.time-field label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
}

.search-wrap input,
.time-field input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
}

.time-filter {
  display: grid;
  grid-template-columns: minmax(132px, 1fr) 108px minmax(132px, 1fr) 108px auto;
  align-items: end;
  gap: 10px;
}

.time-field {
  min-width: 0;
}

.time-field.compact {
  min-width: 98px;
}

.highlight-filter {
  display: grid;
  grid-template-columns: 112px 112px auto;
  align-items: end;
  gap: 10px;
}

.pager {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  white-space: nowrap;
}

.pager span {
  min-width: 72px;
  text-align: center;
  color: var(--muted);
}

.hint {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  line-height: 1.6;
}

#filterInfo {
  color: var(--brand);
}

#highlightInfo {
  color: var(--warn);
}

.empty {
  margin-top: 14px;
  min-height: 260px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--panel);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  padding: 32px;
}

.empty h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.empty p {
  margin: 0;
  color: var(--muted);
}

.empty.is-hidden {
  display: none;
}

.customer-page {
  margin-top: 14px;
}

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

.customer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 18px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.customer-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.25;
}

.customer-subtitle {
  margin: 0;
  color: var(--muted);
}

.customer-total {
  text-align: right;
  white-space: nowrap;
}

.customer-total span {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.customer-total strong {
  color: var(--accent);
  font-size: 24px;
}

.orders {
  display: grid;
  gap: 0;
}

.order-card {
  display: grid;
  grid-template-columns: 1.35fr 1.25fr 1.25fr 1.35fr 1.25fr 1.45fr 0.95fr;
  border-bottom: 1px solid var(--line);
}

.order-card:nth-child(even) {
  background: #fbfdff;
}

.order-card.highlight-time {
  background: #fff7df;
  box-shadow: inset 4px 0 0 #f59e0b;
}

.order-card.highlight-time:nth-child(even) {
  background: #fff3c4;
}

.order-section {
  min-width: 0;
  padding: 12px 12px 14px;
  border-right: 1px solid var(--line);
}

.order-section:last-of-type {
  border-right: 0;
}

.order-section h3 {
  margin: 0 0 10px;
  color: #27364f;
  font-size: 14px;
  line-height: 1.25;
}

.order-section p {
  margin: 0 0 6px;
  color: var(--text);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.order-section p:last-child {
  margin-bottom: 0;
}

.note p {
  min-height: 42px;
  color: #344054;
}

.check-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 28px;
  margin-bottom: 8px;
  cursor: pointer;
}

.check-line input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.refund-line {
  color: var(--accent);
  font-weight: 700;
}

.order-card.has-discount .refund-line,
.order-card.has-discount .reason-line {
  color: var(--danger);
}

.warning-line,
.reason-line {
  color: var(--warn);
}

.reason-line.is-ok {
  color: var(--muted);
}

.raw-fields {
  grid-column: 1 / -1;
  padding: 10px 12px 12px;
  background: #f8fafc;
  border-top: 1px solid var(--line);
}

.order-card.highlight-time .raw-fields {
  background: #fff8df;
}

.raw-fields summary {
  width: fit-content;
  color: var(--brand);
  cursor: pointer;
}

.raw-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 8px 12px;
  margin: 10px 0 0;
}

.raw-grid div {
  min-width: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.raw-grid dt {
  display: inline;
  color: var(--muted);
}

.raw-grid dd {
  display: inline;
  margin: 0;
}

.subtotal-row {
  padding: 14px 18px;
  background: #f8fafc;
  color: var(--muted);
}

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

.notice {
  margin-top: 14px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
}

@media (max-width: 1180px) {
  .topbar,
  .customer-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

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

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

  .pager {
    justify-content: flex-start;
  }

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

  .order-section {
    border-bottom: 1px solid var(--line);
  }

  .raw-grid {
    grid-template-columns: repeat(2, minmax(160px, 1fr));
  }
}

@media (max-width: 720px) {
  main {
    padding: 12px;
  }

  .topbar {
    padding: 14px 12px;
  }

  .top-actions,
  .top-actions button,
  .file-button {
    width: 100%;
  }

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

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

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

  .time-filter button,
  .highlight-filter button {
    grid-column: 1 / -1;
  }

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

  .order-card {
    grid-template-columns: 1fr;
  }

  .order-section {
    border-right: 0;
  }

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