/* ============================================================
   Soul 登录工具 — 暗色主题 UI v2
   功能层不动（app.js 所有 ID/class 保持不变）
   ============================================================ */

/* ---- Design Tokens ---- */
:root {
  color-scheme: dark;

  --bg-root: #090b10;
  --bg-surface: #131620;
  --bg-card: #181b27;
  --bg-hover: #1e2132;
  --bg-input: #10131e;

  --border: #1f2333;
  --border-light: #2a2e40;

  --text: #e4e6f0;
  --text-dim: #8b8fab;
  --text-muted: #5f647d;

  --accent: #8b5cf6;
  --accent-glow: rgba(139, 92, 246, 0.25);
  --accent-soft: rgba(139, 92, 246, 0.10);
  --accent-hover: #9d74f7;

  --danger: #f0445a;
  --danger-soft: rgba(240, 68, 90, 0.12);
  --success: #22c570;
  --success-soft: rgba(34, 197, 112, 0.12);
  --warn: #f0a020;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  --sidebar-w: 232px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: "Cascadia Code", "Fira Code", "JetBrains Mono", Consolas, monospace;

  --transition: 160ms ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg-root);
  color: var(--text);
  font: 14px/1.6 var(--font);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* ---- App Shell ---- */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 20;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 22px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent), #6366f1);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  margin-bottom: 10px;
}

.sidebar-brand h1 {
  font-size: 16px; font-weight: 700; letter-spacing: -0.2px;
  color: var(--text);
}

.sidebar-brand .subtitle {
  font-size: 11px; color: var(--text-muted); margin-top: 2px;
}

/* ---- Sidebar Nav (.tabs — JS 依赖此类名) ---- */
nav.tabs {
  padding: 12px 10px;
  display: flex; flex-direction: column;
  gap: 2px;
  flex: 1;
}

nav.tabs button {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  padding: 10px 14px;
  border: none; border-radius: var(--radius);
  background: transparent;
  color: var(--text-dim);
  font-size: 13.5px; font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition);
  position: relative;
}

nav.tabs button .nav-icon { font-size: 16px; width: 22px; text-align: center; flex-shrink: 0; }

nav.tabs button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

nav.tabs button.active {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.2);
}

nav.tabs button.active::before {
  content: '';
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--accent);
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-muted);
  text-align: center;
}

/* ---- Main Area ---- */
.main-area {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column;
}

.topbar-minimal {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 10px 24px;
  background: var(--bg-root);
  border-bottom: 1px solid var(--border);
  min-height: 48px;
}

.content {
  padding: 20px 24px 40px;
  max-width: 1260px;
  width: 100%;
}

/* ---- Cards / Panels ---- */
.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.panel-title {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

/* ---- Config Card ---- */
.config-card { margin-bottom: 20px; }

.config-card .panel-title { margin-bottom: 14px; }

.config-toggle {
  background: none; border: 1px solid var(--border-light);
  color: var(--text-dim); font-size: 12px;
  padding: 5px 10px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all var(--transition);
}
.config-toggle:hover { border-color: var(--accent); color: var(--text); }

.config-body { display: block; }
.config-body.collapsed { display: none; }

/* ---- Section Labels ---- */
.config-section-label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.6px; color: var(--text-muted);
  margin: 14px 0 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.config-section-label:first-child { margin-top: 0; }

/* ---- Headings ---- */
h2 {
  font-size: 17px; font-weight: 600;
  letter-spacing: -0.2px;
  margin: 0;
}
h3 {
  font-size: 14px; font-weight: 600;
  color: var(--text-dim);
  margin: 20px 0 10px;
}

/* ---- Forms ---- */
label {
  display: flex; flex-direction: column;
  gap: 5px;
  font-size: 12px; color: var(--text-dim);
  margin-bottom: 10px;
}
label.inline { flex-direction: row; align-items: center; margin: 0; gap: 8px; }

input, select, textarea {
  font: inherit;
  width: 100%;
  background: var(--bg-input);
  color: var(--text);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea {
  resize: vertical;
  min-height: 90px;
  font-family: var(--font-mono);
  font-size: 13px;
}

select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238b8fab'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
  padding-right: 30px;
}

::placeholder { color: var(--text-muted); }

/* ---- Buttons ---- */
button {
  font: inherit; cursor: pointer;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 13px; font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
}

button:hover {
  background: var(--bg-hover);
  color: var(--text);
  border-color: var(--border-light);
}

button.primary, button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover, button.active:hover {
  background: var(--accent-hover);
  color: #fff;
}

button.danger { color: var(--danger); border-color: rgba(240,68,90,0.25); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }

button:disabled { cursor: wait; opacity: 0.5; }

/* ---- Tabs (功能层 .tab-panel 切换) ---- */
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Toolbars / Actions ---- */
.actions, .toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 8px; margin: 12px 0;
}
.toolbar input, .toolbar select, .toolbar button,
.actions input, .actions select { width: auto; min-width: 100px; }

/* ---- Status Line ---- */
.statusline {
  padding: 10px 14px; margin: 12px 0;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  border-left: 3px solid var(--accent);
}

/* ---- Log Console ---- */
.log {
  min-height: 100px; max-height: 240px;
  overflow: auto; white-space: pre-wrap; word-break: break-word;
  padding: 12px 14px; margin-top: 10px;
  background: #0a0d14;
  color: #a0e8a0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 12.5px; line-height: 1.7;
}

/* ---- Tables ---- */
.table-wrap {
  width: 100%; overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0 16px;
}
.table-wrap.small { max-height: 360px; }

table {
  width: 100%; border-collapse: collapse;
  min-width: 760px;
  font-size: 13px;
}

th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left; vertical-align: top;
}

th {
  background: var(--bg-surface);
  color: var(--text-dim);
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px;
  position: sticky; top: 0; z-index: 1;
}

tbody tr:hover { background: rgba(255,255,255,0.02); }

td.muted { color: var(--text-muted); }
td.ok { color: var(--success); font-weight: 600; }
td.fail { color: var(--danger); }

/* ---- Batch Code Input (JS 渲染) ---- */
.batch-code {
  width: 120px; min-width: 100px;
  padding: 6px 8px; font-size: 13px;
}

/* ---- Resend Button (JS 渲染) ---- */
.resend-btn { font-size: 12px; padding: 5px 10px; }

/* ---- Data Grid (ag-grid) ---- */
.data-grid {
  width: 100%; height: 460px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin: 12px 0 16px;
  overflow: hidden;
  --ag-font-family: var(--font);
  --ag-font-size: 13px;
  --ag-row-height: 36px;
  --ag-header-height: 38px;
  --ag-border-color: var(--border);
  --ag-header-background-color: var(--bg-surface);
  --ag-odd-row-background-color: rgba(255,255,255,0.015);
  --ag-selected-row-background-color: rgba(139,92,246,0.12);
  --ag-row-hover-color: rgba(255,255,255,0.03);
  --ag-background-color: var(--bg-card);
  --ag-foreground-color: var(--text);
  --ag-secondary-foreground-color: var(--text-dim);
  --ag-header-foreground-color: var(--text-dim);
  --ag-input-focus-border-color: var(--accent);
}
.data-grid.small { height: 320px; }

.data-grid .grid-select { width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--accent); }
.data-grid .row-selected-manual { background: rgba(139,92,246,0.12) !important; }

/* ---- Group List ---- */
.group-list {
  display: flex; flex-direction: column;
  gap: 3px; margin-bottom: 14px;
}

.group-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px; padding: 9px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all var(--transition);
}
.group-item:hover { background: var(--bg-hover); border-color: var(--border); }
.group-item.active {
  background: var(--accent-soft);
  border-color: rgba(139,92,246,0.25);
  color: var(--accent);
}

.group-item .group-copy,
.group-item .group-shuffle {
  font-size: 11px; padding: 3px 8px; border-radius: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--text-muted); cursor: pointer;
  transition: all var(--transition);
}
.group-item .group-copy:hover,
.group-item .group-shuffle:hover {
  border-color: var(--border-light);
  color: var(--text); background: var(--bg-hover);
}
.group-item.active .group-copy,
.group-item.active .group-shuffle {
  color: var(--accent);
}

/* ---- Mini Form ---- */
.mini-form {
  display: flex; gap: 6px; margin-bottom: 10px;
}
.mini-form input { min-width: 0; }

/* ---- Data Layout ---- */
.data-layout {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 16px;
}

.side {
  align-self: start;
  position: sticky; top: 64px;
}

/* ---- Toast ---- */
.toast {
  max-width: 480px;
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* ---- Grid Utilities ---- */
.grid { display: grid; gap: 12px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---- Badge ---- */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600;
}
.badge-ok { background: var(--success-soft); color: var(--success); }
.badge-fail { background: var(--danger-soft); color: var(--danger); }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .sidebar {
    width: 180px;
    --sidebar-w: 180px;
  }
  .main-area { margin-left: 180px; }
  .content { padding: 14px; }
  .cols-2, .cols-3, .cols-4, .data-layout { grid-template-columns: 1fr; }
  .side { position: static; }
}

@media (max-width: 680px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    position: relative; width: 100%; bottom: auto;
    border-right: none; border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  nav.tabs { flex-direction: row; flex-wrap: wrap; padding: 8px; gap: 4px; }
  nav.tabs button { width: auto; padding: 7px 12px; font-size: 12px; }
  nav.tabs button.active::before { display: none; }
  .sidebar-brand { padding: 12px 14px; }
  .sidebar-footer { display: none; }
  .main-area { margin-left: 0; }
}
