﻿:root {
  --bg: #fafbfc;
  --surface: #ffffff;
  --surface-2: #f3f5f7;
  --border: #e2e6ea;
  --border-focus: #0969da;
  --text: #1f2328;
  --text-muted: #656d76;
  --accent: #0969da;
  --accent-hover: #0550ae;
  --accent-glow: rgba(9, 105, 218, 0.12);
  --success: #1a7f37;
  --success-bg: #dafbe1;
  --danger: #cf222e;
  --danger-bg: #ffebe9;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(31, 35, 40, 0.04), 0 1px 2px rgba(31, 35, 40, 0.06);
  --shadow-md: 0 4px 12px rgba(31, 35, 40, 0.06), 0 1px 4px rgba(31, 35, 40, 0.04);
}

[data-theme="dark"] {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --border: #30363d;
  --border-focus: #58a6ff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --accent-glow: rgba(88, 166, 255, 0.15);
  --success: #3fb950;
  --success-bg: rgba(63, 185, 80, 0.1);
  --danger: #f85149;
  --danger-bg: rgba(248, 81, 73, 0.1);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 1px 2px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.25), 0 1px 4px rgba(0, 0, 0, 0.15);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 64px 24px 40px;
}

.header {
  margin-bottom: 28px;
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

.header h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.3px;
}

.header .badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  background: var(--accent-glow);
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  border-radius: 20px;
}

.header .badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card + .card { margin-top: 16px; }

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 5px; }
.field-help { margin-top: 5px; font-size: 12px; color: var(--text-muted); line-height: 1.45; }
.proxy-controls { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; }
.proxy-controls .field { margin-bottom: 16px; }
.mode2-paypal-switch { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; padding: 13px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); cursor: pointer; }
.mode2-paypal-switch span { flex: 1; min-width: 0; }
.mode2-paypal-switch strong, .mode2-paypal-switch small { display: block; }
.mode2-paypal-switch strong { font-size: 14px; color: var(--text); }
.mode2-paypal-switch small { margin-top: 3px; font-size: 12px; color: var(--text-muted); }
.mode2-paypal-switch input { position: absolute; opacity: 0; pointer-events: none; }
.mode2-paypal-switch i { position: relative; width: 42px; height: 24px; flex: 0 0 42px; border-radius: 999px; background: var(--border); transition: background .18s ease; }
.mode2-paypal-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .18s ease; }
.mode2-paypal-switch input:checked + i { background: var(--accent); }
.mode2-paypal-switch input:checked + i::after { transform: translateX(18px); }
.mode2-paypal-options { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; margin-bottom: 8px; }
.mode2-paypal-input { grid-column: 1 / -1; display: block; padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius-sm); background: var(--accent-glow); }
.mode2-paypal-options[hidden], .mode2-paypal-input[hidden] { display: none; }
.mode2-paypal-input .field { min-width: 0; margin-bottom: 0; }
.mode2-paypal-code-controls { display: grid; grid-template-columns: minmax(0, 1fr) 136px; align-items: stretch; gap: 10px; }
.mode2-paypal-code-controls input, .mode2-paypal-code-controls button { height: 40px; }
.mode2-paypal-code-controls button { width: 136px; padding-inline: 12px; white-space: nowrap; }
.proxy-pool-field { flex: 0 0 150px; min-width: 140px; }
.proxy-region-field { flex: 0 0 150px; min-width: 140px; }
#mode5ProxyModeField { flex-basis: 190px; }
#mode5ProxyRegionField { flex-basis: 170px; }

textarea, input, select {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
  height: 200px;
  resize: none;
  font-family: "SF Mono", "Cascadia Code", "Menlo", monospace;
  font-size: 13px;
  overflow-y: auto;
  overflow-x: hidden;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-all;
}

.token-meta-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-top: 5px;
  min-height: 34px;
}
.token-refresh {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  padding: 0;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.token-refresh:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--surface-2); }
.token-refresh[hidden] { display: none; }
.token-refresh.loading svg { animation: spin 0.75s linear infinite; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--surface-2); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--text-muted) var(--surface-2); }

textarea:focus, input:focus, select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

input[readonly] { background: var(--surface-2); color: var(--text-muted); cursor: default; }

.input-label-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 5px; }
.input-label-row label { margin-bottom: 0; }
.mode-hint { font-size: 12px; font-weight: 600; color: var(--accent); }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23656d76' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.mode-config-grid { grid-template-columns: minmax(0, 1.2fr) repeat(2, minmax(0, .8fr)) minmax(0, 1fr); }
.grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }

.token-meta { flex: 1 1 auto; padding-top: 2px; font-size: 12px; color: var(--text-muted); min-height: 17px; line-height: 1.45; word-break: break-word; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

.toggle-advanced { display: inline-flex; align-items: center; gap: 5px; padding: 6px 0; font-size: 13px; color: var(--text-muted); cursor: pointer; border: none; background: none; transition: color 0.15s; }
.toggle-advanced:hover { color: var(--accent); }
.toggle-advanced svg { transition: transform 0.2s; }
.toggle-advanced.open svg { transform: rotate(90deg); }

.advanced-panel { display: none; margin-top: 12px; }
.advanced-panel.show { display: block; }

.actions { display: flex; gap: 8px; align-items: center; margin-top: 20px; flex-wrap: wrap; }

button, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; border: none; border-radius: var(--radius-sm); padding: 0 16px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-decoration: none; transition: all 0.15s;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-danger-outline { background: transparent; color: var(--danger); border: 1.5px solid var(--danger); font-weight: 600; }
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #15652c; }
button:disabled, a.btn.disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.35); border-top-color: #fff; border-radius: 50%; animation: spin 0.5s linear infinite; }
.spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

.progress-bar { display: none; height: 6px; background: var(--surface-2); border-radius: 3px; margin-top: 14px; overflow: hidden; }
.progress-bar.active { display: block; }
.progress-bar-fill { height: 100%; background: var(--accent); border-radius: 3px; width: 0%; transition: width 0.4s ease; }
.progress-text { display: none; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.progress-text.active { display: block; }

.mode7-input-tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; margin-bottom: 14px; padding: 3px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); }
.mode7-input-tabs[hidden] { display: none; }
.mode7-input-tab { height: 36px; border: 0; border-radius: 5px; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 700; cursor: pointer; transition: color 0.15s, background 0.15s, box-shadow 0.15s; }
.mode7-input-tab:hover:not(:disabled) { color: var(--text); background: var(--surface-2); }
.mode7-input-tab.active { color: var(--text); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border), var(--shadow); }
.mode7-input-tab:disabled { cursor: not-allowed; opacity: 0.65; }
.mode7-batch-panel { margin: 0 0 18px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.mode7-batch-panel[hidden] { display: none; }
.mode7-batch-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; }
.mode7-batch-title { font-size: 14px; font-weight: 700; color: var(--text); }
.mode7-batch-help { margin-top: 3px; font-size: 12px; line-height: 1.5; color: var(--text-muted); }
.mode7-batch-count { flex: 0 0 auto; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--accent); }
.mode7-batch-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mode7-file-button { display: inline-flex; align-items: center; justify-content: center; height: 38px; padding: 0 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 700; cursor: pointer; }
.mode7-file-button:hover { border-color: var(--accent); }
.mode7-concurrency-label { margin-left: 4px; font-size: 12px; color: var(--text-muted); }
input.mode7-concurrency { width: 70px; height: 38px; }
.mode7-batch-controls button { height: 38px; }
.mode7-batch-summary { min-height: 20px; margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.mode7-batch-progress { height: 5px; overflow: hidden; border-radius: 999px; background: var(--border); }
.mode7-batch-progress > div { width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width 0.2s ease; }
.mode7-batch-list { display: grid; gap: 5px; max-height: 280px; margin-top: 10px; overflow-y: auto; }
.mode7-batch-row { display: grid; grid-template-columns: 48px minmax(120px, 0.8fr) minmax(160px, 1.2fr); align-items: center; gap: 8px; min-height: 34px; padding: 6px 9px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); font-size: 12px; }
.mode7-batch-index { color: var(--text-muted); font-family: "SF Mono","Cascadia Code","Menlo",monospace; }
.mode7-batch-identity, .mode7-batch-state { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mode7-batch-state { text-align: right; color: var(--text-muted); }
.mode7-batch-row.is-running { border-color: rgba(9,105,218,0.35); }
.mode7-batch-row.is-running .mode7-batch-state { color: var(--accent); }
.mode7-batch-row.is-success { border-color: rgba(26,127,55,0.32); background: var(--success-bg); }
.mode7-batch-row.is-success .mode7-batch-state { color: var(--success); }
.mode7-batch-row.is-error { border-color: rgba(207,34,46,0.28); background: var(--danger-bg); }
.mode7-batch-row.is-error .mode7-batch-state { color: var(--danger); }

.status-bar { margin-top: 10px; min-height: 22px; font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.status-bar.error { color: var(--danger); }
.status-bar.success { color: var(--success); }

.result-card { display: none; margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.result-card.show { display: block; }
.result-header { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.result-row { margin-bottom: 10px; }
.result-row:last-child { margin-bottom: 0; }
.result-label { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; margin-bottom: 4px; }
.result-value { padding: 9px 12px; background: var(--surface-2); border-radius: var(--radius-sm); font-size: 13px; font-family: "SF Mono","Cascadia Code","Menlo",monospace; word-break: break-all; line-height: 1.5; border: 1px solid var(--border); }
.result-value.success-value { border-color: rgba(26,127,55,0.25); background: var(--success-bg); color: var(--success); }
.result-value.error-value { border-color: rgba(207,34,46,0.25); background: var(--danger-bg); color: var(--danger); }
.upi-qr-shell { position: relative; display: inline-block; width: min(280px, 100%); padding: 12px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; vertical-align: top; }
.upi-qr-shell img { display: block; width: 100%; height: auto; max-height: 280px; background: #fff; image-rendering: pixelated; transition: filter 0.2s ease; }
.upi-qr-shell.is-terminal img { filter: blur(6px); }
.upi-qr-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 14px; text-align: center; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; color: #fff; }
.upi-qr-overlay.show { opacity: 1; }
.upi-qr-overlay-icon { width: 72px; height: 72px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 44px; line-height: 1; font-weight: 800; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,0.25); }
.upi-qr-overlay-text { font-size: 22px; font-weight: 800; letter-spacing: 1px; text-shadow: 0 1px 6px rgba(0,0,0,0.45); }
.upi-qr-overlay.variant-paid { background: rgba(26,127,55,0.86); }
.upi-qr-overlay.variant-paid .upi-qr-overlay-icon { color: #1a7f37; }
.upi-qr-overlay.variant-expired { background: rgba(191,73,14,0.86); }
.upi-qr-overlay.variant-expired .upi-qr-overlay-icon { color: #bf490e; }
.upi-qr-overlay.variant-failed { background: rgba(207,34,46,0.86); }
.upi-qr-overlay.variant-failed .upi-qr-overlay-icon { color: #cf222e; }

.error-detail { display: none; margin-top: 14px; }
.error-detail.show { display: block; }
.error-detail pre { padding: 12px 14px; background: var(--danger-bg); border: 1px solid rgba(207,34,46,0.2); border-radius: var(--radius-sm); font-size: 12px; font-family: "SF Mono","Cascadia Code","Menlo",monospace; color: var(--danger); white-space: pre-wrap; word-break: break-all; max-height: 220px; overflow-y: auto; line-height: 1.55; }

@media (max-width: 768px) {
  main { padding: 64px 16px 20px; }
  .header h1 { font-size: 20px; }
  .grid-2, .grid-3, .grid-4, .mode-config-grid { grid-template-columns: minmax(0, 1fr); }
  .card { padding: 16px; }
  textarea { height: auto; min-height: 100px; max-height: none; resize: vertical; }
  .actions { flex-direction: column; align-items: stretch; }
  button, a.btn { width: 100%; }
  .token-refresh { width: 34px; height: 34px; }
  .mode7-batch-head { flex-direction: column; }
  .mode7-batch-count { max-width: 100%; }
  .mode7-batch-controls > * { width: auto; }
  .mode7-batch-row { grid-template-columns: 42px minmax(90px, 0.75fr) minmax(120px, 1.25fr); }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-4, .mode-config-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Theme toggle */
.top-bar { position: fixed; top: 0; left: 0; padding: 16px 24px; z-index: 1100; display: flex; align-items: center; gap: 8px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface); color: var(--text-muted); cursor: pointer; transition: all 0.15s; box-shadow: var(--shadow); }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.language-select { width: auto; min-width: 88px; height: 36px; padding: 0 28px 0 10px; font-size: 12px; font-weight: 600; background-color: var(--surface); box-shadow: var(--shadow); }
.theme-toggle .icon-sun, .theme-toggle .icon-moon { width: 18px; height: 18px; flex-shrink: 0; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline-block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Login overlay */
.login-overlay { display: none; position: fixed; inset: 0; z-index: 1000; background: var(--bg); align-items: center; justify-content: center; }
.login-overlay.show { display: flex; }
.login-card { width: 100%; max-width: 380px; padding: 32px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-md); text-align: center; }
.login-card h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.login-card p { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }
.login-card input { margin-bottom: 14px; text-align: center; font-size: 15px; letter-spacing: 1px; }
.login-card .login-error { font-size: 13px; color: var(--danger); min-height: 20px; margin-bottom: 10px; }
.login-card button { width: 100%; }

/* Logout button */
.btn-logout { background: none; border: 1px solid var(--border); color: var(--text-muted); font-size: 12px; height: 32px; padding: 0 12px; border-radius: var(--radius-sm); }
.btn-logout:hover { color: var(--danger); border-color: var(--danger); }
.account-name { max-width: 180px; overflow: hidden; color: var(--text-muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Two-column Layout ===== */
.token-catalog-section { width: 100%; max-width: 1240px; margin: 0 auto; }
.token-catalog-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.token-catalog-heading h2 { font-size: 17px; line-height: 1.3; }
.token-catalog-heading p { margin-top: 2px; font-size: 12px; color: var(--text-muted); }
.token-catalog-heading-actions { display: flex; align-items: center; gap: 8px; }
.token-catalog-heading-actions .btn-primary { min-height: 34px; padding: 0 14px; }
.token-success-count { margin-left: 10px; color: var(--success); font-weight: 700; }
.token-catalog-refresh { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); }
.token-catalog-refresh:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.token-catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; align-items: start; }
.token-catalog-card { min-width: 0; padding: 15px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); transition: border-color .15s; }
.token-catalog-card:hover { border-color: var(--border-focus); }
.token-card-header { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center; }
.token-catalog-avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 6px; background: var(--success-bg); color: var(--success); font-size: 13px; font-weight: 800; }
.token-catalog-copy { min-width: 0; }
.token-catalog-name { overflow: hidden; color: var(--text); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.token-catalog-note { min-height: 17px; overflow: hidden; color: var(--text-muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.token-card-controls { display: flex; gap: 8px; margin-top: 10px; }
.token-catalog-action { flex: 1; min-width: 0; height: 34px; white-space: nowrap; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.token-catalog-action:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
.token-catalog-stop { flex: 0 0 86px; width: 86px; height: 34px; padding-inline: 0; }
.token-catalog-action[hidden], .token-catalog-stop[hidden], .token-catalog-pagination[hidden] { display: none !important; }
.token-catalog-card.is-running { border-color: var(--accent); }
.token-catalog-card.is-running .token-catalog-action { color: #fff; background: var(--accent); border-color: var(--accent); }
.token-card-detail { min-height: 390px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.token-card-detail[hidden], .main-layout[hidden] { display: none !important; }
.token-card-progress { height: 5px; overflow: hidden; border-radius: 3px; background: var(--surface-2); }
.token-card-progress > div { width: 0; height: 100%; border-radius: 3px; background: var(--accent); transition: width .25s ease; }
.token-card-status { min-height: 20px; margin: 6px 0 10px; color: var(--text-muted); font-size: 11px; }
.token-card-status.is-countdown { display: inline-flex; align-items: center; min-height: 30px; padding: 5px 10px; border: 1px solid var(--accent); border-radius: 6px; background: var(--accent-glow); color: var(--accent); font-family: "SF Mono", "Cascadia Code", monospace; font-size: 15px; font-weight: 800; font-variant-numeric: tabular-nums; }
.token-card-output { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 12px; }
.token-card-label { margin-bottom: 6px; color: var(--text-muted); font-size: 11px; font-weight: 700; }
.token-card-qr-shell { display: grid; place-items: center; width: 100%; aspect-ratio: 1; overflow: hidden; border: 1px solid var(--border); border-radius: 6px; background: #fff; color: #687281; font-size: 11px; }
.token-card-qr-shell img { display: block; width: 100%; height: 100%; object-fit: contain; }
.token-catalog-card.is-expired .token-card-qr-shell img { filter: grayscale(1); opacity: .35; }
.token-catalog-card.is-expired .token-card-status { color: var(--danger); font-weight: 700; }
.token-card-qr-shell img[hidden], .token-card-qr-shell span[hidden] { display: none; }
.token-card-log { height: 180px; overflow: auto; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text-muted); font-family: "SF Mono", "Cascadia Code", monospace; font-size: 10px; line-height: 1.55; }
.token-card-log-line + .token-card-log-line { margin-top: 4px; }
.token-card-log-line.is-success { color: var(--success); }
.token-card-log-line.is-error { color: var(--danger); }
.token-card-link-panel { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.token-card-link { display: block; min-height: 36px; padding: 8px 10px; overflow-wrap: anywhere; border-radius: 5px; background: var(--surface-2); color: var(--accent); font-family: "SF Mono", "Cascadia Code", monospace; font-size: 10px; text-decoration: none; }
.token-card-link:not([href]) { color: var(--text-muted); }
.token-card-link-actions { display: flex; gap: 8px; margin-top: 8px; }
.token-card-link-actions button, .token-card-link-actions a { min-width: 96px; height: 34px; }
.token-catalog-empty { padding: 18px 0; color: var(--text-muted); font-size: 13px; text-align: center; }
.token-catalog-pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; color: var(--text-muted); font-size: 12px; }
.token-catalog-pagination button { height: 34px; }

.main-layout { display: grid; grid-template-columns: minmax(0, 1fr) 440px; gap: 20px; align-items: stretch; min-width: 0; }
.main-layout.jp-hidden { grid-template-columns: minmax(0, 1fr); width: 100%; max-width: 920px; margin-inline: auto; }
.main-layout.jp-hidden .jp-panel { display: none; }
.main-layout.jp-hidden .pp-panel { width: 100%; }
.main-layout > *, .pp-panel, .pp-panel > div, .field, #accessTokenField { min-width: 0; }
.main-layout > .card + .card { margin-top: 0; }
@media (max-width: 1100px) { .main-layout { grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; } }
@media (max-width: 900px) { .main-layout { grid-template-columns: minmax(0, 1fr); } }

/* ===== JP Generator ===== */
.jp-panel { align-self: start; }
.jp-gen-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.jp-gen-header h2 { font-size: 18px; font-weight: 700; }
.jp-country-badge { display: inline-flex; align-items: center; padding: 2px 8px; font-size: 11px; font-weight: 700; color: var(--danger); background: var(--danger-bg); border-radius: 20px; }
.jp-country-badge.is-br { color: var(--success); background: var(--success-bg); }
.jp-country-badge.is-us { color: var(--accent); background: var(--accent-glow); }
.jp-country-badge.is-gb { color: #6d28d9; background: #ede9fe; }
[data-theme="dark"] .jp-country-badge.is-gb { color: #c4b5fd; background: rgba(139, 92, 246, 0.16); }
.jp-country-tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; margin-bottom: 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.jp-country-tab { height: 30px; border: none; border-radius: 4px; background: transparent; color: var(--text-muted); font-size: 13px; font-weight: 700; cursor: pointer; transition: background 0.15s, color 0.15s; }
.jp-country-tab:hover { color: var(--text); background: var(--surface-2); }
.jp-country-tab.active { color: var(--text); background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--border); }
.jp-gen-btn { width: 100%; height: 38px; background: linear-gradient(135deg, #e53935, #d32f2f); color: #fff; font-size: 14px; font-weight: 700; border: none; border-radius: var(--radius-sm); cursor: pointer; margin-bottom: 14px; transition: opacity 0.15s; }
.jp-gen-btn:hover { opacity: 0.9; }

.jp-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; margin-bottom: 12px; }
.jp-fields .jp-cell { background: var(--surface); padding: 7px 9px; }
.jp-fields .jp-cell.full { grid-column: 1 / -1; }
.jp-fields.is-jp .jp-cell[data-field="street"] { grid-column: auto; }

.jp-field-label { font-size: 14px; font-weight: 600; color: var(--text-muted); letter-spacing: 0.2px; margin-bottom: 4px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.jp-field-value { font-size: 16px; font-weight: 500; color: var(--text); word-break: break-all; line-height: 1.4; font-family: "SF Mono","Cascadia Code","Menlo",monospace; }

.jp-copy-btn { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; min-width: 46px; height: 26px; padding: 0 10px; font-size: 12px; font-weight: 700; color: #fff; background: #5c6bc0; border: none; border-radius: 5px; cursor: pointer; transition: background 0.15s, opacity 0.15s; white-space: nowrap; }
.jp-copy-btn:hover { background: #4f5fb5; }
.jp-copy-btn.copied { background: var(--success); }

.jp-copy-all-btn { width: 100%; height: 36px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-size: 13px; font-weight: 700; color: var(--text); cursor: pointer; transition: border-color 0.15s, background 0.15s; }
.jp-copy-all-btn:hover { border-color: var(--accent); background: var(--accent-glow); }

@media (max-width: 768px) {
  .jp-fields { grid-template-columns: 1fr 1fr; }
  .jp-fields .jp-cell.full { grid-column: 1 / -1; }
  .jp-fields.is-jp .jp-cell[data-field="street"] { grid-column: auto; }
}

@media (max-width: 640px) {
  .token-catalog-grid { grid-template-columns: 1fr; }
  .token-card-detail { min-height: 0; }
  .token-card-output { grid-template-columns: 1fr; }
  .token-card-qr-shell { width: min(240px, 100%); margin-inline: auto; }
  .mode2-paypal-options { grid-template-columns: 1fr; }
  .proxy-controls { flex-direction: column; gap: 0; }
  .proxy-pool-field { flex-basis: auto; width: 100%; }
  .proxy-region-field { flex-basis: auto; width: 100%; }
}

@media (max-width: 480px) {
  .mode2-paypal-code-controls { grid-template-columns: minmax(0, 1fr); }
  .mode2-paypal-code-controls button { width: 100%; }
}
