:root {
  --side-bg: #f4f6f8;
  --side-card: #ffffff;
  --side-ink: #1a2332;
  --side-muted: #6b7785;
  --side-line: #e2e8ef;
  --accent: #1677ff;
  --accent-ink: #ffffff;
  --danger: #ff4d4f;
  --ok: #19c37d;
  --warn: #faad14;
  --locked: #ff6b6b;
  --inactive: #b37feb;
  --console-bg: #14181f;
  --console-panel: #1b212b;
  --console-ink: #e8eef6;
  --console-muted: #8b97a8;
  --console-line: #2a3340;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden; /* 整页不要下拉，只让右侧结果区滚动 */
  font-family: "Outfit", sans-serif;
  color: var(--side-ink);
  background: #0e1218;
}

.layout {
  display: grid;
  grid-template-columns: minmax(320px, 380px) 1fr;
  height: 100vh;
  min-height: 560px;
  overflow: hidden;
}

.sidebar {
  background: var(--side-bg);
  border-right: 1px solid var(--side-line);
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  overflow: hidden; /* 左侧不要下拉条 */
  min-height: 0;
}

.side-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.brand {
  margin: 0;
  letter-spacing: 0.16em;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
}

.side-head h1 {
  margin: 0.2rem 0 0;
  font-size: 1.25rem;
  font-weight: 700;
}

.auth-box {
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.auth-box input {
  width: 7.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--side-line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-size: 0.82rem;
}

.side-card {
  background: var(--side-card);
  border: 1px solid var(--side-line);
  border-radius: 12px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.side-card-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.86rem;
  font-weight: 600;
}

.import-meta {
  color: var(--side-muted);
  font-weight: 500;
  font-size: 0.78rem;
}

.side-card:has(#accounts) {
  flex: 1;
  min-height: 0;
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 120px;
  max-height: none;
  resize: none;
  border: 1px solid var(--side-line);
  border-radius: 10px;
  padding: 0.65rem 0.7rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.75rem;
  line-height: 1.45;
  background: #fafbfc;
  overflow: auto;
  scrollbar-width: thin;
}

.side-actions, .run-row {
  display: flex;
  gap: 0.5rem;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.86rem;
  color: var(--side-muted);
}

.field input {
  width: 5.5rem;
  padding: 0.4rem 0.55rem;
  border: 1px solid var(--side-line);
  border-radius: 8px;
  font: inherit;
  text-align: right;
}

.conc-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  background: #f7f9fb;
  border: 1px solid var(--side-line);
}

.conc-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--side-muted);
}

.conc-summary b {
  color: var(--side-ink);
  font-variant-numeric: tabular-nums;
}

.conc-sep { opacity: 0.45; }

.btn-sm {
  padding: 0.38rem 0.65rem;
  font-size: 0.82rem;
  flex: none;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(10, 14, 20, 0.45);
  backdrop-filter: blur(4px);
}

.modal-backdrop[hidden] { display: none; }

.modal-card {
  width: min(100%, 380px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--side-line);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
  padding: 1rem 1.05rem 1.05rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.modal-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-x {
  border: 0;
  background: transparent;
  width: 2rem;
  height: 2rem;
  border-radius: 8px;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--side-muted);
  cursor: pointer;
}

.modal-x:hover { background: #f0f3f7; color: var(--side-ink); }

.modal-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--side-muted);
}

.modal-hint b { color: var(--accent); font-variant-numeric: tabular-nums; }

.modal-note {
  margin: 0;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--side-muted);
}

.modal-actions {
  display: flex;
  gap: 0.45rem;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-actions .btn.primary {
  flex: none;
  min-width: 4.5rem;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  background: #eef2f6;
  padding: 0.25rem;
  border-radius: 10px;
}

.mode-btn {
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-weight: 600;
  color: var(--side-muted);
  cursor: pointer;
}

.mode-btn.active {
  background: #fff;
  color: var(--side-ink);
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.hint {
  margin: 0;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8f3ff 0%, #f3ffe8 55%, #fff4e5 100%);
  border: 1px solid #d6e4ff;
  color: #1a2332;
  font-size: 0.8rem;
  line-height: 1.45;
  font-weight: 600;
}

.hint .p-ok { color: #0f9d58; }
.hint .p-fast { color: #1677ff; }
.hint .p-normal { color: #722ed1; }
.hint .p-warn { color: #d48806; }
.hint .p-bad { color: #cf1322; }
.hint .p-mute { color: #5b6b7c; font-weight: 500; }
.hint .p-num { color: #0958d9; font-variant-numeric: tabular-nums; }

.btn {
  border: 0;
  border-radius: 9px;
  padding: 0.55rem 0.9rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.btn.primary {
  flex: 1;
  background: var(--accent);
  color: var(--accent-ink);
}

.btn.danger {
  flex: 1;
  background: var(--danger);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  border: 1px solid var(--side-line);
  color: var(--side-ink);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.file {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.console {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden; /* 右侧外层不下拉，只有结果表下拉 */
  background: var(--console-bg);
  color: var(--console-ink);
  padding: 0.9rem 1rem 1rem;
  gap: 0.75rem;
}

.stat-cards {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 0.55rem;
}

.stat {
  border-radius: 12px;
  padding: 0.7rem 0.75rem;
  background: var(--console-panel);
  border: 1px solid var(--console-line);
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 68px;
}

.stat b {
  font-size: 1.35rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  color: var(--console-muted);
  font-size: 0.78rem;
}

.stat.ok b { color: var(--ok); }
.stat.bad b { color: #ff7a6e; }
.stat.lock b { color: var(--warn); }
.stat.warn b { color: #6eb5ff; }
.stat.prog b { color: #c8d0da; font-size: 1.05rem; }
.stat.time b { color: #b8c4ff; font-size: 1.05rem; }

.stat-cards.fast-only {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.stat-cards.fast-only .stat.lock,
.stat-cards.fast-only .stat.warn {
  display: none;
}

.console-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  min-height: 1.8rem;
}

.chip, .chip-btn {
  border: 1px solid var(--console-line);
  border-radius: 999px;
  padding: 0.22rem 0.65rem;
  font-size: 0.75rem;
  color: var(--console-muted);
  background: transparent;
}

.chip-btn {
  cursor: pointer;
  font: inherit;
  color: var(--console-ink);
}

.chip-btn:hover { border-color: currentColor; }
.chip-btn.needs_2fa, .chip-btn.alive, .chip-btn.ok { color: var(--ok); }
.chip-btn.wrong_password, .chip-btn.bad { color: #ff7a6e; }
.chip-btn.locked, .chip-btn.inactive { color: var(--warn); }
.chip-btn.federated { color: #6eb5ff; }
.chip-btn.need_retry, .chip-btn.unknown, .chip-btn.rate_limited { color: #9aa7b5; }
.chip-btn.not_found { color: #7ec8ff; }

.console .btn.ghost {
  background: transparent;
  border-color: var(--console-line);
  color: var(--console-ink);
}

.table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto; /* 只有这里下拉 */
  border: 1px solid var(--console-line);
  border-radius: 12px;
  background: #12161d;
  position: relative;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: #6b7785 transparent;
}

.table-wrap::-webkit-scrollbar { width: 10px; }
.table-wrap::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--console-muted) 55%, transparent);
  border-radius: 999px;
}
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #1a212c;
  color: var(--console-muted);
  font-weight: 500;
  font-size: 0.75rem;
  text-align: left;
  padding: 0.65rem 0.7rem;
  border-bottom: 1px solid var(--console-line);
}

td {
  padding: 0.48rem 0.7rem;
  border-bottom: 1px solid color-mix(in srgb, var(--console-line) 70%, transparent);
  vertical-align: middle;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

tr:hover td { background: rgba(255,255,255,0.02); }

.col-acc { width: 34%; }
.col-pw { width: 28%; }
.col-res { width: 24%; }
.col-ms { width: 14%; text-align: right; }

.badge {
  display: inline-block;
  padding: 0.14rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid transparent;
  font-family: "Outfit", sans-serif;
}

.badge.needs_2fa, .badge.alive, .badge.ok {
  color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 40%, transparent);
  background: color-mix(in srgb, var(--ok) 12%, transparent);
}
.badge.wrong_password, .badge.bad {
  color: #ff7a6e;
  border-color: color-mix(in srgb, #ff7a6e 40%, transparent);
  background: color-mix(in srgb, #ff7a6e 12%, transparent);
}
.badge.locked, .badge.inactive {
  color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 40%, transparent);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}
.badge.federated {
  color: #6eb5ff;
  border-color: color-mix(in srgb, #6eb5ff 40%, transparent);
  background: color-mix(in srgb, #6eb5ff 12%, transparent);
}
.badge.pending, .badge.checking, .badge.need_retry, .badge.unknown, .badge.rate_limited {
  color: #9aa7b5;
  border-color: color-mix(in srgb, #9aa7b5 35%, transparent);
}
.badge.not_found {
  color: #7ec8ff;
  border-color: color-mix(in srgb, #7ec8ff 40%, transparent);
}

.ms {
  color: var(--console-muted);
  font-variant-numeric: tabular-nums;
}

.log-empty {
  position: absolute;
  inset: 2.8rem 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--console-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.log-empty[hidden] { display: none; }

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }
  .sidebar { max-height: none; }
  .console { min-height: 70vh; }
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .stat.prog { grid-column: 1 / -1; }
}
