:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --card: #ffffff;
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --ring: rgba(15, 23, 42, 0.16);
  --accent: #0ea5e9;
  --success: #16a34a;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

.app-shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--border);
  background: #fff;
  padding: 22px 16px;
}

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

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

.brand-title {
  font-size: 15px;
  font-weight: 650;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 12px;
}

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

.nav-item {
  border-radius: 8px;
  color: #334155;
  padding: 10px 12px;
  text-decoration: none;
  font-size: 14px;
}

.nav-item.active,
.nav-item:hover {
  background: #f1f5f9;
  color: var(--foreground);
}

.side-note {
  position: absolute;
  bottom: 20px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--success);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 22px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  letter-spacing: 0;
}

h2 {
  font-size: 17px;
  letter-spacing: 0;
}

p {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-bottom: 18px;
}

.two-col {
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.card-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.form,
.wide {
  display: grid;
  gap: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: #334155;
  font-size: 13px;
  font-weight: 550;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--foreground);
  font: inherit;
  font-size: 14px;
  padding: 10px 11px;
  outline: none;
}

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

input:focus,
select:focus,
textarea:focus {
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px var(--ring);
}

.checkbox {
  display: flex;
  grid-template-columns: auto 1fr;
  align-items: center;
  flex-direction: row;
}

.checkbox input {
  width: 16px;
  height: 16px;
}

.section-title {
  color: #0f172a;
  font-size: 14px;
  font-weight: 700;
  padding-top: 6px;
}

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

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

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

.button.secondary {
  border-color: var(--border);
  background: #fff;
  color: #0f172a;
}

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

.button.disabled {
  pointer-events: none;
  opacity: 0.48;
}

.qr-box {
  display: grid;
  min-height: 300px;
  place-items: center;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
  margin-bottom: 14px;
}

.qr-box img {
  width: 260px;
  height: 260px;
}

.qr-box.compact {
  min-height: 240px;
}

.qr-box.compact img {
  width: 220px;
  height: 220px;
}

.permanent-card {
  margin-top: 18px;
}

.permanent-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
  align-items: stretch;
}

.permanent-info {
  display: grid;
  align-content: start;
  gap: 12px;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.32fr) minmax(0, 0.68fr);
  gap: 18px;
  align-items: start;
}

.merchant-panel {
  position: sticky;
  top: 24px;
}

.merchant-list {
  display: grid;
  gap: 10px;
}

.merchant-item {
  display: grid;
  width: 100%;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--foreground);
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.merchant-item:hover,
.merchant-item.active {
  border-color: #94a3b8;
  box-shadow: 0 0 0 4px var(--ring);
}

.merchant-item strong {
  font-size: 14px;
}

.merchant-item span,
.merchant-item small {
  color: var(--muted);
  font-size: 12px;
}

.permanent-preview {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: stretch;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.empty-state {
  color: var(--muted);
  font-size: 14px;
}

pre {
  overflow: auto;
  min-height: 220px;
  margin: 0;
  border-radius: 8px;
  background: #020617;
  color: #dbeafe;
  font-size: 12px;
  line-height: 1.6;
  padding: 14px;
}

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

.order-item {
  display: grid;
  gap: 4px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.order-item strong {
  font-size: 13px;
}

.order-item span {
  color: var(--muted);
  font-size: 12px;
}

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

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

.pay-body {
  min-height: 100vh;
  background: #f8fafc;
}

.pay-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 18px;
}

.pay-panel {
  width: min(100%, 460px);
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 20px;
  box-shadow: 0 12px 36px rgba(15, 23, 42, 0.08);
}

.pay-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.pay-brand h1 {
  font-size: 24px;
}

.customer-form {
  display: grid;
  gap: 14px;
}

.button.full {
  width: 100%;
}

.channel-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.channel-strip span {
  display: grid;
  min-height: 32px;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: #334155;
  font-size: 12px;
  font-weight: 650;
  background: #f8fafc;
}

.customer-result {
  display: grid;
  gap: 12px;
}

.customer-qr {
  min-height: 260px;
}

.customer-qr:empty {
  display: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .side-note {
    position: static;
    margin-top: 18px;
  }

  .two-col,
  .field-row,
  .permanent-grid,
  .admin-layout,
  .permanent-preview {
    grid-template-columns: 1fr;
  }

  .merchant-panel {
    position: static;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    flex-direction: column;
  }
}

@media (max-width: 520px) {
  .pay-shell {
    align-items: start;
    padding: 12px;
  }

  .pay-panel {
    min-height: calc(100vh - 24px);
    box-shadow: none;
  }

  .channel-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
