:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2329;
  --muted: #6b7280;
  --primary: #185fa5;
  --primary-strong: #0c447c;
  --success: #0f6e56;
  --danger: #a32d2d;
  --warn: #854f0b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
h1, h2, h3 { font-weight: 500; line-height: 1.4; }
h1 { font-size: 18px; margin: 0 0 4px; }
h2 { font-size: 15px; margin: 0 0 14px; }

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; font-weight: 500; }
.brand-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); display: inline-block; }
.link-btn { font-size: 13px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); color: var(--text); }
.link-btn:hover { border-color: var(--primary); color: var(--primary); }

.wrap { max-width: 1080px; margin: 24px auto; padding: 0 16px; }

.shell { max-width: 1080px; margin: 24px auto; padding: 0 16px; display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 20px; align-items: start; }
.main { min-width: 0; }
.tabs { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 20px; }
.tab {
  border: 1px solid transparent;
  background: transparent;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--muted);
  text-align: left;
  transition: background 0.15s, color 0.15s;
}
.tab:hover { background: #eef2f7; color: var(--text); }
.tab.active { background: var(--card); border-color: var(--border); color: var(--primary); font-weight: 500; box-shadow: var(--shadow); }
#logoutBtn { margin-top: auto; color: var(--danger); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.muted { color: var(--muted); font-size: 12px; }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 18px;
  background: var(--primary);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, transform 0.05s;
}
.btn:hover { background: var(--primary-strong); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: #f1f3f5; color: var(--text); }
.btn.ghost:hover { background: #e5e7eb; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #791f1f; }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 8px; }
.btn.big { width: 100%; padding: 14px; font-size: 16px; margin-top: 14px; }

label { display: block; margin: 12px 0 4px; color: #4b5563; font-size: 13px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  background: var(--card);
  color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #b5d4f4; border-color: var(--primary); }
input[type=checkbox] { width: auto; accent-color: var(--primary); transform: translateY(1px); }
textarea { min-height: 64px; resize: vertical; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > .col { flex: 1 1 220px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr)); gap: 12px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid #eef0f2; font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-weight: 500; background: #fafafa; white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 560px; }

.stat { padding: 18px 20px; }
.stat .muted { font-size: 13px; margin-bottom: 2px; }
.stat .total { font-size: 26px; }

.notice { padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: 13px; }
.notice.err { background: #fcebeb; color: #791f1f; }
.notice.ok { background: #e1f5ee; color: #085041; }
.notice.info { background: #e6f1fb; color: #0c447c; }
.hidden { display: none !important; }

.pay-shell { max-width: 960px; margin: 36px auto; }
.pay-msg { margin-bottom: 12px; }
.pay-content .pay-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.pay-summary, .pay-form { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
#linkMeta { margin-bottom: 12px; }

.product-line {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f1f3;
}
.product-line:last-child { border-bottom: 0; }
.product-line label { margin: 0; display: flex; gap: 10px; align-items: center; }
.product-line input[type=number] { width: 70px; }

.total-row { display: flex; justify-content: space-between; align-items: center; margin: 18px 0 4px; padding-top: 12px; border-top: 1px dashed var(--border); }
.total { font-size: 26px; font-weight: 500; color: var(--primary); }

.currency-wrap { position: relative; }
.currency-wrap .prefix {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}
.currency-wrap input { padding-left: 46px; }

.card-field { border: 1px solid #d1d5db; border-radius: 10px; padding: 10px; margin: 8px 0; min-height: 44px; background: var(--card); }
.card-field:focus-within { outline: 2px solid #b5d4f4; border-color: var(--primary); }

.badge { display: inline-block; padding: 3px 9px; border-radius: 12px; font-size: 12px; background: #f1f3f5; color: #4b5563; }
.badge.CAPTURED, .badge.COMPLETED { background: #e1f5ee; color: #085041; }
.badge.FAILED, .badge.DECLINED { background: #fcebeb; color: #791f1f; }
.badge.CREATED { background: #fae9da; color: var(--warn); }

.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px; word-break: break-all; }

@media (max-width: 920px) {
  .shell { display: block; }
  .tabs { flex-direction: row; overflow-x: auto; position: static; padding-bottom: 6px; margin-bottom: 4px; }
  .tab { white-space: nowrap; }
  #logoutBtn { margin-top: 0; margin-left: auto; }
  .pay-content .pay-layout { grid-template-columns: 1fr; }
  .pay-shell { margin: 18px auto; max-width: 560px; }
  .row > .col { flex: 1 1 100%; }
}

@media (max-width: 640px) {
  .topbar { padding: 10px 14px; }
  .wrap, .shell { margin: 14px auto; padding: 0 10px; }
  .card { padding: 14px; border-radius: 10px; margin-bottom: 12px; }
  .pay-shell { margin: 10px auto; }
  .pay-summary, .pay-form { padding: 14px; border-radius: 10px; }
  h1 { font-size: 17px; }
  .total { font-size: 22px; }
  input, select, textarea, .btn { font-size: 16px; }
  .card-field { min-height: 46px; padding: 11px; }
  th, td { padding: 8px; font-size: 12px; }
  .table-scroll table { min-width: 520px; }
  .product-line { align-items: flex-start; gap: 8px; }
  .product-line input[type=number] { width: 62px; flex: none; }
  .btn.big { padding: 13px; }
}

.steps { display: flex; align-items: center; gap: 10px; max-width: 560px; margin: 36px auto 14px; }
.step { font-size: 13px; color: var(--muted); white-space: nowrap; }
.step.active { color: var(--primary); font-weight: 500; }
.step-line { flex: 1; height: 1px; background: var(--border); }
.pay-shell { max-width: 560px; margin: 0 auto 32px; }
.pay-summary h1, .pay-form h1 { margin-bottom: 6px; }
#backBtn { background: transparent; border: 0; color: var(--primary); padding: 6px 0; font-size: 13px; }
#backBtn:hover { text-decoration: underline; }

.form-section { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 18px; padding: 18px 0; border-bottom: 1px solid var(--border); }
.form-section:last-of-type { border-bottom: 0; }
.form-cat { font-weight: 500; color: var(--text); padding-top: 4px; }
.form-body { min-width: 0; }
.radio-row { display: flex; gap: 18px; flex-wrap: wrap; }
.radio-row label { margin: 0; display: inline-flex; gap: 6px; align-items: center; font-size: 14px; color: var(--text); white-space: nowrap; }
.seg-row { display: flex; gap: 10px; flex-wrap: wrap; }
.seg {
  border: 1px solid var(--border);
  background: var(--card);
  padding: 9px 18px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.seg:hover { border-color: var(--primary); color: var(--primary); }
.seg.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 500; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

@media (max-width: 760px) {
  .form-section { grid-template-columns: 1fr; gap: 8px; }
  .form-cat { padding-top: 0; }
}
