/* ==================== 基础 ==================== */
:root {
  --bg: #0d1117;
  --bg-soft: #161b27;
  --card: #171e2c;
  --card-hover: #1c2436;
  --border: #26304a;
  --text: #dbe2f0;
  --text-dim: #8b96ad;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --green: #3fb96b;
  --red: #e5534b;
  --yellow: #d9a53f;
  --radius: 12px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #2c3654; border-radius: 6px; }
::-webkit-scrollbar-track { background: transparent; }

/* ==================== 布局 ==================== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 22px;
  height: 54px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { font-weight: 700; font-size: 15px; letter-spacing: 0.5px; white-space: nowrap; }

.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 6px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  white-space: nowrap;
  transition: all 0.15s;
}
.nav a:hover { color: var(--text); background: var(--accent-soft); }
.nav a.active { color: #fff; background: var(--accent-soft); }

.user-box { display: flex; align-items: center; gap: 10px; color: var(--text-dim); white-space: nowrap; }
.user-box b { color: var(--text); }

main { flex: 1; padding: 22px; max-width: 1080px; width: 100%; margin: 0 auto; }

/* ==================== 卡片 ==================== */
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h3 {
  margin: 0 0 14px;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 .spacer { flex: 1; }

.kv { display: flex; justify-content: space-between; padding: 6px 0; gap: 12px; }
.kv .k { color: var(--text-dim); }
.kv .v { text-align: right; word-break: break-all; }

/* ==================== 表单 ==================== */
label.field { display: block; margin-bottom: 12px; }
label.field span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-dim);
  font-size: 13px;
}

input, select {
  width: 100%;
  padding: 9px 12px;
  background: #0f1522;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border 0.15s;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: #566179; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row > * { flex-shrink: 0; }

/* ==================== 按钮 ==================== */
button {
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
}
button:hover { background: var(--card-hover); border-color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.12); }
button.danger { background: transparent; border-color: var(--red); color: var(--red); }
button.danger:hover { background: rgba(229, 83, 75, 0.12); }
button.small { padding: 5px 10px; font-size: 13px; }

/* ==================== 徽章 ==================== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.badge.green { color: var(--green); border-color: rgba(63, 185, 107, 0.5); background: rgba(63, 185, 107, 0.1); }
.badge.red { color: var(--red); border-color: rgba(229, 83, 75, 0.5); background: rgba(229, 83, 75, 0.1); }
.badge.yellow { color: var(--yellow); border-color: rgba(217, 165, 63, 0.5); background: rgba(217, 165, 63, 0.1); }
.badge.blue { color: var(--accent); border-color: rgba(79, 140, 255, 0.5); background: var(--accent-soft); }

/* ==================== 表格 ==================== */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
th { color: var(--text-dim); font-weight: 600; font-size: 12px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--card-hover); }

/* ==================== 日志 ==================== */
.log-view {
  background: #0a0e16;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 65vh;
  overflow-y: auto;
  color: #a8b6cf;
}
.log-view .lv-warn { color: var(--yellow); }
.log-view .lv-error { color: var(--red); }

/* ==================== 提示条 ==================== */
.hint {
  color: var(--text-dim);
  font-size: 12.5px;
  line-height: 1.7;
  background: rgba(79, 140, 255, 0.06);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

/* ==================== 登录页 ==================== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 380px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 34px 30px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 20px; margin: 0 0 6px; text-align: center; }
.login-card .sub { color: var(--text-dim); text-align: center; margin-bottom: 26px; font-size: 13px; }

/* ==================== 步骤条（TG 绑定） ==================== */
.steps { display: flex; gap: 8px; margin-bottom: 16px; }
.step {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 8px;
  font-size: 12.5px;
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.step.active { color: #fff; background: var(--accent-soft); border-color: var(--accent); }
.step.done { color: var(--green); border-color: rgba(63, 185, 107, 0.5); }

/* ==================== Toast ==================== */
#toast-box {
  position: fixed;
  top: 66px;
  right: 20px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  padding: 11px 16px;
  min-width: 240px;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: slide-in 0.2s ease;
  font-size: 13.5px;
}
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
@keyframes slide-in {
  from { transform: translateX(30px); opacity: 0; }
  to { transform: none; opacity: 1; }
}

/* ==================== 其他 ==================== */
.muted { color: var(--text-dim); font-size: 12.5px; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.section-title {
  margin: 22px 0 12px;
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
code.inline {
  background: #0f1522;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12.5px;
  color: var(--accent);
}
.screenshot-preview { max-width: 100%; max-height: 320px; border-radius: 8px; border: 1px solid var(--border); }

/* ==================== 截图库存 ==================== */
.sub-title {
  margin: 14px 0 8px;
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}
.inv-period { margin-bottom: 18px; }
.inv-period:last-child { margin-bottom: 0; }
.inv-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.slot {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0f1522;
  display: flex;
  flex-direction: column;
  min-height: 120px;
}
.slot img { width: 100%; height: 130px; object-fit: cover; display: block; }
.slot.used { opacity: 0.55; }
.slot.empty {
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  border-style: dashed;
  transition: all 0.15s;
}
.slot.empty:hover { border-color: var(--accent); background: var(--accent-soft); }
.slot.empty .plus { font-size: 22px; color: var(--accent); line-height: 1; }
.slot-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  flex-wrap: wrap;
}
.slot-bar .small { padding: 3px 8px; font-size: 12px; }

/* ==================== 绑定码 ==================== */
.code-box {
  margin-top: 10px;
  padding: 14px;
  text-align: center;
  font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace;
  font-size: 30px;
  letter-spacing: 8px;
  color: var(--accent);
  background: #0f1522;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  user-select: all;
}
