:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --pending: #d97706;
  --pending-bg: #fef3c7;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --bg: #f3f4f6;
  --card: #ffffff;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

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

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  padding-bottom: var(--safe-bottom);
}

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

/* ---------------- 页眉 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
  box-shadow: 0 2px 8px rgba(30, 58, 138, 0.25);
}

.brand {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.nav {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.nav-btn:active {
  background: rgba(255, 255, 255, 0.34);
}

/* ---------------- 布局 ---------------- */

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 14px 12px 48px;
}

.layout {
  display: block;
}

.list-section {
  margin-top: 16px;
}

/* ---------------- 手机端板块切换 ---------------- */

.tabs {
  display: flex;
  gap: 6px;
  background: #e5e7eb;
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 15px;
  font-family: inherit;
  color: var(--muted);
  cursor: pointer;
}

.tab.active {
  background: #fff;
  color: var(--primary);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ---------------- 卡片 / 表单 ---------------- */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 16px;
}

.card h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
}

.center {
  text-align: center;
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field label .req {
  color: var(--danger);
}

input[type="text"],
input[type="number"],
input[type="password"],
textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

input[type="file"] {
  width: 100%;
  font-size: 13px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: 10px;
  background: #fafafa;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 46px;
  padding: 11px 18px;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.btn:active {
  opacity: 0.85;
}

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

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

.btn-success {
  background: var(--success);
  color: #fff;
}

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

.btn-ghost {
  background: #f3f4f6;
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 38px;
  padding: 8px 14px;
  font-size: 13px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ---------------- 工具条 / 筛选 ---------------- */

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

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 2px;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex: 0 0 auto;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}

.filter-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---------------- 统计 ---------------- */

.stats {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 12px;
}

.stats::-webkit-scrollbar {
  display: none;
}

.stat {
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  color: var(--muted);
}

.stat b {
  font-size: 16px;
  margin-left: 4px;
}

/* ---------------- 列表 ---------------- */

.list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.item {
  display: flex;
  gap: 12px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  padding: 14px;
}

.item-thumb {
  width: 84px;
  height: 84px;
  flex: 0 0 84px;
  border-radius: 10px;
  object-fit: cover;
  background: #f3f4f6;
  border: 1px solid var(--border);
  cursor: pointer;
}

.item-thumb.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
}

.item-body {
  flex: 1;
  min-width: 0;
}

.item-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.item-title {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.item-price {
  color: var(--danger);
  font-weight: 700;
  font-size: 15px;
}

.price-old {
  color: var(--muted);
  text-decoration: line-through;
  font-size: 14px;
  margin-right: 6px;
}

.price-new {
  color: var(--danger);
  font-weight: 700;
  font-size: 15px;
}

.item-desc {
  color: #374151;
  font-size: 14px;
  margin: 6px 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.item-meta {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.badge.pending {
  background: var(--pending-bg);
  color: var(--pending);
}

.badge.approved {
  background: var(--success-bg);
  color: var(--success);
}

.badge.rejected {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.purchased {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge.not_purchased {
  background: #f3f4f6;
  color: #6b7280;
}

.badge.unset {
  background: #f3f4f6;
  color: #9ca3af;
}

/* ---------------- 审批 / 购买 ---------------- */

.review-box {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f9fafb;
  border: 1px solid var(--border);
  font-size: 13px;
}

.review-box .label,
.purchase-box .label {
  color: var(--muted);
  margin-right: 4px;
}

.review-box .line,
.purchase-box .line {
  line-height: 1.5;
  word-break: break-word;
}

.review-box .line + .line,
.purchase-box .line + .line {
  margin-top: 3px;
}

.purchase-box {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.purchase-box .row {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.purchase-box .row .btn {
  flex: 1;
}

.review-actions {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.review-actions .row {
  display: flex;
  gap: 8px;
}

.review-actions .row .btn {
  flex: 1;
}

.review-actions textarea {
  min-height: 56px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 10px;
  font-size: 14px;
  background: #fff;
  border-radius: var(--radius);
}

/* ---------------- 登录 ---------------- */

.login-wrap {
  max-width: 380px;
  margin: 40px auto;
}

.login-wrap .card {
  text-align: center;
  padding: 24px 20px;
}

.login-wrap .lock {
  font-size: 34px;
  margin-bottom: 6px;
}

/* ---------------- 提示 / 弹层 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(16px);
  background: #111827;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 999;
  max-width: 86vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  background: var(--danger);
}

.toast.success {
  background: var(--success);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.78);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.show {
  display: flex;
}

.modal img {
  max-width: 94vw;
  max-height: 90vh;
  border-radius: 10px;
}

.dialog {
  width: 100%;
  max-width: 340px;
  background: #fff;
  border-radius: 14px;
  padding: 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.dialog h3 {
  margin: 0 0 6px;
  font-size: 16px;
  text-align: center;
}

.dialog-hint {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}

.dialog input[type="number"] {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.dialog-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.dialog-actions .btn {
  flex: 1;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.preview {
  margin-top: 10px;
  display: none;
}

.preview.show {
  display: block;
}

.preview img {
  max-width: 100%;
  max-height: 240px;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.logout {
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  padding: 8px 4px;
  cursor: pointer;
}

/* ---------------- 桌面端增强 ---------------- */

@media (min-width: 900px) {
  body {
    font-size: 15px;
  }

  .topbar {
    padding: 16px 24px;
  }

  .brand {
    font-size: 20px;
  }

  .container {
    padding: 24px 16px 60px;
  }

  .layout {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    align-items: start;
  }

  .tabs {
    display: none;
  }

  .panel {
    display: block;
  }

  .list-section {
    margin-top: 0;
  }

  .filters {
    flex-wrap: wrap;
    overflow: visible;
  }

  .stats {
    flex-wrap: wrap;
    overflow: visible;
  }

  .item-thumb {
    width: 110px;
    height: 110px;
    flex-basis: 110px;
  }

  .purchase-box .row .btn,
  .review-actions .row .btn {
    flex: 0 0 auto;
  }

  .toast {
    top: 20px;
    bottom: auto;
    transform: translateX(-50%) translateY(-16px);
  }

  .toast.show {
    transform: translateX(-50%) translateY(0);
  }
}
