:root {
  --bg: #0c1320;
  --panel: #151f2e;
  --line: #2b3748;
  --text: #edf4ff;
  --muted: #91a4c5;
  --accent: #5d9cff;
  --ok: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }
.admin-login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.admin-login-card { width: min(420px, 100%); }
.admin-login-card form { margin: 24px 0 20px; }
.admin-login-card input, .admin-login-card button { width: 100%; }
.admin-login-error { color: #fca5a5; margin: 0 0 14px; }

.hero-copy { display: flex; flex: 1; min-width: 0; flex-direction: column; justify-content: center; }
.mode-switch { display: flex; gap: 8px; margin-top: 12px; }
.mode-link { padding: 8px 11px; border: 1px solid var(--line); border-radius: 6px; color: var(--muted); text-decoration: none; font-size: 13px; }
html:not(.admin-mode) .admin-only-panel { display: none !important; }
html.admin-mode .client-only-panel { display: none !important; }
html:not(.admin-mode) #account-import-tabs { display: none; }
.legacy-hidden { display: none !important; }
.hidden { display: none !important; }
.email-authorization-form { display: flex; align-items: end; gap: 14px; }
.email-authorization-form label { flex: 1; min-width: 0; }
.email-authorization-form input { width: 100%; }
.email-authorization-form textarea { width: 100%; min-height: 94px; resize: vertical; }
#email-authorization-submit:disabled { opacity: .55; cursor: wait; }
#email-batch-state:not(:empty) { margin-bottom: 10px; }
#account-import-panel table { min-width: 940px; table-layout: fixed; }
#account-import-panel th { width: 90px; }
#account-import-panel th:first-child { width: 42px; }
#account-import-panel th:nth-child(2) { width: auto; }
#account-import-panel th:nth-child(6) { width: 150px; }
#account-import-panel th:last-child { width: 140px; }
#vault-account-body td:nth-child(6) { overflow: hidden; text-overflow: ellipsis; }
#vault-account-body td:last-child button + button { margin-left: 8px; }
#vault-workspace-editor { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; }
#account-import-panel th,
#vault-account-body td { white-space: nowrap; }
#vault-account-body td { padding-top: 9px; padding-bottom: 9px; }
#vault-account-body td:nth-child(2) { overflow: hidden; text-overflow: ellipsis; }
.vault-pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; }
.vault-pagination button:disabled { opacity: .4; cursor: not-allowed; }
@media (max-width: 600px) {
  .email-authorization-form { flex-direction: column; align-items: stretch; }
}

@media (max-width: 860px) {
  .hero { display: grid; grid-template-columns: 1fr; }
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
}

.app {
  width: min(1480px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 32px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(680px, 1fr) 360px;
  gap: 20px;
  align-items: start;
}

.left-pane, .right-pane {
  min-width: 0;
}

.right-pane {
  position: sticky;
  top: 18px;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: center;
  margin-bottom: 20px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.3;
}

h2 { margin: 0 0 8px; font-size: 18px; }
p { margin: 0; }
.sub, .panel-head p { color: var(--muted); line-height: 1.65; }

.summary, .panel {
  border: 1px solid var(--line);
  background: var(--panel);
}

.summary {
  min-width: 128px;
  border-radius: 8px;
  padding: 12px 16px;
}

.summary span { color: var(--muted); display: block; margin-bottom: 6px; }
.summary strong { font-size: 24px; }

.panel {
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 16px;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}

.token-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 16px;
}

label { display: block; margin-bottom: 14px; }
label span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

input, textarea {
  width: 100%;
  color: var(--text);
  background: rgba(3, 8, 19, .78);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font: inherit;
}

select {
  width: 100%;
  color: var(--text);
  background: rgba(3, 8, 19, .78);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  outline: none;
  font: inherit;
}

textarea {
  resize: vertical;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.compact-textarea {
  height: 76px;
  min-height: 76px;
  max-height: 96px;
}

input:focus, textarea:focus, select:focus { border-color: rgba(93, 156, 255, .72); }

.wide { grid-column: span 2; }

.actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.k12-bottom-actions {
  flex-wrap: nowrap;
}

.k12-flow-hint {
  margin: 2px 0 10px;
}

.k12-bottom-actions #k12-open-btn {
  margin-right: auto;
}

.k12-bottom-actions select {
  width: 170px;
}

.sub2-upload-grid {
  display: grid;
  grid-template-columns: 1.4fr .8fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

html:not(.admin-mode) .layout { grid-template-columns: minmax(0, 1fr); }
html.admin-mode .layout { grid-template-columns: minmax(620px, 1fr) 400px; }

.protocol-sub2-run-controls {
  display: grid;
  grid-template-columns: minmax(150px, 220px) minmax(230px, 320px) minmax(220px, 1fr);
  gap: 14px;
  align-items: end;
  margin: 2px 0 14px;
}

.protocol-sub2-run-controls label {
  margin: 0;
}

.protocol-sub2-poll-toggle {
  min-height: 47px;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(3, 8, 19, .5);
  cursor: pointer;
}

.output-toggle { min-width: 260px; margin: 0; }
.sub2-settings { padding-top: 16px; border-top: 1px solid var(--line); }

.protocol-sub2-poll-toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  flex: 0 0 42px;
  width: 42px;
  height: 24px;
  margin: 0;
  border-radius: 12px;
  background: rgba(145, 164, 197, .35);
  transition: background .18s ease;
}

.toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  margin: 0;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}

.protocol-sub2-poll-toggle > input:checked + .toggle-track {
  background: #22c55e;
}

.protocol-sub2-poll-toggle > input:checked + .toggle-track .toggle-thumb {
  transform: translateX(18px);
}

.protocol-sub2-poll-toggle > input:focus-visible + .toggle-track {
  outline: 2px solid #60a5fa;
  outline-offset: 3px;
}

.toggle-copy {
  min-width: 0;
  margin: 0;
}

.toggle-copy strong,
.toggle-copy small {
  display: block;
}

.toggle-copy strong {
  color: var(--text);
  font-size: 14px;
}

.toggle-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.protocol-sub2-poll-state {
  min-height: 47px;
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: rgba(3, 8, 19, .42);
  font-size: 13px;
  line-height: 1.45;
}

.protocol-sub2-poll-state.running {
  color: #9ef6bd;
  border-color: rgba(34, 197, 94, .36);
  background: rgba(34, 197, 94, .09);
}

.modal-card.sub2-oauth-card {
  width: min(520px, calc(100vw - 48px));
}

.sub2-oauth-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 12px 0 16px;
}

.hero-config-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, .8fr) minmax(150px, .7fr) minmax(150px, .7fr);
  gap: 12px;
  align-items: end;
}

.hero-config-grid label {
  min-width: 0;
}

.hero-country-controls {
  display: grid;
  gap: 8px;
}

.hero-country-controls input,
.hero-country-controls select {
  min-width: 0;
}

.hero-choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin-top: 14px;
}

.hero-choice-group {
  min-width: 0;
}

.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
}

.hero-check-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  min-height: 38px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.hero-check-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
}

.hero-check-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}

.hero-preview-result {
  margin-bottom: 0;
  color: #b9d7ff;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}

.tab-btn {
  padding: 8px 12px;
  font-size: 13px;
}

.tab-btn.active {
  border: 0;
  background: #2563eb;
}

.row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(74px, 1fr));
  gap: 8px;
  align-items: center;
  width: max-content;
}

.row-actions button {
  min-width: 74px;
  text-align: center;
}

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: rgba(255,255,255,.07);
  border-radius: 12px;
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 700;
}

button:hover { border-color: rgba(255,255,255,.25); transform: translateY(-1px); }

.email-copy {
  display: inline;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: copy;
}

.email-copy:hover {
  border-color: transparent;
  color: #67e8f9;
  transform: none;
}

.email-copy:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 3px;
}
.primary { border: 0; background: #2563eb; }
.protocol-register {
  color: #f0fdf4;
  border-color: rgba(74, 222, 128, .48);
  background: rgba(22, 163, 74, .24);
}
.ghost { background: transparent; }
.warn { color: #fff; background: rgba(245, 158, 11, .22); border-color: rgba(245, 158, 11, .45); }
.danger { color: #fff; background: rgba(239, 68, 68, .18); border-color: rgba(239, 68, 68, .35); }
.k12 { color: #fff; background: rgba(168, 85, 247, .24); border-color: rgba(168, 85, 247, .45); }
.small { padding: 7px 9px; font-size: 12px; }
.search { width: 240px; }

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
}

table {
  width: 100%;
  min-width: 1130px;
  border-collapse: collapse;
}

.console-log {
  min-height: calc(100vh - 230px);
  max-height: calc(100vh - 230px);
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e5ff;
  background: rgba(3, 8, 19, .82);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  tab-size: 2;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .45) transparent;
  user-select: text;
}

.console-log::selection,
.k12-log::selection { background: rgba(56, 189, 248, .28); }

.k12-log {
  min-height: 160px;
  max-height: 260px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: #d7e5ff;
  background: rgba(3, 8, 19, .82);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  line-height: 1.55;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

.log-panel {
  margin-bottom: 0;
}

th, td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  background: rgba(255,255,255,.04);
}

tr:last-child td { border-bottom: 0; }
.empty { color: var(--muted); text-align: center; padding: 32px; }
code { color: #b9d5ff; word-break: break-all; }

.badge {
  display: inline-flex;
  padding: 5px 8px;
  border-radius: 999px;
  color: #9ef6bd;
  background: rgba(34,197,94,.14);
  font-size: 12px;
  font-weight: 700;
}

.status-wait { color: #fde68a; background: rgba(245, 158, 11, .16); }
.status-doing { color: #bfdbfe; background: rgba(59, 130, 246, .16); }
.status-done { color: #9ef6bd; background: rgba(34,197,94,.14); }
.status-failed { color: #fecaca; background: rgba(239, 68, 68, .18); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 460px;
  padding: 13px 15px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #12203a;
}

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
  z-index: 20;
}

.modal-card {
  width: min(760px, 100%);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  background: #111c30;
}

.modal-card textarea {
  min-height: 240px;
}

.modal-card textarea.compact-textarea {
  height: 76px;
  min-height: 76px;
  max-height: 96px;
}

.row-actions button[onclick*="openSub2OAuthModal"] {
  display: none !important;
}

.token-modal-card {
  max-height: calc(100vh - 48px);
  overflow-y: auto;
}

.token-modal-fields {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

.token-modal-card .token-field {
  margin: 0;
}

.token-modal-card .token-field textarea {
  height: 170px;
  min-height: 110px;
  max-height: 240px;
}

.token-modal-card #token-modal-refresh-value {
  height: 120px;
}

.hidden { display: none; }

@media (max-width: 880px) {
  .hero, .panel-head { flex-direction: column; align-items: stretch; }
  .grid, .token-grid { grid-template-columns: 1fr; }
  .hero-config-grid, .hero-choice-grid, .sub2-upload-grid, .protocol-sub2-run-controls { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .layout, html.admin-mode .layout { grid-template-columns: minmax(0, 1fr); }
  .right-pane { position: static; }
  .console-log { min-height: 320px; max-height: 520px; }
}


/* ??????????????? */
table th, table td {
  padding-left: 12px;
  padding-right: 12px;
}

#account-body td:nth-child(1),
thead th:nth-child(1) { width: 42px; }
#account-body td:nth-child(2),
thead th:nth-child(2) { width: 290px; }
#account-body td:nth-child(3),
thead th:nth-child(3) { width: 120px; }
#account-body td:nth-child(4),
thead th:nth-child(4) { width: 80px; }
#account-body td:nth-child(5),
thead th:nth-child(5) { width: 300px; }
#account-body td:nth-child(6),
thead th:nth-child(6) { width: 80px; }
#account-body td:nth-child(7),
thead th:nth-child(7) { width: 120px; }
#account-body td:nth-child(8),
thead th:nth-child(8) { width: 170px; }
#account-body td:nth-child(9),
thead th:nth-child(9) { width: 170px; }

.account-select-head,
.account-select-cell {
  width: 42px;
  min-width: 42px;
  text-align: center;
}

.account-select {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: #22c55e;
  cursor: pointer;
}

.row-actions {
  grid-template-columns: repeat(2, minmax(58px, 1fr));
  gap: 6px;
  width: 170px;
}

.row-actions button {
  min-width: 58px;
}

.account-list-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.account-list-tools .search {
  flex: 0 1 240px;
}

.account-selection-state {
  color: #86efac;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

#authorization-tasks-panel table { table-layout: fixed; min-width: 1380px; }
#authorization-tasks-panel th:nth-child(1), #account-body td:nth-child(1) { width: 42px; }
#authorization-tasks-panel th:nth-child(2), #account-body td:nth-child(2) { width: auto; }
#authorization-tasks-panel th:nth-child(3), #account-body td:nth-child(3) { width: 300px; }
#authorization-tasks-panel th:nth-child(4), #account-body td:nth-child(4) { width: 200px; }
#authorization-tasks-panel th:nth-child(5), #account-body td:nth-child(5) { width: 96px; }
#authorization-tasks-panel th:nth-child(6), #account-body td:nth-child(6) { width: 155px; }
#authorization-tasks-panel th:nth-child(7), #account-body td:nth-child(7) { width: 270px; }
#account-body td { padding-top: 10px; padding-bottom: 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#account-body .email-copy { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#account-body .row-actions { display: flex; flex-wrap: nowrap; gap: 6px; width: auto; }
.credential-summary { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.credential-summary .badge { flex: none; }
#account-body .task-status-cell { white-space: normal; }
.task-status-detail { display: block; margin-top: 5px; font-size: 12px; line-height: 1.5; color: var(--muted); overflow-wrap: anywhere; }
.task-status-detail.is-error { color: #fca5a5; }
.task-batch-toolbar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin: 0 0 16px; }
.task-batch-toolbar button:disabled { opacity: .4; cursor: not-allowed; }

.proxy-pool-actions {
  margin-top: 2px;
}

#proxy-test-all-btn {
  min-width: 92px;
}

.proxy-test-overview {
  display: grid;
  gap: 8px;
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.proxy-test-overview-copy {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

#proxy-health-summary {
  color: #cbd8ec;
  font-weight: 700;
}

#proxy-test-progress-label {
  min-width: 110px;
  overflow-wrap: anywhere;
  text-align: right;
}

.proxy-test-progress {
  position: relative;
  width: 100%;
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: rgba(255, 255, 255, .08);
}

.proxy-test-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: #3b82f6;
  transition: width .18s ease;
}

.proxy-list-shell {
  margin-top: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(3, 8, 19, .46);
}

.proxy-list-head,
.proxy-list-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 68px 70px 104px 116px;
  gap: 7px;
  align-items: center;
}

.proxy-list-head {
  min-height: 34px;
  padding: 7px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, .04);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 700;
}

.proxy-list {
  max-height: 420px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, .4) transparent;
}

.proxy-list-row {
  min-height: 48px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}

.proxy-list-row:last-child {
  border-bottom: 0;
}

.proxy-list-row.is-testing {
  background: rgba(56, 189, 248, .055);
}

.proxy-address-text {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: #dbeafe;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.proxy-health-badge {
  display: inline-flex;
  width: 64px;
  min-height: 25px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.proxy-health-ok {
  color: #9ef6bd;
  border-color: rgba(34, 197, 94, .26);
  background: rgba(34, 197, 94, .12);
}

.proxy-health-bad {
  color: #fecaca;
  border-color: rgba(239, 68, 68, .3);
  background: rgba(239, 68, 68, .14);
}

.proxy-health-testing {
  color: #bae6fd;
  border-color: rgba(56, 189, 248, .3);
  background: rgba(56, 189, 248, .13);
}

.proxy-health-unknown {
  color: #d6deeb;
  border-color: rgba(148, 163, 184, .24);
  background: rgba(148, 163, 184, .1);
}

.proxy-latency,
.proxy-tested-at {
  color: var(--muted);
  font-size: 11px;
  white-space: nowrap;
}

.proxy-row-actions {
  display: grid;
  grid-template-columns: repeat(2, 54px);
  gap: 6px;
  justify-content: end;
}

.proxy-row-actions button {
  width: 54px;
  min-width: 54px;
}

.proxy-row-actions button:disabled,
#proxy-test-all-btn:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none;
}

.proxy-list-empty {
  margin: 0;
  padding: 26px 12px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 1120px) {
  html.admin-mode .layout {
    grid-template-columns: minmax(0, 1fr);
  }

  html.admin-mode .right-pane {
    position: static;
  }
}

@media (max-width: 680px) {
  .proxy-test-overview-copy {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  #proxy-test-progress-label {
    min-width: 0;
    text-align: left;
  }

  .proxy-list-head {
    display: none;
  }

  .proxy-list-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "address address"
      "status latency"
      "tested actions";
    gap: 7px 10px;
    min-height: 96px;
    padding: 10px;
  }

  .proxy-address-text { grid-area: address; }
  .proxy-health-badge { grid-area: status; }
  .proxy-latency { grid-area: latency; justify-self: end; }
  .proxy-tested-at { grid-area: tested; align-self: center; }
  .proxy-row-actions { grid-area: actions; }
}

.small {
  padding: 6px 7px;
  font-size: 12px;
}
