:root {
  --bg: #07111f;
  --panel: rgba(17, 28, 48, .9);
  --line: rgba(255, 255, 255, .1);
  --text: #edf4ff;
  --muted: #91a4c5;
  --accent: #5d9cff;
  --ok: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Microsoft YaHei", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(93, 156, 255, .28), transparent 34rem),
    radial-gradient(circle at 85% 10%, rgba(34, 197, 94, .14), transparent 28rem),
    var(--bg);
}

.app {
  width: min(1760px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 36px 0 52px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 430px;
  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: 24px;
  align-items: end;
  margin-bottom: 22px;
}

.tag {
  margin: 0 0 10px;
  color: #74f0b0;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.05;
}

h2 { margin: 0 0 8px; font-size: 20px; }
p { margin: 0; }
.sub, .panel-head p { color: var(--muted); line-height: 1.65; }

.summary, .panel {
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.025));
  box-shadow: 0 22px 60px rgba(0, 0, 0, .28);
  backdrop-filter: blur(16px);
}

.summary {
  min-width: 180px;
  border-radius: 20px;
  padding: 18px;
}

.summary span { color: var(--muted); display: block; margin-bottom: 6px; }
.summary strong { font-size: 34px; }

.panel {
  border-radius: 22px;
  padding: 22px;
  margin-bottom: 20px;
}

.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;
}

.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;
}

.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: linear-gradient(135deg, #3b82f6, #22c55e);
}

.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: linear-gradient(135deg, #3b82f6, #22c55e); }
.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: 14px;
  border: 1px solid var(--line);
  background: #12203a;
  box-shadow: 0 22px 60px rgba(0,0,0,.32);
}

.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;
  box-shadow: 0 22px 80px rgba(0,0,0,.45);
}

.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 { grid-template-columns: 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;
}

.small {
  padding: 6px 7px;
  font-size: 12px;
}
