:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #18202c;
  --muted: #657184;
  --line: #dfe5ee;
  --primary: #176b87;
  --primary-strong: #0f5368;
  --danger: #b3261e;
  --ok: #237447;
  --warn: #a15c00;
  --soft: #eef3f6;
  --shadow: 0 10px 28px rgba(20, 32, 45, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  line-height: 1.5;
}

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

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0;
}

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

.nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.nav a,
.button,
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  min-height: 38px;
  padding: 8px 13px;
  border-radius: 7px;
  font: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav a.active,
.button.primary,
button.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

button.primary:hover,
.button.primary:hover {
  background: var(--primary-strong);
}

button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

button.ok {
  color: #fff;
  background: var(--ok);
  border-color: var(--ok);
}

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

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 56px;
}

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

.grid.two {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  align-items: start;
}

.stats {
  grid-template-columns: repeat(6, minmax(120px, 1fr));
}

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

.panel {
  padding: 20px;
}

.panel h2,
.panel h3 {
  margin: 0 0 14px;
  font-size: 18px;
}

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

.panel-title h2,
.panel-title h3 {
  margin: 0;
}

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

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  color: #364252;
}

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

textarea {
  min-height: 96px;
  resize: vertical;
}

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

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

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

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

th {
  color: #344052;
  background: #f9fbfc;
  font-size: 13px;
  white-space: nowrap;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: #334155;
  background: #f8fafc;
  white-space: nowrap;
}

.badge.pending {
  color: #7a4b00;
  border-color: #f0d6a8;
  background: #fff7e8;
}

.badge.approved {
  color: #0f5d36;
  border-color: #bddfcb;
  background: #edf8f1;
}

.badge.rejected {
  color: #8d1f19;
  border-color: #efc2bf;
  background: #fff0ef;
}

.badge.return_pending {
  color: #0f5368;
  border-color: #b8dbe6;
  background: #edf8fb;
}

.badge.returned {
  color: #305c30;
  border-color: #c8dec2;
  background: #f1f8ef;
}

.badge.overdue {
  color: #8d1f19;
  border-color: #efc2bf;
  background: #fff0ef;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.stat-card strong {
  display: block;
  font-size: 26px;
  line-height: 1.1;
}

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

.detail {
  display: grid;
  gap: 10px;
}

.detail-row {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.detail-row span:first-child {
  color: var(--muted);
  font-size: 13px;
}

.photo-preview {
  width: 100%;
  max-height: 260px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.notice {
  border: 1px solid #c7d9e0;
  background: var(--soft);
  color: #263947;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

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

.success {
  color: var(--ok);
}

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

.qq-box {
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  min-height: 108px;
}

.qq-reply {
  white-space: pre-wrap;
  color: #263947;
}

.qr-token {
  width: 180px;
  height: 180px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(45deg, #fff, #fff 8px, #edf3f7 8px, #edf3f7 16px);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  padding: 16px;
  color: #304050;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  .page {
    width: min(100vw - 20px, 1180px);
    margin-top: 14px;
  }

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

  .panel {
    padding: 16px;
  }

  table {
    min-width: 760px;
  }
}
