* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f0f2f5;
  color: #1a1a1a;
}
a { color: #1677ff; text-decoration: none; }
a:hover { color: #4096ff; }

.app-shell {
  display: flex;
  min-height: 100vh;
}
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: #001529;
  color: rgba(255, 255, 255, 0.85);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  padding: 14px 16px 10px;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-brand .brand-logo {
  width: 64px;
  border-radius: 10px;
}
.brand-logo {
  display: block;
  height: auto;
  margin: 0 auto;
}
.sidebar-brand small {
  display: block;
  margin-top: 6px;
  font-size: 0.75rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.45);
}
.sidebar-portal-title {
  margin: 8px 0 0;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  line-height: 1.3;
}
.sidebar-brand--merchant .sidebar-portal-title {
  color: #69b1ff;
}
.sidebar-brand--admin .sidebar-portal-title {
  color: #faad14;
}
.sidebar-nav {
  flex: 1;
  padding: 12px 0;
  overflow-y: auto;
}
.sidebar-nav a {
  display: block;
  padding: 10px 20px;
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.9rem;
  border-left: 3px solid transparent;
  transition: background 0.15s, color 0.15s;
}
.sidebar-nav a:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.06);
}
.sidebar-nav a.active {
  color: #fff;
  background: #1677ff;
  border-left-color: #69b1ff;
}
.sidebar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}
.sidebar-user {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.sidebar-footer a {
  flex-shrink: 0;
  padding: 10px 10px;
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.9rem;
}
.sidebar-footer a:hover { color: #fff; }

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.page-header {
  background: #fff;
  padding: 16px 24px;
  border-bottom: 1px solid #e8e8e8;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.page-header h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
}
.content {
  flex: 1;
  padding: 20px 24px 32px;
}
.content-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.login-wrap { max-width: 360px; margin: 4rem auto; text-align: center; }
.login-wrap .brand-logo { width: 80px; margin-bottom: 0.35rem; border-radius: 12px; }
.login-sub { margin: 0 0 1.25rem; font-size: 1.15rem; font-weight: 600; letter-spacing: 0.06em; }
.login-sub--merchant { color: #0958d9; }
.login-sub--admin { color: #d46b08; }
.login-links { margin-top: 1rem; display: flex; gap: 1rem; justify-content: center; font-size: .9rem; }
.login-links a { color: #1677ff; }
.card { background: #fff; padding: 1.25rem; border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,.06); }
form label { display: block; margin-top: .75rem; text-align: left; font-size: .9rem; }
form input, form select { width: 100%; padding: .5rem; margin-top: .25rem; border: 1px solid #d9d9d9; border-radius: 4px; }
button, .btn {
  display: inline-block;
  margin-top: 1rem;
  padding: .5rem 1rem;
  background: #1677ff;
  color: #fff;
  border: 0;
  border-radius: 4px;
  text-decoration: none;
  cursor: pointer;
  font-size: .9rem;
}
button:hover, .btn:hover { background: #4096ff; color: #fff; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .65rem .75rem; border-bottom: 1px solid #f0f0f0; text-align: left; font-size: .9rem; }
th { background: #fafafa; font-weight: 600; color: #666; }
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.toolbar h2 { margin: 0; font-size: 1rem; }
.list-pager {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #f0f0f0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
}
.pager-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}
.pager-meta {
  color: #666;
  font-size: 0.9rem;
}
.pager-btn {
  display: inline-block;
  padding: 4px 12px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  color: #1677ff;
  font-size: 0.9rem;
  background: #fff;
}
.pager-btn:hover:not(.disabled) {
  border-color: #1677ff;
  color: #0958d9;
}
.pager-btn.disabled {
  color: #bbb;
  border-color: #eee;
  cursor: not-allowed;
}
.pager-size {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  color: #666;
}
.per-page-select,
.per-page-custom {
  padding: 4px 8px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  font-size: 0.9rem;
}
.per-page-custom {
  width: 72px;
}
.per-page-apply {
  padding: 4px 10px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  background: #fff;
  font-size: 0.9rem;
  cursor: pointer;
}
.per-page-apply:hover {
  border-color: #1677ff;
  color: #1677ff;
}
.pager { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; }
.flash.error { color: #cf1322; margin: 0 0 1rem; }
.flash.success { color: #389e0d; margin: 0 0 1rem; }
.form-grid { display: grid; grid-template-columns: 140px 1fr; gap: .5rem 1rem; align-items: center; max-width: 640px; }
.form-grid > label { margin-top: 0; }
.form-grid > input,
.form-grid > select,
.form-grid > div { margin-top: 0; }
.form-inline-check {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  margin: 0;
  font-weight: normal;
  cursor: pointer;
}
.form-inline-check input[type="checkbox"] {
  width: auto;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
}
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem 1rem; }
.detail-grid span { display: block; color: #666; font-size: .85rem; }
.hint { color: #666; font-size: .9rem; margin: 0 0 1rem; }
.form-note { margin: 0; color: #888; font-size: .85rem; }
.mono-sm { font-size: .78rem; word-break: break-all; }
.actions-cell { white-space: nowrap; }
.actions-cell a, .actions-cell .btn-copy, .actions-cell .btn-debug, .actions-cell .btn-delete { margin-right: .5rem; }
.btn-debug {
  display: inline-block;
  margin-top: 0;
  padding: .35rem .65rem;
  background: #fff;
  color: #389e0d;
  border: 1px solid #389e0d;
  border-radius: 4px;
  font-size: .8rem;
  text-decoration: none;
}
.btn-debug:hover { background: #f6ffed; color: #389e0d; }
.btn-copy {
  margin-top: 0;
  padding: .35rem .65rem;
  background: #fff;
  color: #1677ff;
  border: 1px solid #1677ff;
  font-size: .8rem;
}
.btn-copy:hover { background: #e6f4ff; color: #1677ff; }
.form-delete {
  display: inline;
  margin: 0;
}
.btn-delete {
  margin-top: 0;
  padding: .35rem .65rem;
  background: #fff;
  color: #cf1322;
  border: 1px solid #ffa39e;
  border-radius: 4px;
  font-size: .8rem;
  cursor: pointer;
}
.btn-delete:hover { background: #fff1f0; color: #cf1322; }
.actions-cell .form-delete { margin-right: .5rem; }
.copy-src { display: none; }
.integration-pre {
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  padding: 1rem;
  font-size: .85rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
}

.switch-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  vertical-align: middle;
}
.switch-text {
  font-size: .85rem;
  color: #595959;
  min-width: 2em;
}
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 22px;
  flex-shrink: 0;
}
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
  position: absolute;
}
.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #bfbfbf;
  border-radius: 22px;
  transition: background 0.2s;
}
.switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.switch input:checked + .switch-slider {
  background: #52c41a;
}
.switch input:checked + .switch-slider::before {
  transform: translateX(22px);
}
.switch input:disabled + .switch-slider {
  cursor: default;
  opacity: 0.85;
}
.switch-wrap--readonly .switch-slider {
  cursor: default;
}
.detail-span-2 { grid-column: 1 / -1; }
.merchant-detail-grid { max-width: 720px; }

body.confirm-dialog-open { overflow: hidden; }
.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.confirm-dialog[hidden] { display: none; }
.confirm-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.confirm-dialog-panel {
  position: relative;
  width: min(420px, 100%);
  background: #fff;
  border-radius: 10px;
  padding: 22px 24px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
}
.confirm-dialog-title {
  margin: 0 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f1f1f;
}
.confirm-dialog-message {
  margin: 0;
  color: #595959;
  font-size: 0.95rem;
  line-height: 1.6;
  white-space: pre-wrap;
}
.confirm-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}
.confirm-dialog-cancel,
.confirm-dialog-ok {
  margin-top: 0;
  min-width: 80px;
  padding: 7px 16px;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.confirm-dialog-cancel {
  background: #fff;
  color: #595959;
  border: 1px solid #d9d9d9;
}
.confirm-dialog-cancel:hover {
  color: #1677ff;
  border-color: #1677ff;
}
.confirm-dialog-ok {
  background: #ff4d4f;
  color: #fff;
  border: 1px solid #ff4d4f;
}
.confirm-dialog-ok:hover {
  background: #cf1322;
  border-color: #cf1322;
}

@media (max-width: 768px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .sidebar-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
  .sidebar-nav a { border-left: none; border-radius: 4px; padding: 6px 12px; }
  .sidebar-footer { display: none; }
  .content { padding: 16px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
}
