:root {
  --bg: #eef1f6;
  --panel: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #eff6ff;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --ok: #059669;
  --ok-bg: #ecfdf5;
  --head: #0f172a;
  --row-hover: #f8fafc;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px -12px rgba(15, 23, 42, 0.18);
  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "Cascadia Mono", "SF Mono", "Consolas", "Sarasa Mono SC", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

::selection { background: #bfdbfe; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-radius: 4px;
}

.top {
  background: var(--head);
  color: #f8fafc;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, 0 6px 16px -10px rgba(15, 23, 42, 0.5);
}
.top .brand { font-weight: 700; font-size: 15px; letter-spacing: 0.02em; }
.top .right { display: flex; align-items: center; gap: 0.75rem; font-size: 13px; color: #cbd5e1; }
.top a { color: #93c5fd; }
.top .btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.25);
  color: #e2e8f0;
}
.top .btn-secondary:hover { background: rgba(255, 255, 255, 0.16); filter: none; }

.wrap {
  width: min(1280px, 100%);
  margin: 0 auto;
  padding: 0.9rem 0.9rem 3rem;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}
.toolbar .grow { flex: 1; min-width: 180px; }
.toolbar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  margin-right: 0.5rem;
  letter-spacing: 0.01em;
}

.tabs {
  display: flex;
  gap: 0.3rem;
  overflow-x: auto;
  max-width: 100%;
  padding-bottom: 2px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.32rem 0.65rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  border-radius: 999px;
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.tab:hover { text-decoration: none; background: var(--row-hover); border-color: var(--line-strong); }
.tab.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: 0 2px 8px -2px rgba(37, 99, 235, 0.5);
}
.tab .n {
  font-family: var(--mono);
  font-size: 12px;
  opacity: 0.85;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0.42rem 0.8rem;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  white-space: nowrap;
  transition: filter 0.15s ease, background-color 0.15s ease, border-color 0.15s ease, transform 0.06s ease;
  user-select: none;
}
.btn:hover { filter: brightness(1.07); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--line-strong); }
.btn-secondary:hover { background: var(--row-hover); filter: none; }
.btn-danger { background: var(--danger); }
.btn-ok { background: var(--ok); }
.btn-sm { padding: 0.22rem 0.5rem; font-size: 12px; font-weight: 600; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font: inherit;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:hover, select:hover, textarea:hover { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}
input[readonly] { background: #f8fafc; color: var(--muted); }
textarea { min-height: 72px; resize: vertical; }
label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin: 0.6rem 0 0.25rem;
}
label:first-child { margin-top: 0; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-h {
  padding: 0.55rem 0.8rem;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  font-size: 13px;
  background: #f8fafc;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.panel-b { padding: 0.8rem; }

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.desktop-table {
  overflow: auto;
  max-height: calc(100vh - 170px);
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}
table.data th, table.data td {
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 0.6rem;
  text-align: left;
  vertical-align: top;
  background: #fff;
  color: var(--ink);
}
table.data th {
  background: #f8fafc;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
  box-shadow: 0 1px 0 var(--line);
}
table.data tbody tr { cursor: pointer; transition: background-color 0.12s ease; }
table.data tbody tr:hover td { background: var(--row-hover); }
table.data tbody tr.rejected td { background: #fff7f7; }
table.data tbody tr.rejected:hover td { background: #ffefef; }
table.data .num { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data .note {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #9a3412;
  background: #ffedd5;
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  display: inline-block;
}
table.data .amt {
  font-family: var(--mono);
  font-weight: 700;
  white-space: nowrap;
}
table.data .addr {
  max-width: 220px;
  color: var(--muted);
  font-size: 12px;
}

/* 手机：卡片列表，避免宽表横向滚动 */
.order-cards { display: none; }
.order-card {
  display: block;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid var(--line);
  color: inherit;
  text-decoration: none;
  background: #fff;
  transition: background-color 0.12s ease;
}
.order-card:last-child { border-bottom: 0; }
.order-card:active, .order-card:hover { background: var(--row-hover); text-decoration: none; }
.order-card .c1 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
}
.order-card .c2 {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.75rem;
  align-items: center;
  margin-bottom: 0.3rem;
}
.order-card .c3 { font-size: 12px; color: var(--muted); line-height: 1.5; }
.order-card .c3 div { margin-top: 0.15rem; }

@media (max-width: 800px) {
  .desktop-table { display: none; }
  .order-cards { display: block; }
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.5rem;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.badge-pending { background: var(--warn-bg); color: var(--warn); }
.badge-paid { background: var(--accent-soft); color: var(--accent-strong); }
.badge-rejected { background: var(--danger-bg); color: var(--danger); }
.badge-done { background: var(--ok-bg); color: var(--ok); }

.alert {
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.75rem;
  font-size: 13px;
  border: 1px solid transparent;
}
.alert-error { background: var(--danger-bg); color: var(--danger); border-color: #fecaca; }
.alert-ok { background: var(--ok-bg); color: var(--ok); border-color: #a7f3d0; }
.alert-warn { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }

.grid-2, .grid-3 {
  display: grid;
  gap: 0.6rem 0.8rem;
}
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .wrap { padding: 0.6rem 0.6rem 2.5rem; }
}

.kv {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.45rem 0.6rem;
  font-size: 13px;
}
.kv .k { color: var(--muted); }
.kv .v { word-break: break-word; }
.kv .v.strong { font-weight: 700; }

.pay-strip {
  display: grid;
  grid-template-columns: 1fr 1fr 1.2fr;
  gap: 0.6rem;
  margin-bottom: 0.75rem;
}
@media (max-width: 720px) {
  .pay-strip { grid-template-columns: 1fr; }
}
.pay-cell {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.65rem 0.8rem;
  box-shadow: var(--shadow-sm);
}
.pay-cell .lbl { font-size: 12px; color: var(--muted); margin-bottom: 0.2rem; }
.pay-cell .val {
  font-family: var(--mono);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
}
.pay-cell.money { border-color: #bfdbfe; background: linear-gradient(180deg, #eff6ff, #fff); }
.pay-cell.note-cell { border-color: #fdba74; background: linear-gradient(180deg, #fff7ed, #fff); }
.pay-cell.note-cell .val { color: #9a3412; }

.qrbox {
  text-align: center;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.5rem;
}
.qrbox img { max-width: min(560px, 100%); height: auto; display: block; margin: 0 auto; }

.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(37, 99, 235, 0.35), transparent 60%),
    radial-gradient(700px 500px at 0% 110%, rgba(14, 165, 233, 0.25), transparent 55%),
    #0f172a;
}
.login-box {
  width: min(380px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 1.6rem 1.5rem 1.4rem;
  box-shadow: 0 24px 60px -20px rgba(2, 6, 23, 0.7);
}
.login-box .logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  display: grid;
  place-items: center;
  margin-bottom: 0.8rem;
  box-shadow: 0 8px 20px -8px rgba(37, 99, 235, 0.7);
}
.login-box h1 { margin: 0 0 0.2rem; font-size: 19px; letter-spacing: 0.01em; }
.login-box .sub { color: var(--muted); margin: 0 0 1.1rem; font-size: 13px; }

.actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.copy-inline { display: inline-flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }

.search {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}
.search input { min-width: 0; flex: 1; }

.hint { font-size: 12px; color: var(--muted); margin: 0.3rem 0 0; }

.detail-grid {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 0.75rem;
  align-items: start;
}
@media (max-width: 800px) {
  .detail-grid { grid-template-columns: 1fr; }
}

.reject-line {
  color: var(--danger);
  font-size: 12px;
  margin-top: 0.2rem;
}

/* Toast 轻提示（替代 alert） */
.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 0.5rem 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
