:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-soft: #eef3f1;
  --fg: #17211d;
  --muted: #66736e;
  --border: #d8e0dc;
  --accent: #16735f;
  --accent-strong: #0d5b4a;
  --danger: #b42318;
  --warning: #b25e09;
  --info: #1d5b99;
  --radius: 8px;
  --shadow: 0 12px 28px rgba(25, 39, 34, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-size: 15px;
  line-height: 1.5;
  overflow-x: hidden;
}

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

button, input, select, textarea {
  font: inherit;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--fg);
  padding: 10px 12px;
  min-height: 42px;
}

.short-input {
  width: 96px;
}

textarea { resize: vertical; }

input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 3px solid rgba(22, 115, 95, 0.22);
  outline-offset: 2px;
}

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

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px 1fr;
}

.sidebar {
  background: #10231f;
  color: #e8f2ef;
  padding: 20px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: #fff;
  margin-bottom: 28px;
}

.brand:hover { text-decoration: none; }
.brand small { display: block; color: #a8bbb5; font-size: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--accent);
  font-weight: 700;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-list a {
  color: #cddbd7;
  padding: 10px 12px;
  border-radius: var(--radius);
}

.nav-list a.active, .nav-list a:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  text-decoration: none;
}

.main { min-width: 0; }

.main > .panel {
  margin: 16px 28px 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 24px 28px 12px;
}

.topbar h1, .panel h2, .checkout-head h1, .state-card h1 {
  margin: 0;
  line-height: 1.2;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.user-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  color: var(--fg);
  min-width: max-content;
}

.user-chip small { color: var(--muted); }

.logout-form button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  padding: 2px 0 0;
  cursor: pointer;
}

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

.login-shell {
  width: min(100%, 420px);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
}

.login-brand {
  color: var(--fg);
  margin-bottom: 22px;
}

.login-brand small { color: var(--muted); }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
  padding: 16px 28px 28px;
}

.content-grid-narrow {
  grid-template-columns: minmax(0, 760px) 360px;
}

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

.panel-head p, .checkout-head p, .empty-state p, .state-card p {
  color: var(--muted);
  margin: 6px 0 0;
}

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

.field-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.filters {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
}

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

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-secondary { background: #fff; color: var(--fg); border-color: var(--border); }
.btn-danger { background: #fff; color: var(--danger); border-color: rgba(180, 35, 24, 0.35); }
.btn-block { width: 100%; }

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

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

th, td {
  text-align: left;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  overflow-wrap: anywhere;
}

th {
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
}

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

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
  font-weight: 700;
}

.status-submitted, .status-active { color: var(--info); background: #eaf3fb; border-color: #c8def2; }
.status-completed { color: var(--accent-strong); background: #e8f4f1; border-color: #bdded6; }
.status-draft { color: var(--warning); background: #fff6e8; border-color: #f4d2a2; }
.status-cancelled, .status-disabled, .status-expired { color: var(--danger); background: #fff0ee; border-color: #f2c4bf; }

.money {
  font-weight: 800;
  color: var(--accent-strong);
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 0 0 20px;
}

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

.detail-list div {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fbfcfc;
}

.detail-list .full { grid-column: 1 / -1; }
.detail-list dt { color: var(--muted); font-size: 13px; }
.detail-list dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }

.side-panel {
  align-self: start;
  display: grid;
  gap: 16px;
}

.danger-zone {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.empty-state, .error-state, .notice {
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 18px;
  background: #fbfcfc;
}

.notice { margin: 0 28px 12px; border-style: solid; }
.notice-error { border-color: #f2c4bf; background: #fff0ee; }
.notice-success { border-color: #bdded6; background: #e8f4f1; }
.error-state { border-color: #f2c4bf; background: #fff0ee; }
.compact { padding: 14px; }

.form-error {
  border: 1px solid #f2c4bf;
  color: var(--danger);
  background: #fff0ee;
  border-radius: var(--radius);
  padding: 10px 12px;
}

.form-error p { margin: 0; }

.field-hint {
  margin: -8px 0 8px;
  color: var(--muted);
  font-size: 13px;
}

.copy-line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.qr-preview, .qr-card img, .pay-code img {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.qr-preview { aspect-ratio: 1; object-fit: contain; padding: 10px; }

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

.qr-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  min-width: 0;
}

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

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

.inline-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.inline-form select { min-width: 120px; }

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  color: var(--muted);
}

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

.state-card { max-width: 520px; }

.mobile-page {
  background: #eef3f1;
}

.phone-shell {
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px;
}

.checkout-card {
  background: #fff;
  min-height: calc(100vh - 28px);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.checkout-head {
  margin-bottom: 16px;
}

.checkout-head h1 {
  font-size: 24px;
}

.amount-box {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 14px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--surface-soft);
}

.amount-box span { color: var(--muted); }
.amount-box strong { font-size: 28px; color: var(--accent-strong); }

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

.pay-code {
  margin: 0;
  text-align: center;
}

.pay-code img {
  aspect-ratio: 1;
  object-fit: contain;
  padding: 8px;
}

.pay-code figcaption {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.checkout-card form {
  display: grid;
  gap: 12px;
}

.state-meta {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  color: var(--fg);
  font-weight: 700;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 14px;
  }
  .brand { margin-bottom: 12px; }
  .nav-list {
    grid-auto-flow: column;
    grid-auto-columns: max-content;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
  }
  .topbar, .content-grid { padding-left: 16px; padding-right: 16px; }
  .main > .panel { margin: 16px; }
  .content-grid, .content-grid-narrow { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 14px; }
  .layout { display: block; }
  .sidebar {
    padding: 10px 12px 8px;
  }
  .brand {
    gap: 10px;
    margin-bottom: 8px;
  }
  .brand-mark {
    width: 32px;
    height: 32px;
  }
  .nav-list {
    margin: 0 -4px;
    padding: 0 4px 2px;
  }
  .nav-list a {
    padding: 8px 10px;
    font-size: 14px;
  }
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px 14px 10px;
  }
  .topbar h1 { font-size: 22px; }
  .user-chip { align-items: flex-start; }
  .notice { margin: 0 14px 10px; }
  .main > .panel {
    margin: 12px 12px 18px;
  }
  .content-grid {
    padding: 12px 12px 18px;
    gap: 12px;
  }
  .panel {
    padding: 14px;
  }
  .panel-head, .detail-head {
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
  }
  .filters,
  .field-row,
  .detail-list-wide,
  .copy-line,
  .pay-grid {
    grid-template-columns: 1fr;
  }
  .filters {
    gap: 10px;
  }
  .filter-actions,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }
  .filter-actions .btn,
  .actions .btn,
  .actions form {
    width: 100%;
  }
  .pagination {
    align-items: stretch;
    flex-direction: column;
  }
  .pagination > div {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .inline-form {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
  .inline-form select,
  .inline-form .short-input {
    min-width: 0;
    width: 100%;
  }
  .table-wrap {
    overflow: visible;
    border: 0;
    border-radius: 0;
  }
  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }
  table {
    min-width: 0;
  }
  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  tbody {
    display: grid;
    gap: 10px;
  }
  tr {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    padding: 8px 12px;
  }
  td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    border-bottom: 0;
    padding: 7px 0;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
  }
  td[data-label="操作"] {
    grid-template-columns: 1fr;
    padding-top: 10px;
  }
  td[data-label="操作"]::before {
    display: none;
  }
  td[data-label="操作"] .link-action,
  td[data-label="操作"] .btn {
    width: 100%;
  }
  .amount-box { align-items: flex-start; flex-direction: column; }
  .amount-box strong { font-size: 24px; }
  .checkout-card {
    min-height: calc(100vh - 20px);
    padding: 16px;
  }
  .phone-shell { padding: 10px; }
}

@media (max-width: 380px) {
  .brand small { display: none; }
  td {
    grid-template-columns: 76px minmax(0, 1fr);
  }
  .pagination > div {
    grid-template-columns: 1fr;
  }
}
