* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #1e293b;
  background: linear-gradient(160deg, #eef2ff 0%, #f8fafc 45%, #f1f5f9 100%);
}

.page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.card {
  width: 100%;
  max-width: 440px;
  background: #fff;
  border-radius: 20px;
  padding: 36px 32px 32px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.08);
}

.card-wide {
  max-width: 1100px;
}

.card-result {
  max-width: 560px;
}


.title {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0 0 28px;
  font-size: 14px;
  color: #64748b;
  line-height: 1.6;
}

.field-label {
  display: block;
  margin-bottom: 10px;
  font-size: 15px;
  font-weight: 600;
  color: #0f172a;
}

.amount-wrap {
  position: relative;
}

.amount-prefix {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 700;
  color: #2563eb;
}

.amount-input {
  width: 100%;
  height: 56px;
  padding: 0 16px 0 42px;
  border: none;
  border-radius: 12px;
  background: #f1f5f9;
  font-size: 22px;
  font-weight: 600;
  color: #0f172a;
  outline: none;
  transition: box-shadow .2s, background .2s;
}

.amount-input:focus {
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-select,
.field-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: #f1f5f9;
  font-size: 15px;
  color: #0f172a;
  outline: none;
  transition: box-shadow .2s, background .2s;
}

.field-select:focus,
.field-input:focus {
  background: #eef2ff;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field-block {
  margin-bottom: 18px;
}

.field-hint {
  margin: 10px 0 24px;
  font-size: 13px;
  color: #94a3b8;
}

.btn-primary {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 12px;
  background: #2563eb;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-primary:active {
  transform: scale(0.99);
}

.btn-primary:disabled {
  opacity: .65;
  cursor: not-allowed;
}

.message {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.message.error {
  background: #fef2f2;
  color: #b91c1c;
}

.message.success {
  background: #ecfdf5;
  color: #047857;
}

/* Admin layout */
.admin-shell {
  min-height: 100vh;
  display: flex;
}

.admin-sidebar {
  width: 220px;
  background: #0f172a;
  color: #cbd5e1;
  padding: 24px 16px;
  flex-shrink: 0;
}

.admin-brand {
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 28px;
  padding: 0 8px;
}

.admin-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.admin-nav button {
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: inherit;
  padding: 12px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.admin-nav button.active,
.admin-nav button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.admin-main {
  flex: 1;
  padding: 24px;
  overflow: auto;
}

.admin-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.admin-topbar h2 {
  margin: 0;
  font-size: 22px;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #64748b;
  font-size: 14px;
}

.panel-card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.06);
  margin-bottom: 20px;
}

.panel-card h3 {
  margin: 0 0 16px;
  font-size: 16px;
}

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

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  color: #475569;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.btn {
  border: none;
  background: #2563eb;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

.btn.secondary {
  background: #fff;
  color: #2563eb;
  border: 1px solid #2563eb;
}

.btn.danger {
  background: #ef4444;
}

.hint {
  margin-top: 10px;
  font-size: 12px;
  color: #94a3b8;
}

.mono {
  font-family: Consolas, "Courier New", monospace;
  word-break: break-all;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  border-bottom: 1px solid #f1f5f9;
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.ok { color: #16a34a; }
.fail { color: #dc2626; }

.result-box {
  margin-top: 16px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  font-family: Consolas, monospace;
  font-size: 12px;
}

.upstream-card {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  margin-top: 12px;
}

.link-list {
  margin-top: 20px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.link-list-title {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.link-row {
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid #e2e8f0;
}

.link-row:last-child {
  border-bottom: none;
}

.link-no {
  flex-shrink: 0;
  width: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f1f5f9;
  color: #475569;
  font-size: 14px;
  font-weight: 700;
  border-right: 1px solid #e2e8f0;
}

.link-item {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 10px 14px;
  color: #2563eb;
  text-decoration: none;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
  background: #fff;
  transition: background .2s;
}

.link-row:hover .link-no {
  background: #eef2ff;
  color: #2563eb;
}

.link-item:hover {
  background: #f8fafc;
}

.link-empty {
  margin-top: 16px;
  font-size: 14px;
  color: #94a3b8;
}

.hidden { display: none !important; }

@media (max-width: 768px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px;
  }
  .admin-brand { margin-bottom: 0; width: 100%; }
  .admin-nav { flex-direction: row; flex-wrap: wrap; width: 100%; }
  .admin-nav button { width: auto; }
}
