/* 风格参考 https://team.k12.ltd/ — light console layout */
:root {
  color-scheme: light;
  --bg-body: #eff2f7;
  --bg-panel: rgba(255, 255, 255, 0.9);
  --bg-input: rgba(255, 255, 255, 0.62);
  --bg-term: #f8fafc;
  --term-header: rgba(255, 255, 255, 0.74);
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text-main: #2c3e50;
  --text-muted: #6f7d90;
  --accent: #409eff;
  --accent-hover: #79bbff;
  --green: #67c23a;
  --red: #f56c6c;
  --yellow: #e6a23c;
  --font-ui: Inter, "HarmonyOS Sans SC", "Microsoft YaHei", "PingFang SC",
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: SFMono-Regular, Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { min-height: 100%; }
body {
  min-height: 100vh;
  display: flex;
  overflow: hidden;
  color: var(--text-main);
  background: linear-gradient(120deg, #f0f7ff 0%, #e7f2ff 50%, #edf7ff 100%);
  font-family: var(--font-ui);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 420px;
  height: 420px;
  border-radius: 50%;
  filter: blur(70px);
  opacity: 0.42;
  content: "";
  pointer-events: none;
}
body::before { top: -170px; right: -110px; background: #b6d4ff; }
body::after { bottom: -190px; left: -130px; background: #7debdc; }

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: #337ecc; text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid rgba(64, 158, 255, 0.7); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 420px;
  min-width: 360px;
  height: 100vh;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.54);
  border-right: 1px solid var(--border);
  box-shadow: 2px 0 12px rgba(31, 38, 135, 0.12);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.top-links {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  display: flex;
  gap: 6px;
  z-index: 2;
}
.top-links a,
.top-links button {
  min-height: 30px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  text-decoration: none;
}
.top-links a:hover,
.top-links button:hover {
  color: #337ecc;
  border-color: rgba(64, 158, 255, 0.28);
}

.brand {
  padding: 1.5rem 6.5rem 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.34);
}
.brand h1 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-main);
}
.brand p {
  margin-top: 0.3rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

.task-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.85rem;
  padding: 0.38rem 0.65rem;
  border: 1px solid rgba(64, 158, 255, 0.2);
  border-radius: 999px;
  background: rgba(64, 158, 255, 0.1);
  color: #337ecc;
  font-size: 0.75rem;
  font-weight: 650;
}
.task-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.13);
}
.task-status-dot.busy {
  background: var(--yellow);
  box-shadow: 0 0 0 3px rgba(230, 162, 60, 0.18);
  animation: pulse 1s ease infinite;
}
@keyframes pulse {
  50% { opacity: 0.45; }
}

.control-group {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.form-label {
  display: block;
  margin-bottom: 0.55rem;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

input, select, textarea {
  width: 100%;
  padding: 0.65rem 0.75rem;
  outline: 0;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--text-main);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
input + input,
input + .input-grid,
textarea + .hint,
.input-grid + .input-grid { margin-top: 0.65rem; }
textarea { min-height: 82px; resize: vertical; font-family: var(--font-mono); font-size: 0.86rem; }
textarea.access-token-input { min-height: 140px; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--accent);
}

.hint {
  margin-top: 0.45rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.5;
}

.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.input-grid label > span {
  display: block;
  margin: 0 0 0.4rem 0.1rem;
  color: var(--text-muted);
  font-size: 0.75rem;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.segmented label { position: relative; min-width: 0; }
.segmented input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  opacity: 0;
  pointer-events: none;
}
.segmented span {
  display: grid;
  min-height: 42px;
  place-items: center;
  padding: 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.52);
  font-size: 0.82rem;
  text-align: center;
}
.segmented input:checked + span {
  color: #337ecc;
  border-color: rgba(64, 158, 255, 0.38);
  background: rgba(64, 158, 255, 0.12);
}

.cdk-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.55rem;
  align-items: stretch;
}
.cdk-row input { margin: 0; }
.cdk-row .btn-secondary { min-height: 100%; white-space: nowrap; }

.drop {
  margin-top: 0.65rem;
  border: 1.5px dashed rgba(64, 158, 255, 0.35);
  border-radius: 8px;
  padding: 0.85rem 0.75rem;
  text-align: center;
  color: var(--text-muted);
  background: rgba(64, 158, 255, 0.04);
  cursor: pointer;
  font-size: 0.78rem;
  transition: border-color 0.15s, background 0.15s;
}
.drop:hover, .drop.dragover {
  border-color: var(--accent);
  background: rgba(64, 158, 255, 0.1);
  color: #337ecc;
}
.drop strong { color: var(--text-main); }

.session-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  align-items: center;
  margin-top: 0.65rem;
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-muted);
  font-size: 0.72rem;
}
.pill strong { color: var(--text-main); font-weight: 700; }
.pill.ok { color: #529b2e; background: #f0f9eb; border-color: rgba(103, 194, 58, 0.25); }
.pill.err { color: #c45656; background: #fef0f0; border-color: rgba(245, 108, 108, 0.25); }

.action-area { padding: 0.5rem 1.5rem 1.5rem; }
.btn-primary, .btn-secondary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 600;
  text-decoration: none;
}
.btn-primary {
  width: 100%;
  border: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.72rem 1rem;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.compact {
  width: auto;
  min-height: 38px;
  padding: 0.55rem 0.8rem;
  font-size: 0.82rem;
}
.btn-secondary {
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.72);
  color: #516071;
  padding: 0.55rem 0.8rem;
}
.btn-secondary:hover {
  color: #337ecc;
  border-color: rgba(64, 158, 255, 0.28);
  background: rgba(64, 158, 255, 0.08);
}
.btn-secondary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 0.65rem; }
.compliance-note {
  margin-top: 0.65rem;
  color: var(--text-muted);
  font-size: 0.69rem;
  line-height: 1.45;
  text-align: center;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner.dark {
  border-color: rgba(64, 158, 255, 0.25);
  border-top-color: var(--accent);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Main ---------- */
.main-content {
  flex: 1;
  min-width: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 1.5rem;
  background: transparent;
}

.status-board {
  margin-bottom: 1.25rem;
  padding: 1rem 1.15rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(20px);
}
.status-board-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}
.status-kicker {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-bottom: 0.3rem;
  color: #337ecc;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}
.status-kicker::before {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.14);
  content: "";
}
.status-board h2 { font-size: 1rem; color: var(--text-main); }
.status-board p {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}
.status-board-meta {
  display: grid;
  justify-items: end;
  gap: 0.45rem;
  min-width: max-content;
}
.status-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.7rem;
}
.status-legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.status-swatch {
  width: 11px;
  height: 11px;
  display: inline-block;
  border-radius: 4px;
  background: #dfe7f1;
}
.status-swatch.success {
  background: linear-gradient(145deg, #7bdc55, var(--green));
}
.status-swatch.failure { background: var(--red); }
.status-history-meta {
  display: flex;
  justify-content: flex-end;
  color: var(--text-muted);
  font-size: 0.68rem;
  margin-bottom: 0.35rem;
}
.status-grid {
  display: grid;
  grid-template-columns: repeat(48, minmax(0, 1fr));
  gap: 2px;
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}
.status-cell {
  aspect-ratio: 1;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 3px;
  background: #dfe7f1;
  cursor: help;
}
.status-cell.success {
  background: linear-gradient(145deg, #7bdc55, var(--green));
}
.status-cell.failure { background: var(--red); }
.status-cell.mixed {
  background: linear-gradient(135deg, var(--green) 0 48%, var(--red) 52% 100%);
}
.status-cell:hover {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  filter: brightness(1.05);
}

/* Terminal */
.terminal-wrapper {
  height: min(42vh, 420px);
  min-height: 280px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
  backdrop-filter: blur(20px);
}
.terminal-header {
  display: flex;
  align-items: center;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.84);
}
.traffic-lights { display: flex; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; }
.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27c93f; }
.term-title {
  flex: 1;
  margin-right: 44px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
  text-align: center;
}
.terminal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  color: #334155;
  font: 0.9rem/1.65 var(--font-mono);
  background: #f8fafc;
}
.log-line {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.3rem;
  word-break: break-word;
}
.log-time { flex: 0 0 auto; color: #94a3b8; }
.log-prompt::before { content: "› "; color: var(--accent); }
.log-line.ok .log-msg { color: #529b2e; }
.log-line.err .log-msg { color: #c45656; }
.log-line.warn .log-msg { color: #b88230; }

/* Result */
.result-panel {
  margin-top: 1.25rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}
.result-label {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}
.result-panel strong {
  font-size: 1.05rem;
  color: var(--text-main);
}
.result-amount {
  margin-top: 0.35rem;
  color: #337ecc;
  font-size: 0.9rem;
  font-weight: 650;
}
.result-meta {
  margin-top: 0.35rem;
  color: var(--text-muted);
  font-size: 0.78rem;
}
.result-url {
  display: block;
  margin-top: 0.55rem;
  color: #337ecc;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  word-break: break-all;
}
.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  flex-shrink: 0;
}

/* History panel */
.accounts-panel {
  margin-top: 1.25rem;
  padding: 1.1rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
}
.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.9rem;
}
.panel-header h2 { font-size: 1rem; color: var(--text-main); }
.panel-header p {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.45;
}
.table-wrap { width: 100%; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 7px;
  font-size: 0.86rem;
}
th {
  padding: 0.35rem 0.65rem;
  color: #516071;
  font-weight: 700;
  font-size: 0.75rem;
  text-align: left;
  white-space: nowrap;
}
td {
  padding: 0.7rem 0.65rem;
  color: #516071;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.62);
  vertical-align: middle;
}
td:first-child { border-left: 1px solid var(--border); border-radius: 8px 0 0 8px; }
td:last-child { border-right: 1px solid var(--border); border-radius: 0 8px 8px 0; }
tbody tr:hover td {
  border-color: rgba(64, 158, 255, 0.18);
  background: rgba(64, 158, 255, 0.06);
}
.empty-row {
  text-align: center;
  color: var(--text-muted);
  border-radius: 8px !important;
}
.mono { font-family: var(--font-mono); font-size: 0.78rem; }
.url-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status {
  display: inline-block;
  padding: 0.18rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(15, 23, 42, 0.05);
}
.status.done { color: #529b2e; background: #f0f9eb; }
.status.error { color: #c45656; background: #fef0f0; }
.status.working { color: #b88230; background: #fdf6ec; }
.row-action {
  min-height: 32px;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.72);
  color: #516071;
  font-size: 0.75rem;
  font-weight: 600;
}
.row-action:hover {
  color: #337ecc;
  border-color: rgba(64, 158, 255, 0.28);
  background: rgba(64, 158, 255, 0.08);
}

/* Toast */
.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: min(360px, calc(100vw - 2rem));
}
.toast .item {
  padding: 0.75rem 0.9rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: #1f2937;
  color: #fff;
  font-size: 0.85rem;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.2);
  animation: in 0.18s ease;
}
.toast .item.err { border-color: rgba(245, 108, 108, 0.45); }
.toast .item.ok { border-color: rgba(103, 194, 58, 0.45); }
@keyframes in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* Admin pages reuse */
.admin-wrap {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 60px;
}
.admin-card {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.1);
  padding: 1.15rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(16px);
}
.admin-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.admin-tabs button {
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #516071;
  font-weight: 650;
}
.admin-tabs button.active {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.field { margin-bottom: 12px; }
.field label {
  display: block;
  margin-bottom: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 600;
}
.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.stat {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.7);
}
.stat .k { color: var(--text-muted); font-size: 0.75rem; }
.stat .v { font-size: 1.25rem; font-weight: 700; margin-top: 4px; color: var(--text-main); }
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 650;
}
.badge.ok { background: #f0f9eb; color: #529b2e; }
.badge.fail { background: #fef0f0; color: #c45656; }

/* Responsive */
@media (max-width: 960px) {
  body { display: block; overflow-x: hidden; overflow-y: auto; }
  .sidebar {
    width: 100%;
    min-width: 0;
    height: auto;
    overflow: visible;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .main-content {
    width: 100%;
    height: auto;
    min-height: 100vh;
    overflow: visible;
    padding: 1rem;
  }
  .status-board-head { flex-direction: column; }
  .status-board-meta { width: 100%; justify-items: start; min-width: 0; }
  .status-legend { justify-content: flex-start; }
  .status-grid { grid-template-columns: repeat(24, minmax(0, 1fr)); }
  .terminal-wrapper { height: 50vh; min-height: 260px; }
  .result-panel { flex-direction: column; }
  .result-actions { width: 100%; }
  .result-actions > * { flex: 1; }
  .row-2, .input-grid, .segmented { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr; }
  table thead { display: none; }
  table, tbody, tbody tr, tbody td { display: block; width: 100%; }
  tbody tr {
    margin-top: 0.75rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
  }
  tbody td {
    display: grid;
    grid-template-columns: minmax(5rem, 32%) minmax(0, 1fr);
    gap: 0.6rem;
    border: 0;
    border-top: 1px solid var(--border);
    border-radius: 0 !important;
    background: transparent;
    white-space: normal;
  }
  tbody td:first-child { border-top: 0; }
  tbody td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 700;
  }
  tbody td.empty-row { display: block; text-align: center; }
  tbody td.empty-row::before { content: none; }
}

@media (max-width: 480px) {
  .top-links { top: 0.85rem; right: 0.85rem; }
  .brand { padding: 1.15rem 5rem 1rem 1rem; }
  .brand h1 { font-size: 1.3rem; }
  .control-group { padding: 1rem; }
  .action-area { padding: 0.5rem 1rem 1.1rem; }
  input, select, textarea { font-size: 16px; }
  .status-grid { grid-template-columns: repeat(16, minmax(0, 1fr)); }
}
