:root {
  /* 白天（默认） */
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2328;
  --muted: #6b7280;
  --line: #e5e7eb;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-hover: 0 6px 20px rgba(16, 24, 40, 0.10);
  --input-bg: #ffffff;

  --green: #16a34a;
  --green-bg: rgba(22, 163, 74, 0.10);
  --red: #dc2626;
  --red-bg: rgba(220, 38, 38, 0.10);
  --blue: #2563eb;
  --blue-bg: rgba(37, 99, 235, 0.10);
  --amber: #d97706;
  --amber-bg: rgba(217, 119, 6, 0.12);
}

[data-theme="dark"] {
  --bg: #14161a;
  --card: #1e2126;
  --ink: #e7e9ec;
  --muted: #9aa0a6;
  --line: #2a2d33;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 6px 20px rgba(0, 0, 0, 0.5);
  --input-bg: #1e2126;

  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.16);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.16);
  --blue: #60a5fa;
  --blue-bg: rgba(96, 165, 250, 0.16);
  --amber: #fbbf24;
  --amber-bg: rgba(251, 191, 36, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}

/* 顶栏 */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 9px; }
.logo {
  width: 26px; height: 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--blue);
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  border-radius: 7px;
}
.title { font-size: 16px; font-weight: 700; }
.account { display: flex; align-items: center; gap: 8px; }
.username { color: var(--muted); font-size: 13px; }

.badge {
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
}
.badge-user { color: var(--blue); background: var(--blue-bg); border-color: transparent; }
.badge-subadmin { color: var(--amber); background: var(--amber-bg); border-color: transparent; }
.badge-admin { color: var(--red); background: var(--red-bg); border-color: transparent; }

/* 布局 */
.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 18px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel { display: flex; flex-direction: column; gap: 12px; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.panel-head h2 { margin: 0; font-size: 16px; font-weight: 700; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--red); font-size: 13px; margin-top: 8px; }

/* 提醒横幅 */
.notice {
  background: var(--blue-bg);
  border: 1px solid var(--blue);
  color: var(--blue);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  text-align: center;
}

/* 按钮 */
.btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: filter .12s, transform .05s, background .12s;
}
.btn:hover { filter: brightness(1.03); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost { background: transparent; }
.icon-btn { min-width: 52px; }
.btn-green { background: var(--green-bg); border-color: transparent; color: var(--green); }
.btn-red { background: var(--red-bg); border-color: transparent; color: var(--red); }
.btn-blue { background: var(--blue-bg); border-color: transparent; color: var(--blue); }

/* 后端卡片 */
.backend-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 12px;
}
.backend-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 9px;
  transition: box-shadow .12s;
}
.backend-card:hover { box-shadow: var(--shadow-hover); }

.backend-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.backend-name { font-weight: 600; }
.dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex: none; box-shadow: 0 0 5px currentColor;
}
.dot-running { background: var(--green); color: var(--green); }
.dot-stopped { background: var(--red); color: var(--red); }

.status-pill {
  font-size: 12px; font-weight: 600; padding: 1px 9px; border-radius: 999px;
}
.status-running { color: var(--green); background: var(--green-bg); }
.status-stopped { color: var(--red); background: var(--red-bg); }

.backend-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 12px; }
.backend-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.backend-actions .btn { padding: 5px 10px; font-size: 12px; }

.group-tag {
  font-size: 11px; color: var(--blue); background: var(--blue-bg);
  padding: 0 7px; border-radius: 5px;
}
.remote-tag {
  font-size: 11px; color: var(--muted); background: var(--bg);
  border: 1px solid var(--line); padding: 0 6px; border-radius: 5px;
}

/* 表单 */
.submit-box { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
input, textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--blue); }

/* 弹窗表单网格 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.form-grid label {
  display: flex; flex-direction: column; gap: 5px;
  font-size: 13px; color: var(--muted);
}
.form-grid label[data-when] { margin: 0; }
@media (max-width: 560px) { .form-grid { grid-template-columns: 1fr; } }

/* 折叠分组 */
.fold-group {
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: var(--card);
  box-shadow: var(--shadow);
}
.fold-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: none;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  font-family: inherit;
}
.fold-head:hover { background: var(--bg); }
.fold-count {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 500;
}
.fold-arrow { margin-left: auto; transition: transform .15s; }
.fold-group.collapsed .fold-arrow { transform: rotate(-90deg); }
.fold-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 14px 14px; }
.fold-group.collapsed .fold-body { display: none; }

/* 列表条目（投稿 / 账号） */
.content-list { display: flex; flex-direction: column; gap: 10px; }
.item {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: var(--shadow);
}
.item-text { white-space: pre-wrap; word-break: break-word; }
.item-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.item-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tag { font-size: 11px; padding: 0 7px; border-radius: 5px; }
.tag-pending { color: var(--amber); background: var(--amber-bg); }
.tag-approved { color: var(--green); background: var(--green-bg); }
.tag-rejected { color: var(--red); background: var(--red-bg); }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 17, 21, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50;
}
.modal {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 18px; width: 100%; max-width: 380px;
  display: flex; flex-direction: column; gap: 12px;
  box-shadow: var(--shadow-hover);
}
.modal-wide { max-width: 620px; }
.modal h3 { margin: 0; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }

.log-view {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  max-height: 55vh;
  overflow: auto;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  white-space: pre-wrap;
  word-break: break-all;
  margin: 0;
  color: var(--ink);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 8px;
  z-index: 99;
  max-width: 90vw;
  font-size: 14px;
  box-shadow: var(--shadow-hover);
}
.toast-error { border-color: var(--red); color: var(--red); }

/* 移动端适配 */
@media (max-width: 560px) {
  .backend-list { grid-template-columns: 1fr; }
  .container { padding: 14px 12px 40px; }
  .topbar { padding: 10px 12px; }
  .title { font-size: 15px; }
  .username { display: none; }
}
