:root {
  --bg: #f4f7f8;
  --surface: #ffffff;
  --surface-muted: #f0f5f3;
  --surface-tint: #e6f4f1;
  --ink: #18212c;
  --muted: #667085;
  --line: #d7e0e6;
  --line-strong: #b8c6d0;
  --primary: #0f766e;
  --primary-strong: #0a5e58;
  --primary-soft: #def4ee;
  --blue: #2563eb;
  --blue-soft: #e7efff;
  --amber: #a16207;
  --amber-soft: #fff4d6;
  --red: #b42318;
  --red-soft: #ffe7e5;
  --green: #027a48;
  --green-soft: #e1f6ea;
  --shadow: 0 14px 32px rgba(24, 33, 44, 0.08);
  --shadow-soft: 0 8px 18px rgba(24, 33, 44, 0.05);
  --radius: 8px;
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  min-height: 100%;
  margin: 0;
  background: linear-gradient(180deg, #f8fbfa 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: 0;
}

button, input, select, textarea { font: inherit; }
button { color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
img { display: block; }

.mono {
  font-family: "Cascadia Mono", Consolas, "SFMono-Regular", monospace;
  word-break: break-all;
}
.muted { color: var(--muted); }
.strong { font-weight: 700; }
.full { grid-column: 1 / -1; }
.stack { display: grid; gap: 14px; }
.truncate {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-page,
.pay-page,
.standalone-page {
  min-height: 100vh;
  padding: 28px 16px;
}

.auth-page {
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #eef8f4 0%, #f7f9fb 48%, #eef3fb 100%);
}
.auth-shell {
  width: min(1040px, 100%);
  min-height: 560px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 420px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.auth-intro {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 28px;
  padding: 44px;
  background: #143431;
  color: #fff;
}
.brand-mark,
.brand-badge {
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius);
  font-weight: 800;
}
.brand-mark {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  font-size: 22px;
}
.auth-intro h1 {
  margin: 24px 0 10px;
  font-size: 38px;
  line-height: 1.12;
}
.auth-intro p {
  max-width: 460px;
  margin: 0;
  color: rgba(255, 255, 255, 0.84);
}
.auth-snapshot {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.auth-snapshot div {
  min-width: 0;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.08);
}
.auth-snapshot span {
  display: block;
  margin-bottom: 6px;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
}
.auth-snapshot strong { color: #fff; }
.auth-panel {
  align-self: center;
  padding: 38px;
}
.auth-panel h2 {
  margin: 0 0 6px;
  font-size: 24px;
}
.auth-panel > p {
  margin: 0 0 24px;
  color: var(--muted);
}
.auth-panel form + .muted {
  margin: 14px 0 0;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
}
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
}
.brand-badge {
  width: 38px;
  height: 38px;
  background: var(--primary);
  color: #fff;
  font-size: 18px;
}
.brand-title {
  min-width: 0;
  display: grid;
  gap: 1px;
}
.brand-title strong {
  line-height: 1.15;
  font-size: 15px;
}
.brand-title span {
  color: var(--muted);
  font-size: 12px;
}
.nav {
  min-height: 0;
  display: grid;
  gap: 5px;
  overflow-y: auto;
}
.nav-section {
  margin: 14px 8px 5px;
  color: #8a96a6;
  font-size: 12px;
  font-weight: 700;
}
.nav button {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  text-align: left;
}
.nav button span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.nav button small {
  color: #98a2b3;
  font-size: 11px;
}
.nav button:hover {
  border-color: var(--line);
  background: #f8fbfa;
}
.nav button.is-active {
  border-color: #bce4dd;
  background: var(--primary-soft);
  color: var(--primary-strong);
}
.nav button.is-active small { color: var(--primary); }
.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 72px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 251, 250, 0.9);
  backdrop-filter: blur(12px);
}
.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.2;
}
.topbar p {
  margin: 3px 0 0;
  color: var(--muted);
}
.content {
  width: min(1320px, 100%);
  padding: 24px 26px 32px;
}

.standalone-page {
  background: var(--bg);
}
.standalone-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.page-head h1,
.page-head h2 {
  margin: 0;
  font-size: 26px;
  line-height: 1.2;
}
.page-head p {
  margin: 6px 0 0;
  color: var(--muted);
}

.section,
.api-doc,
.settings-form {
  display: grid;
  gap: 16px;
  min-width: 0;
}
.grid {
  display: grid;
  gap: 14px;
}
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

.panel,
.stat,
.table-wrap,
.notice,
.pay-box,
.upload-row {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}
.panel {
  min-width: 0;
  padding: 18px;
}
.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-header h2,
.panel-header h3 {
  margin: 0;
  font-size: 18px;
  line-height: 1.25;
}
.panel-header p {
  margin: 4px 0 0;
  color: var(--muted);
}
.panel-subtitle {
  margin: -6px 0 16px;
  color: var(--muted);
}

.stat {
  position: relative;
  min-width: 0;
  padding: 16px;
  overflow: hidden;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--primary);
}
.stat:nth-child(2)::before { background: var(--green); }
.stat:nth-child(3)::before { background: var(--blue); }
.stat:nth-child(4)::before { background: var(--amber); }
.stat span {
  display: block;
  color: var(--muted);
}
.stat strong {
  display: block;
  min-width: 0;
  margin-top: 8px;
  overflow-wrap: anywhere;
  font-size: 26px;
  line-height: 1.16;
}
.stat small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}
.field label {
  color: #344054;
  font-weight: 700;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #cbd7df;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
}
.field textarea {
  min-height: 96px;
  resize: vertical;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  outline: 3px solid rgba(15, 118, 110, 0.16);
}
.field input[readonly] {
  background: #f8fbfa;
  color: #3d4957;
}
.field-hint {
  color: var(--muted);
  font-size: 12px;
}
.settings-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
  gap: 16px;
}
.settings-stack {
  display: grid;
  gap: 16px;
}

.actions,
.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.button-row { justify-content: flex-end; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  max-width: 100%;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover {
  border-color: var(--line-strong);
  text-decoration: none;
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}
.btn.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.btn.primary:hover { background: var(--primary-strong); }
.btn.danger {
  border-color: #f0b9b4;
  color: var(--red);
}
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost {
  background: transparent;
  color: inherit;
}
.btn.small {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 13px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  max-width: 100%;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.status-pill.ok { background: var(--green-soft); color: var(--green); }
.status-pill.warn { background: var(--amber-soft); color: var(--amber); }
.status-pill.bad { background: var(--red-soft); color: var(--red); }
.status-pill.info { background: var(--blue-soft); color: var(--blue); }

.detail-list {
  display: grid;
  gap: 0;
  margin: 12px 0 0;
}
.detail-list div {
  min-width: 0;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}
.detail-list div:last-child { border-bottom: 0; }
.detail-list span {
  flex: 0 0 auto;
  color: var(--muted);
}
.detail-list strong {
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}

.table-wrap {
  min-width: 0;
  overflow: hidden;
}
.table-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}
.table-tools:last-child {
  border-top: 1px solid var(--line);
  border-bottom: 0;
}
.table-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
}
table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}
th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
th {
  background: #f8fbfa;
  color: #526070;
  font-size: 12px;
  font-weight: 800;
}
td { color: #263241; }
tr:last-child td { border-bottom: 0; }
.code-cell {
  max-width: 340px;
  word-break: break-all;
}
.cell-main { font-weight: 700; }
.cell-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.notice {
  padding: 14px;
  color: #344054;
}
.notice.accent {
  border-color: #bce4dd;
  background: var(--primary-soft);
}
.empty {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.qr-preview {
  width: 128px;
  height: 128px;
  display: grid;
  place-items: center;
  border: 1px dashed #b8c5d0;
  border-radius: var(--radius);
  background: #fff;
  overflow: hidden;
}
.qr-preview img,
.pay-qr img {
  max-width: 100%;
  max-height: 100%;
}
.qr-preview.large {
  width: 184px;
  height: 184px;
}
.bind-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 184px;
  gap: 18px;
  align-items: center;
}

.upload-list {
  display: grid;
  gap: 10px;
}
.upload-row {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr) 128px auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
}
.upload-thumb {
  width: 72px;
  height: 72px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.upload-row strong {
  display: block;
  min-width: 0;
}
.upload-drop {
  display: grid;
  place-items: center;
  min-height: 160px;
  padding: 22px;
  border: 1px dashed #b8c5d0;
  border-radius: var(--radius);
  background: #f8fbfa;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius);
  background: #18212c;
  color: #fff;
  box-shadow: var(--shadow);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: 0.18s ease;
}
.toast.show {
  transform: translateY(0);
  opacity: 1;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(24, 33, 44, 0.56);
}
.modal-backdrop.show { display: flex; }
.modal {
  width: min(600px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}
.modal header,
.modal footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.modal footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}
.modal header h2 {
  margin: 0;
  font-size: 18px;
}
.modal-body { padding: 18px; }

.api-doc pre {
  overflow-x: auto;
  margin: 14px 0 0;
  padding: 14px;
  border-radius: var(--radius);
  background: #18212c;
  color: #e6edf3;
}

.pay-page {
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f7fbf9 0%, #eef4f4 100%);
}
.pay-box {
  width: min(480px, 100%);
  padding: 22px;
}
.pay-brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.pay-title {
  margin: 8px 0 0;
  font-size: 24px;
  line-height: 1.2;
}
.amount {
  margin: 6px 0 16px;
  font-size: 38px;
  line-height: 1.08;
  font-weight: 850;
}
.countdown {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}
.countdown strong {
  min-width: 0;
  padding: 10px 8px;
  border-radius: var(--radius);
  background: var(--surface-muted);
  text-align: center;
  overflow-wrap: anywhere;
}
.pay-qr {
  display: grid;
  place-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
.pay-qr img {
  width: min(268px, 100%);
  aspect-ratio: 1;
}
.pay-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}
.pay-success,
.pay-expired,
.center-state {
  text-align: center;
}
.pay-success strong,
.pay-expired strong,
.center-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}
.return-actions {
  justify-content: center;
  margin-top: 16px;
}

@media (max-width: 1100px) {
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
}

@media (max-width: 920px) {
  .auth-shell,
  .app-shell,
  .grid.cols-2,
  .grid.cols-3,
  .form-grid {
    grid-template-columns: 1fr;
  }
  .app-shell,
  .main {
    width: 100vw;
    min-width: 0;
    max-width: 100vw;
  }
  .app-shell {
    overflow-x: hidden;
  }
  .sidebar,
  .topbar,
  .content {
    width: 100%;
    min-width: 0;
    max-width: 100vw;
  }
  .auth-shell { min-height: 0; }
  .auth-intro { padding: 30px; }
  .auth-panel { padding: 30px; }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    gap: 12px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .nav {
    display: flex;
    overflow-x: auto;
    padding-bottom: 2px;
  }
  .nav-section { display: none; }
  .nav button {
    width: auto;
    min-width: 128px;
    flex: 0 0 auto;
  }
  .nav button small { display: none; }
  .sidebar-footer {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .topbar { position: relative; }
  .content { padding: 18px; }
  .bind-card {
    grid-template-columns: 1fr;
  }
  .upload-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .upload-row .actions,
  .upload-row .field {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .auth-page,
  .pay-page,
  .standalone-page {
    padding: 16px 12px;
  }
  .auth-intro,
  .auth-panel,
  .pay-box {
    padding: 20px;
  }
  .auth-snapshot {
    grid-template-columns: 1fr;
  }
  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 14px 16px;
  }
  .topbar .actions,
  .page-head,
  .table-tools {
    align-items: stretch;
    flex-direction: column;
  }
  .topbar .btn,
  .auth-panel .btn,
  .pay-actions .btn,
  .return-actions .btn {
    width: 100%;
  }
  .button-row { justify-content: stretch; }
  .button-row .btn { flex: 1; }
  .grid.cols-4 { grid-template-columns: 1fr; }
  .detail-list div {
    display: grid;
    gap: 3px;
  }
  .detail-list strong {
    text-align: left;
  }
}
