:root {
  --bg: #f0f2f5;
  --panel: #ffffff;
  --ink: #1a2332;
  --muted: #5c6b7a;
  --line: #e5e7eb;
  --accent: #0b6e4f;
  --accent-soft: #e6f4ef;
  --nav-active: #e8f5f0;
  --warn: #9a3412;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
  --radius: 12px;
  --sidebar-w: 220px;
  --font: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

/* —— App shell (sidebar layout) —— */
.app-shell {
  display: flex;
  min-height: 100vh;
}
.app-shell[hidden] { display: none !important; }

.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}
.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
}
.sidebar-title {
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.2;
}
.sidebar-ver {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 2px;
}
.sidebar-section {
  font-size: 0.72rem;
  color: #9aa6b2;
  padding: 4px 10px 8px;
  letter-spacing: 0.04em;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: transparent !important;
  border: none !important;
  color: var(--ink) !important;
  border-radius: 10px !important;
  padding: 10px 12px !important;
  font-size: 0.92rem !important;
  font-weight: 500;
}
.nav-item:hover { background: #f5f7f9 !important; }
.nav-item.active {
  background: var(--nav-active) !important;
  color: var(--accent) !important;
  box-shadow: inset 3px 0 0 var(--accent);
}
.nav-ico {
  width: 1.2em;
  text-align: center;
  opacity: 0.75;
  font-size: 0.9rem;
}
.sidebar-foot {
  padding: 12px 8px 4px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}
.sidebar-foot .badge {
  display: block;
  border-radius: 8px;
  white-space: normal;
  line-height: 1.35;
}

.app-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 28px 12px;
  background: transparent;
}
.topbar h1 {
  margin: 0;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
}
.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}
.page-body {
  padding: 8px 28px 40px;
  flex: 1;
}
.page-view[hidden] { display: none !important; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.card-head h2 {
  margin: 0;
  font-size: 1rem;
}
.card-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.danger-btn {
  color: var(--danger) !important;
  border-color: #f0c4c4 !important;
}
.danger-btn:hover { background: #fef2f2 !important; }

.badge {
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid #b7dccb;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.82rem;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.site-list {
  max-height: min(56vh, 560px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { width: auto; }
  .page-body, .topbar { padding-left: 16px; padding-right: 16px; }
}

/* legacy panel compat */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.panel h2 {
  margin: 0;
  padding: 14px 16px;
  font-size: 1rem;
  border-bottom: 1px solid var(--line);
}
.panel .body { padding: 14px 16px 16px; }
.site-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}
.site-item:last-child { border-bottom: 0; }
.site-item label {
  display: flex;
  gap: 10px;
  width: 100%;
  cursor: pointer;
}
.site-meta { flex: 1; min-width: 0; }
.site-meta strong { display: block; font-size: 0.92rem; }
.site-meta small { color: var(--muted); word-break: break-all; }
.tag {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 4px;
  background: #eef2f6;
  color: var(--muted);
}
.tag.on { background: var(--accent-soft); color: var(--accent); }
.tag.off { background: #f3e8e8; color: var(--danger); }

.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}
button, .btn {
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font: inherit;
  cursor: pointer;
}
button.secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--line);
}
button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
input[type="text"], input[type="number"], select {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}
input[type="text"] { min-width: 160px; }

.status-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--line);
  font-size: 0.88rem;
  color: var(--muted);
  white-space: pre-wrap;
}
.status-box.running { border-color: #86b7a5; background: var(--accent-soft); color: var(--accent); }
.status-box.error { border-color: #f0b4b4; background: #fef2f2; color: var(--danger); }
.status-box.done { border-color: #86efac; background: #f0fdf4; color: var(--ok); }

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.table-wrap { overflow: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
th, td {
  text-align: left;
  vertical-align: top;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  position: sticky;
  top: 0;
  background: #fff;
}
td.title { font-weight: 600; max-width: 420px; }
td.title .title-link {
  display: inline;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  text-align: left;
  line-height: 1.45;
}
td.title .title-link:hover {
  color: var(--accent);
  text-decoration: underline;
}
a { color: var(--accent); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 50;
}
.modal-backdrop[hidden] { display: none !important; }
.modal {
  width: min(820px, 100%);
  max-height: min(86vh, 900px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 16px 48px rgba(16, 24, 40, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px 10px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 {
  margin: 4px 0 0;
  font-size: 1.1rem;
  line-height: 1.4;
}
.modal-meta {
  color: var(--muted);
  font-size: 0.8rem;
}
.modal-body {
  padding: 16px 18px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.65;
  font-size: 0.95rem;
  color: var(--ink);
  flex: 1;
}
.modal-wide {
  width: min(960px, 100%);
}
.modal-body-form {
  white-space: normal;
}
.modal-foot-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.import-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.import-preview-table th,
.import-preview-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  vertical-align: top;
  text-align: left;
}
.import-preview-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.78rem;
}
.import-preview-table input[type="text"] {
  width: 100%;
  min-width: 0 !important;
  font-size: 0.85rem;
  padding: 6px 8px;
}
.import-preview-table .col-idx { width: 36px; color: var(--muted); }
.import-preview-table .col-name { width: 28%; }
.import-preview-table .col-status { width: 90px; }
.import-preview-table .col-act { width: 56px; }
.modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line);
  background: #fafbfc;
}
.pager {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.88rem;
}
.cat {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  background: #eef2f6;
  font-size: 0.75rem;
}
.jobs {
  margin-top: 16px;
}
.jobs details {
  border-top: 1px solid var(--line);
  padding: 8px 0;
}
.jobs summary { cursor: pointer; color: var(--muted); }

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.user-chip {
  font-size: 0.85rem;
  color: var(--muted);
  background: #fff;
  border: 1px solid var(--line);
  padding: 6px 10px;
  border-radius: 999px;
}
.owner-tag {
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: 2px;
}

/* 参考项目风格：左右分栏认证页 */
.auth-shell {
  min-height: 100vh;
  display: flex;
  background: #f4f6f8;
}
.auth-shell[hidden],
#loginPanel[hidden],
#registerPanel[hidden] {
  display: none !important;
}
.auth-aside {
  display: none;
  width: 46%;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px;
  color: #fff;
  background:
    radial-gradient(800px 400px at 20% 10%, rgba(96, 165, 250, 0.35), transparent 55%),
    linear-gradient(160deg, #0b3b7a 0%, #1d4ed8 48%, #2563eb 100%);
}
.auth-brand {
  font-weight: 700;
  letter-spacing: 0.02em;
}
.auth-aside-copy h1 {
  margin: 0 0 12px;
  font-size: 1.85rem;
  line-height: 1.3;
}
.auth-aside-copy p {
  margin: 0;
  max-width: 22rem;
  color: rgba(255, 255, 255, 0.78);
  line-height: 1.7;
  font-size: 0.95rem;
}
.auth-aside-foot {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.45);
}
.auth-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}
.auth-panel {
  width: min(400px, 100%);
}
.auth-panel h2 {
  margin: 0;
  font-size: 1.55rem;
  color: #0f172a;
}
.auth-desc {
  margin: 8px 0 0;
  color: #64748b;
  font-size: 0.9rem;
  line-height: 1.5;
}
.auth-form {
  margin-top: 28px;
  display: grid;
  gap: 14px;
}
.cn-label {
  display: block;
  font-size: 0.85rem;
  color: #475569;
  font-weight: 500;
}
.cn-input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  background: #fff;
  font: inherit;
  color: #0f172a;
}
.cn-input:focus {
  outline: none;
  border-color: #60a5fa;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}
.cn-btn-primary {
  width: 100%;
  margin-top: 4px;
  border: 0;
  border-radius: 10px;
  padding: 11px 14px;
  background: #2563eb;
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.cn-btn-primary:hover { background: #1d4ed8; }
.cn-btn-primary:disabled { opacity: 0.65; cursor: not-allowed; }
.cn-btn-ghost {
  border: 1px solid #dbe3ec;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 0.8rem;
  white-space: nowrap;
  cursor: pointer;
}
.cn-btn-ghost:disabled { opacity: 0.55; cursor: not-allowed; }
.captcha-row, .code-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
  margin-top: 6px;
}
.captcha-row .cn-input,
.code-row .cn-input {
  margin-top: 0;
  flex: 1;
}
.captcha-img-btn {
  border: 1px solid #dbe3ec;
  border-radius: 10px;
  padding: 0;
  background: #f8fafc;
  cursor: pointer;
  overflow: hidden;
  height: 42px;
}
.captcha-img-btn img {
  display: block;
  width: 120px;
  height: 40px;
}
.field-hint {
  margin: 6px 0 0;
  font-size: 0.75rem;
  color: #94a3b8;
}
.auth-switch {
  margin: 22px 0 0;
  text-align: center;
  font-size: 0.9rem;
  color: #64748b;
}
.auth-switch a {
  color: #2563eb;
  font-weight: 600;
  text-decoration: none;
}
.auth-switch a:hover { color: #1d4ed8; }
.auth-msg {
  margin: 14px 0 0;
  font-size: 0.88rem;
  line-height: 1.45;
  border-radius: 10px;
  padding: 0;
}
.auth-msg:not(:empty) {
  padding: 10px 12px;
  background: #eff6ff;
  color: #1d4ed8;
}
.auth-msg.is-error:not(:empty) {
  background: #fef2f2;
  color: #b91c1c;
}
@media (min-width: 960px) {
  .auth-aside { display: flex; }
}

.cfg-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.cfg-tab {
  background: #fff !important;
  color: var(--ink) !important;
  border-color: var(--line) !important;
  padding: 6px 10px !important;
  font-size: 0.82rem !important;
}
.cfg-tab.active {
  background: var(--accent-soft) !important;
  color: var(--accent) !important;
  border-color: #b7dccb !important;
}
.admin-scope {
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.admin-scope[hidden] {
  display: none !important;
}
.admin-scope select { width: 100%; }
.add-source-row { align-items: stretch; }
.add-source-row input { min-width: 0 !important; }
#importText, #topicsBox textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font: inherit;
  resize: vertical;
}
.sch-line { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; }
.sch-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.sch-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}
.sch-grid input { width: 100%; }
.site-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.site-actions button {
  padding: 4px 8px !important;
  font-size: 0.75rem !important;
}
.tag.ready { background: var(--accent-soft); color: var(--accent); }
.tag.pending { background: #fff7ed; color: #c2410c; }
.tag.unsupported { background: #f3f4f6; color: #6b7280; }
.topic-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
}
.topic-card h4 { margin: 0 0 8px; font-size: 0.92rem; }
.topic-card label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 6px;
}
.topic-card input { width: 100%; margin-top: 4px; min-width: 0 !important; }
.field-hint { margin: 0 0 8px; font-size: 0.8rem; color: var(--muted); }
